about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/mod.rs5
-rw-r--r--src/test/ui/diagnostic-width/long-E0308.rs2
-rw-r--r--src/test/ui/diagnostic-width/long-E0308.stderr24
-rw-r--r--src/test/ui/typeck/return_type_containing_closure.stderr3
4 files changed, 18 insertions, 16 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
index 1750282712a..7b936c7693b 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
@@ -2503,7 +2503,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
         Some(match (exp_found.expected.unpack(), exp_found.found.unpack()) {
             (ty::TermKind::Ty(expected), ty::TermKind::Ty(found)) => {
                 let (mut exp, mut fnd) = self.cmp(expected, found);
-                let len = self.tcx.sess().diagnostic_width().saturating_sub(20);
+                // Use the terminal width as the basis to determine when to compress the printed
+                // out type, but give ourselves some leeway to avoid ending up creating a file for
+                // a type that is somewhat shorter than the path we'd write to.
+                let len = self.tcx.sess().diagnostic_width() + 40;
                 let exp_s = exp.content();
                 let fnd_s = fnd.content();
                 let mut exp_p = None;
diff --git a/src/test/ui/diagnostic-width/long-E0308.rs b/src/test/ui/diagnostic-width/long-E0308.rs
index 22ee1cd8d55..3fd7a7110fd 100644
--- a/src/test/ui/diagnostic-width/long-E0308.rs
+++ b/src/test/ui/diagnostic-width/long-E0308.rs
@@ -1,4 +1,4 @@
-// compile-flags: --diagnostic-width=100
+// compile-flags: --diagnostic-width=60
 // normalize-stderr-test: "long-type-\d+" -> "long-type-hash"
 
 struct Atype<T, K>(T, K);
diff --git a/src/test/ui/diagnostic-width/long-E0308.stderr b/src/test/ui/diagnostic-width/long-E0308.stderr
index 142e34f7687..c784995b0e8 100644
--- a/src/test/ui/diagnostic-width/long-E0308.stderr
+++ b/src/test/ui/diagnostic-width/long-E0308.stderr
@@ -8,35 +8,35 @@ LL |  |         Ctype<
 LL |  |           Atype<
 ...   |
 LL |  |       i32
-LL |  |     > = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(...
+LL |  |     > = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok...
    |  |_____-___^
    | ||_____|
    | |      expected due to this
-LL | |          Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(...
+LL | |          Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok...
 LL | |              Ok("")
 LL | |          ))))))))))))))))))))))))))))))
 LL | |      ))))))))))))))))))))))))))))));
    | |___________________________________^ expected struct `Atype`, found enum `Result`
    |
-   = note: expected struct `Atype<Btype<Ctype<Atype<Btype<Ctype<..., ...>, ...>, ...>, ...>, ...>, ...>`
+   = note: expected struct `Atype<Btype<Ctype<..., ...>, ...>, ...>`
            the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
-                found enum `Result<Result<Result<Result<Result<..., ...>, ...>, ...>, ...>, ...>`
+                found enum `Result<Result<..., ...>, ...>`
            the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
 
 error[E0308]: mismatched types
   --> $DIR/long-E0308.rs:46:26
    |
-LL |       ))))))))))))))))) == Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok...
+LL |       ))))))))))))))))) == Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O...
    |  __________________________^
-LL | |         Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O...
+LL | |         Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(...
 LL | |             Ok(Ok(Ok(Ok(Ok(Ok(Ok("")))))))
 LL | |         ))))))))))))))))))))))))))))))
 LL | |     ))))))))))))))))))))))));
    | |____________________________^ expected enum `Option`, found enum `Result`
    |
-   = note: expected enum `Option<Result<Option<Option<Option<Option<Option<Option<Option<...>>>>>>>, ...>>`
+   = note: expected enum `Option<Result<Option<Option<...>>, ...>>`
            the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
-              found enum `Result<Result<Result<Result<Result<..., ...>, ...>, ...>, ...>, ...>`
+              found enum `Result<Result<..., ...>, ...>`
            the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
 
 error[E0308]: mismatched types
@@ -54,25 +54,25 @@ LL | |     > = ();
    | |_____|
    |       expected due to this
    |
-   = note: expected struct `Atype<Btype<Ctype<Atype<Btype<Ctype<..., ...>, ...>, ...>, ...>, ...>, ...>`
+   = note: expected struct `Atype<Btype<Ctype<..., ...>, ...>, ...>`
            the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
            found unit type `()`
 
 error[E0308]: mismatched types
   --> $DIR/long-E0308.rs:80:17
    |
-LL |       let _: () = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(
+LL |       let _: () = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O...
    |  ____________--___^
    | |            |
    | |            expected due to this
-LL | |         Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O...
+LL | |         Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(...
 LL | |             Ok(Ok(Ok(Ok(Ok(Ok(Ok("")))))))
 LL | |         ))))))))))))))))))))))))))))))
 LL | |     ))))))))))))))))))))))));
    | |____________________________^ expected `()`, found enum `Result`
    |
    = note: expected unit type `()`
-                   found enum `Result<Result<Result<Result<Result<..., ...>, ...>, ...>, ...>, ...>`
+                   found enum `Result<Result<..., ...>, ...>`
            the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
 
 error: aborting due to 4 previous errors
diff --git a/src/test/ui/typeck/return_type_containing_closure.stderr b/src/test/ui/typeck/return_type_containing_closure.stderr
index d6c103de3dc..90b552a6283 100644
--- a/src/test/ui/typeck/return_type_containing_closure.stderr
+++ b/src/test/ui/typeck/return_type_containing_closure.stderr
@@ -5,8 +5,7 @@ LL |     vec!['a'].iter().map(|c| c)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found struct `Map`
    |
    = note: expected unit type `()`
-                 found struct `Map<std::slice::Iter<'_, char>, ...>`
-           the full type name has been written to '$TEST_BUILD_DIR/typeck/return_type_containing_closure/return_type_containing_closure.long-type-hash.txt'
+                 found struct `Map<std::slice::Iter<'_, char>, [closure@$DIR/return_type_containing_closure.rs:4:26: 4:29]>`
 help: consider using a semicolon here
    |
 LL |     vec!['a'].iter().map(|c| c);