mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-16 05:56:56 +00:00
Merge 73e10eaf96
into 65fa0ab924
This commit is contained in:
commit
908cf1d92d
@ -1263,7 +1263,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
expr_ty: Ty<'tcx>,
|
||||
expected_ty: Ty<'tcx>,
|
||||
) -> bool {
|
||||
if let ty::Ref(_, inner_ty, hir::Mutability::Not) = expr_ty.kind()
|
||||
if !expr.span.in_external_macro(self.tcx.sess.source_map())
|
||||
&& let ty::Ref(_, inner_ty, hir::Mutability::Not) = expr_ty.kind()
|
||||
&& let Some(clone_trait_def) = self.tcx.lang_items().clone_trait()
|
||||
&& expected_ty == *inner_ty
|
||||
&& self
|
||||
|
18
tests/ui/macros/suggest-in-extern-macro-issue-139253.rs
Normal file
18
tests/ui/macros/suggest-in-extern-macro-issue-139253.rs
Normal file
@ -0,0 +1,18 @@
|
||||
#[derive(Clone, Debug)]
|
||||
struct Point<T> {
|
||||
v: T,
|
||||
}
|
||||
|
||||
macro_rules! local_macro {
|
||||
($val:expr $(,)?) => {
|
||||
match $val {
|
||||
tmp => tmp, //~ ERROR mismatched types [E0308]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a: Point<u8> = dbg!(Point { v: 42 });
|
||||
let b: Point<u8> = dbg!(&a); //~ ERROR mismatched types [E0308]
|
||||
let c: Point<u8> = local_macro!(&a);
|
||||
}
|
30
tests/ui/macros/suggest-in-extern-macro-issue-139253.stderr
Normal file
30
tests/ui/macros/suggest-in-extern-macro-issue-139253.stderr
Normal file
@ -0,0 +1,30 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/suggest-in-extern-macro-issue-139253.rs:16:24
|
||||
|
|
||||
LL | let b: Point<u8> = dbg!(&a);
|
||||
| ^^^^^^^^ expected `Point<u8>`, found `&Point<u8>`
|
||||
|
|
||||
= note: expected struct `Point<_>`
|
||||
found reference `&Point<_>`
|
||||
= note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/suggest-in-extern-macro-issue-139253.rs:9:20
|
||||
|
|
||||
LL | tmp => tmp,
|
||||
| ^^^ expected `Point<u8>`, found `&Point<u8>`
|
||||
...
|
||||
LL | let c: Point<u8> = local_macro!(&a);
|
||||
| ---------------- in this macro invocation
|
||||
|
|
||||
= note: expected struct `Point<_>`
|
||||
found reference `&Point<_>`
|
||||
= note: this error originates in the macro `local_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: consider using clone here
|
||||
|
|
||||
LL | tmp => tmp.clone(),
|
||||
| ++++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
Loading…
Reference in New Issue
Block a user