Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 252c43b

Browse files
committed
Do not mention lifetime names in force trimmed paths
1 parent 81973a3 commit 252c43b

23 files changed

+44
-40
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,6 +2070,10 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
20702070
return true;
20712071
}
20722072

2073+
if FORCE_TRIMMED_PATH.with(|flag| flag.get()) {
2074+
return false;
2075+
}
2076+
20732077
let identify_regions = self.tcx.sess.opts.unstable_opts.identify_regions;
20742078

20752079
match *region {

tests/ui/associated-type-bounds/inside-adt.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ LL | union U1 { f: ManuallyDrop<dyn Iterator<Item: Copy>> }
9595
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
9696
|
9797
= help: within `ManuallyDrop<(dyn Iterator<Item = impl Copy> + 'static)>`, the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Copy> + 'static)`
98-
= note: required because it appears within the type `ManuallyDrop<(dyn Iterator<Item = impl Copy> + 'static)>`
98+
= note: required because it appears within the type `ManuallyDrop<dyn Iterator<Item = impl Copy>>`
9999
= note: no field of a union may have a dynamically sized type
100100
= help: change the field's type to have a statically known size
101101
help: borrowed types always have a statically known size
@@ -114,7 +114,7 @@ LL | union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> }
114114
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
115115
|
116116
= help: within `ManuallyDrop<(dyn Iterator<Item = impl Sized + 'static> + 'static)>`, the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized + 'static> + 'static)`
117-
= note: required because it appears within the type `ManuallyDrop<(dyn Iterator<Item = impl Sized + 'static> + 'static)>`
117+
= note: required because it appears within the type `ManuallyDrop<dyn Iterator<Item = impl Sized + 'static>>`
118118
= note: no field of a union may have a dynamically sized type
119119
= help: change the field's type to have a statically known size
120120
help: borrowed types always have a statically known size

tests/ui/associated-types/issue-43924.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ note: required by a bound in `Foo::Out`
1010
LL | type Out: Default + ToString + ?Sized = dyn ToString;
1111
| ^^^^^^^ required by this bound in `Foo::Out`
1212

13-
error[E0599]: no function or associated item named `default` found for trait object `(dyn ToString + 'static)` in the current scope
13+
error[E0599]: no function or associated item named `default` found for trait object `dyn ToString` in the current scope
1414
--> $DIR/issue-43924.rs:14:39
1515
|
1616
LL | assert_eq!(<() as Foo<u32>>::Out::default().to_string(), "false");
17-
| ^^^^^^^ function or associated item not found in `(dyn ToString + 'static)`
17+
| ^^^^^^^ function or associated item not found in `dyn ToString`
1818

1919
error: aborting due to 2 previous errors
2020

