Skip to content

Commit 5a20489

Browse files
committed
Rename TypeckTables to TypeckResults.
1 parent 62db617 commit 5a20489

File tree

103 files changed

+471
-424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+471
-424
lines changed

clippy_lints/src/arithmetic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
8686
_ => (),
8787
}
8888

89-
let (l_ty, r_ty) = (cx.tables().expr_ty(l), cx.tables().expr_ty(r));
89+
let (l_ty, r_ty) = (cx.typeck_results().expr_ty(l), cx.typeck_results().expr_ty(r));
9090
if l_ty.peel_refs().is_integral() && r_ty.peel_refs().is_integral() {
9191
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
9292
self.expr_span = Some(expr.span);
@@ -96,8 +96,8 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
9696
}
9797
},
9898
hir::ExprKind::Unary(hir::UnOp::UnNeg, arg) => {
99-
let ty = cx.tables().expr_ty(arg);
100-
if constant_simple(cx, cx.tables(), expr).is_none() {
99+
let ty = cx.typeck_results().expr_ty(arg);
100+
if constant_simple(cx, cx.typeck_results(), expr).is_none() {
101101
if ty.is_integral() {
102102
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
103103
self.expr_span = Some(expr.span);

clippy_lints/src/assertions_on_constants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
7272
}
7373
if_chain! {
7474
if let ExprKind::Unary(_, ref lit) = e.kind;
75-
if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.tables(), lit);
75+
if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.typeck_results(), lit);
7676
if is_true;
7777
then {
7878
lint_true(true);
@@ -121,7 +121,7 @@ fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>)
121121
if let ExprKind::DropTemps(ref expr) = expr.kind;
122122
if let ExprKind::Unary(UnOp::UnNot, ref expr) = expr.kind;
123123
// bind the first argument of the `assert!` macro
124-
if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.tables(), expr);
124+
if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.typeck_results(), expr);
125125
// arm 1 pattern
126126
if let PatKind::Lit(ref lit_expr) = arms[0].pat.kind;
127127
if let ExprKind::Lit(ref lit) = lit_expr.kind;

