-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
elided_named_lifetimes: bless & add tests
- Loading branch information
1 parent
f7b0b22
commit a9b959a
Showing
45 changed files
with
460 additions
and
27 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
10 changes: 10 additions & 0 deletions
10
tests/ui/const-generics/type-dependent/issue-71348.full.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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
warning: elided lifetime has a name | ||
--> $DIR/issue-71348.rs:18:68 | ||
| | ||
LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target | ||
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` | ||
| | ||
= note: `#[warn(elided_named_lifetimes)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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
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,10 @@ | ||
warning: elided lifetime has a name | ||
--> $DIR/rpit-assoc-pair-with-lifetime.rs:3:82 | ||
| | ||
LL | pub fn iter<'a>(v: Vec<(u32, &'a u32)>) -> impl DoubleEndedIterator<Item = (u32, &u32)> { | ||
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` | ||
| | ||
= note: `#[warn(elided_named_lifetimes)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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
16 changes: 13 additions & 3 deletions
16
tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.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,12 +1,22 @@ | ||
warning: elided lifetime has a name | ||
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:6:36 | ||
| | ||
LL | fn foo<'a>(&'a self, x: &i32) -> &i32 { | ||
| -- ^ this elided lifetime gets resolved as `'a` | ||
| | | ||
| lifetime `'a` declared here | ||
| | ||
= note: `#[warn(elided_named_lifetimes)]` on by default | ||
|
||
error[E0621]: explicit lifetime required in the type of `x` | ||
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:8:36 | ||
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:9:36 | ||
| | ||
LL | fn foo<'a>(&'a self, x: &i32) -> &i32 { | ||
| ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32` | ||
LL | | ||
... | ||
LL | if true { &self.field } else { x } | ||
| ^ lifetime `'a` required | ||
|
||
error: aborting due to 1 previous error | ||
error: aborting due to 1 previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0621`. |
12 changes: 12 additions & 0 deletions
12
tests/ui/lint/elided-named-lifetimes/example-from-issue48686.rs
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 @@ | ||
#![deny(elided_named_lifetimes)] | ||
|
||
struct Foo; | ||
|
||
impl Foo { | ||
pub fn get_mut(&'static self, x: &mut u8) -> &mut u8 { | ||
//~^ ERROR elided lifetime has a name | ||
unsafe { &mut *(x as *mut _) } | ||
} | ||
} | ||
|
||
fn main() {} |
14 changes: 14 additions & 0 deletions
14
tests/ui/lint/elided-named-lifetimes/example-from-issue48686.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: elided lifetime has a name | ||
--> $DIR/example-from-issue48686.rs:6:50 | ||
| | ||
LL | pub fn get_mut(&'static self, x: &mut u8) -> &mut u8 { | ||
| ^ this elided lifetime gets resolved as `'static` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/example-from-issue48686.rs:1:9 | ||
| | ||
LL | #![deny(elided_named_lifetimes)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
27 changes: 27 additions & 0 deletions
27
tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.rs
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,27 @@ | ||
#![deny(elided_named_lifetimes)] | ||
|
||
fn ampersand<'a>(x: &'a u8) -> &u8 { | ||
//~^ ERROR elided lifetime has a name | ||
x | ||
} | ||
|
||
struct Brackets<'a>(&'a u8); | ||
|
||
fn brackets<'a>(x: &'a u8) -> Brackets { | ||
//~^ ERROR elided lifetime has a name | ||
Brackets(x) | ||
} | ||
|
||
struct Comma<'a, T>(&'a T); | ||
|
||
fn comma<'a>(x: &'a u8) -> Comma<u8> { | ||
//~^ ERROR elided lifetime has a name | ||
Comma(x) | ||
} | ||
|
||
fn underscore<'a>(x: &'a u8) -> &'_ u8 { | ||
//~^ ERROR elided lifetime has a name | ||
x | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.