forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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#125258 - compiler-errors:static-if-no-lt, r=nnethercote Resolve elided lifetimes in assoc const to static if no other lifetimes are in scope Implements the change to elided lifetime resolution in *associated consts* subject to FCP here: rust-lang#125190 (comment) Specifically, walk the enclosing lifetime ribs in an associated const, and if we find no other lifetimes, then resolve to `'static`. Also make it work for traits, but don't lint -- just give a hard error in that case.
- Loading branch information
Showing
21 changed files
with
386 additions
and
210 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
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 |
---|---|---|
@@ -1,12 +1,10 @@ | ||
//@ check-pass | ||
|
||
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 | ||
// Now resolves to `&'static &'static str`. | ||
} | ||
|
||
fn main() {} |
This file was deleted.
Oops, something went wrong.
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
16 changes: 1 addition & 15 deletions
16
tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.stderr
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 |
---|---|---|
@@ -1,23 +1,9 @@ | ||
warning: `&` without an explicit lifetime name cannot be used here | ||
--> $DIR/infer-placeholder-in-non-suggestable-pos.rs:6:18 | ||
| | ||
LL | const ASSOC: &dyn Fn(_) = 1i32; | ||
| ^ | ||
| | ||
= 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 ASSOC: &'static dyn Fn(_) = 1i32; | ||
| +++++++ | ||
|
||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants | ||
--> $DIR/infer-placeholder-in-non-suggestable-pos.rs:6:26 | ||
| | ||
LL | const ASSOC: &dyn Fn(_) = 1i32; | ||
| ^ not allowed in type signatures | ||
|
||
error: aborting due to 1 previous error; 1 warning emitted | ||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0121`. |
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
Oops, something went wrong.