clippy_lints/src/assign_ops.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ impl<'tcx> LateLintPass<'tcx> for AssignOps {
8282
hir::ExprKind::Assign(assignee, e, _) => {
8383
if let hir::ExprKind::Binary(op, l, r) = &e.kind {
8484
let lint = |assignee: &hir::Expr<'_>, rhs: &hir::Expr<'_>| {
85-
let ty = cx.tables().expr_ty(assignee);
86-
let rty = cx.tables().expr_ty(rhs);
85+
let ty = cx.typeck_results().expr_ty(assignee);
86+
let rty = cx.typeck_results().expr_ty(rhs);
8787
macro_rules! ops {
8888
($op:expr,
8989
$cx:expr,
@@ -167,7 +167,7 @@ impl<'tcx> LateLintPass<'tcx> for AssignOps {
167167
// a = b commutative_op a
168168
// Limited to primitive type as these ops are know to be commutative
169169
if SpanlessEq::new(cx).ignore_fn().eq_expr(assignee, r)
170-
&& cx.tables().expr_ty(assignee).is_primitive_ty()
170+
&& cx.typeck_results().expr_ty(assignee).is_primitive_ty()
171171
{
172172
match op.node {
173173
hir::BinOpKind::Add

clippy_lints/src/atomic_ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const ATOMIC_TYPES: [&str; 12] = [
5353
];
5454

5555
fn type_is_atomic(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
56-
if let ty::Adt(&ty::AdtDef { did, .. }, _) = cx.tables().expr_ty(expr).kind {
56+
if let ty::Adt(&ty::AdtDef { did, .. }, _) = cx.typeck_results().expr_ty(expr).kind {
5757
ATOMIC_TYPES
5858
.iter()
5959
.any(|ty| match_def_path(cx, did, &["core", "sync", "atomic", ty]))

clippy_lints/src/attrs.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -461,15 +461,15 @@ fn check_clippy_lint_names(cx: &LateContext<'_>, ident: &str, items: &[NestedMet
461461

462462
fn is_relevant_item(cx: &LateContext<'_>, item: &Item<'_>) -> bool {
463463
if let ItemKind::Fn(_, _, eid) = item.kind {
464-
is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value)
464+
is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value)
465465
} else {
466466
true
467467
}
468468
}
469469

470470
fn is_relevant_impl(cx: &LateContext<'_>, item: &ImplItem<'_>) -> bool {
471471
match item.kind {
472-
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value),
472+
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value),
473473
_ => false,
474474
}
475475
}
@@ -478,31 +478,34 @@ fn is_relevant_trait(cx: &LateContext<'_>, item: &TraitItem<'_>) -> bool {
478478
match item.kind {
479479
TraitItemKind::Fn(_, TraitFn::Required(_)) => true,
480480
TraitItemKind::Fn(_, TraitFn::Provided(eid)) => {
481-
is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value)
481+
is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value)
482482
},
483483
_ => false,
484484
}
485485
}
486486

487-
fn is_relevant_block(cx: &LateContext<'_>, tables: &ty::TypeckTables<'_>, block: &Block<'_>) -> bool {
487+
fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, block: &Block<'_>) -> bool {
488488
block.stmts.first().map_or(
489-
block.expr.as_ref().map_or(false, |e| is_relevant_expr(cx, tables, e)),
489+
block
490+
.expr
491+
.as_ref()
492+
.map_or(false, |e| is_relevant_expr(cx, typeck_results, e)),
490493
|stmt| match &stmt.kind {
491494
StmtKind::Local(_) => true,
492-
StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, tables, expr),
495+
StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, typeck_results, expr),
493496
_ => false,
494497
},
495498
)
496499
}
497500

498-
fn is_relevant_expr(cx: &LateContext<'_>, tables: &ty::TypeckTables<'_>, expr: &Expr<'_>) -> bool {
501+
fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, expr: &Expr<'_>) -> bool {
499502
match &expr.kind {
500-
ExprKind::Block(block, _) => is_relevant_block(cx, tables, block),
501-
ExprKind::Ret(Some(e)) => is_relevant_expr(cx, tables, e),
503+
ExprKind::Block(block, _) => is_relevant_block(cx, typeck_results, block),
504+
ExprKind::Ret(Some(e)) => is_relevant_expr(cx, typeck_results, e),
502505
ExprKind::Ret(None) | ExprKind::Break(_, None) => false,
503506
ExprKind::Call(path_expr, _) => {
504507
if let ExprKind::Path(qpath) = &path_expr.kind {
505-
tables
508+
typeck_results
506509
.qpath_res(qpath, path_expr.hir_id)
507510
.opt_def_id()
508511
.map_or(true, |fun_id| !match_def_path(cx, fun_id, &paths::BEGIN_PANIC))

clippy_lints/src/await_holding_lock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ impl LateLintPass<'_> for AwaitHoldingLock {
5959
hir_id: body.value.hir_id,
6060
};
6161
let def_id = cx.tcx.hir().body_owner_def_id(body_id);
62-
let tables = cx.tcx.typeck_tables_of(def_id);
63-
check_interior_types(cx, &tables.generator_interior_types, body.value.span);
62+
let typeck_results = cx.tcx.typeck(def_id);
63+
check_interior_types(cx, &typeck_results.generator_interior_types, body.value.span);
6464
}
6565
}
6666
}

clippy_lints/src/bit_mask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ fn check_ineffective_gt(cx: &LateContext<'_>, span: Span, m: u128, c: u128, op:
319319
}
320320

321321
fn fetch_int_literal(cx: &LateContext<'_>, lit: &Expr<'_>) -> Option<u128> {
322-
match constant(cx, cx.tables(), lit)?.0 {
322+
match constant(cx, cx.typeck_results(), lit)?.0 {
323323
Constant::Int(n) => Some(n),
324324
_ => None,
325325
}

clippy_lints/src/booleans.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,12 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
111111
match &e.kind {
112112
ExprKind::Unary(UnOp::UnNot, inner) => return Ok(Bool::Not(box self.run(inner)?)),
113113
ExprKind::Binary(binop, lhs, rhs) => match &binop.node {
114-
BinOpKind::Or => return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?)),
115-
BinOpKind::And => return Ok(Bool::And(self.extract(BinOpKind::And, &[lhs, rhs], Vec::new())?)),
114+
BinOpKind::Or => {
115+
return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?));
116+
},
117+
BinOpKind::And => {
118+
return Ok(Bool::And(self.extract(BinOpKind::And, &[lhs, rhs], Vec::new())?));
119+
},
116120
_ => (),
117121
},
118122
ExprKind::Lit(lit) => match lit.node {
@@ -248,7 +252,7 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
248252
})
249253
},
250254
ExprKind::MethodCall(path, _, args, _) if args.len() == 1 => {
251-
let type_of_receiver = cx.tables().expr_ty(&args[0]);
255+
let type_of_receiver = cx.typeck_results().expr_ty(&args[0]);
252256
if !is_type_diagnostic_item(cx, type_of_receiver, sym!(option_type))
253257
&& !is_type_diagnostic_item(cx, type_of_receiver, sym!(result_type))
254258
{
@@ -450,7 +454,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
450454
self.bool_expr(e)
451455
},
452456
ExprKind::Unary(UnOp::UnNot, inner) => {
453-
if self.cx.tables().node_types()[inner.hir_id].is_bool() {
457+
if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() {
454458
self.bool_expr(e);
455459
} else {
456460
walk_expr(self, e);
@@ -465,7 +469,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
465469
}
466470

467471
fn implements_ord<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> bool {
468-
let ty = cx.tables().expr_ty(expr);
472+
let ty = cx.typeck_results().expr_ty(expr);
469473
get_trait_def_id(cx, &paths::ORD).map_or(false, |id| implements_trait(cx, ty, id, &[]))
470474
}
471475

clippy_lints/src/bytecount.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
5353
if let ExprKind::Binary(ref op, ref l, ref r) = body.value.kind;
5454
if op.node == BinOpKind::Eq;
5555
if match_type(cx,
56-
walk_ptrs_ty(cx.tables().expr_ty(&filter_args[0])),
56+
walk_ptrs_ty(cx.typeck_results().expr_ty(&filter_args[0])),
5757
&paths::SLICE_ITER);
5858
then {
5959
let needle = match get_path_name(l) {
@@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
6363
_ => { return; }
6464
}
6565
};
66-
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables().expr_ty(needle)).kind {
66+
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.typeck_results().expr_ty(needle)).kind {
6767
return;
6868
}
6969
let haystack = if let ExprKind::MethodCall(ref path, _, ref args, _) =

clippy_lints/src/cognitive_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl CognitiveComplexity {
6060
let mut helper = CCHelper { cc: 1, returns: 0 };
6161
helper.visit_expr(expr);
6262
let CCHelper { cc, returns } = helper;
63-
let ret_ty = cx.tables().node_type(expr.hir_id);
63+
let ret_ty = cx.typeck_results().node_type(expr.hir_id);
6464
let ret_adjust = if is_type_diagnostic_item(cx, ret_ty, sym!(result_type)) {
6565
returns
6666
} else {

clippy_lints/src/comparison_chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain {
9999
}
100100

101101
// Check that the type being compared implements `core::cmp::Ord`
102-
let ty = cx.tables().expr_ty(lhs1);
102+
let ty = cx.typeck_results().expr_ty(lhs1);
103103
let is_ord = get_trait_def_id(cx, &paths::ORD).map_or(false, |id| implements_trait(cx, ty, id, &[]));
104104

105105
if !is_ord {

clippy_lints/src/consts.rs

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ pub fn lit_to_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant {
174174

175175
pub fn constant<'tcx>(
176176
lcx: &LateContext<'tcx>,
177-
tables: &ty::TypeckTables<'tcx>,
177+
typeck_results: &ty::TypeckResults<'tcx>,
178178
e: &Expr<'_>,
179179
) -> Option<(Constant, bool)> {
180180
let mut cx = ConstEvalLateContext {
181181
lcx,
182-
tables,
182+
typeck_results,
183183
param_env: lcx.param_env,
184184
needed_resolution: false,
185185
substs: lcx.tcx.intern_substs(&[]),
@@ -189,20 +189,20 @@ pub fn constant<'tcx>(
189189

190190
pub fn constant_simple<'tcx>(
191191
lcx: &LateContext<'tcx>,
192-
tables: &ty::TypeckTables<'tcx>,
192+
typeck_results: &ty::TypeckResults<'tcx>,
193193
e: &Expr<'_>,
194194
) -> Option<Constant> {
195-
constant(lcx, tables, e).and_then(|(cst, res)| if res { None } else { Some(cst) })
195+
constant(lcx, typeck_results, e).and_then(|(cst, res)| if res { None } else { Some(cst) })
196196
}
197197

198-
/// Creates a `ConstEvalLateContext` from the given `LateContext` and `TypeckTables`.
198+
/// Creates a `ConstEvalLateContext` from the given `LateContext` and `TypeckResults`.
199199
pub fn constant_context<'a, 'tcx>(
200200
lcx: &'a LateContext<'tcx>,
201-
tables: &'a ty::TypeckTables<'tcx>,
201+
typeck_results: &'a ty::TypeckResults<'tcx>,
202202
) -> ConstEvalLateContext<'a, 'tcx> {
203203
ConstEvalLateContext {
204204
lcx,
205-
tables,
205+
typeck_results,
206206
param_env: lcx.param_env,
207207
needed_resolution: false,
208208
substs: lcx.tcx.intern_substs(&[]),
@@ -211,7 +211,7 @@ pub fn constant_context<'a, 'tcx>(
211211

212212
pub struct ConstEvalLateContext<'a, 'tcx> {
213213
lcx: &'a LateContext<'tcx>,
214-
tables: &'a ty::TypeckTables<'tcx>,
214+
typeck_results: &'a ty::TypeckResults<'tcx>,
215215
param_env: ty::ParamEnv<'tcx>,
216216
needed_resolution: bool,
217217
substs: SubstsRef<'tcx>,
@@ -224,21 +224,21 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
224224
return self.ifthenelse(cond, then, otherwise);
225225
}
226226
match e.kind {
227-
ExprKind::Path(ref qpath) => self.fetch_path(qpath, e.hir_id, self.tables.expr_ty(e)),
227+
ExprKind::Path(ref qpath) => self.fetch_path(qpath, e.hir_id, self.typeck_results.expr_ty(e)),
228228
ExprKind::Block(ref block, _) => self.block(block),
229-
ExprKind::Lit(ref lit) => Some(lit_to_constant(&lit.node, self.tables.expr_ty_opt(e))),
229+
ExprKind::Lit(ref lit) => Some(lit_to_constant(&lit.node, self.typeck_results.expr_ty_opt(e))),
230230
ExprKind::Array(ref vec) => self.multi(vec).map(Constant::Vec),
231231
ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple),
232232
ExprKind::Repeat(ref value, _) => {
233-
let n = match self.tables.expr_ty(e).kind {
233+
let n = match self.typeck_results.expr_ty(e).kind {
234234
ty::Array(_, n) => n.try_eval_usize(self.lcx.tcx, self.lcx.param_env)?,
235235
_ => span_bug!(e.span, "typeck error"),
236236
};
237237
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n))
238238
},
239239
ExprKind::Unary(op, ref operand) => self.expr(operand).and_then(|o| match op {
240-
UnOp::UnNot => self.constant_not(&o, self.tables.expr_ty(e)),
241-
UnOp::UnNeg => self.constant_negate(&o, self.tables.expr_ty(e)),
240+
UnOp::UnNot => self.constant_not(&o, self.typeck_results.expr_ty(e)),
241+
UnOp::UnNeg => self.constant_negate(&o, self.typeck_results.expr_ty(e)),
242242
UnOp::UnDeref => Some(o),
243243
}),
244244
ExprKind::Binary(op, ref left, ref right) => self.binop(op, left, right),
@@ -247,7 +247,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
247247
if_chain! {
248248
if args.is_empty();
249249
if let ExprKind::Path(qpath) = &callee.kind;
250-
let res = self.tables.qpath_res(qpath, callee.hir_id);
250+
let res = self.typeck_results.qpath_res(qpath, callee.hir_id);
251251
if let Some(def_id) = res.opt_def_id();
252252
let def_path: Vec<_> = self.lcx.get_def_path(def_id).into_iter().map(Symbol::as_str).collect();
253253
let def_path: Vec<&str> = def_path.iter().take(4).map(|s| &**s).collect();
@@ -319,10 +319,10 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
319319

320320
/// Lookup a possibly constant expression from a `ExprKind::Path`.
321321
fn fetch_path(&mut self, qpath: &QPath<'_>, id: HirId, ty: Ty<'tcx>) -> Option<Constant> {
322-
let res = self.tables.qpath_res(qpath, id);
322+
let res = self.typeck_results.qpath_res(qpath, id);
323323
match res {
324324
Res::Def(DefKind::Const | DefKind::AssocConst, def_id) => {
325-
let substs = self.tables.node_substs(id);
325+
let substs = self.typeck_results.node_substs(id);
326326
let substs = if self.substs.is_empty() {
327327
substs
328328
} else {
@@ -332,7 +332,13 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
332332
let result = self
333333
.lcx
334334
.tcx
335-
.const_eval_resolve(self.param_env, ty::WithOptConstParam::unknown(def_id), substs, None, None)
335+
.const_eval_resolve(
336+
self.param_env,
337+
ty::WithOptConstParam::unknown(def_id),
338+
substs,
339+
None,
340+
None,
341+
)
336342
.ok()
337343
.map(|val| rustc_middle::ty::Const::from_value(self.lcx.tcx, val, ty))?;
338344
let result = miri_to_const(&result);
@@ -396,7 +402,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
396402
let l = self.expr(left)?;
397403
let r = self.expr(right);
398404
match (l, r) {
399-
(Constant::Int(l), Some(Constant::Int(r))) => match self.tables.expr_ty_opt(left)?.kind {
405+
(Constant::Int(l), Some(Constant::Int(r))) => match self.typeck_results.expr_ty_opt(left)?.kind {
400406
ty::Int(ity) => {
401407
let l = sext(self.lcx.tcx, l, ity);
402408
let r = sext(self.lcx.tcx, r, ity);
@@ -488,23 +494,25 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
488494
pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
489495
use rustc_middle::mir::interpret::{ConstValue, Scalar};
490496
match result.val {
491-
ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data: d, .. })) => match result.ty.kind {
492-
ty::Bool => Some(Constant::Bool(d == 1)),
493-
ty::Uint(_) | ty::Int(_) => Some(Constant::Int(d)),
494-
ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(
495-
d.try_into().expect("invalid f32 bit representation"),
496-
))),
497-
ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits(
498-
d.try_into().expect("invalid f64 bit representation"),
499-
))),
500-
ty::RawPtr(type_and_mut) => {
501-
if let ty::Uint(_) = type_and_mut.ty.kind {
502-
return Some(Constant::RawPtr(d));
503-
}
504-
None
505-
},
506-
// FIXME: implement other conversions.
507-
_ => None,
497+
ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data: d, .. })) => {
498+
match result.ty.kind {
499+
ty::Bool => Some(Constant::Bool(d == 1)),
500+
ty::Uint(_) | ty::Int(_) => Some(Constant::Int(d)),
501+
ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(
502+
d.try_into().expect("invalid f32 bit representation"),
503+
))),
504+
ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits(
505+
d.try_into().expect("invalid f64 bit representation"),
506+
))),
507+
ty::RawPtr(type_and_mut) => {
508+
if let ty::Uint(_) = type_and_mut.ty.kind {
509+
return Some(Constant::RawPtr(d));
510+
}
511+
None
512+
},
513+
// FIXME: implement other conversions.
514+
_ => None,
515+
}
508516
},
509517
ty::ConstKind::Value(ConstValue::Slice { data, start, end }) => match result.ty.kind {
510518
ty::Ref(_, tam, _) => match tam.kind {

0 commit comments

Comments
 (0)