Skip to content

Commit 911f309

Browse files
committed
Correctly handle const paths with a qself
1 parent 57276ce commit 911f309

File tree

3 files changed

+7
-5
lines changed
  • compiler

3 files changed

+7
-5
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2369,13 +2369,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23692369
} else {
23702370
&anon.value
23712371
};
2372-
if let ExprKind::Path(qself, path) = &expr.kind
2373-
// FIXME(min_generic_const_args): we only allow one-segment const paths for now
2372+
// FIXME(min_generic_const_args): we only allow one-segment const paths for now
2373+
if let ExprKind::Path(None, path) = &expr.kind
23742374
&& path.is_potential_trivial_const_arg()
23752375
{
23762376
let qpath = self.lower_qpath(
23772377
expr.id,
2378-
qself,
2378+
&None,
23792379
path,
23802380
ParamMode::Optional,
23812381
AllowReturnTypeNotation::No,

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2060,7 +2060,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
20602060
_ => ty::Const::new_error_with_message(
20612061
tcx,
20622062
qpath.span(),
2063-
"Const::lower_const_arg_path: invalid qpath",
2063+
format!("Const::lower_const_arg_path: invalid qpath {qpath:?}"),
20642064
),
20652065
}
20662066
}

compiler/rustc_middle/src/ty/consts.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::borrow::Cow;
2+
13
use either::Either;
24
use rustc_data_structures::intern::Interned;
35
use rustc_error_messages::MultiSpan;
@@ -141,7 +143,7 @@ impl<'tcx> Const<'tcx> {
141143
pub fn new_error_with_message<S: Into<MultiSpan>>(
142144
tcx: TyCtxt<'tcx>,
143145
span: S,
144-
msg: &'static str,
146+
msg: impl Into<Cow<'static, str>>,
145147
) -> Const<'tcx> {
146148
let reported = tcx.dcx().span_delayed_bug(span, msg);
147149
Const::new_error(tcx, reported)

0 commit comments

Comments
 (0)