tests/ui/async-await/issue-98634.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ impl Runtime {
4343
fn main() {
4444
Runtime.block_on(async {
4545
StructAsync { callback }.await;
46-
//~^ ERROR expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
47-
//~| ERROR expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
48-
//~| ERROR expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
46+
//~^ ERROR expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
47+
//~| ERROR expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
48+
//~| ERROR expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
4949
});
5050
}

tests/ui/async-await/issue-98634.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0271]: expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
1+
error[E0271]: expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
22
--> $DIR/issue-98634.rs:45:23
33
|
44
LL | StructAsync { callback }.await;
@@ -17,7 +17,7 @@ note: required by a bound in `StructAsync`
1717
LL | pub struct StructAsync<F: Fn() -> Pin<Box<dyn Future<Output = ()>>>> {
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StructAsync`
1919

20-
error[E0271]: expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
20+
error[E0271]: expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
2121
--> $DIR/issue-98634.rs:45:9
2222
|
2323
LL | StructAsync { callback }.await;
@@ -36,7 +36,7 @@ note: required by a bound in `StructAsync`
3636
LL | pub struct StructAsync<F: Fn() -> Pin<Box<dyn Future<Output = ()>>>> {
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StructAsync`
3838

39-
error[E0271]: expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
39+
error[E0271]: expected `fn() -> impl Future<Output = ()> {callback}` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
4040
--> $DIR/issue-98634.rs:45:33
4141
|
4242
LL | StructAsync { callback }.await;

tests/ui/feature-gates/feature-gate-trivial_bounds.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ LL | fn unsized_local() where Dst<dyn A>: Sized {
9595
| ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
9696
|
9797
= help: within `Dst<(dyn A + 'static)>`, the trait `Sized` is not implemented for `(dyn A + 'static)`
98-
note: required because it appears within the type `Dst<(dyn A + 'static)>`
98+
note: required because it appears within the type `Dst<dyn A>`
9999
--> $DIR/feature-gate-trivial_bounds.rs:48:8
100100
|
101101
LL | struct Dst<X: ?Sized> {

tests/ui/function-pointer/unsized-ret.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LL | foo::<for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a), _>(None, (&()
2323
| required by a bound introduced by this call
2424
|
2525
= help: within `for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a)`, the trait `for<'a> Sized` is not implemented for `(dyn std::fmt::Display + 'a)`
26-
= note: required because it appears within the type `fn(&'a ()) -> (dyn Display + 'a)`
26+
= note: required because it appears within the type `fn(&()) -> dyn Display`
2727
note: required by a bound in `foo`
2828
--> $DIR/unsized-ret.rs:5:11
2929
|

tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ LL | | ),
1111
LL | | ) {
1212
| |_- expected `&dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn Fn(u32) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a))` because of return type
1313
LL | f
14-
| ^ expected `&dyn Fn(&'a (dyn Fn(&'a ...) + 'a))`, found `&dyn Fn(u32)`
14+
| ^ expected `&dyn Fn(&dyn Fn(&dyn Fn(&...)))`, found `&dyn Fn(u32)`
1515
|
16-
= note: expected reference `&dyn Fn(&'a (dyn Fn(&'a (dyn Fn(&'a (dyn Fn(&'a (dyn Fn(&'a (dyn Fn(...) + 'a)) + 'a)) + 'a)) + 'a)) + 'a))`
16+
= note: expected reference `&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&...)))))))))))`
1717
the full type name has been written to '$TEST_BUILD_DIR/higher-rank-trait-bounds/hang-on-deeply-nested-dyn/hang-on-deeply-nested-dyn.long-type-hash.txt'
1818
found reference `&dyn Fn(u32)`
1919

tests/ui/higher-rank-trait-bounds/issue-30786.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ note: the following trait bounds were not satisfied:
1919
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
2020
| --------- - ^^^^^^ unsatisfied trait bound introduced here
2121

22-
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, fn(&'a u64) -> &'a u64 {identity::<u64>}>, [[email protected]:129:30]>`, but its trait bounds were not satisfied
22+
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, fn(&u64) -> &u64 {identity::<u64>}>, [[email protected]:129:30]>`, but its trait bounds were not satisfied
2323
--> $DIR/issue-30786.rs:130:24
2424
|
2525
LL | pub struct Filter<S, F> {

tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | fn fuz() -> (usize, Trait) { (42, Struct) }
1616
| doesn't have a size known at compile-time
1717
|
1818
= help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)`
19-
= note: required because it appears within the type `(usize, (dyn Trait + 'static))`
19+
= note: required because it appears within the type `(usize, dyn Trait)`
2020
= note: the return type of a function must have a statically known size
2121

2222
error[E0308]: mismatched types
@@ -37,7 +37,7 @@ LL | fn bar() -> (usize, dyn Trait) { (42, Struct) }
3737
| doesn't have a size known at compile-time
3838
|
3939
= help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)`
40-
= note: required because it appears within the type `(usize, (dyn Trait + 'static))`
40+
= note: required because it appears within the type `(usize, dyn Trait)`
4141
= note: the return type of a function must have a statically known size
4242

4343
error[E0746]: return type cannot have an unboxed trait object

tests/ui/issues/issue-102964.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/issue-102964.rs:5:41
33
|
44
LL | fn bar_function<T>(function: Foo<T>) -> RcFoo<T> {
5-
| ------------ ^^^^^^^^ expected `Rc<&dyn Fn(&'a T)>`, found `()`
5+
| ------------ ^^^^^^^^ expected `Rc<&dyn Fn(&T)>`, found `()`
66
| |
77
| implicitly returns `()` as its body has no tail or `return` expression
88
|

tests/ui/issues/issue-19521.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0599]: no method named `homura` found for reference `&'static str` in the current scope
1+
error[E0599]: no method named `homura` found for reference `&str` in the current scope
22
--> $DIR/issue-19521.rs:2:8
33
|
44
LL | "".homura()();
5-
| ^^^^^^ method not found in `&'static str`
5+
| ^^^^^^ method not found in `&str`
66

77
error: aborting due to previous error
88

tests/ui/issues/issue-24322.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/issue-24322.rs:8:29
33
|
44
LL | let x: &fn(&B) -> u32 = &B::func;
5-
| -------------- ^^^^^^^^ expected `&fn(&'a B) -> u32`, found `&fn(&'a B) -> u32 {B::func}`
5+
| -------------- ^^^^^^^^ expected `&fn(&B) -> u32`, found `&fn(&B) -> u32 {B::func}`
66
| |
77
| expected due to this
88
|

tests/ui/issues/issue-57362-2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0599]: the function or associated item `make_g` exists for fn pointer `fn(&'a ())`, but its trait bounds were not satisfied
1+
error[E0599]: the function or associated item `make_g` exists for fn pointer `fn(&())`, but its trait bounds were not satisfied
22
--> $DIR/issue-57362-2.rs:22:25
33
|
44
LL | let x = <fn (&())>::make_g();
5-
| ^^^^^^ function or associated item cannot be called on `fn(&'a ())` due to unsatisfied trait bounds
5+
| ^^^^^^ function or associated item cannot be called on `fn(&())` due to unsatisfied trait bounds
66
|
77
= note: the following trait bounds were not satisfied:
88
`for<'a> fn(&'a ()): X`

tests/ui/kindck/kindck-send-object1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LL | assert_send::<Box<dyn Dummy + 'a>>();
2020
|
2121
= help: the trait `Send` is not implemented for `(dyn Dummy + 'a)`
2222
= note: required for `Unique<(dyn Dummy + 'a)>` to implement `Send`
23-
= note: required because it appears within the type `Box<(dyn Dummy + 'a)>`
23+
= note: required because it appears within the type `Box<dyn Dummy>`
2424
note: required by a bound in `assert_send`
2525
--> $DIR/kindck-send-object1.rs:5:18
2626
|

tests/ui/nll/issue-57642-higher-ranked-subtype.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0599]: the function or associated item `make_g` exists for fn pointer `fn(&'a ())`, but its trait bounds were not satisfied
1+
error[E0599]: the function or associated item `make_g` exists for fn pointer `fn(&())`, but its trait bounds were not satisfied
22
--> $DIR/issue-57642-higher-ranked-subtype.rs:31:25
33
|
44
LL | let x = <fn (&())>::make_g();
5-
| ^^^^^^ function or associated item cannot be called on `fn(&'a ())` due to unsatisfied trait bounds
5+
| ^^^^^^ function or associated item cannot be called on `fn(&())` due to unsatisfied trait bounds
66
|
77
= note: the following trait bounds were not satisfied:
88
`for<'a> fn(&'a ()): X`
@@ -13,11 +13,11 @@ note: `X` defines an item `make_g`, perhaps you need to implement it
1313
LL | trait X {
1414
| ^^^^^^^
1515

16-
error[E0599]: no function or associated item named `make_f` found for fn pointer `fn(&'a ())` in the current scope
16+
error[E0599]: no function or associated item named `make_f` found for fn pointer `fn(&())` in the current scope
1717
--> $DIR/issue-57642-higher-ranked-subtype.rs:35:25
1818
|
1919
LL | let x = <fn (&())>::make_f();
20-
| ^^^^^^ function or associated item not found in `fn(&'a ())`
20+
| ^^^^^^ function or associated item not found in `fn(&())`
2121
|
2222
= help: items from traits can only be used if the trait is implemented and in scope
2323
note: `Y` defines an item `make_f`, perhaps you need to implement it

tests/ui/object-pointer-types.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ LL | fn owned(self: Box<Self>);
1616
LL | x.owned();
1717
| ^^^^^ method not found in `&mut dyn Foo`
1818

19-
error[E0599]: no method named `managed` found for struct `Box<(dyn Foo + 'static)>` in the current scope
19+
error[E0599]: no method named `managed` found for struct `Box<dyn Foo>` in the current scope
2020
--> $DIR/object-pointer-types.rs:23:7
2121
|
2222
LL | x.managed();
23-
| ^^^^^^^ method not found in `Box<(dyn Foo + 'static)>`
23+
| ^^^^^^^ method not found in `Box<dyn Foo>`
2424

2525
error: aborting due to 3 previous errors
2626

tests/ui/suggestions/issue-101984.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | let (cmp, router) = self.router.at()?;
55
| ^^^^^^^^^^^^^ ----------------- this expression has type `Match<&(for<'a> fn(&'a ()), Box<Wrapper>)>`
66
| |
7-
| expected `Match<&(fn(&'a ()), Box<Wrapper>)>`, found `(_, _)`
7+
| expected `Match<&(fn(&()), Box<Wrapper>)>`, found `(_, _)`
88
|
99
= note: expected struct `Match<&(for<'a> fn(&'a ()), Box<Wrapper>)>`
1010
found tuple `(_, _)`

tests/ui/suggestions/remove-as_str.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0599]: no method named `as_str` found for reference `&str` in the current
44
LL | s.as_str();
55
| -^^^^^^-- help: remove this method call
66

7-
error[E0599]: no method named `as_str` found for reference `&'a str` in the current scope
7+
error[E0599]: no method named `as_str` found for reference `&str` in the current scope
88
--> $DIR/remove-as_str.rs:7:7
99
|
1010
LL | s.as_str();

tests/ui/suggestions/suggest-using-chars.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pub fn main() {
2-
let _ = "foo".iter(); //~ ERROR no method named `iter` found for reference `&'static str` in the current scope
3-
let _ = "foo".foo(); //~ ERROR no method named `foo` found for reference `&'static str` in the current scope
2+
let _ = "foo".iter(); //~ ERROR no method named `iter` found for reference `&str` in the current scope
3+
let _ = "foo".foo(); //~ ERROR no method named `foo` found for reference `&str` in the current scope
44
let _ = String::from("bar").iter(); //~ ERROR no method named `iter` found for struct `String` in the current scope
55
let _ = (&String::from("bar")).iter(); //~ ERROR no method named `iter` found for reference `&String` in the current scope
66
let _ = 0.iter(); //~ ERROR no method named `iter` found for type `{integer}` in the current scope

tests/ui/suggestions/suggest-using-chars.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
error[E0599]: no method named `iter` found for reference `&'static str` in the current scope
1+
error[E0599]: no method named `iter` found for reference `&str` in the current scope
22
--> $DIR/suggest-using-chars.rs:2:19
33
|
44
LL | let _ = "foo".iter();
5-
| ^^^^ method not found in `&'static str`
5+
| ^^^^ method not found in `&str`
66
|
77
help: because of the in-memory representation of `&str`, to obtain an `Iterator` over each of its codepoint use method `chars`
88
|
99
LL | let _ = "foo".chars();
1010
| ~~~~~
1111

12-
error[E0599]: no method named `foo` found for reference `&'static str` in the current scope
12+
error[E0599]: no method named `foo` found for reference `&str` in the current scope
1313
--> $DIR/suggest-using-chars.rs:3:19
1414
|
1515
LL | let _ = "foo".foo();
16-
| ^^^ method not found in `&'static str`
16+
| ^^^ method not found in `&str`
1717

1818
error[E0599]: no method named `iter` found for struct `String` in the current scope
1919
--> $DIR/suggest-using-chars.rs:4:33

tests/ui/type-alias-impl-trait/issue-98604.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ async fn test() {}
77
#[allow(unused_must_use)]
88
fn main() {
99
Box::new(test) as AsyncFnPtr;
10-
//~^ ERROR expected `fn() -> impl Future<Output = ()> {test}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
10+
//~^ ERROR expected `fn() -> impl Future<Output = ()> {test}` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>
1111
}

tests/ui/type-alias-impl-trait/issue-98604.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0271]: expected `fn() -> impl Future<Output = ()> {test}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
1+
error[E0271]: expected `fn() -> impl Future<Output = ()> {test}` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>`
22
--> $DIR/issue-98604.rs:9:5
33
|
44
LL | Box::new(test) as AsyncFnPtr;

0 commit comments

Comments
 (0)