Make sure that const prop does not produce unsilenceable lints after inlining
This commit is contained in:
parent
b8727e2d60
commit
0491e74dd9
@ -440,7 +440,15 @@ fn remove_const(ecx: &mut InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>, lo
|
||||
}
|
||||
|
||||
fn lint_root(&self, source_info: SourceInfo) -> Option<HirId> {
|
||||
match &self.source_scopes[source_info.scope].local_data {
|
||||
let mut data = &self.source_scopes[source_info.scope];
|
||||
// FIXME(oli-obk): we should be able to just walk the `inlined_parent_scope`, but it
|
||||
// does not work as I thought it would. Needs more investigation and documentation.
|
||||
while data.inlined.is_some() {
|
||||
trace!(?data);
|
||||
data = &self.source_scopes[data.parent_scope.unwrap()];
|
||||
}
|
||||
trace!(?data);
|
||||
match &data.local_data {
|
||||
ClearCrossCrate::Set(data) => Some(data.lint_root),
|
||||
ClearCrossCrate::Clear => None,
|
||||
}
|
||||
|
15
src/test/ui/const_prop/inline_spans_lint_attribute.rs
Normal file
15
src/test/ui/const_prop/inline_spans_lint_attribute.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Must be build-pass, because check-pass will not run const prop and thus not emit the lint anyway.
|
||||
// build-pass
|
||||
// compile-flags: -Zmir-opt-level=2
|
||||
|
||||
#![deny(warnings)]
|
||||
|
||||
fn main() {
|
||||
#[allow(arithmetic_overflow)]
|
||||
let _ = add(u8::MAX, 1);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn add(x: u8, y: u8) -> u8 {
|
||||
x + y
|
||||
}
|
Loading…
Reference in New Issue
Block a user