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#115429 - compiler-errors:assoc-ct-lt-fallth…
…rough, r=cjgillot Fall through when resolving elided assoc const lifetimes `@QuineDot` makes a good point in rust-lang#115010 (comment) that we probably should not accept *more* code due to rust-lang#115011 even though that code will eventually become a forbid-warning in a few versions (rust-lang#115010 (comment)). Fall through when walking thru the `AnonymousWarnToStatic` (renamed to `AnonymousWarn`) rib so that we can resolve as a fresh lifetime like we did before.
- Loading branch information
Showing
3 changed files
with
88 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
struct S; | ||
|
||
impl S { | ||
const C: &&str = &""; | ||
//~^ WARN `&` without an explicit lifetime name cannot be used here | ||
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
//~| WARN `&` without an explicit lifetime name cannot be used here | ||
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
//~| ERROR in type `&&str`, reference has a longer lifetime than the data it references | ||
} | ||
|
||
fn main() {} |
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,47 @@ | ||
warning: `&` without an explicit lifetime name cannot be used here | ||
--> $DIR/double-elided.rs:4:14 | ||
| | ||
LL | const C: &&str = &""; | ||
| ^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #115010 <https://github.com/rust-lang/rust/issues/115010> | ||
= note: `#[warn(elided_lifetimes_in_associated_constant)]` on by default | ||
help: use the `'static` lifetime | ||
| | ||
LL | const C: &'static &str = &""; | ||
| +++++++ | ||
|
||
warning: `&` without an explicit lifetime name cannot be used here | ||
--> $DIR/double-elided.rs:4:15 | ||
| | ||
LL | const C: &&str = &""; | ||
| ^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #115010 <https://github.com/rust-lang/rust/issues/115010> | ||
help: use the `'static` lifetime | ||
| | ||
LL | const C: &&'static str = &""; | ||
| +++++++ | ||
|
||
error[E0491]: in type `&&str`, reference has a longer lifetime than the data it references | ||
--> $DIR/double-elided.rs:4:5 | ||
| | ||
LL | const C: &&str = &""; | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the pointer is valid for the anonymous lifetime as defined here | ||
--> $DIR/double-elided.rs:4:14 | ||
| | ||
LL | const C: &&str = &""; | ||
| ^ | ||
note: but the referenced data is only valid for the anonymous lifetime as defined here | ||
--> $DIR/double-elided.rs:4:14 | ||
| | ||
LL | const C: &&str = &""; | ||
| ^ | ||
|
||
error: aborting due to previous error; 2 warnings emitted | ||
|
||
For more information about this error, try `rustc --explain E0491`. |