Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3136bfe

Browse files
committed
Special case the situation where the previous span is the same as the new one
1 parent d5b6510 commit 3136bfe

File tree

5 files changed

+17
-25
lines changed

5 files changed

+17
-25
lines changed

compiler/rustc_typeck/src/collect/type_of.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,11 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
610610
concrete_type.span,
611611
format!("expected `{}`, got `{}`", prev.ty, concrete_type.ty),
612612
);
613-
err.span_note(prev.span, "previous use here");
613+
if prev.span == concrete_type.span {
614+
err.span_label(prev.span, "this expression supplies two conflicting concrete types for the same opaque type");
615+
} else {
616+
err.span_note(prev.span, "previous use here");
617+
}
614618
err.emit();
615619
}
616620
} else {
Lines changed: 3 additions & 6 deletions
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

Lines changed: 3 additions & 6 deletions
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

Lines changed: 3 additions & 6 deletions
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

Lines changed: 3 additions & 6 deletions
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)