Skip to content

Commit fdd23ca

Browse files
committed
nameres stuff
1 parent a43257a commit fdd23ca

File tree

3 files changed

+11
-4
lines changed
  • compiler
    • rustc_hir_analysis/src/hir_ty_lowering
    • rustc_hir_typeck/src
    • rustc_middle/src/hir

3 files changed

+11
-4
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,9 +2484,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24842484
debug!(?expr);
24852485

24862486
// If the rhs is an anon const naming generics it shouldn't have
2487-
// access to then we lower to `ConstKind::Error`.
2487+
// access to then we lower to `ConstKind::Error`. This prevents
2488+
// `try_lower_anon_const_lit` from ICEing on anon consts such as
2489+
// `const { N }` which aren't supposed to be legal.
24882490
if let ty::AnonConstKind::MCG = tcx.anon_const_kind(anon.def_id)
2489-
&& let Err(e) = tcx.hir_const_arg_anon_check_invalid_param_uses(anon.def_id)
2491+
&& let Err(e) = tcx.check_anon_const_invalid_param_uses(anon.def_id)
24902492
{
24912493
return ty::Const::new_error(tcx, e);
24922494
}

compiler/rustc_hir_typeck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn typeck_with_inspect<'tcx>(
117117

118118
if let DefKind::AnonConst = tcx.def_kind(def_id)
119119
&& let ty::AnonConstKind::MCG = tcx.anon_const_kind(def_id)
120-
&& let Err(e) = tcx.hir_const_arg_anon_check_invalid_param_uses(def_id)
120+
&& let Err(e) = tcx.check_anon_const_invalid_param_uses(def_id)
121121
{
122122
e.raise_fatal();
123123
}

compiler/rustc_middle/src/hir/map.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,12 @@ impl<'tcx> TyCtxt<'tcx> {
10911091
None
10921092
}
10931093

1094-
pub fn hir_const_arg_anon_check_invalid_param_uses(
1094+
// FIXME(mgca): this is pretty iffy. In the long term we should make
1095+
// HIR ty lowering able to return `Error` versions of types/consts when
1096+
// lowering them in contexts that aren't supposed to use generic parameters.
1097+
//
1098+
// This current impl strategy is incomplete and doesn't handle `Self` ty aliases.
1099+
pub fn check_anon_const_invalid_param_uses(
10951100
self,
10961101
anon: LocalDefId,
10971102
) -> Result<(), ErrorGuaranteed> {

0 commit comments

Comments
 (0)