Skip to content

Commit 81c86dd

Browse files
committed
show fnsig's output when there is difference
1 parent f46c412 commit 81c86dd

File tree

6 files changed

+10
-15
lines changed

6 files changed

+10
-15
lines changed

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

+3-8
Original file line numberDiff line numberDiff line change
@@ -1168,17 +1168,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
11681168
let output1 = sig1.output();
11691169
let output2 = sig2.output();
11701170
let (x1, x2) = self.cmp(output1, output2);
1171-
let only_output_diff = !lifetime_diff
1172-
&& sig1.c_variadic == sig2.c_variadic
1173-
&& sig1.safety == sig2.safety
1174-
&& sig1.abi == sig2.abi
1175-
&& sig1.inputs() == sig2.inputs()
1176-
&& x1 != x2;
1177-
if !output1.is_unit() || only_output_diff {
1171+
let output_diff = x1 != x2;
1172+
if !output1.is_unit() || output_diff {
11781173
values.0.push_normal(" -> ");
11791174
(values.0).0.extend(x1.0);
11801175
}
1181-
if !output2.is_unit() || only_output_diff {
1176+
if !output2.is_unit() || output_diff {
11821177
values.1.push_normal(" -> ");
11831178
(values.1).0.extend(x2.0);
11841179
}

tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ LL | extern "rust-call" fn call(self, args: ()) -> () {}
9292
| ^^^^ expected `&Foo`, found `Foo`
9393
|
9494
= note: expected signature `extern "rust-call" fn(&Foo, ()) -> _`
95-
found signature `extern "rust-call" fn(Foo, ())`
95+
found signature `extern "rust-call" fn(Foo, ()) -> ()`
9696
help: change the self-receiver type to match the trait
9797
|
9898
LL | extern "rust-call" fn call(&self, args: ()) -> () {}
@@ -162,7 +162,7 @@ LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {}
162162
| ^^^^^ types differ in mutability
163163
|
164164
= note: expected signature `extern "rust-call" fn(&mut Bar, ()) -> _`
165-
found signature `extern "rust-call" fn(&Bar, ())`
165+
found signature `extern "rust-call" fn(&Bar, ()) -> ()`
166166
help: change the self-receiver type to match the trait
167167
|
168168
LL | extern "rust-call" fn call_mut(&mut self, args: ()) -> () {}

tests/ui/fn/fn_def_opaque_coercion_to_fn_ptr.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | x = foo::<()>;
1010
| ^^^^^^^^^ expected fn item, found a different fn item
1111
|
1212
= note: expected fn item `fn(F) -> F {bar::<F>}`
13-
found fn item `fn(()) {foo::<()>}`
13+
found fn item `fn(()) -> () {foo::<()>}`
1414

1515
error[E0308]: mismatched types
1616
--> $DIR/fn_def_opaque_coercion_to_fn_ptr.rs:27:9
@@ -26,7 +26,7 @@ LL | let mut x = bar::<()>;
2626
LL | x = foo::<I>;
2727
| ^^^^^^^^ expected fn item, found a different fn item
2828
|
29-
= note: expected fn item `fn(()) {bar::<()>}`
29+
= note: expected fn item `fn(()) -> () {bar::<()>}`
3030
found fn item `fn(I) -> I {foo::<I>}`
3131
help: use parentheses to call this function
3232
|

tests/ui/impl-trait/trait_type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn fmt(&self, x: &str) -> () { }
55
| ^^^^ types differ in mutability
66
|
77
= note: expected signature `fn(&MyType, &mut Formatter<'_>) -> Result<(), std::fmt::Error>`
8-
found signature `fn(&MyType, &str)`
8+
found signature `fn(&MyType, &str) -> ()`
99
help: change the parameter type to match the trait
1010
|
1111
LL | fn fmt(&self, x: &mut Formatter<'_>) -> () { }

tests/ui/panic-handler/panic-handler-bad-signature-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn panic(info: PanicInfo) -> () {}
55
| ^^^^^^^^^ expected `&PanicInfo<'_>`, found `PanicInfo<'_>`
66
|
77
= note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !`
8-
found signature `for<'a> fn(PanicInfo<'a>)`
8+
found signature `for<'a> fn(PanicInfo<'a>) -> ()`
99

1010
error: aborting due to 1 previous error
1111

tests/ui/traits/impl-method-mismatch.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: type in trait
1010
LL | fn jumbo(&self, x: &usize) -> usize;
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= note: expected signature `fn(&_, &_) -> usize`
13-
found signature `unsafe fn(&_, &_)`
13+
found signature `unsafe fn(&_, &_) -> ()`
1414

1515
error: aborting due to 1 previous error
1616

0 commit comments

Comments
 (0)