|
1 | | -#![allow(unused_imports)] |
2 | | -#![allow(unused_variables)] |
3 | | -#![allow(dead_code)] |
4 | | - |
5 | 1 | use crate::rustc_index::Idx; |
6 | 2 | use crate::thir::cx::ThirBuildCx; |
7 | 3 | use hir::HirId; |
8 | 4 | use itertools::Itertools; |
9 | 5 | use rustc_hir as hir; |
10 | | -use rustc_hir::BodyId; |
11 | 6 | use rustc_hir::def_id::{DefId, LocalDefId}; |
12 | 7 | use rustc_middle::hir::place::{Place, Projection, ProjectionKind}; |
13 | 8 | use rustc_middle::middle::region; |
14 | 9 | use rustc_middle::mir::FakeReadCause; |
15 | 10 | use rustc_middle::thir; |
16 | 11 | 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, |
19 | 14 | }; |
20 | 15 | use rustc_middle::ty; |
21 | 16 | 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, |
25 | 19 | }; |
26 | | -use rustc_middle::ty::{BoundVarReplacerDelegate, TypeFoldable, TypeFolder, UpvarArgs}; |
| 20 | +use rustc_middle::ty::{TypeFoldable, TypeFolder, UpvarArgs}; |
27 | 21 | use rustc_span::Span; |
28 | 22 | use std::collections::{HashMap, HashSet}; |
29 | 23 | use std::sync::{Arc, RwLock}; |
@@ -188,13 +182,7 @@ pub(crate) struct VerusThirBuildCtxt { |
188 | 182 | } |
189 | 183 |
|
190 | 184 | 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 { |
198 | 186 | VerusThirBuildCtxt { |
199 | 187 | ctxt: get_verus_erasure_ctxt_option(), |
200 | 188 | closure_overrides: HashMap::new(), |
@@ -315,7 +303,7 @@ pub(crate) fn should_erase_var(verus_ctxt: &VerusThirBuildCtxt, var_hir_id: HirI |
315 | 303 | pub(crate) fn handle_var<'tcx>( |
316 | 304 | cx: &mut ThirBuildCx<'tcx>, |
317 | 305 | expr: &'tcx hir::Expr<'tcx>, |
318 | | - var_hir_id: HirId, |
| 306 | + _var_hir_id: HirId, |
319 | 307 | spec: bool, |
320 | 308 | ) -> Option<ExprKind<'tcx>> { |
321 | 309 | 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 |
784 | 772 | expr, |
785 | 773 | )); |
786 | 774 | } |
787 | | - hir::ExprKind::Block(block, _) => { |
| 775 | + hir::ExprKind::Block(_block, _) => { |
788 | 776 | if let Some(b) = erase_block_for_pattern_checking( |
789 | 777 | self.cx, |
790 | 778 | self.erasure_ctxt, |
@@ -859,7 +847,7 @@ fn erase_let_for_pattern_checking<'tcx>( |
859 | 847 | let hir::StmtKind::Let(local) = stmt.kind else { |
860 | 848 | unreachable!(); |
861 | 849 | }; |
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; |
863 | 851 | if els.is_some() { |
864 | 852 | panic!("erase_let_for_pattern_checking: let-else statement not expected in erased code"); |
865 | 853 | } |
@@ -1208,7 +1196,7 @@ fn mk_closure_magic_coercion_fn<'tcx, 'a>( |
1208 | 1196 | // with bound variables. |
1209 | 1197 | let mut replacer = ReErasedReplacer::new(tcx); |
1210 | 1198 | 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() { |
1212 | 1200 | let t = ty.fold_with(&mut replacer); |
1213 | 1201 | output_tys.push(t); |
1214 | 1202 | } |
@@ -1310,7 +1298,7 @@ fn mk_closure_magic_coercion_fn<'tcx, 'a>( |
1310 | 1298 | tcx.mk_type_list_from_iter(input_tys.iter().cloned().chain(std::iter::once(output_ty))); |
1311 | 1299 |
|
1312 | 1300 | let mut bound_var_kinds = vec![]; |
1313 | | - for i in 0..replacer.current_var { |
| 1301 | + for _i in 0..replacer.current_var { |
1314 | 1302 | bound_var_kinds.push(BoundVariableKind::Region(BoundRegionKind::Anon)); |
1315 | 1303 | } |
1316 | 1304 | 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>( |
1388 | 1376 | } |
1389 | 1377 |
|
1390 | 1378 | 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 { |
1392 | 1380 | return None; |
1393 | 1381 | }; |
1394 | 1382 |
|
1395 | 1383 | let tcx = cx.tcx; |
1396 | 1384 |
|
1397 | 1385 | 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() { |
1399 | 1387 | ty::Closure(def_id, args) => (def_id, UpvarArgs::Closure(args), None), |
1400 | 1388 | ty::Coroutine(def_id, args) => { |
1401 | 1389 | (def_id, UpvarArgs::Coroutine(args), Some(tcx.coroutine_movability(def_id))) |
@@ -1509,7 +1497,7 @@ pub(crate) fn possibly_handle_complex_closure_block<'tcx>( |
1509 | 1497 | pub(crate) fn get_closure_expr<'tcx>(e: &'tcx hir::Expr<'tcx>) -> &'tcx hir::Expr<'tcx> { |
1510 | 1498 | match &e.kind { |
1511 | 1499 | 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]), |
1513 | 1501 | _ => panic!("get_closure_expr failed"), |
1514 | 1502 | } |
1515 | 1503 | } |
|
0 commit comments