diff --git a/compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/builtin.rs b/compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/builtin.rs index 567f16dec5b1b..6f723bebbf1b8 100644 --- a/compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/builtin.rs +++ b/compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/builtin.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT //! this module lazily declares builtin functions in CBMC use self::BuiltinFn::*; -use super::{Expr, Location, Symbol, SymbolTable, Type}; +use super::{Expr, Location, Symbol, Type}; #[derive(Debug, Clone, Copy)] pub enum BuiltinFn { diff --git a/compiler/rustc_codegen_llvm/src/gotoc/metadata.rs b/compiler/rustc_codegen_llvm/src/gotoc/metadata.rs index c55b566ae95a4..2407ffcb71fff 100644 --- a/compiler/rustc_codegen_llvm/src/gotoc/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/gotoc/metadata.rs @@ -37,7 +37,7 @@ pub struct CurrentFnCtx<'tcx> { /// the codegen instance for the current function instance: Instance<'tcx>, /// the def id for the current instance - def_id: DefId, + _def_id: DefId, /// the mir for the current instance mir: &'tcx Body<'tcx>, /// the goto labels for all blocks @@ -56,7 +56,7 @@ impl CurrentFnCtx<'tcx> { Self { instance, mir: tcx.instance_mir(instance.def), - def_id: instance.def_id(), + _def_id: instance.def_id(), labels: vec![], block: vec![], current_bb: None, diff --git a/compiler/rustc_codegen_llvm/src/gotoc/operand.rs b/compiler/rustc_codegen_llvm/src/gotoc/operand.rs index c428ccc97fd60..55e9276e529de 100644 --- a/compiler/rustc_codegen_llvm/src/gotoc/operand.rs +++ b/compiler/rustc_codegen_llvm/src/gotoc/operand.rs @@ -425,7 +425,7 @@ impl<'tcx> GotocCtx<'tcx> { // initializers. For example, for a boolean static variable, the variable will have type // CBool and the initializer will be a single byte (a one-character array) representing the // bit pattern for the boolean value. - let alloc_typ_ref = self.ensure_struct(&format!("{}::struct", name), |ctx, name| { + let alloc_typ_ref = self.ensure_struct(&format!("{}::struct", name), |ctx, _| { ctx.codegen_allocation_data(alloc) .iter() .enumerate() diff --git a/compiler/rustc_codegen_llvm/src/gotoc/place.rs b/compiler/rustc_codegen_llvm/src/gotoc/place.rs index 917d73aca03d1..e8faacf0d23b9 100644 --- a/compiler/rustc_codegen_llvm/src/gotoc/place.rs +++ b/compiler/rustc_codegen_llvm/src/gotoc/place.rs @@ -8,11 +8,9 @@ use super::cbmc::goto_program::{Expr, Type}; use super::metadata::*; use super::typ::tuple_fld; -use rustc_ast::ast::Mutability; -use rustc_middle::ty::{self, Ty, TyS, VariantDef}; use rustc_middle::{ mir::{Field, Local, Place, ProjectionElem}, - ty::layout::HasTyCtxt, + ty::{self, Ty, TyS, VariantDef}, }; use rustc_target::abi::{LayoutOf, TagEncoding, Variants}; use tracing::debug; diff --git a/compiler/rustc_codegen_llvm/src/gotoc/typ.rs b/compiler/rustc_codegen_llvm/src/gotoc/typ.rs index f8dc033109e1e..a8e530ae4b973 100644 --- a/compiler/rustc_codegen_llvm/src/gotoc/typ.rs +++ b/compiler/rustc_codegen_llvm/src/gotoc/typ.rs @@ -141,7 +141,7 @@ impl<'tcx> GotocCtx<'tcx> { /// } /// Ensures that the vtable is added to the symbol table. fn codegen_trait_vtable_type(&mut self, t: &'tcx ty::TyS<'tcx>) -> Type { - self.ensure_struct(&self.vtable_name(t), |ctx, name| ctx.trait_vtable_field_types(t)) + self.ensure_struct(&self.vtable_name(t), |ctx, _| ctx.trait_vtable_field_types(t)) } /// a trait dyn Trait is translated to @@ -150,7 +150,7 @@ impl<'tcx> GotocCtx<'tcx> { /// void* vtable; /// } fn codegen_trait_fat_ptr_type(&mut self, t: &'tcx ty::TyS<'tcx>) -> Type { - self.ensure_struct(&self.normalized_trait_name(t), |ctx, name| { + self.ensure_struct(&self.normalized_trait_name(t), |ctx, _| { // At this point in time, the vtable hasn't been codegen yet. // However, all we need to know is its name, which we do know. // See the comment on codegen_ty_ref. @@ -313,7 +313,7 @@ impl<'tcx> GotocCtx<'tcx> { // struct [T; n] { // T _0[n]; // } - self.ensure_struct(&array_name, |ctx, name| { + self.ensure_struct(&array_name, |ctx, _| { if et.is_unit() { // we do not generate a struct with an array of units vec![] @@ -347,8 +347,8 @@ impl<'tcx> GotocCtx<'tcx> { } else { // we do not have to do two insertions for tuple because it is impossible for // finite tuples to loop. - self.ensure_struct(&self.ty_mangled_name(ty), |tcx, name| { - tcx.codegen_ty_tuple_fields(name, ty, ts) + self.ensure_struct(&self.ty_mangled_name(ty), |tcx, _| { + tcx.codegen_ty_tuple_fields(ty, ts) }) } } @@ -392,11 +392,10 @@ impl<'tcx> GotocCtx<'tcx> { fn codegen_ty_tuple_fields( &mut self, - name: &str, t: Ty<'tcx>, substs: ty::subst::SubstsRef<'tcx>, ) -> Vec { - self.codegen_ty_tuple_like(name, t, substs.iter().map(|g| g.expect_ty()).collect()) + self.codegen_ty_tuple_like(t, substs.iter().map(|g| g.expect_ty()).collect()) } fn codegen_struct_padding( @@ -434,7 +433,6 @@ impl<'tcx> GotocCtx<'tcx> { /// * initial_offset - offset which has been accumulated in parent struct, in bits fn codegen_struct_fields( &mut self, - name: &str, flds: Vec<(String, Ty<'tcx>)>, layout: &Layout, initial_offset: usize, @@ -492,25 +490,19 @@ impl<'tcx> GotocCtx<'tcx> { } } - fn codegen_ty_tuple_like( - &mut self, - name: &str, - t: Ty<'tcx>, - tys: Vec>, - ) -> Vec { + fn codegen_ty_tuple_like(&mut self, t: Ty<'tcx>, tys: Vec>) -> Vec { let layout = self.layout_of(t); let flds: Vec<_> = tys.iter().enumerate().map(|(i, t)| (tuple_fld(i), *t)).collect(); // tuple cannot have other initial offset - self.codegen_struct_fields(name, flds, layout.layout, 0) + self.codegen_struct_fields(flds, layout.layout, 0) } /// a closure is a struct of all its environments /// that is, a closure is just a tuple with a unique type identifier, so that Fn related traits /// can find its impl. fn codegen_ty_closure(&mut self, t: Ty<'tcx>, substs: ty::subst::SubstsRef<'tcx>) -> Type { - let name = self.ty_mangled_name(t); - self.ensure_struct(&name, |ctx, name| { - ctx.codegen_ty_tuple_like(name, t, substs.as_closure().upvar_tys().collect()) + self.ensure_struct(&self.ty_mangled_name(t), |ctx, _| { + ctx.codegen_ty_tuple_like(t, substs.as_closure().upvar_tys().collect()) }) } @@ -524,7 +516,7 @@ impl<'tcx> GotocCtx<'tcx> { ty::Adt(..) if self.is_unsized(t) => { // https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp let fat_ptr_name = format!("&{}", self.ty_mangled_name(t)); - self.ensure_struct(&fat_ptr_name, |ctx, name| { + self.ensure_struct(&fat_ptr_name, |ctx, _| { vec![ Type::datatype_component("data", ctx.codegen_ty(t).to_pointer()), Type::datatype_component("len", Type::size_t()), @@ -666,17 +658,16 @@ impl<'tcx> GotocCtx<'tcx> { def: &'tcx AdtDef, subst: &'tcx InternalSubsts<'tcx>, ) -> Type { - self.ensure_struct(&self.ty_mangled_name(ty), |ctx, name| { + self.ensure_struct(&self.ty_mangled_name(ty), |ctx, _| { let variant = &def.variants.raw[0]; let layout = ctx.layout_of(ty); - ctx.codegen_variant_struct_fields(name, variant, subst, layout.layout, 0) + ctx.codegen_variant_struct_fields(variant, subst, layout.layout, 0) }) } /// generate a struct representing the layout of the variant fn codegen_variant_struct_fields( &mut self, - name: &str, variant: &VariantDef, subst: &'tcx InternalSubsts<'tcx>, layout: &Layout, @@ -687,7 +678,7 @@ impl<'tcx> GotocCtx<'tcx> { .iter() .map(|f| (f.ident.name.to_string(), f.ty(self.tcx, subst))) .collect(); - self.codegen_struct_fields(name, flds, layout, initial_offset) + self.codegen_struct_fields(flds, layout, initial_offset) } /// codegen unions @@ -697,7 +688,7 @@ impl<'tcx> GotocCtx<'tcx> { def: &'tcx AdtDef, subst: &'tcx InternalSubsts<'tcx>, ) -> Type { - self.ensure_union(&self.ty_mangled_name(ty), |ctx, name| { + self.ensure_union(&self.ty_mangled_name(ty), |ctx, _| { def.variants.raw[0] .fields .iter() @@ -763,7 +754,7 @@ impl<'tcx> GotocCtx<'tcx> { Some(variant) => { // a single enum is pretty much like a struct let layout = ctx.layout_of(ty).layout; - ctx.codegen_variant_struct_fields(name, variant, subst, layout, 0) + ctx.codegen_variant_struct_fields(variant, subst, layout, 0) } } } @@ -804,7 +795,6 @@ impl<'tcx> GotocCtx<'tcx> { // dataful_variant is pretty much the only variant which contains the valid data let variant = &adtdef.variants[*dataful_variant]; ctx.codegen_variant_struct_fields( - name, variant, subst, &variants[*dataful_variant], @@ -923,7 +913,7 @@ impl<'tcx> GotocCtx<'tcx> { let case_name = format!("{}::{}", name, case.ident.name); debug!("handling variant {}: {:?}", case_name, case); self.ensure_struct(&case_name, |tcx, _| { - tcx.codegen_variant_struct_fields(&case_name, case, subst, variant, initial_offset) + tcx.codegen_variant_struct_fields(case, subst, variant, initial_offset) }) }