Rollup merge of #152001 - reddevilmidzy:mgca-i, r=BoxyUwU
mGCA: Validate const literal against expected type close: rust-lang/rust#151625 close: rust-lang/rust#150983 also fix: https://github.com/rust-lang/rust/issues/133966 (moved crashes test)
This commit is contained in:
commit
5ae6bb3faf
40 changed files with 532 additions and 233 deletions
|
|
@ -1,12 +1,11 @@
|
|||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_middle::mir::interpret::LitToConstInput;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::thir::visit;
|
||||
use rustc_middle::thir::visit::Visitor;
|
||||
use rustc_middle::ty::abstract_const::CastKind;
|
||||
use rustc_middle::ty::{self, Expr, TyCtxt, TypeVisitableExt};
|
||||
use rustc_middle::ty::{self, Expr, LitToConstInput, TyCtxt, TypeVisitableExt};
|
||||
use rustc_middle::{mir, thir};
|
||||
use rustc_span::Span;
|
||||
use tracing::instrument;
|
||||
|
|
@ -59,7 +58,10 @@ fn recurse_build<'tcx>(
|
|||
}
|
||||
&ExprKind::Literal { lit, neg } => {
|
||||
let sp = node.span;
|
||||
tcx.at(sp).lit_to_const(LitToConstInput { lit: lit.node, ty: node.ty, neg })
|
||||
match tcx.at(sp).lit_to_const(LitToConstInput { lit: lit.node, ty: node.ty, neg }) {
|
||||
Some(value) => ty::Const::new_value(tcx, value.valtree, value.ty),
|
||||
None => ty::Const::new_misc_error(tcx),
|
||||
}
|
||||
}
|
||||
&ExprKind::NonHirLiteral { lit, user_ty: _ } => {
|
||||
let val = ty::ValTree::from_scalar_int(tcx, lit);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue