mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Point at binop lhs and rhs when expression is multiline
``` error[E0277]: cannot add `()` to `u32` --> $DIR/multiline-span-simple.rs:13:18 | LL | foo(1 as u32 + | -------- ^ no implementation for `u32 + ()` LL | LL | / bar(x, LL | | LL | | y), | |______________- ```
This commit is contained in:
@@ -2916,12 +2916,21 @@ pub(super) fn note_obligation_cause_code<G: EmissionGuarantee, T>(
|
||||
| ObligationCauseCode::CheckAssociatedTypeBounds { .. }
|
||||
| ObligationCauseCode::LetElse
|
||||
| ObligationCauseCode::UnOp { .. }
|
||||
| ObligationCauseCode::BinOp { .. }
|
||||
| ObligationCauseCode::AscribeUserTypeProvePredicate(..)
|
||||
| ObligationCauseCode::AlwaysApplicableImpl
|
||||
| ObligationCauseCode::ConstParam(_)
|
||||
| ObligationCauseCode::ReferenceOutlivesReferent(..)
|
||||
| ObligationCauseCode::ObjectTypeBound(..) => {}
|
||||
ObligationCauseCode::BinOp { lhs_hir_id, rhs_hir_id, .. } => {
|
||||
if let hir::Node::Expr(lhs) = tcx.hir_node(lhs_hir_id)
|
||||
&& let hir::Node::Expr(rhs) = tcx.hir_node(rhs_hir_id)
|
||||
&& tcx.sess.source_map().lookup_char_pos(lhs.span.lo()).line
|
||||
!= tcx.sess.source_map().lookup_char_pos(rhs.span.hi()).line
|
||||
{
|
||||
err.span_label(lhs.span, "");
|
||||
err.span_label(rhs.span, "");
|
||||
}
|
||||
}
|
||||
ObligationCauseCode::RustCall => {
|
||||
if let Some(pred) = predicate.as_trait_clause()
|
||||
&& tcx.is_lang_item(pred.def_id(), LangItem::Sized)
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
error[E0277]: cannot add `()` to `u32`
|
||||
--> $DIR/multiline-span-simple.rs:13:18
|
||||
|
|
||||
LL | foo(1 as u32 +
|
||||
| ^ no implementation for `u32 + ()`
|
||||
LL | foo(1 as u32 +
|
||||
| -------- ^ no implementation for `u32 + ()`
|
||||
LL |
|
||||
LL | / bar(x,
|
||||
LL | |
|
||||
LL | | y),
|
||||
| |______________-
|
||||
|
|
||||
= help: the trait `Add<()>` is not implemented for `u32`
|
||||
help: the following other types implement trait `Add<Rhs>`
|
||||
|
||||
@@ -2,7 +2,9 @@ error[E0277]: cannot add `()` to `{integer}`
|
||||
--> $DIR/unit-type-add-error-11771.rs:5:7
|
||||
|
|
||||
LL | 1 +
|
||||
| ^ no implementation for `{integer} + ()`
|
||||
| - ^ no implementation for `{integer} + ()`
|
||||
LL | x
|
||||
| -
|
||||
|
|
||||
= help: the trait `Add<()>` is not implemented for `{integer}`
|
||||
= help: the following other types implement trait `Add<Rhs>`:
|
||||
@@ -20,7 +22,9 @@ error[E0277]: cannot add `()` to `{integer}`
|
||||
--> $DIR/unit-type-add-error-11771.rs:10:7
|
||||
|
|
||||
LL | 1 +
|
||||
| ^ no implementation for `{integer} + ()`
|
||||
| - ^ no implementation for `{integer} + ()`
|
||||
LL | x
|
||||
| -
|
||||
|
|
||||
= help: the trait `Add<()>` is not implemented for `{integer}`
|
||||
= help: the following other types implement trait `Add<Rhs>`:
|
||||
|
||||
Reference in New Issue
Block a user