Skip to content

Commit 3ffbd66

Browse files
committed
anon-const, do not add in-band lifetimes
1 parent b7c687c commit 3ffbd66

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2345,12 +2345,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23452345
// but as we already mention the parent generics this is not actually needed.
23462346
//
23472347
// Consider only adding explicit higher ranked lifetimes here.
2348+
2349+
// We only need `in_scope_lifetimes` because all in-band lifetimes are
2350+
// added to the generics of the parent.
23482351
let lifetime_params: Vec<(Span, ParamName)> = this
23492352
.in_scope_lifetimes
23502353
.iter()
23512354
.cloned()
23522355
.map(|name| (name.ident().span, name))
2353-
.chain(this.lifetimes_to_define.iter().cloned())
23542356
.collect();
23552357

23562358
let generic_params =

src/test/ui/const-generics/binders/arr-in-arr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct Bar<'a, 'b, 'c>(&'a (), &'b (), &'c ());
77
trait Baz<'a, 'b, T> {}
88

99
struct Foo<'a>(&'a ()) where for<'b> [u8; {
10-
let _: Box<dyn for<'c> Baz<'a, 'b, [u8; {
10+
let _: Box<dyn for<'c> Baz<'a, 'b, [u8; {
1111
let _: Bar<'a, 'b, 'c>;
1212
3
1313
}]>>;

src/test/ui/const-generics/binders/const-eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ fn test<T>() {
1414

1515
fn main() {
1616
test::<u32>();
17-
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// run-pass
2+
#![feature(in_band_lifetimes, const_generics)]
3+
#![allow(incomplete_features)]
4+
5+
struct Foo<T>(T);
6+
7+
impl Foo<[u8; { let _: &'a (); 3 }]> {
8+
fn test() -> Self {
9+
Foo([0; 3])
10+
}
11+
}
12+
13+
fn main() {
14+
assert_eq!(Foo::test().0, [0; 3]);
15+
}

0 commit comments

Comments
 (0)