forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#79298 - lcnr:new-elysium, r=matthewjasper
correctly deal with late-bound lifetimes in anon consts adds support for using late bound lifetimes of the parent context in anon consts. ```rust #![feature(const_generics)] const fn inner<'a>() -> usize where &'a (): Sized { 3 } fn test<'a>() { let _: [u8; inner::<'a>()]; } ``` The lifetime `'a` is late bound in `test` so it's not included in its generics but is instead dealt with separately in borrowck. This didn't previously work for anon consts as they have to use the late bound lifetimes of their parent which has to be explicitly handled. r? `@matthewjasper` cc `@varkor` `@eddyb`
- Loading branch information
Showing
6 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// run-pass | ||
#![feature(const_generics)] | ||
#![allow(incomplete_features)] | ||
|
||
const fn inner<'a>() -> usize where &'a (): Sized { | ||
3 | ||
} | ||
|
||
fn test<'a>() { | ||
let _ = || { | ||
let _: [u8; inner::<'a>()]; | ||
let _ = [0; inner::<'a>()]; | ||
}; | ||
} | ||
|
||
fn main() { | ||
test(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// run-pass | ||
#![feature(const_generics)] | ||
#![allow(incomplete_features)] | ||
|
||
const fn inner<'a>() -> usize where &'a (): Sized { | ||
3 | ||
} | ||
|
||
fn test<'a>() { | ||
let _: [u8; inner::<'a>()]; | ||
let _ = [0; inner::<'a>()]; | ||
} | ||
|
||
fn main() { | ||
test(); | ||
} |