Remove unnecessary label

This commit is contained in:
Esteban Kuber 2021-09-07 14:25:40 +00:00
parent dbecdd5124
commit 88a5321060
8 changed files with 21 additions and 37 deletions

View File

@ -2312,14 +2312,17 @@ fn note_obligation_cause_code<T>(
_ => self.tcx.typeck(parent_id),
};
let ty = typeck_results.expr_ty_adjusted(expr);
err.span_label(
expr.peel_blocks().span,
&if ty.references_error() {
String::new()
} else {
format!("this tail expression is of type `{:?}`", ty)
},
);
let span = expr.peel_blocks().span;
if Some(span) != err.span.primary_span() {
err.span_label(
span,
&if ty.references_error() {
String::new()
} else {
format!("this tail expression is of type `{:?}`", ty)
},
);
}
}
if let Some(Node::Expr(hir::Expr {
kind:
@ -2328,7 +2331,9 @@ fn note_obligation_cause_code<T>(
..
})) = hir.find(call_hir_id)
{
err.span_label(*span, "required by a bound introduced by this call");
if Some(*span) != err.span.primary_span() {
err.span_label(*span, "required by a bound introduced by this call");
}
}
ensure_sufficient_stack(|| {
self.note_obligation_cause_code(

View File

@ -5,10 +5,7 @@ LL | #[derive(Clone)]
| ----- in this derive macro expansion
...
LL | x: Error
| ^^^^^^^^
| |
| the trait `Clone` is not implemented for `Error`
| required by a bound introduced by this call
| ^^^^^^^^ the trait `Clone` is not implemented for `Error`
|
note: required by `clone`
--> $SRC_DIR/core/src/clone.rs:LL:COL

View File

@ -5,10 +5,7 @@ LL | #[derive(Clone)]
| ----- in this derive macro expansion
...
LL | Error
| ^^^^^
| |
| the trait `Clone` is not implemented for `Error`
| required by a bound introduced by this call
| ^^^^^ the trait `Clone` is not implemented for `Error`
|
note: required by `clone`
--> $SRC_DIR/core/src/clone.rs:LL:COL

View File

@ -5,10 +5,7 @@ LL | #[derive(Clone)]
| ----- in this derive macro expansion
LL | struct Struct {
LL | x: Error
| ^^^^^^^^
| |
| the trait `Clone` is not implemented for `Error`
| required by a bound introduced by this call
| ^^^^^^^^ the trait `Clone` is not implemented for `Error`
|
note: required by `clone`
--> $SRC_DIR/core/src/clone.rs:LL:COL

View File

@ -5,10 +5,7 @@ LL | #[derive(Clone)]
| ----- in this derive macro expansion
LL | struct Struct(
LL | Error
| ^^^^^
| |
| the trait `Clone` is not implemented for `Error`
| required by a bound introduced by this call
| ^^^^^ the trait `Clone` is not implemented for `Error`
|
note: required by `clone`
--> $SRC_DIR/core/src/clone.rs:LL:COL

View File

@ -29,10 +29,7 @@ LL | #[derive(Clone)]
| ----- in this derive macro expansion
LL | struct C {
LL | x: NoCloneOrEq
| ^^^^^^^^^^^^^^
| |
| the trait `Clone` is not implemented for `NoCloneOrEq`
| required by a bound introduced by this call
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoCloneOrEq`
|
note: required by `clone`
--> $SRC_DIR/core/src/clone.rs:LL:COL

View File

@ -6,10 +6,7 @@ LL | #[test]
LL | / fn can_parse_zero_as_f32() -> Result<f32, ParseFloatError> {
LL | | "0".parse()
LL | | }
| | ^
| | |
| |_`main` can only return types that implement `Termination`
| required by a bound introduced by this call
| |_^ `main` can only return types that implement `Termination`
|
= help: the trait `Termination` is not implemented for `Result<f32, ParseFloatError>`
note: required by a bound in `assert_test_result`

View File

@ -5,10 +5,7 @@ LL | #[derive(Clone)]
| ----- in this derive macro expansion
LL | struct FooHolster {
LL | the_foos: Vec<Foo>,
| ^^^^^^^^^^^^^^^^^^
| |
| expected an implementor of trait `Clone`
| required by a bound introduced by this call
| ^^^^^^^^^^^^^^^^^^ expected an implementor of trait `Clone`
|
= note: required because of the requirements on the impl of `Clone` for `Vec<Foo>`
note: required by `clone`