Special case the situation where the previous span is the same as the new one

This commit is contained in:
Oli Scherer 2022-02-09 17:39:28 +00:00
parent d5b6510bfb
commit 3136bfef93
5 changed files with 17 additions and 25 deletions

View File

@ -610,7 +610,11 @@ fn check(&mut self, def_id: LocalDefId) {
concrete_type.span,
format!("expected `{}`, got `{}`", prev.ty, concrete_type.ty),
);
err.span_note(prev.span, "previous use here");
if prev.span == concrete_type.span {
err.span_label(prev.span, "this expression supplies two conflicting concrete types for the same opaque type");
} else {
err.span_note(prev.span, "previous use here");
}
err.emit();
}
} else {

View File

@ -1,14 +1,11 @@
error: concrete type differs from previous defining opaque type use
--> $DIR/issue-86465.rs:6:5
|
LL | (a, a)
| ^^^^^^ expected `&'a u32`, got `&'b u32`
|
note: previous use here
--> $DIR/issue-86465.rs:6:5
|
LL | (a, a)
| ^^^^^^
| |
| expected `&'a u32`, got `&'b u32`
| this expression supplies two conflicting concrete types for the same opaque type
error: aborting due to previous error

View File

@ -1,14 +1,11 @@
error: concrete type differs from previous defining opaque type use
--> $DIR/multiple-def-uses-in-one-fn-infer.rs:10:5
|
LL | (42_i64, 60)
| ^^^^^^^^^^^^ expected `i64`, got `i32`
|
note: previous use here
--> $DIR/multiple-def-uses-in-one-fn-infer.rs:10:5
|
LL | (42_i64, 60)
| ^^^^^^^^^^^^
| |
| expected `i64`, got `i32`
| this expression supplies two conflicting concrete types for the same opaque type
error: aborting due to previous error

View File

@ -1,14 +1,11 @@
error: concrete type differs from previous defining opaque type use
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5
|
LL | (i, i)
| ^^^^^^ expected `&'a i32`, got `&'b i32`
|
note: previous use here
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5
|
LL | (i, i)
| ^^^^^^
| |
| expected `&'a i32`, got `&'b i32`
| this expression supplies two conflicting concrete types for the same opaque type
error: aborting due to previous error

View File

@ -1,14 +1,11 @@
error: concrete type differs from previous defining opaque type use
--> $DIR/multiple-def-uses-in-one-fn2.rs:10:5
|
LL | (a.clone(), a)
| ^^^^^^^^^^^^^^ expected `A`, got `B`
|
note: previous use here
--> $DIR/multiple-def-uses-in-one-fn2.rs:10:5
|
LL | (a.clone(), a)
| ^^^^^^^^^^^^^^
| |
| expected `A`, got `B`
| this expression supplies two conflicting concrete types for the same opaque type
error: aborting due to previous error