You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move semantics with declarative macros 2.0 are broken. Can copy non-copy types. Playground
#![feature(decl_macro)]#![allow(unused_macros)]#[derive(Debug)]structNonCopy(String);structFoo{x:NonCopy,}macro copy($foo:ident){
$foo.x}macro_rules! copy2 {($foo:ident) => {
$foo.x
}}fnmain(){let foo = Foo{x:NonCopy("foo".into())};assert_two_copies(copy!(foo), foo.x);// A similar old-style macro will not work://assert_two_copies(copy2!(foo), foo.x);}fnassert_two_copies(a:NonCopy,b:NonCopy){println!("Got two copies: {:?}, {:?}", a, b);}
Activity
kennytm commentedon Nov 27, 2017
The error is caught when enabling MIR borrow-check (pass
-Z borrowck-miror-Z nll), so this is a HIR borrow-check-only issue.petrochenkov commentedon Nov 27, 2017
Probably some fields are compared by name without hygiene adjustments.
pnkfelix commentedon Dec 21, 2017
(tagging with nll labels just so we remember to look at this case when double checking lexical vs NLL.)
nikomatsakis commentedon Apr 3, 2018
We should file this under #47366, seems like?
petrochenkov commentedon Apr 3, 2018
It's very likely this is fixed on my field hygiene branch, I'll check.
valff commentedon Apr 3, 2018
@nikomatsakis Thanks for the reference. I will make a PR with a test for this bug soon.
Regression test for rust-lang#46314
Auto merge of #49642 - kennytm:rollup, r=kennytm
Auto merge of #49718 - petrochenkov:fieldcmp, r=eddyb