Skip to content

Commit 56d3699

Browse files
committed
Correctly handle const paths with a qself
1 parent e325740 commit 56d3699

File tree

3 files changed

+7
-5
lines changed
  • compiler

3 files changed

+7
-5
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,13 +2131,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21312131
} else {
21322132
&anon.value
21332133
};
2134-
if let ExprKind::Path(qself, path) = &expr.kind
2135-
// FIXME(min_generic_const_args): we only allow one-segment const paths for now
2134+
// FIXME(min_generic_const_args): we only allow one-segment const paths for now
2135+
if let ExprKind::Path(None, path) = &expr.kind
21362136
&& path.is_potential_trivial_const_arg()
21372137
{
21382138
let qpath = self.lower_qpath(
21392139
expr.id,
2140-
qself,
2140+
&None,
21412141
path,
21422142
ParamMode::Optional,
21432143
AllowReturnTypeNotation::No,

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
21262126
_ => ty::Const::new_error_with_message(
21272127
tcx,
21282128
qpath.span(),
2129-
"Const::lower_const_arg_path: invalid qpath",
2129+
format!("Const::lower_const_arg_path: invalid qpath {qpath:?}"),
21302130
),
21312131
}
21322132
}

compiler/rustc_middle/src/ty/consts.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::borrow::Cow;
2+
13
use rustc_data_structures::intern::Interned;
24
use rustc_error_messages::MultiSpan;
35
use rustc_hir::def::{DefKind, Res};
@@ -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)