Skip to content

Commit 5c642d7

Browse files
Don't elide information when printing E0308 with Zverbose
1 parent e960b5e commit 5c642d7

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12621262
let num_display_types = consts_offset - regions_len;
12631263
for (i, (ta1, ta2)) in type_arguments.take(num_display_types).enumerate() {
12641264
let i = i + regions_len;
1265-
if ta1 == ta2 {
1265+
if ta1 == ta2 && !self.tcx.sess.verbose() {
12661266
values.0.push_normal("_");
12671267
values.1.push_normal("_");
12681268
} else {
@@ -1278,7 +1278,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12781278
let const_arguments = sub1.consts().zip(sub2.consts());
12791279
for (i, (ca1, ca2)) in const_arguments.enumerate() {
12801280
let i = i + consts_offset;
1281-
if ca1 == ca2 {
1281+
if ca1 == ca2 && !self.tcx.sess.verbose() {
12821282
values.0.push_normal("_");
12831283
values.1.push_normal("_");
12841284
} else {
@@ -1457,7 +1457,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
14571457
(ty::FnPtr(sig1), ty::FnPtr(sig2)) => self.cmp_fn_sig(sig1, sig2),
14581458

14591459
_ => {
1460-
if t1 == t2 {
1460+
if t1 == t2 && !self.tcx.sess.verbose() {
14611461
// The two types are the same, elide and don't highlight.
14621462
(DiagnosticStyledString::normal("_"), DiagnosticStyledString::normal("_"))
14631463
} else {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// compile-flags: -Zverbose
2+
3+
fn foo(_: i32, _: i32) {}
4+
5+
fn needs_ptr(_: fn(i32, u32)) {}
6+
//~^ NOTE function defined here
7+
//~| NOTE
8+
9+
fn main() {
10+
needs_ptr(foo);
11+
//~^ ERROR mismatched types
12+
//~| NOTE expected `u32`, found `i32`
13+
//~| NOTE expected fn pointer `fn(i32, u32)`
14+
//~| NOTE arguments to this function are incorrect
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/signature-error-reporting-under-verbose.rs:10:15
3+
|
4+
LL | needs_ptr(foo);
5+
| --------- ^^^ expected `u32`, found `i32`
6+
| |
7+
| arguments to this function are incorrect
8+
|
9+
= note: expected fn pointer `fn(i32, u32)`
10+
found fn item `fn(i32, i32) {foo}`
11+
note: function defined here
12+
--> $DIR/signature-error-reporting-under-verbose.rs:5:4
13+
|
14+
LL | fn needs_ptr(_: fn(i32, u32)) {}
15+
| ^^^^^^^^^ ---------------
16+
17+
error: aborting due to previous error
18+
19+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)