Skip to content

Commit e9381e0

Browse files
danielsntedinski
authored andcommitted
Squashed a bunch of warnings (rust-lang#28)
1 parent f0e6fea commit e9381e0

File tree

5 files changed

+22
-34
lines changed

5 files changed

+22
-34
lines changed

compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
//! this module lazily declares builtin functions in CBMC
44
use self::BuiltinFn::*;
5-
use super::{Expr, Location, Symbol, SymbolTable, Type};
5+
use super::{Expr, Location, Symbol, Type};
66

77
#[derive(Debug, Clone, Copy)]
88
pub enum BuiltinFn {

compiler/rustc_codegen_llvm/src/gotoc/metadata.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct CurrentFnCtx<'tcx> {
3737
/// the codegen instance for the current function
3838
instance: Instance<'tcx>,
3939
/// the def id for the current instance
40-
def_id: DefId,
40+
_def_id: DefId,
4141
/// the mir for the current instance
4242
mir: &'tcx Body<'tcx>,
4343
/// the goto labels for all blocks
@@ -56,7 +56,7 @@ impl CurrentFnCtx<'tcx> {
5656
Self {
5757
instance,
5858
mir: tcx.instance_mir(instance.def),
59-
def_id: instance.def_id(),
59+
_def_id: instance.def_id(),
6060
labels: vec![],
6161
block: vec![],
6262
current_bb: None,

compiler/rustc_codegen_llvm/src/gotoc/operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl<'tcx> GotocCtx<'tcx> {
425425
// initializers. For example, for a boolean static variable, the variable will have type
426426
// CBool and the initializer will be a single byte (a one-character array) representing the
427427
// bit pattern for the boolean value.
428-
let alloc_typ_ref = self.ensure_struct(&format!("{}::struct", name), |ctx, name| {
428+
let alloc_typ_ref = self.ensure_struct(&format!("{}::struct", name), |ctx, _| {
429429
ctx.codegen_allocation_data(alloc)
430430
.iter()
431431
.enumerate()

compiler/rustc_codegen_llvm/src/gotoc/place.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
use super::cbmc::goto_program::{Expr, Type};
99
use super::metadata::*;
1010
use super::typ::tuple_fld;
11-
use rustc_ast::ast::Mutability;
12-
use rustc_middle::ty::{self, Ty, TyS, VariantDef};
1311
use rustc_middle::{
1412
mir::{Field, Local, Place, ProjectionElem},
15-
ty::layout::HasTyCtxt,
13+
ty::{self, Ty, TyS, VariantDef},
1614
};
1715
use rustc_target::abi::{LayoutOf, TagEncoding, Variants};
1816
use tracing::debug;

compiler/rustc_codegen_llvm/src/gotoc/typ.rs

+17-27
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'tcx> GotocCtx<'tcx> {
141141
/// }
142142
/// Ensures that the vtable is added to the symbol table.
143143
fn codegen_trait_vtable_type(&mut self, t: &'tcx ty::TyS<'tcx>) -> Type {
144-
self.ensure_struct(&self.vtable_name(t), |ctx, name| ctx.trait_vtable_field_types(t))
144+
self.ensure_struct(&self.vtable_name(t), |ctx, _| ctx.trait_vtable_field_types(t))
145145
}
146146

147147
/// a trait dyn Trait is translated to
@@ -150,7 +150,7 @@ impl<'tcx> GotocCtx<'tcx> {
150150
/// void* vtable;
151151
/// }
152152
fn codegen_trait_fat_ptr_type(&mut self, t: &'tcx ty::TyS<'tcx>) -> Type {
153-
self.ensure_struct(&self.normalized_trait_name(t), |ctx, name| {
153+
self.ensure_struct(&self.normalized_trait_name(t), |ctx, _| {
154154
// At this point in time, the vtable hasn't been codegen yet.
155155
// However, all we need to know is its name, which we do know.
156156
// See the comment on codegen_ty_ref.
@@ -313,7 +313,7 @@ impl<'tcx> GotocCtx<'tcx> {
313313
// struct [T; n] {
314314
// T _0[n];
315315
// }
316-
self.ensure_struct(&array_name, |ctx, name| {
316+
self.ensure_struct(&array_name, |ctx, _| {
317317
if et.is_unit() {
318318
// we do not generate a struct with an array of units
319319
vec![]
@@ -347,8 +347,8 @@ impl<'tcx> GotocCtx<'tcx> {
347347
} else {
348348
// we do not have to do two insertions for tuple because it is impossible for
349349
// finite tuples to loop.
350-
self.ensure_struct(&self.ty_mangled_name(ty), |tcx, name| {
351-
tcx.codegen_ty_tuple_fields(name, ty, ts)
350+
self.ensure_struct(&self.ty_mangled_name(ty), |tcx, _| {
351+
tcx.codegen_ty_tuple_fields(ty, ts)
352352
})
353353
}
354354
}
@@ -392,11 +392,10 @@ impl<'tcx> GotocCtx<'tcx> {
392392

393393
fn codegen_ty_tuple_fields(
394394
&mut self,
395-
name: &str,
396395
t: Ty<'tcx>,
397396
substs: ty::subst::SubstsRef<'tcx>,
398397
) -> Vec<DatatypeComponent> {
399-
self.codegen_ty_tuple_like(name, t, substs.iter().map(|g| g.expect_ty()).collect())
398+
self.codegen_ty_tuple_like(t, substs.iter().map(|g| g.expect_ty()).collect())
400399
}
401400

402401
fn codegen_struct_padding<T>(
@@ -434,7 +433,6 @@ impl<'tcx> GotocCtx<'tcx> {
434433
/// * initial_offset - offset which has been accumulated in parent struct, in bits
435434
fn codegen_struct_fields(
436435
&mut self,
437-
name: &str,
438436
flds: Vec<(String, Ty<'tcx>)>,
439437
layout: &Layout,
440438
initial_offset: usize,
@@ -492,25 +490,19 @@ impl<'tcx> GotocCtx<'tcx> {
492490
}
493491
}
494492

495-
fn codegen_ty_tuple_like(
496-
&mut self,
497-
name: &str,
498-
t: Ty<'tcx>,
499-
tys: Vec<Ty<'tcx>>,
500-
) -> Vec<DatatypeComponent> {
493+
fn codegen_ty_tuple_like(&mut self, t: Ty<'tcx>, tys: Vec<Ty<'tcx>>) -> Vec<DatatypeComponent> {
501494
let layout = self.layout_of(t);
502495
let flds: Vec<_> = tys.iter().enumerate().map(|(i, t)| (tuple_fld(i), *t)).collect();
503496
// tuple cannot have other initial offset
504-
self.codegen_struct_fields(name, flds, layout.layout, 0)
497+
self.codegen_struct_fields(flds, layout.layout, 0)
505498
}
506499

507500
/// a closure is a struct of all its environments
508501
/// that is, a closure is just a tuple with a unique type identifier, so that Fn related traits
509502
/// can find its impl.
510503
fn codegen_ty_closure(&mut self, t: Ty<'tcx>, substs: ty::subst::SubstsRef<'tcx>) -> Type {
511-
let name = self.ty_mangled_name(t);
512-
self.ensure_struct(&name, |ctx, name| {
513-
ctx.codegen_ty_tuple_like(name, t, substs.as_closure().upvar_tys().collect())
504+
self.ensure_struct(&self.ty_mangled_name(t), |ctx, _| {
505+
ctx.codegen_ty_tuple_like(t, substs.as_closure().upvar_tys().collect())
514506
})
515507
}
516508

@@ -524,7 +516,7 @@ impl<'tcx> GotocCtx<'tcx> {
524516
ty::Adt(..) if self.is_unsized(t) => {
525517
// https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp
526518
let fat_ptr_name = format!("&{}", self.ty_mangled_name(t));
527-
self.ensure_struct(&fat_ptr_name, |ctx, name| {
519+
self.ensure_struct(&fat_ptr_name, |ctx, _| {
528520
vec![
529521
Type::datatype_component("data", ctx.codegen_ty(t).to_pointer()),
530522
Type::datatype_component("len", Type::size_t()),
@@ -666,17 +658,16 @@ impl<'tcx> GotocCtx<'tcx> {
666658
def: &'tcx AdtDef,
667659
subst: &'tcx InternalSubsts<'tcx>,
668660
) -> Type {
669-
self.ensure_struct(&self.ty_mangled_name(ty), |ctx, name| {
661+
self.ensure_struct(&self.ty_mangled_name(ty), |ctx, _| {
670662
let variant = &def.variants.raw[0];
671663
let layout = ctx.layout_of(ty);
672-
ctx.codegen_variant_struct_fields(name, variant, subst, layout.layout, 0)
664+
ctx.codegen_variant_struct_fields(variant, subst, layout.layout, 0)
673665
})
674666
}
675667

676668
/// generate a struct representing the layout of the variant
677669
fn codegen_variant_struct_fields(
678670
&mut self,
679-
name: &str,
680671
variant: &VariantDef,
681672
subst: &'tcx InternalSubsts<'tcx>,
682673
layout: &Layout,
@@ -687,7 +678,7 @@ impl<'tcx> GotocCtx<'tcx> {
687678
.iter()
688679
.map(|f| (f.ident.name.to_string(), f.ty(self.tcx, subst)))
689680
.collect();
690-
self.codegen_struct_fields(name, flds, layout, initial_offset)
681+
self.codegen_struct_fields(flds, layout, initial_offset)
691682
}
692683

693684
/// codegen unions
@@ -697,7 +688,7 @@ impl<'tcx> GotocCtx<'tcx> {
697688
def: &'tcx AdtDef,
698689
subst: &'tcx InternalSubsts<'tcx>,
699690
) -> Type {
700-
self.ensure_union(&self.ty_mangled_name(ty), |ctx, name| {
691+
self.ensure_union(&self.ty_mangled_name(ty), |ctx, _| {
701692
def.variants.raw[0]
702693
.fields
703694
.iter()
@@ -763,7 +754,7 @@ impl<'tcx> GotocCtx<'tcx> {
763754
Some(variant) => {
764755
// a single enum is pretty much like a struct
765756
let layout = ctx.layout_of(ty).layout;
766-
ctx.codegen_variant_struct_fields(name, variant, subst, layout, 0)
757+
ctx.codegen_variant_struct_fields(variant, subst, layout, 0)
767758
}
768759
}
769760
}
@@ -804,7 +795,6 @@ impl<'tcx> GotocCtx<'tcx> {
804795
// dataful_variant is pretty much the only variant which contains the valid data
805796
let variant = &adtdef.variants[*dataful_variant];
806797
ctx.codegen_variant_struct_fields(
807-
name,
808798
variant,
809799
subst,
810800
&variants[*dataful_variant],
@@ -923,7 +913,7 @@ impl<'tcx> GotocCtx<'tcx> {
923913
let case_name = format!("{}::{}", name, case.ident.name);
924914
debug!("handling variant {}: {:?}", case_name, case);
925915
self.ensure_struct(&case_name, |tcx, _| {
926-
tcx.codegen_variant_struct_fields(&case_name, case, subst, variant, initial_offset)
916+
tcx.codegen_variant_struct_fields(case, subst, variant, initial_offset)
927917
})
928918
}
929919

0 commit comments

Comments
 (0)