Skip to content

Commit 88a5321

Browse files
committed
Remove unnecessary label
1 parent dbecdd5 commit 88a5321

8 files changed

+21
-37
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -2312,14 +2312,17 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
23122312
_ => self.tcx.typeck(parent_id),
23132313
};
23142314
let ty = typeck_results.expr_ty_adjusted(expr);
2315-
err.span_label(
2316-
expr.peel_blocks().span,
2317-
&if ty.references_error() {
2318-
String::new()
2319-
} else {
2320-
format!("this tail expression is of type `{:?}`", ty)
2321-
},
2322-
);
2315+
let span = expr.peel_blocks().span;
2316+
if Some(span) != err.span.primary_span() {
2317+
err.span_label(
2318+
span,
2319+
&if ty.references_error() {
2320+
String::new()
2321+
} else {
2322+
format!("this tail expression is of type `{:?}`", ty)
2323+
},
2324+
);
2325+
}
23232326
}
23242327
if let Some(Node::Expr(hir::Expr {
23252328
kind:
@@ -2328,7 +2331,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
23282331
..
23292332
})) = hir.find(call_hir_id)
23302333
{
2331-
err.span_label(*span, "required by a bound introduced by this call");
2334+
if Some(*span) != err.span.primary_span() {
2335+
err.span_label(*span, "required by a bound introduced by this call");
2336+
}
23322337
}
23332338
ensure_sufficient_stack(|| {
23342339
self.note_obligation_cause_code(

src/test/ui/derives/derives-span-Clone-enum-struct-variant.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ LL | #[derive(Clone)]
55
| ----- in this derive macro expansion
66
...
77
LL | x: Error
8-
| ^^^^^^^^
9-
| |
10-
| the trait `Clone` is not implemented for `Error`
11-
| required by a bound introduced by this call
8+
| ^^^^^^^^ the trait `Clone` is not implemented for `Error`
129
|
1310
note: required by `clone`
1411
--> $SRC_DIR/core/src/clone.rs:LL:COL

src/test/ui/derives/derives-span-Clone-enum.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ LL | #[derive(Clone)]
55
| ----- in this derive macro expansion
66
...
77
LL | Error
8-
| ^^^^^
9-
| |
10-
| the trait `Clone` is not implemented for `Error`
11-
| required by a bound introduced by this call
8+
| ^^^^^ the trait `Clone` is not implemented for `Error`
129
|
1310
note: required by `clone`
1411
--> $SRC_DIR/core/src/clone.rs:LL:COL

src/test/ui/derives/derives-span-Clone-struct.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ LL | #[derive(Clone)]
55
| ----- in this derive macro expansion
66
LL | struct Struct {
77
LL | x: Error
8-
| ^^^^^^^^
9-
| |
10-
| the trait `Clone` is not implemented for `Error`
11-
| required by a bound introduced by this call
8+
| ^^^^^^^^ the trait `Clone` is not implemented for `Error`
129
|
1310
note: required by `clone`
1411
--> $SRC_DIR/core/src/clone.rs:LL:COL

src/test/ui/derives/derives-span-Clone-tuple-struct.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ LL | #[derive(Clone)]
55
| ----- in this derive macro expansion
66
LL | struct Struct(
77
LL | Error
8-
| ^^^^^
9-
| |
10-
| the trait `Clone` is not implemented for `Error`
11-
| required by a bound introduced by this call
8+
| ^^^^^ the trait `Clone` is not implemented for `Error`
129
|
1310
note: required by `clone`
1411
--> $SRC_DIR/core/src/clone.rs:LL:COL

src/test/ui/derives/deriving-no-inner-impl-error-message.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ LL | #[derive(Clone)]
2929
| ----- in this derive macro expansion
3030
LL | struct C {
3131
LL | x: NoCloneOrEq
32-
| ^^^^^^^^^^^^^^
33-
| |
34-
| the trait `Clone` is not implemented for `NoCloneOrEq`
35-
| required by a bound introduced by this call
32+
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoCloneOrEq`
3633
|
3734
note: required by `clone`
3835
--> $SRC_DIR/core/src/clone.rs:LL:COL

src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ LL | #[test]
66
LL | / fn can_parse_zero_as_f32() -> Result<f32, ParseFloatError> {
77
LL | | "0".parse()
88
LL | | }
9-
| | ^
10-
| | |
11-
| |_`main` can only return types that implement `Termination`
12-
| required by a bound introduced by this call
9+
| |_^ `main` can only return types that implement `Termination`
1310
|
1411
= help: the trait `Termination` is not implemented for `Result<f32, ParseFloatError>`
1512
note: required by a bound in `assert_test_result`

src/test/ui/traits/issue-71136.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ LL | #[derive(Clone)]
55
| ----- in this derive macro expansion
66
LL | struct FooHolster {
77
LL | the_foos: Vec<Foo>,
8-
| ^^^^^^^^^^^^^^^^^^
9-
| |
10-
| expected an implementor of trait `Clone`
11-
| required by a bound introduced by this call
8+
| ^^^^^^^^^^^^^^^^^^ expected an implementor of trait `Clone`
129
|
1310
= note: required because of the requirements on the impl of `Clone` for `Vec<Foo>`
1411
note: required by `clone`

0 commit comments

Comments
 (0)