diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2024-12-30 17:57:59 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-30 17:57:59 +0000 |
| commit | 7a834b5d3a63881e90160e92addeab0a1cda3e57 (patch) | |
| tree | 2553787d6d7cc7fbd1afc4531d8fded75e050328 /tests | |
| parent | 2aea7a080d7d04d433d76772a7b3200c3324e6a1 (diff) | |
| parent | a657fcc89a1d2b3badc50f101818b8fcd6f220fd (diff) | |
Use the full lifetime name in suggestions (#13907)
Using `lifetime.ident.name` in suggestions will not output the raw modifier. For example, `'r#struct` will be rendered as `'struct` which would be incorrect. Fix #13899 changelog: [`needless_arbitrary_self_type`]: use the raw lifetime name in suggestions
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/needless_arbitrary_self_type.fixed | 5 | ||||
| -rw-r--r-- | tests/ui/needless_arbitrary_self_type.rs | 5 | ||||
| -rw-r--r-- | tests/ui/needless_arbitrary_self_type.stderr | 14 |
3 files changed, 23 insertions, 1 deletions
diff --git a/tests/ui/needless_arbitrary_self_type.fixed b/tests/ui/needless_arbitrary_self_type.fixed index 9da60c687d4..530eb77d83d 100644 --- a/tests/ui/needless_arbitrary_self_type.fixed +++ b/tests/ui/needless_arbitrary_self_type.fixed @@ -64,4 +64,9 @@ impl ValType { } } +trait Foo<'r#struct> { + fn f1(&'r#struct self) {} + fn f2(&'r#struct mut self) {} +} + fn main() {} diff --git a/tests/ui/needless_arbitrary_self_type.rs b/tests/ui/needless_arbitrary_self_type.rs index fc4ec5cb0b3..5a1ff96a11c 100644 --- a/tests/ui/needless_arbitrary_self_type.rs +++ b/tests/ui/needless_arbitrary_self_type.rs @@ -64,4 +64,9 @@ impl ValType { } } +trait Foo<'r#struct> { + fn f1(self: &'r#struct Self) {} + fn f2(self: &'r#struct mut Self) {} +} + fn main() {} diff --git a/tests/ui/needless_arbitrary_self_type.stderr b/tests/ui/needless_arbitrary_self_type.stderr index c653267f752..7ebbbaa122f 100644 --- a/tests/ui/needless_arbitrary_self_type.stderr +++ b/tests/ui/needless_arbitrary_self_type.stderr @@ -37,5 +37,17 @@ error: the type of the `self` parameter does not need to be arbitrary LL | pub fn mut_ref_bad_with_lifetime<'a>(self: &'a mut Self) { | ^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a mut self` -error: aborting due to 6 previous errors +error: the type of the `self` parameter does not need to be arbitrary + --> tests/ui/needless_arbitrary_self_type.rs:68:11 + | +LL | fn f1(self: &'r#struct Self) {} + | ^^^^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'r#struct self` + +error: the type of the `self` parameter does not need to be arbitrary + --> tests/ui/needless_arbitrary_self_type.rs:69:11 + | +LL | fn f2(self: &'r#struct mut Self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'r#struct mut self` + +error: aborting due to 8 previous errors |
