about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-01-06 01:03:52 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-01-30 20:12:21 +0000
commit81973a39e05bfc5ddad4b5a54903c2c8fbdfa273 (patch)
treedbd0983c2dc59a962daf3a5a09a67628ec39cfa1
parent3fa95b847be64342562bccd55abb7e55c8daa3f2 (diff)
downloadrust-81973a39e05bfc5ddad4b5a54903c2c8fbdfa273.tar.gz
rust-81973a39e05bfc5ddad4b5a54903c2c8fbdfa273.zip
Don't show `for<'lt>` in force trimmed paths
-rw-r--r--compiler/rustc_middle/src/ty/print/pretty.rs11
-rw-r--r--tests/ui/function-pointer/unsized-ret.stderr2
-rw-r--r--tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.stderr4
-rw-r--r--tests/ui/higher-rank-trait-bounds/issue-30786.stderr2
-rw-r--r--tests/ui/issues/issue-102964.stderr2
-rw-r--r--tests/ui/issues/issue-24322.stderr2
-rw-r--r--tests/ui/issues/issue-57362-2.stderr4
-rw-r--r--tests/ui/nll/issue-57642-higher-ranked-subtype.stderr8
-rw-r--r--tests/ui/regions/issue-102374.stderr2
-rw-r--r--tests/ui/suggestions/issue-101984.stderr2
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::<for<'a> 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<T> StreamExt for T where for<'a> &'a mut T: Stream {}
    |         ---------     -                          ^^^^^^ unsatisfied trait bound introduced here
 
-error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@issue-30786.rs:129:30]>`, but its trait bounds were not satisfied
+error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@issue-30786.rs:129:30]>`, but its trait bounds were not satisfied
   --> $DIR/issue-30786.rs:130:24
    |
 LL | pub struct Filter<S, F> {
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<T>(function: Foo<T>) -> RcFoo<T> {
-   |    ------------                         ^^^^^^^^ 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 = <fn (&())>::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 = <fn (&())>::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 = <fn (&())>::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<Wrapper>)>`
    |             |
-   |             expected `Match<&(for<'a> fn(&'a ()), ...)>`, found `(_, _)`
+   |             expected `Match<&(fn(&'a ()), Box<Wrapper>)>`, found `(_, _)`
    |
    = note: expected struct `Match<&(for<'a> fn(&'a ()), Box<Wrapper>)>`
                found tuple `(_, _)`