File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ #[ macro_export]
2+ macro_rules! is_equal {
3+ ( $left: expr, $right: expr) => {
4+ $left == $right //~ ERROR can't compare `&{integer}` with `{integer}` [E0277]
5+ } ;
6+ }
7+
8+ fn main ( ) {
9+ let x = 1 ;
10+ let y = & x;
11+ assert ! ( y == 1 ) ; //~ ERROR can't compare `&{integer}` with `{integer}` [E0277]
12+ assert_eq ! ( y, 2 ) ; //~ ERROR can't compare `&{integer}` with `{integer}` [E0277]
13+ is_equal ! ( y, 2 ) ;
14+ }
Original file line number Diff line number Diff line change 1+ error[E0277]: can't compare `&{integer}` with `{integer}`
2+ --> $DIR/dont-suggest-within-macro-issue-139251.rs:11:15
3+ |
4+ LL | assert!(y == 1);
5+ | ^^ no implementation for `&{integer} == {integer}`
6+ |
7+ = help: the trait `PartialEq<{integer}>` is not implemented for `&{integer}`
8+ help: consider dereferencing here
9+ |
10+ LL | assert!(*y == 1);
11+ | +
12+
13+ error[E0277]: can't compare `&{integer}` with `{integer}`
14+ --> $DIR/dont-suggest-within-macro-issue-139251.rs:12:5
15+ |
16+ LL | assert_eq!(y, 2);
17+ | ^^^^^^^^^^^^^^^^ no implementation for `&{integer} == {integer}`
18+ |
19+ = help: the trait `PartialEq<{integer}>` is not implemented for `&{integer}`
20+ = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
21+
22+ error[E0277]: can't compare `&{integer}` with `{integer}`
23+ --> $DIR/dont-suggest-within-macro-issue-139251.rs:4:15
24+ |
25+ LL | $left == $right
26+ | ^^ no implementation for `&{integer} == {integer}`
27+ ...
28+ LL | is_equal!(y, 2);
29+ | --------------- in this macro invocation
30+ |
31+ = help: the trait `PartialEq<{integer}>` is not implemented for `&{integer}`
32+ = note: this error originates in the macro `is_equal` (in Nightly builds, run with -Z macro-backtrace for more info)
33+ help: consider dereferencing here
34+ |
35+ LL | is_equal!(*y, 2);
36+ | +
37+
38+ error: aborting due to 3 previous errors
39+
40+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments