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

Commit 81973a3

Browse files
committed
Don't show for<'lt> in force trimmed paths
1 parent 3fa95b8 commit 81973a3

File tree

10 files changed

+22
-17
lines changed

10 files changed

+22
-17
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,6 +2346,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
23462346
} else {
23472347
let tcx = self.tcx;
23482348

2349+
let trim_path = FORCE_TRIMMED_PATH.with(|flag| flag.get());
23492350
// Closure used in `RegionFolder` to create names for anonymous late-bound
23502351
// regions. We use two `DebruijnIndex`es (one for the currently folded
23512352
// late-bound region and the other for the binder level) to determine
@@ -2400,8 +2401,10 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
24002401
}
24012402
};
24022403

2403-
start_or_continue(&mut self, "for<", ", ");
2404-
do_continue(&mut self, name);
2404+
if !trim_path {
2405+
start_or_continue(&mut self, "for<", ", ");
2406+
do_continue(&mut self, name);
2407+
}
24052408
tcx.mk_region(ty::ReLateBound(ty::INNERMOST, ty::BoundRegion { var: br.var, kind }))
24062409
};
24072410
let mut folder = RegionFolder {
@@ -2412,7 +2415,9 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
24122415
};
24132416
let new_value = value.clone().skip_binder().fold_with(&mut folder);
24142417
let region_map = folder.region_map;
2415-
start_or_continue(&mut self, "", "> ");
2418+
if !trim_path {
2419+
start_or_continue(&mut self, "", "> ");
2420+
}
24162421
(new_value, region_map)
24172422
};
24182423

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 `for<'a> fn(&'a ()) -> (dyn Display + 'a)`
26+
= note: required because it appears within the type `fn(&'a ()) -> (dyn Display + 'a)`
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 for<'a> Fn(&'a ...)`, found `&dyn Fn(u32)`
14+
| ^ expected `&dyn Fn(&'a (dyn Fn(&'a ...) + 'a))`, found `&dyn Fn(u32)`
1515
|
16-
= note: expected reference `&dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a ...) + 'a)) + 'a)) + 'a))`
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))`
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, for<'a> 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(&'a u64) -> &'a 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/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 for<'a> Fn(&'a T)>`, found `()`
5+
| ------------ ^^^^^^^^ expected `Rc<&dyn Fn(&'a T)>`, found `()`
66
| |
77
| implicitly returns `()` as its body has no tail or `return` expression
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 `&for<'a> fn(&'a B) -> u32`, found `&for<'a> fn(&'a B) -> u32 {B::func}`
5+
| -------------- ^^^^^^^^ expected `&fn(&'a B) -> u32`, found `&fn(&'a 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 `for<'a> fn(&'a ())`, but its trait bounds were not satisfied
1+
error[E0599]: the function or associated item `make_g` exists for fn pointer `fn(&'a ())`, 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 `for<'a> fn(&'a ())` due to unsatisfied trait bounds
5+
| ^^^^^^ function or associated item cannot be called on `fn(&'a ())` due to unsatisfied trait bounds
66
|
77
= note: the following trait bounds were not satisfied:
88
`for<'a> fn(&'a ()): X`

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 `for<'a> fn(&'a ())`, but its trait bounds were not satisfied
1+
error[E0599]: the function or associated item `make_g` exists for fn pointer `fn(&'a ())`, 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 `for<'a> fn(&'a ())` due to unsatisfied trait bounds
5+
| ^^^^^^ function or associated item cannot be called on `fn(&'a ())` 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 `for<'a> fn(&'a ())` in the current scope
16+
error[E0599]: no function or associated item named `make_f` found for fn pointer `fn(&'a ())` 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 `for<'a> fn(&'a ())`
20+
| ^^^^^^ function or associated item not found in `fn(&'a ())`
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/regions/issue-102374.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | f
77
| ^ expected `i32`, found fn pointer
88
|
99
= note: expected type `i32`
10-
found fn pointer `for<'z1, 'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, 'p, 'q, 'r, 's, 't, 'u, 'v, 'w, 'x, 'y, 'z, 'z0> fn(Cell<...>)`
10+
found fn pointer `fn(Cell<...>)`
1111
the full type name has been written to '$TEST_BUILD_DIR/regions/issue-102374/issue-102374.long-type-hash.txt'
1212

1313
error: aborting due to previous error

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<&(for<'a> fn(&'a ()), ...)>`, found `(_, _)`
7+
| expected `Match<&(fn(&'a ()), Box<Wrapper>)>`, found `(_, _)`
88
|
99
= note: expected struct `Match<&(for<'a> fn(&'a ()), Box<Wrapper>)>`
1010
found tuple `(_, _)`

0 commit comments

Comments
 (0)