Skip to content

Commit 278d492

Browse files
committed
cleanup dead code in rustc_mir_build_additional_files
1 parent de72e80 commit 278d492

1 file changed

Lines changed: 14 additions & 26 deletions

File tree

  • source/rustc_mir_build_additional_files

source/rustc_mir_build_additional_files/verus.rs

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
1-
#![allow(unused_imports)]
2-
#![allow(unused_variables)]
3-
#![allow(dead_code)]
4-
51
use crate::rustc_index::Idx;
62
use crate::thir::cx::ThirBuildCx;
73
use hir::HirId;
84
use itertools::Itertools;
95
use rustc_hir as hir;
10-
use rustc_hir::BodyId;
116
use rustc_hir::def_id::{DefId, LocalDefId};
127
use rustc_middle::hir::place::{Place, Projection, ProjectionKind};
138
use rustc_middle::middle::region;
149
use rustc_middle::mir::FakeReadCause;
1510
use rustc_middle::thir;
1611
use rustc_middle::thir::{
17-
AdtExprBase, Arm, ArmId, Block, BlockId, BlockSafety, ClosureExpr, Expr, ExprId, ExprKind,
18-
LocalVarId, Pat, PatKind, Stmt, StmtId, StmtKind, TempLifetime,
12+
AdtExprBase, Arm, ArmId, Block, BlockId, BlockSafety, Expr, ExprId, ExprKind, LocalVarId, Pat,
13+
PatKind, Stmt, StmtId, StmtKind, TempLifetime,
1914
};
2015
use rustc_middle::ty;
2116
use rustc_middle::ty::{
22-
Binder, BoundRegion, BoundRegionKind, BoundVar, BoundVariableKind, CapturedPlace, ConstKind,
23-
GenericArg, Mutability, Region, RegionKind, Ty, TyCtxt, TyKind, TypeSuperFoldable,
24-
TypeVisitableExt, UpvarCapture,
17+
Binder, BoundRegion, BoundRegionKind, BoundVar, BoundVariableKind, CapturedPlace, GenericArg,
18+
Mutability, Ty, TyCtxt, TyKind, TypeSuperFoldable, UpvarCapture,
2519
};
26-
use rustc_middle::ty::{BoundVarReplacerDelegate, TypeFoldable, TypeFolder, UpvarArgs};
20+
use rustc_middle::ty::{TypeFoldable, TypeFolder, UpvarArgs};
2721
use rustc_span::Span;
2822
use std::collections::{HashMap, HashSet};
2923
use std::sync::{Arc, RwLock};
@@ -188,13 +182,7 @@ pub(crate) struct VerusThirBuildCtxt {
188182
}
189183

