Stop using the const_eval
query for initializers of statics
As a side effect, we now represent most promoteds as `ConstValue::Scalar` again. This is useful because all implict promoteds are just references anyway and most explicit promoteds are numeric arguments to `asm!` or SIMD instructions.
This commit is contained in:
parent
083f1d7a37
commit
2d7ac728e4
17 changed files with 53 additions and 108 deletions
|
@ -1473,21 +1473,18 @@ declare_lint_pass!(
|
|||
UnusedBrokenConst => []
|
||||
);
|
||||
|
||||
fn check_const(cx: &LateContext<'_>, body_id: hir::BodyId) {
|
||||
let def_id = cx.tcx.hir().body_owner_def_id(body_id).to_def_id();
|
||||
// trigger the query once for all constants since that will already report the errors
|
||||
// FIXME: Use ensure here
|
||||
let _ = cx.tcx.const_eval_poly(def_id);
|
||||
}
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for UnusedBrokenConst {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
|
||||
match it.kind {
|
||||
hir::ItemKind::Const(_, body_id) => {
|
||||
check_const(cx, body_id);
|
||||
let def_id = cx.tcx.hir().body_owner_def_id(body_id).to_def_id();
|
||||
// trigger the query once for all constants since that will already report the errors
|
||||
// FIXME: Use ensure here
|
||||
let _ = cx.tcx.const_eval_poly(def_id);
|
||||
}
|
||||
hir::ItemKind::Static(_, _, body_id) => {
|
||||
check_const(cx, body_id);
|
||||
let def_id = cx.tcx.hir().body_owner_def_id(body_id).to_def_id();
|
||||
let _ = cx.tcx.eval_static_initializer(def_id);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue