From 81973a39e05bfc5ddad4b5a54903c2c8fbdfa273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 6 Jan 2023 01:03:52 +0000 Subject: [PATCH] Don't show `for<'lt>` in force trimmed paths --- compiler/rustc_middle/src/ty/print/pretty.rs | 11 ++++++++--- tests/ui/function-pointer/unsized-ret.stderr | 2 +- .../hang-on-deeply-nested-dyn.stderr | 4 ++-- tests/ui/higher-rank-trait-bounds/issue-30786.stderr | 2 +- tests/ui/issues/issue-102964.stderr | 2 +- tests/ui/issues/issue-24322.stderr | 2 +- tests/ui/issues/issue-57362-2.stderr | 4 ++-- tests/ui/nll/issue-57642-higher-ranked-subtype.stderr | 8 ++++---- tests/ui/regions/issue-102374.stderr | 2 +- tests/ui/suggestions/issue-101984.stderr | 2 +- 10 files changed, 22 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index f2abec216b7..d9d6e65a97a 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2346,6 +2346,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { } else { let tcx = self.tcx; + let trim_path = FORCE_TRIMMED_PATH.with(|flag| flag.get()); // Closure used in `RegionFolder` to create names for anonymous late-bound // regions. We use two `DebruijnIndex`es (one for the currently folded // late-bound region and the other for the binder level) to determine @@ -2400,8 +2401,10 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { } }; - start_or_continue(&mut self, "for<", ", "); - do_continue(&mut self, name); + if !trim_path { + start_or_continue(&mut self, "for<", ", "); + do_continue(&mut self, name); + } tcx.mk_region(ty::ReLateBound(ty::INNERMOST, ty::BoundRegion { var: br.var, kind })) }; let mut folder = RegionFolder { @@ -2412,7 +2415,9 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { }; let new_value = value.clone().skip_binder().fold_with(&mut folder); let region_map = folder.region_map; - start_or_continue(&mut self, "", "> "); + if !trim_path { + start_or_continue(&mut self, "", "> "); + } (new_value, region_map) }; diff --git a/tests/ui/function-pointer/unsized-ret.stderr b/tests/ui/function-pointer/unsized-ret.stderr index 6f430687e6d..dd00ff103e7 100644 --- a/tests/ui/function-pointer/unsized-ret.stderr +++ b/tests/ui/function-pointer/unsized-ret.stderr @@ -23,7 +23,7 @@ LL | foo:: fn(&'a ()) -> (dyn std::fmt::Display + 'a), _>(None, (&() | required by a bound introduced by this call | = 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)` - = note: required because it appears within the type `for<'a> fn(&'a ()) -> (dyn Display + 'a)` + = note: required because it appears within the type `fn(&'a ()) -> (dyn Display + 'a)` note: required by a bound in `foo` --> $DIR/unsized-ret.rs:5:11 | diff --git a/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.stderr b/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.stderr index 3e388653471..173bc47b272 100644 --- a/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.stderr +++ b/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.stderr @@ -11,9 +11,9 @@ LL | | ), LL | | ) { | |_- 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 LL | f - | ^ expected `&dyn for<'a> Fn(&'a ...)`, found `&dyn Fn(u32)` + | ^ expected `&dyn Fn(&'a (dyn Fn(&'a ...) + 'a))`, found `&dyn Fn(u32)` | - = 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))` + = 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))` 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' found reference `&dyn Fn(u32)` diff --git a/tests/ui/higher-rank-trait-bounds/issue-30786.stderr b/tests/ui/higher-rank-trait-bounds/issue-30786.stderr index 0458d2535f2..67105510573 100644 --- a/tests/ui/higher-rank-trait-bounds/issue-30786.stderr +++ b/tests/ui/higher-rank-trait-bounds/issue-30786.stderr @@ -19,7 +19,7 @@ note: the following trait bounds were not satisfied: LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here -error[E0599]: the method `countx` exists for struct `Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@issue-30786.rs:129:30]>`, but its trait bounds were not satisfied +error[E0599]: the method `countx` exists for struct `Filter &'a u64 {identity::}>, [closure@issue-30786.rs:129:30]>`, but its trait bounds were not satisfied --> $DIR/issue-30786.rs:130:24 | LL | pub struct Filter { diff --git a/tests/ui/issues/issue-102964.stderr b/tests/ui/issues/issue-102964.stderr index 4be53fd09e5..0cec4751fb8 100644 --- a/tests/ui/issues/issue-102964.stderr +++ b/tests/ui/issues/issue-102964.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-102964.rs:5:41 | LL | fn bar_function(function: Foo) -> RcFoo { - | ------------ ^^^^^^^^ expected `Rc<&dyn for<'a> Fn(&'a T)>`, found `()` + | ------------ ^^^^^^^^ expected `Rc<&dyn Fn(&'a T)>`, found `()` | | | implicitly returns `()` as its body has no tail or `return` expression | diff --git a/tests/ui/issues/issue-24322.stderr b/tests/ui/issues/issue-24322.stderr index 37cc3413f75..583afaead2d 100644 --- a/tests/ui/issues/issue-24322.stderr +++ b/tests/ui/issues/issue-24322.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-24322.rs:8:29 | LL | let x: &fn(&B) -> u32 = &B::func; - | -------------- ^^^^^^^^ expected `&for<'a> fn(&'a B) -> u32`, found `&for<'a> fn(&'a B) -> u32 {B::func}` + | -------------- ^^^^^^^^ expected `&fn(&'a B) -> u32`, found `&fn(&'a B) -> u32 {B::func}` | | | expected due to this | diff --git a/tests/ui/issues/issue-57362-2.stderr b/tests/ui/issues/issue-57362-2.stderr index 7d08c4643ff..8dcf7911baf 100644 --- a/tests/ui/issues/issue-57362-2.stderr +++ b/tests/ui/issues/issue-57362-2.stderr @@ -1,8 +1,8 @@ -error[E0599]: the function or associated item `make_g` exists for fn pointer `for<'a> fn(&'a ())`, but its trait bounds were not satisfied +error[E0599]: the function or associated item `make_g` exists for fn pointer `fn(&'a ())`, but its trait bounds were not satisfied --> $DIR/issue-57362-2.rs:22:25 | LL | let x = ::make_g(); - | ^^^^^^ function or associated item cannot be called on `for<'a> fn(&'a ())` due to unsatisfied trait bounds + | ^^^^^^ function or associated item cannot be called on `fn(&'a ())` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `for<'a> fn(&'a ()): X` diff --git a/tests/ui/nll/issue-57642-higher-ranked-subtype.stderr b/tests/ui/nll/issue-57642-higher-ranked-subtype.stderr index 6e96f40c0e0..ceef6e34d02 100644 --- a/tests/ui/nll/issue-57642-higher-ranked-subtype.stderr +++ b/tests/ui/nll/issue-57642-higher-ranked-subtype.stderr @@ -1,8 +1,8 @@ -error[E0599]: the function or associated item `make_g` exists for fn pointer `for<'a> fn(&'a ())`, but its trait bounds were not satisfied +error[E0599]: the function or associated item `make_g` exists for fn pointer `fn(&'a ())`, but its trait bounds were not satisfied --> $DIR/issue-57642-higher-ranked-subtype.rs:31:25 | LL | let x = ::make_g(); - | ^^^^^^ function or associated item cannot be called on `for<'a> fn(&'a ())` due to unsatisfied trait bounds + | ^^^^^^ function or associated item cannot be called on `fn(&'a ())` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `for<'a> fn(&'a ()): X` @@ -13,11 +13,11 @@ note: `X` defines an item `make_g`, perhaps you need to implement it LL | trait X { | ^^^^^^^ -error[E0599]: no function or associated item named `make_f` found for fn pointer `for<'a> fn(&'a ())` in the current scope +error[E0599]: no function or associated item named `make_f` found for fn pointer `fn(&'a ())` in the current scope --> $DIR/issue-57642-higher-ranked-subtype.rs:35:25 | LL | let x = ::make_f(); - | ^^^^^^ function or associated item not found in `for<'a> fn(&'a ())` + | ^^^^^^ function or associated item not found in `fn(&'a ())` | = help: items from traits can only be used if the trait is implemented and in scope note: `Y` defines an item `make_f`, perhaps you need to implement it diff --git a/tests/ui/regions/issue-102374.stderr b/tests/ui/regions/issue-102374.stderr index 157850693ab..af64b6867bb 100644 --- a/tests/ui/regions/issue-102374.stderr +++ b/tests/ui/regions/issue-102374.stderr @@ -7,7 +7,7 @@ LL | f | ^ expected `i32`, found fn pointer | = note: expected type `i32` - 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<...>)` + found fn pointer `fn(Cell<...>)` the full type name has been written to '$TEST_BUILD_DIR/regions/issue-102374/issue-102374.long-type-hash.txt' error: aborting due to previous error diff --git a/tests/ui/suggestions/issue-101984.stderr b/tests/ui/suggestions/issue-101984.stderr index 6ae2842b2bf..3492f4ea0f1 100644 --- a/tests/ui/suggestions/issue-101984.stderr +++ b/tests/ui/suggestions/issue-101984.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | let (cmp, router) = self.router.at()?; | ^^^^^^^^^^^^^ ----------------- this expression has type `Match<&(for<'a> fn(&'a ()), Box)>` | | - | expected `Match<&(for<'a> fn(&'a ()), ...)>`, found `(_, _)` + | expected `Match<&(fn(&'a ()), Box)>`, found `(_, _)` | = note: expected struct `Match<&(for<'a> fn(&'a ()), Box)>` found tuple `(_, _)`