Skip to content

Commit 7c44a22

Browse files
committed
rebase
1 parent 7d9d599 commit 7c44a22

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
523523
_ => visit::walk_ty(self, t),
524524
}
525525
}
526-
527-
fn visit_anon_const(&mut self, ct: &'tcx AnonConst) {
528-
self.lctx.allocate_hir_id_counter(ct.id);
529-
self.with_hir_id_owner(Some(ct.id), |this| {
530-
visit::walk_anon_const(this, ct);
531-
});
532-
}
533526
}
534527

535528
self.lower_node_id(CRATE_NODE_ID);
@@ -2401,7 +2394,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24012394
})
24022395
}));
24032396

2404-
hir::AnonConst {
2397+
// The generics of an anonymous constants refer to the
2398+
// generics of their parent anon const, so we only have to
2399+
// deal with each higher ranked lifetime at the outermost const.
2400+
let hrtb_start = mem::replace(&mut this.hrtb_start, None);
2401+
let ct = hir::AnonConst {
24052402
hir_id,
24062403
generics: hir::Generics {
24072404
params: generic_params,
@@ -2414,7 +2411,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24142411
parenthesized: false,
24152412
},
24162413
body: this.lower_const_body(c.value.span, Some(&c.value)),
2417-
}
2414+
};
2415+
this.hrtb_start = hrtb_start;
2416+
ct
24182417
})
24192418
})
24202419
}

compiler/rustc_resolve/src/late/lifetimes.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1577,12 +1577,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
15771577
}
15781578

15791579
fn check_uses_for_lifetimes_defined_by_scope(&mut self) {
1580-
let defined_by = match self.scope {
1581-
Scope::Binder { from_anon_const: true, .. } => {
1582-
debug!("check_uses_for_lifetimes_defined_by_scope: synthetic anon const binder");
1583-
return;
1584-
}
1585-
Scope::Binder { lifetimes, .. } => lifetimes,
1580+
let (defined_by, from_anon_const) = match self.scope {
1581+
&Scope::Binder { ref lifetimes, from_anon_const, .. } => (lifetimes, from_anon_const),
15861582
_ => {
15871583
debug!("check_uses_for_lifetimes_defined_by_scope: not in a binder scope");
15881584
return;
@@ -1600,6 +1596,14 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
16001596
})
16011597
.collect();
16021598

1599+
if from_anon_const {
1600+
debug!("check_uses_for_lifetimes_defined_by_scope: synthetic anon const");
1601+
for def_id in def_ids {
1602+
self.lifetime_uses.remove(&def_id);
1603+
}
1604+
return;
1605+
}
1606+
16031607
// ensure that we issue lints in a repeatable order
16041608
def_ids.sort_by_cached_key(|&def_id| self.tcx.def_path_hash(def_id));
16051609

src/test/ui/associated-item/associated-item-duplicate-bounds.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | links: [u32; A::LINKS],
55
| ^^^^^^^^ cannot perform const operation using `A`
66
|
77
= note: type parameters may not be used in const expressions
8+
= help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
89

910
error: aborting due to previous error
1011

src/test/ui/issues/issue-39559.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | entries: [T; D::dim()],
55
| ^^^^^^ cannot perform const operation using `D`
66
|
77
= note: type parameters may not be used in const expressions
8+
= help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
89

910
error: aborting due to previous error
1011

0 commit comments

Comments
 (0)