Skip to content

Commit a9b959a

Browse files
committed
elided_named_lifetimes: bless & add tests
1 parent f7b0b22 commit a9b959a

File tree

45 files changed

+460
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+460
-27
lines changed

src/tools/clippy/tests/ui/needless_lifetimes.stderr

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
error: elided lifetime has a name
2+
--> tests/ui/needless_lifetimes.rs:266:52
3+
|
4+
LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str {
5+
| -- ^ this elided lifetime gets resolved as `'a`
6+
| |
7+
| lifetime `'a` declared here
8+
|
9+
= note: `-D elided-named-lifetimes` implied by `-D warnings`
10+
= help: to override `-D warnings` add `#[allow(elided_named_lifetimes)]`
11+
112
error: the following explicit lifetimes could be elided: 'a, 'b
213
--> tests/ui/needless_lifetimes.rs:17:23
314
|
@@ -553,5 +564,5 @@ LL - fn one_input<'a>(x: &'a u8) -> &'a u8 {
553564
LL + fn one_input(x: &u8) -> &u8 {
554565
|
555566

556-
error: aborting due to 46 previous errors
567+
error: aborting due to 47 previous errors
557568

src/tools/clippy/tests/ui/ptr_arg.stderr

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
error: elided lifetime has a name
2+
--> tests/ui/ptr_arg.rs:295:56
3+
|
4+
LL | fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str {
5+
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a`
6+
|
7+
= note: `-D elided-named-lifetimes` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(elided_named_lifetimes)]`
9+
110
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
211
--> tests/ui/ptr_arg.rs:13:14
312
|
@@ -212,5 +221,5 @@ error: using a reference to `Cow` is not recommended
212221
LL | fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str {
213222
| ^^^^^^^^^^^^^^^^ help: change this to: `&str`
214223

215-
error: aborting due to 24 previous errors
224+
error: aborting due to 25 previous errors
216225

tests/ui/async-await/issues/issue-63388-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait Foo {}
99
impl Xyz {
1010
async fn do_sth<'a>(
1111
&'a self, foo: &dyn Foo
12-
) -> &dyn Foo
12+
) -> &dyn Foo //~ WARNING elided lifetime has a name
1313
{
1414
//~^ ERROR explicit lifetime required in the type of `foo` [E0621]
1515
foo

tests/ui/async-await/issues/issue-63388-1.stderr

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
warning: elided lifetime has a name
2+
--> $DIR/issue-63388-1.rs:12:10
3+
|
4+
LL | async fn do_sth<'a>(
5+
| -- lifetime `'a` declared here
6+
LL | &'a self, foo: &dyn Foo
7+
LL | ) -> &dyn Foo
8+
| ^ this elided lifetime gets resolved as `'a`
9+
|
10+
= note: `#[warn(elided_named_lifetimes)]` on by default
11+
112
error[E0621]: explicit lifetime required in the type of `foo`
213
--> $DIR/issue-63388-1.rs:13:5
314
|
@@ -10,6 +21,6 @@ LL | | foo
1021
LL | | }
1122
| |_____^ lifetime `'a` required
1223

13-
error: aborting due to 1 previous error
24+
error: aborting due to 1 previous error; 1 warning emitted
1425

1526
For more information about this error, try `rustc --explain E0621`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: elided lifetime has a name
2+
--> $DIR/issue-71348.rs:18:68
3+
|
4+
LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target
5+
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a`
6+
|
7+
= note: `#[warn(elided_named_lifetimes)]` on by default
8+
9+
warning: 1 warning emitted
10+

tests/ui/const-generics/type-dependent/issue-71348.min.stderr

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
warning: elided lifetime has a name
2+
--> $DIR/issue-71348.rs:18:68
3+
|
4+
LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target
5+
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a`
6+
|
7+
= note: `#[warn(elided_named_lifetimes)]` on by default
8+
19
error: `&'static str` is forbidden as the type of a const generic parameter
210
--> $DIR/issue-71348.rs:10:24
311
|
@@ -30,5 +38,5 @@ help: add `#![feature(unsized_const_params)]` to the crate attributes to enable
3038
LL + #![feature(unsized_const_params)]
3139
|
3240

33-
error: aborting due to 2 previous errors
41+
error: aborting due to 2 previous errors; 1 warning emitted
3442

tests/ui/const-generics/type-dependent/issue-71348.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ trait Get<'a, const N: &'static str> {
1717
impl Foo {
1818
fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target
1919
//[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter
20+
//~^^ WARNING elided lifetime has a name
2021
where
2122
Self: Get<'a, N>,
2223
{

tests/ui/consts/min_const_fn/min_const_fn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ impl<T> Foo<T> {
4444
impl<'a, T> Foo<T> {
4545
const fn new_lt(t: T) -> Self { Foo(t) }
4646
const fn into_inner_lt(self) -> T { self.0 } //~ destructor of
47-
const fn get_lt(&'a self) -> &T { &self.0 }
48-
const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
47+
const fn get_lt(&'a self) -> &T { &self.0 } //~ WARNING elided lifetime has a name
48+
const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } //~ WARNING elided lifetime has a name
4949
//~^ mutable references
5050
//~| mutable references
5151
//~| mutable references

tests/ui/consts/min_const_fn/min_const_fn.stderr

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
warning: elided lifetime has a name
2+
--> $DIR/min_const_fn.rs:47:34
3+
|
4+
LL | impl<'a, T> Foo<T> {
5+
| -- lifetime `'a` declared here
6+
...
7+
LL | const fn get_lt(&'a self) -> &T { &self.0 }
8+
| ^ this elided lifetime gets resolved as `'a`
9+
|
10+
= note: `#[warn(elided_named_lifetimes)]` on by default
11+
12+
warning: elided lifetime has a name
13+
--> $DIR/min_const_fn.rs:48:42
14+
|
15+
LL | impl<'a, T> Foo<T> {
16+
| -- lifetime `'a` declared here
17+
...
18+
LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
19+
| ^ this elided lifetime gets resolved as `'a`
20+
121
error[E0493]: destructor of `Foo<T>` cannot be evaluated at compile-time
222
--> $DIR/min_const_fn.rs:37:25
323
|
@@ -228,7 +248,7 @@ LL | const fn no_apit(_x: impl std::fmt::Debug) {}
228248
| |
229249
| the destructor for this type cannot be evaluated in constant functions
230250

231-
error: aborting due to 24 previous errors
251+
error: aborting due to 24 previous errors; 2 warnings emitted
232252

233253
Some errors have detailed explanations: E0493, E0658.
234254
For more information about an error, try `rustc --explain E0493`.

tests/ui/generics/generic-no-mangle.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ run-rustfix
2-
#![allow(dead_code)]
2+
#![allow(dead_code, elided_named_lifetimes)]
33
#![deny(no_mangle_generic_items)]
44

55
pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled

0 commit comments

Comments
 (0)