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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,10 +29,7 @@ LL | #[derive(Clone)]
| ----- in this derive macro expansion | ----- in this derive macro expansion
LL | struct C { LL | struct C {
LL | x: NoCloneOrEq LL | x: NoCloneOrEq
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoCloneOrEq`
| |
| the trait `Clone` is not implemented for `NoCloneOrEq`
| required by a bound introduced by this call
| |
note: required by `clone` note: required by `clone`
--> $SRC_DIR/core/src/clone.rs:LL:COL --> $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 | / fn can_parse_zero_as_f32() -> Result<f32, ParseFloatError> {
LL | | "0".parse() LL | | "0".parse()
LL | | } LL | | }
| | ^ | |_^ `main` can only return types that implement `Termination`
| | |
| |_`main` can only return types that implement `Termination`
| required by a bound introduced by this call
| |
= help: the trait `Termination` is not implemented for `Result<f32, ParseFloatError>` = help: the trait `Termination` is not implemented for `Result<f32, ParseFloatError>`
note: required by a bound in `assert_test_result` note: required by a bound in `assert_test_result`

View File

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