Rollup merge of #149147 - chenyukang:yukang-fix-unused_assignments-macro-gen-147648, r=JonathanBrouwer
Fix unused_assignments false positives from macros Fixes rust-lang/rust#147648
This commit is contained in:
commit
82a17b30d8
3 changed files with 22 additions and 0 deletions
|
|
@ -75,6 +75,11 @@ pub(crate) fn check_liveness<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Den
|
||||||
return DenseBitSet::new_empty(0);
|
return DenseBitSet::new_empty(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't run unused pass for items generated by foreign macros
|
||||||
|
if tcx.def_span(parent).in_external_macro(tcx.sess.source_map()) {
|
||||||
|
return DenseBitSet::new_empty(0);
|
||||||
|
}
|
||||||
|
|
||||||
let mut body = &*tcx.mir_promoted(def_id).0.borrow();
|
let mut body = &*tcx.mir_promoted(def_id).0.borrow();
|
||||||
let mut body_mem;
|
let mut body_mem;
|
||||||
|
|
||||||
|
|
|
||||||
7
tests/ui/liveness/auxiliary/aux_issue_147648.rs
Normal file
7
tests/ui/liveness/auxiliary/aux_issue_147648.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! unused_assign {
|
||||||
|
($x:ident) => {
|
||||||
|
let mut $x = 1;
|
||||||
|
$x = 2;
|
||||||
|
};
|
||||||
|
}
|
||||||
10
tests/ui/liveness/unused-assignments-from-macro-147648.rs
Normal file
10
tests/ui/liveness/unused-assignments-from-macro-147648.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
//@ check-pass
|
||||||
|
//@ aux-build:aux_issue_147648.rs
|
||||||
|
|
||||||
|
#![deny(unused_assignments)]
|
||||||
|
|
||||||
|
extern crate aux_issue_147648;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
aux_issue_147648::unused_assign!(y);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue