about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2024-02-21 08:55:57 +0000
committerGitHub <noreply@github.com>2024-02-21 08:55:57 +0000
commit4a205bba5eb4ca3e17fd920015a8d95001511bc7 (patch)
tree5a832981b5918d663c2b35bad0419b20bc78550c
parent94e459f1a9919eab5f34ccfe4887e03101335eee (diff)
parente35481f90bcd7e4a646aabab1183a33bebae8c94 (diff)
downloadrust-4a205bba5eb4ca3e17fd920015a8d95001511bc7.tar.gz
rust-4a205bba5eb4ca3e17fd920015a8d95001511bc7.zip
Rollup merge of #121328 - ffmancera:ff/verbose_long_type, r=compiler-errors
Make --verbose imply -Z write-long-types-to-disk=no

When shortening the type it is necessary to take into account the `--verbose` flag, if it is activated, we must always show the entire type and not write it in a file.

Fixes: https://github.com/rust-lang/rust/issues/119130
-rw-r--r--compiler/rustc_hir_typeck/src/method/suggest.rs6
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/mod.rs1
-rw-r--r--compiler/rustc_middle/src/ty/error.rs2
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs12
-rw-r--r--tests/ui/diagnostic-width/long-E0308.stderr4
5 files changed, 24 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs
index c77e5856307..cc111af5d8f 100644
--- a/compiler/rustc_hir_typeck/src/method/suggest.rs
+++ b/compiler/rustc_hir_typeck/src/method/suggest.rs
@@ -369,6 +369,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         };
         if let Some(file) = file {
             err.note(format!("the full type name has been written to '{}'", file.display()));
+            err.note(format!(
+                "consider using `--verbose` to print the full type name to the console"
+            ));
         }
 
         err
@@ -493,6 +496,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
         if let Some(file) = ty_file {
             err.note(format!("the full type name has been written to '{}'", file.display(),));
+            err.note(format!(
+                "consider using `--verbose` to print the full type name to the console"
+            ));
         }
         if rcvr_ty.references_error() {
             err.downgrade_to_delayed_bug();
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
index 4f2a576c573..505d56cf491 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
@@ -1935,6 +1935,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                                         "the full type name has been written to '{}'",
                                         path.display(),
                                     ));
+                                    diag.note(format!("consider using `--verbose` to print the full type name to the console"));
                                 }
                             }
                         }
diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs
index 80b763d1469..e15f0378846 100644
--- a/compiler/rustc_middle/src/ty/error.rs
+++ b/compiler/rustc_middle/src/ty/error.rs
@@ -351,7 +351,7 @@ impl<'tcx> TyCtxt<'tcx> {
         })
         .expect("could not write to `String`");
 
-        if !self.sess.opts.unstable_opts.write_long_types_to_disk {
+        if !self.sess.opts.unstable_opts.write_long_types_to_disk || self.sess.opts.verbose {
             return regular;
         }
 
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index 101460789ee..8ae31392b40 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -1283,6 +1283,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                             "the full type name has been written to '{}'",
                             file.display()
                         ));
+                        err.note(format!(
+                            "consider using `--verbose` to print full type name to the console"
+                        ));
                     }
 
                     if imm_ref_self_ty_satisfies_pred && mut_ref_self_ty_satisfies_pred {
@@ -2866,6 +2869,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                         "the full name for the type has been written to '{}'",
                         file.display(),
                     ));
+                    err.note(format!(
+                        "consider using `--verbose` to print the full type name to the console"
+                    ));
                 }
             }
             ObligationCauseCode::RepeatElementCopy {
@@ -3333,6 +3339,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                         "the full type name has been written to '{}'",
                         file.display(),
                     ));
+                    err.note(format!(
+                        "consider using `--verbose` to print the full type name to the console"
+                    ));
                 }
                 let mut parent_predicate = parent_trait_pred;
                 let mut data = &data.derived;
@@ -3386,6 +3395,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                             "the full type name has been written to '{}'",
                             file.display(),
                         ));
+                        err.note(format!(
+                            "consider using `--verbose` to print the full type name to the console"
+                        ));
                     }
                 }
                 // #74711: avoid a stack overflow
diff --git a/tests/ui/diagnostic-width/long-E0308.stderr b/tests/ui/diagnostic-width/long-E0308.stderr
index 1e5966a1c5d..eb37da037e9 100644
--- a/tests/ui/diagnostic-width/long-E0308.stderr
+++ b/tests/ui/diagnostic-width/long-E0308.stderr
@@ -21,6 +21,7 @@ LL |  |     ))))))))))))))))))))))))))))));
    = note: expected struct `Atype<Btype<..., ...>, ...>`
                 found enum `Result<Result<..., ...>, ...>`
    = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
+   = note: consider using `--verbose` to print the full type name to the console
 
 error[E0308]: mismatched types
   --> $DIR/long-E0308.rs:57:26
@@ -36,6 +37,7 @@ LL | |     ))))))))))))))))))))))));
    = note: expected enum `Option<Result<..., ...>>`
               found enum `Result<Result<..., ...>, ...>`
    = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
+   = note: consider using `--verbose` to print the full type name to the console
 
 error[E0308]: mismatched types
   --> $DIR/long-E0308.rs:88:9
@@ -55,6 +57,7 @@ LL | |     > = ();
    = note: expected struct `Atype<Btype<..., ...>, ...>`
            found unit type `()`
    = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
+   = note: consider using `--verbose` to print the full type name to the console
 
 error[E0308]: mismatched types
   --> $DIR/long-E0308.rs:91:17
@@ -72,6 +75,7 @@ LL | |     ))))))))))))))))))))))));
    = note: expected unit type `()`
                    found enum `Result<Result<..., ...>, ...>`
    = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
+   = note: consider using `--verbose` to print the full type name to the console
 
 error: aborting due to 4 previous errors