190184
impl VerusThirBuildCtxt {
191-
pub(crate) fn new<'tcx>(tcx: TyCtxt<'tcx>, local_def_id: LocalDefId) -> Self {
192-
/*if ctxt.is_none() {
193-
let def_id = local_def_id.to_def_id();
194-
let is_const = tcx.is_const_fn(def_id)
195-
|| matches!(tcx.def_kind(def_id), DefKind::Const | DefKind::AssocConst);
196-
}*/
197-
185+
pub(crate) fn new<'tcx>(_tcx: TyCtxt<'tcx>, local_def_id: LocalDefId) -> Self {
198186
VerusThirBuildCtxt {
199187
ctxt: get_verus_erasure_ctxt_option(),
200188
closure_overrides: HashMap::new(),
@@ -315,7 +303,7 @@ pub(crate) fn should_erase_var(verus_ctxt: &VerusThirBuildCtxt, var_hir_id: HirI
315303
pub(crate) fn handle_var<'tcx>(
316304
cx: &mut ThirBuildCx<'tcx>,
317305
expr: &'tcx hir::Expr<'tcx>,
318-
var_hir_id: HirId,
306+
_var_hir_id: HirId,
319307
spec: bool,
320308
) -> Option<ExprKind<'tcx>> {
321309
let Some(erasure_ctxt) = cx.verus_ctxt.ctxt.clone() else {
@@ -784,7 +772,7 @@ impl<'a, 'tcx> rustc_hir::intravisit::Visitor<'tcx> for VisitTreeForPats<'a, 'tc
784772
expr,
785773
));
786774
}
787-
hir::ExprKind::Block(block, _) => {
775+
hir::ExprKind::Block(_block, _) => {
788776
if let Some(b) = erase_block_for_pattern_checking(
789777
self.cx,
790778
self.erasure_ctxt,
@@ -859,7 +847,7 @@ fn erase_let_for_pattern_checking<'tcx>(
859847
let hir::StmtKind::Let(local) = stmt.kind else {
860848
unreachable!();
861849
};
862-
let rustc_hir::LetStmt { super_: _, pat, ty: _, init, els, hir_id, span, source } = local;
850+
let rustc_hir::LetStmt { super_: _, pat, ty: _, init, els, hir_id, span, source: _ } = local;
863851
if els.is_some() {
864852
panic!("erase_let_for_pattern_checking: let-else statement not expected in erased code");
865853
}
@@ -1208,7 +1196,7 @@ fn mk_closure_magic_coercion_fn<'tcx, 'a>(
12081196
// with bound variables.
12091197
let mut replacer = ReErasedReplacer::new(tcx);
12101198
let mut output_tys = vec![];
1211-
for (ty, rust_captured_place) in expected_tys.iter().zip(rust_captured_places.iter()) {
1199+
for ty in expected_tys.iter() {
12121200
let t = ty.fold_with(&mut replacer);
12131201
output_tys.push(t);
12141202
}
@@ -1310,7 +1298,7 @@ fn mk_closure_magic_coercion_fn<'tcx, 'a>(
13101298
tcx.mk_type_list_from_iter(input_tys.iter().cloned().chain(std::iter::once(output_ty)));
13111299

13121300
let mut bound_var_kinds = vec![];
1313-
for i in 0..replacer.current_var {
1301+
for _i in 0..replacer.current_var {
13141302
bound_var_kinds.push(BoundVariableKind::Region(BoundRegionKind::Anon));
13151303
}
13161304
let bound_var_kinds = tcx.mk_bound_variable_kinds(&bound_var_kinds);
@@ -1388,14 +1376,14 @@ pub(crate) fn possibly_handle_complex_closure_block<'tcx>(
13881376
}
13891377

13901378
let expr = get_closure_expr(&block.expr.unwrap());
1391-
let rustc_hir::ExprKind::Closure(closure) = &expr.kind else {
1379+
let rustc_hir::ExprKind::Closure(_closure) = &expr.kind else {
13921380
return None;
13931381
};
13941382

13951383
let tcx = cx.tcx;
13961384

13971385
let closure_ty = cx.typeck_results.expr_ty(expr);
1398-
let (def_id, args, movability) = match *closure_ty.kind() {
1386+
let (def_id, args, _movability) = match *closure_ty.kind() {
13991387
ty::Closure(def_id, args) => (def_id, UpvarArgs::Closure(args), None),
14001388
ty::Coroutine(def_id, args) => {
14011389
(def_id, UpvarArgs::Coroutine(args), Some(tcx.coroutine_movability(def_id)))
@@ -1509,7 +1497,7 @@ pub(crate) fn possibly_handle_complex_closure_block<'tcx>(
15091497
pub(crate) fn get_closure_expr<'tcx>(e: &'tcx hir::Expr<'tcx>) -> &'tcx hir::Expr<'tcx> {
15101498
match &e.kind {
15111499
hir::ExprKind::Closure(_) => e,
1512-
hir::ExprKind::Call(f, args) => get_closure_expr(&args[0]),
1500+
hir::ExprKind::Call(_f, args) => get_closure_expr(&args[0]),
15131501
_ => panic!("get_closure_expr failed"),
15141502
}
15151503
}

0 commit comments

Comments
 (0)