Skip to content

Commit dd7a93d

Browse files
committed
Special case the situation where the previous span is the same as the new one
1 parent 91fa570 commit dd7a93d

File tree

5 files changed

+17
-25
lines changed

5 files changed

+17
-25
lines changed

compiler/rustc_typeck/src/collect/type_of.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,11 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
639639
concrete_type.span,
640640
format!("expected `{}`, got `{}`", prev.ty, concrete_type.ty),
641641
);
642-
err.span_note(prev.span, "previous use here");
642+
if prev.span == concrete_type.span {
643+
err.span_label(prev.span, "this expression supplies two conflicting concrete types for the same opaque type");
644+
} else {
645+
err.span_note(prev.span, "previous use here");
646+
}
643647
err.emit();
644648
}
645649
} else {
+3-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
error: concrete type differs from previous defining opaque type use
22
--> $DIR/issue-86465.rs:6:5
33
|
4-
LL | (a, a)
5-
| ^^^^^^ expected `&'a u32`, got `&'b u32`
6-
|
7-
note: previous use here
8-
--> $DIR/issue-86465.rs:6:5
9-
|
104
LL | (a, a)
115
| ^^^^^^
6+
| |
7+
| expected `&'a u32`, got `&'b u32`
8+
| this expression supplies two conflicting concrete types for the same opaque type
129

1310
error: aborting due to previous error
1411

Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
error: concrete type differs from previous defining opaque type use
22
--> $DIR/multiple-def-uses-in-one-fn-infer.rs:10:5
33
|
4-
LL | (42_i64, 60)
5-
| ^^^^^^^^^^^^ expected `i64`, got `i32`
6-
|
7-
note: previous use here
8-
--> $DIR/multiple-def-uses-in-one-fn-infer.rs:10:5
9-
|
104
LL | (42_i64, 60)
115
| ^^^^^^^^^^^^
6+
| |
7+
| expected `i64`, got `i32`
8+
| this expression supplies two conflicting concrete types for the same opaque type
129

1310
error: aborting due to previous error
1411

Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
error: concrete type differs from previous defining opaque type use
22
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5
33
|
4-
LL | (i, i)
5-
| ^^^^^^ expected `&'a i32`, got `&'b i32`
6-
|
7-
note: previous use here
8-
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5
9-
|
104
LL | (i, i)
115
| ^^^^^^
6+
| |
7+
| expected `&'a i32`, got `&'b i32`
8+
| this expression supplies two conflicting concrete types for the same opaque type
129

1310
error: aborting due to previous error
1411

Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
error: concrete type differs from previous defining opaque type use
22
--> $DIR/multiple-def-uses-in-one-fn2.rs:10:5
33
|
4-
LL | (a.clone(), a)
5-
| ^^^^^^^^^^^^^^ expected `A`, got `B`
6-
|
7-
note: previous use here
8-
--> $DIR/multiple-def-uses-in-one-fn2.rs:10:5
9-
|
104
LL | (a.clone(), a)
115
| ^^^^^^^^^^^^^^
6+
| |
7+
| expected `A`, got `B`
8+
| this expression supplies two conflicting concrete types for the same opaque type
129

1310
error: aborting due to previous error
1411

0 commit comments

Comments
 (0)