mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 05:26:47 +00:00
Merge 7753df37de
into 65fa0ab924
This commit is contained in:
commit
9b46cf0d16
@ -449,6 +449,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
err: &mut Diag<'_>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) -> bool {
|
||||
if obligation.cause.span.in_external_macro(self.infcx.tcx.sess.source_map()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let mut code = obligation.cause.code();
|
||||
if let ObligationCauseCode::FunctionArg { arg_hir_id, call_hir_id, .. } = code
|
||||
&& let Some(typeck_results) = &self.typeck_results
|
||||
|
14
tests/ui/macros/dont-suggest-within-macro-issue-139251.rs
Normal file
14
tests/ui/macros/dont-suggest-within-macro-issue-139251.rs
Normal file
@ -0,0 +1,14 @@
|
||||
#[macro_export]
|
||||
macro_rules! is_equal {
|
||||
($left:expr, $right:expr) => {
|
||||
$left == $right //~ ERROR can't compare `&{integer}` with `{integer}` [E0277]
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = 1;
|
||||
let y = &x;
|
||||
assert!(y == 1); //~ ERROR can't compare `&{integer}` with `{integer}` [E0277]
|
||||
assert_eq!(y, 2); //~ ERROR can't compare `&{integer}` with `{integer}` [E0277]
|
||||
is_equal!(y, 2);
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
error[E0277]: can't compare `&{integer}` with `{integer}`
|
||||
--> $DIR/dont-suggest-within-macro-issue-139251.rs:11:15
|
||||
|
|
||||
LL | assert!(y == 1);
|
||||
| ^^ no implementation for `&{integer} == {integer}`
|
||||
|
|
||||
= help: the trait `PartialEq<{integer}>` is not implemented for `&{integer}`
|
||||
help: consider dereferencing here
|
||||
|
|
||||
LL | assert!(*y == 1);
|
||||
| +
|
||||
|
||||
error[E0277]: can't compare `&{integer}` with `{integer}`
|
||||
--> $DIR/dont-suggest-within-macro-issue-139251.rs:12:5
|
||||
|
|
||||
LL | assert_eq!(y, 2);
|
||||
| ^^^^^^^^^^^^^^^^ no implementation for `&{integer} == {integer}`
|
||||
|
|
||||
= help: the trait `PartialEq<{integer}>` is not implemented for `&{integer}`
|
||||
= help: the following other types implement trait `PartialEq<Rhs>`:
|
||||
f128
|
||||
f16
|
||||
f32
|
||||
f64
|
||||
i128
|
||||
i16
|
||||
i32
|
||||
i64
|
||||
and 8 others
|
||||
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0277]: can't compare `&{integer}` with `{integer}`
|
||||
--> $DIR/dont-suggest-within-macro-issue-139251.rs:4:15
|
||||
|
|
||||
LL | $left == $right
|
||||
| ^^ no implementation for `&{integer} == {integer}`
|
||||
...
|
||||
LL | is_equal!(y, 2);
|
||||
| --------------- in this macro invocation
|
||||
|
|
||||
= help: the trait `PartialEq<{integer}>` is not implemented for `&{integer}`
|
||||
= note: this error originates in the macro `is_equal` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: consider dereferencing here
|
||||
|
|
||||
LL | is_equal!(*y, 2);
|
||||
| +
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
Loading…
Reference in New Issue
Block a user