qualify_min_const_fn: ignore cleanup bbs
This commit is contained in:
parent
6fdf295664
commit
973f318514
@ -40,11 +40,15 @@ pub fn is_min_const_fn<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, msrv: &Msrv)
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
for bb in &*body.basic_blocks {
|
for bb in &*body.basic_blocks {
|
||||||
|
// Cleanup blocks are ignored entirely by const eval, so we can too:
|
||||||
|
// https://github.com/rust-lang/rust/blob/1dea922ea6e74f99a0e97de5cdb8174e4dea0444/compiler/rustc_const_eval/src/transform/check_consts/check.rs#L382
|
||||||
|
if !bb.is_cleanup {
|
||||||
check_terminator(tcx, body, bb.terminator(), msrv)?;
|
check_terminator(tcx, body, bb.terminator(), msrv)?;
|
||||||
for stmt in &bb.statements {
|
for stmt in &bb.statements {
|
||||||
check_statement(tcx, body, def_id, stmt, msrv)?;
|
check_statement(tcx, body, def_id, stmt, msrv)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,4 +158,16 @@ mod issue12677 {
|
|||||||
Self { strings: Vec::new() }
|
Self { strings: Vec::new() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Other {
|
||||||
|
pub text: String,
|
||||||
|
pub vec: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Other {
|
||||||
|
pub fn new(text: String) -> Self {
|
||||||
|
let vec = Vec::new();
|
||||||
|
Self { text, vec }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,5 +146,14 @@ LL | | Self { strings: Vec::new() }
|
|||||||
LL | | }
|
LL | | }
|
||||||
| |_________^
|
| |_________^
|
||||||
|
|
||||||
error: aborting due to 16 previous errors
|
error: this could be a `const fn`
|
||||||
|
--> tests/ui/missing_const_for_fn/could_be_const.rs:168:9
|
||||||
|
|
|
||||||
|
LL | / pub fn new(text: String) -> Self {
|
||||||
|
LL | | let vec = Vec::new();
|
||||||
|
LL | | Self { text, vec }
|
||||||
|
LL | | }
|
||||||
|
| |_________^
|
||||||
|
|
||||||
|
error: aborting due to 17 previous errors
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user