Enable the rust_2018_idioms and unused_lifetimes lints and fix all warnings
They are set to deny by default in the rust-lang/rust repo
This commit is contained in:
parent
fd3be6d492
commit
291c75d10b
@ -5,7 +5,7 @@ use rustc_middle::mir;
|
||||
use crate::abi::pass_mode::*;
|
||||
use crate::prelude::*;
|
||||
|
||||
pub(super) fn add_args_header_comment(fx: &mut FunctionCx<impl Backend>) {
|
||||
pub(super) fn add_args_header_comment(fx: &mut FunctionCx<'_, '_, impl Backend>) {
|
||||
fx.add_global_comment(format!(
|
||||
"kind loc.idx param pass mode ty"
|
||||
));
|
||||
@ -49,7 +49,7 @@ pub(super) fn add_arg_comment<'tcx>(
|
||||
));
|
||||
}
|
||||
|
||||
pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<impl Backend>) {
|
||||
pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<'_, '_, impl Backend>) {
|
||||
fx.add_global_comment(String::new());
|
||||
fx.add_global_comment(format!(
|
||||
"kind local ty size align (abi,pref)"
|
||||
|
@ -92,7 +92,7 @@ fn clif_sig_from_fn_sig<'tcx>(
|
||||
}
|
||||
abi => abi,
|
||||
};
|
||||
let (call_conv, inputs, output): (CallConv, Vec<Ty>, Ty) = match abi {
|
||||
let (call_conv, inputs, output): (CallConv, Vec<Ty<'tcx>>, Ty<'tcx>) = match abi {
|
||||
Abi::Rust => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()),
|
||||
Abi::C => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()),
|
||||
Abi::RustCall => {
|
||||
@ -101,7 +101,7 @@ fn clif_sig_from_fn_sig<'tcx>(
|
||||
ty::Tuple(ref tupled_arguments) => tupled_arguments,
|
||||
_ => bug!("argument to function with \"rust-call\" ABI is not a tuple"),
|
||||
};
|
||||
let mut inputs: Vec<Ty> = vec![sig.inputs()[0]];
|
||||
let mut inputs: Vec<Ty<'tcx>> = vec![sig.inputs()[0]];
|
||||
inputs.extend(extra_args.types());
|
||||
(CallConv::triple_default(triple), inputs, sig.output())
|
||||
}
|
||||
@ -288,7 +288,11 @@ fn local_place<'tcx>(
|
||||
fx.local_map[&local]
|
||||
}
|
||||
|
||||
pub(crate) fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block: Block, should_codegen_locals: bool) {
|
||||
pub(crate) fn codegen_fn_prelude<'tcx>(
|
||||
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
|
||||
start_block: Block,
|
||||
should_codegen_locals: bool,
|
||||
) {
|
||||
let ssa_analyzed = crate::analyze::analyze(fx);
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
@ -332,7 +336,7 @@ pub(crate) fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, star
|
||||
(local, ArgKind::Normal(param), arg_ty)
|
||||
}
|
||||
})
|
||||
.collect::<Vec<(Local, ArgKind, Ty)>>();
|
||||
.collect::<Vec<(Local, ArgKind<'tcx>, Ty<'tcx>)>>();
|
||||
|
||||
assert!(fx.caller_location.is_none());
|
||||
if fx.instance.def.requires_caller_location(fx.tcx) {
|
||||
|
@ -14,7 +14,7 @@ pub(crate) fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyAndL
|
||||
}
|
||||
|
||||
pub(super) fn codegen_return_param(
|
||||
fx: &mut FunctionCx<impl Backend>,
|
||||
fx: &mut FunctionCx<'_, '_, impl Backend>,
|
||||
ssa_analyzed: &rustc_index::vec::IndexVec<Local, crate::analyze::SsaKind>,
|
||||
start_block: Block,
|
||||
) {
|
||||
@ -101,7 +101,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>(
|
||||
(call_inst, meta)
|
||||
}
|
||||
|
||||
pub(crate) fn codegen_return(fx: &mut FunctionCx<impl Backend>) {
|
||||
pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, impl Backend>) {
|
||||
match get_pass_mode(fx.tcx, return_layout(fx)) {
|
||||
PassMode::NoPass | PassMode::ByRef { sized: true } => {
|
||||
fx.bcx.ins().return_(&[]);
|
||||
|
@ -209,7 +209,7 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
|
||||
context.clear();
|
||||
}
|
||||
|
||||
pub(crate) fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func: &Function) {
|
||||
pub(crate) fn verify_func(tcx: TyCtxt<'_>, writer: &crate::pretty_clif::CommentWriter, func: &Function) {
|
||||
tcx.sess.time("verify clif ir", || {
|
||||
let flags = settings::Flags::new(settings::builder());
|
||||
match ::cranelift_codegen::verify_function(&func, &flags) {
|
||||
|
@ -10,7 +10,7 @@ pub(crate) fn mir_var(loc: Local) -> Variable {
|
||||
Variable::with_u32(loc.index() as u32)
|
||||
}
|
||||
|
||||
pub(crate) fn pointer_ty(tcx: TyCtxt) -> types::Type {
|
||||
pub(crate) fn pointer_ty(tcx: TyCtxt<'_>) -> types::Type {
|
||||
match tcx.data_layout.pointer_size.bits() {
|
||||
16 => types::I16,
|
||||
32 => types::I32,
|
||||
@ -19,7 +19,7 @@ pub(crate) fn pointer_ty(tcx: TyCtxt) -> types::Type {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type {
|
||||
pub(crate) fn scalar_to_clif_type(tcx: TyCtxt<'_>, scalar: Scalar) -> Type {
|
||||
match scalar.value {
|
||||
Primitive::Int(int, _sign) => match int {
|
||||
Integer::I8 => types::I8,
|
||||
|
@ -61,7 +61,7 @@ struct WriterRelocate {
|
||||
}
|
||||
|
||||
impl WriterRelocate {
|
||||
fn new(ctx: &DebugContext) -> Self {
|
||||
fn new(ctx: &DebugContext<'_>) -> Self {
|
||||
WriterRelocate {
|
||||
relocs: Vec::new(),
|
||||
writer: EndianVec::new(ctx.endian),
|
||||
|
@ -15,7 +15,7 @@ use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64};
|
||||
|
||||
pub(crate) use emit::{DebugReloc, DebugRelocName};
|
||||
|
||||
fn target_endian(tcx: TyCtxt) -> RunTimeEndian {
|
||||
fn target_endian(tcx: TyCtxt<'_>) -> RunTimeEndian {
|
||||
use rustc_target::abi::Endian;
|
||||
|
||||
match tcx.data_layout.endian {
|
||||
|
@ -31,7 +31,7 @@ fn emit_module<B: Backend>(
|
||||
name: String,
|
||||
kind: ModuleKind,
|
||||
mut module: Module<B>,
|
||||
debug: Option<DebugContext>,
|
||||
debug: Option<DebugContext<'_>>,
|
||||
) -> ModuleCodegenResult
|
||||
where B::Product: Emit + WriteDebugInfo,
|
||||
{
|
||||
@ -72,7 +72,7 @@ fn emit_module<B: Backend>(
|
||||
|
||||
fn reuse_workproduct_for_cgu(
|
||||
tcx: TyCtxt<'_>,
|
||||
cgu: &CodegenUnit,
|
||||
cgu: &CodegenUnit<'_>,
|
||||
work_products: &mut FxHashMap<WorkProductId, WorkProduct>,
|
||||
) -> CompiledModule {
|
||||
let incr_comp_session_dir = tcx.sess.incr_comp_session_dir();
|
||||
|
@ -128,7 +128,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> {
|
||||
} else {
|
||||
&name
|
||||
};
|
||||
let symbol: libloading::Symbol<*const u8> =
|
||||
let symbol: libloading::Symbol<'_, *const u8> =
|
||||
unsafe { lib.get(dlsym_name.as_bytes()) }.unwrap();
|
||||
Some((name, *symbol))
|
||||
}));
|
||||
|
@ -691,7 +691,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
|
||||
};
|
||||
bswap, <T> (v arg) {
|
||||
// FIXME(CraneStation/cranelift#794) add bswap instruction to cranelift
|
||||
fn swap(bcx: &mut FunctionBuilder, v: Value) -> Value {
|
||||
fn swap(bcx: &mut FunctionBuilder<'_>, v: Value) -> Value {
|
||||
match bcx.func.dfg.value_type(v) {
|
||||
types::I8 => v,
|
||||
|
||||
|
12
src/lib.rs
12
src/lib.rs
@ -1,13 +1,13 @@
|
||||
#![feature(rustc_private, decl_macro, type_alias_impl_trait, associated_type_bounds, never_type)]
|
||||
#![allow(intra_doc_link_resolution_failure)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![warn(unused_lifetimes)]
|
||||
|
||||
extern crate flate2;
|
||||
extern crate libc;
|
||||
extern crate tempfile;
|
||||
extern crate rustc_middle;
|
||||
extern crate rustc_codegen_ssa;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_errors;
|
||||
extern crate rustc_fs_util;
|
||||
extern crate rustc_hir;
|
||||
@ -20,6 +20,10 @@ extern crate rustc_symbol_mangling;
|
||||
extern crate rustc_target;
|
||||
extern crate rustc_ast;
|
||||
|
||||
// This prevents duplicating functions and statics that are already part of the host rustc process.
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_driver;
|
||||
|
||||
use std::any::Any;
|
||||
|
||||
use rustc_errors::ErrorReported;
|
||||
@ -166,7 +170,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
Box::new(crate::metadata::CraneliftMetadataLoader)
|
||||
}
|
||||
|
||||
fn provide(&self, providers: &mut Providers) {
|
||||
fn provide(&self, providers: &mut Providers<'_>) {
|
||||
providers.target_features_whitelist = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
if tcx.sess.opts.actually_rustdoc {
|
||||
@ -187,7 +191,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
}
|
||||
};
|
||||
}
|
||||
fn provide_extern(&self, _providers: &mut Providers) {}
|
||||
fn provide_extern(&self, _providers: &mut Providers<'_>) {}
|
||||
|
||||
fn codegen_crate<'tcx>(
|
||||
&self,
|
||||
|
@ -2,7 +2,7 @@ use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility};
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
pub(crate) fn get_clif_linkage(mono_item: MonoItem, linkage: RLinkage, visibility: Visibility) -> Linkage {
|
||||
pub(crate) fn get_clif_linkage(mono_item: MonoItem<'_>, linkage: RLinkage, visibility: Visibility) -> Linkage {
|
||||
match (linkage, visibility) {
|
||||
(RLinkage::External, Visibility::Default) => Linkage::Export,
|
||||
(RLinkage::Internal, Visibility::Default) => Linkage::Local,
|
||||
@ -11,7 +11,7 @@ pub(crate) fn get_clif_linkage(mono_item: MonoItem, linkage: RLinkage, visibilit
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_static_ref_linkage(tcx: TyCtxt, def_id: DefId) -> Linkage {
|
||||
pub(crate) fn get_static_ref_linkage(tcx: TyCtxt<'_>, def_id: DefId) -> Linkage {
|
||||
let fn_attrs = tcx.codegen_fn_attrs(def_id);
|
||||
|
||||
if let Some(linkage) = fn_attrs.linkage {
|
||||
|
@ -65,7 +65,7 @@ pub(crate) fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module<im
|
||||
ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig.clone());
|
||||
{
|
||||
let mut func_ctx = FunctionBuilderContext::new();
|
||||
let mut bcx: FunctionBuilder = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
|
||||
let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
|
||||
|
||||
let block = bcx.create_block();
|
||||
bcx.switch_to_block(block);
|
||||
|
@ -24,7 +24,7 @@ use crate::prelude::*;
|
||||
struct OrdStackSlot(StackSlot);
|
||||
|
||||
impl fmt::Debug for OrdStackSlot {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}", self.0)
|
||||
}
|
||||
}
|
||||
@ -282,7 +282,7 @@ fn combine_stack_addr_with_load_store(func: &mut Function) {
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext) {
|
||||
fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) {
|
||||
// FIXME incrementally rebuild on each call?
|
||||
let mut stack_addr_load_insts_users = HashMap::<Inst, HashSet<Inst>>::new();
|
||||
|
||||
|
@ -185,7 +185,7 @@ impl FuncWriter for &'_ CommentWriter {
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
impl<'a, 'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> {
|
||||
impl<B: Backend + 'static> FunctionCx<'_, '_, B> {
|
||||
pub(crate) fn add_global_comment<S: Into<String>>(&mut self, comment: S) {
|
||||
self.clif_comments.add_global_comment(comment);
|
||||
}
|
||||
@ -248,8 +248,8 @@ pub(crate) fn write_clif_file<'tcx>(
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, B: Backend + 'static> fmt::Debug for FunctionCx<'_, 'tcx, B> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl<B: Backend + 'static> fmt::Debug for FunctionCx<'_, '_, B> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
writeln!(f, "{:?}", self.instance.substs)?;
|
||||
writeln!(f, "{:?}", self.local_map)?;
|
||||
|
||||
|
@ -12,7 +12,7 @@ fn codegen_field<'tcx>(
|
||||
let field_offset = layout.fields.offset(field.index());
|
||||
let field_layout = layout.field(&*fx, field.index());
|
||||
|
||||
let simple = |fx: &mut FunctionCx<_>| {
|
||||
let simple = |fx: &mut FunctionCx<'_, '_, _>| {
|
||||
(
|
||||
base.offset_i64(fx, i64::try_from(field_offset.bytes()).unwrap()),
|
||||
field_layout,
|
||||
@ -93,7 +93,7 @@ impl<'tcx> CValue<'tcx> {
|
||||
}
|
||||
|
||||
// FIXME remove
|
||||
pub(crate) fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> (Pointer, Option<Value>) {
|
||||
pub(crate) fn force_stack(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> (Pointer, Option<Value>) {
|
||||
let layout = self.1;
|
||||
match self.0 {
|
||||
CValueInner::ByRef(ptr, meta) => (ptr, meta),
|
||||
@ -113,7 +113,7 @@ impl<'tcx> CValue<'tcx> {
|
||||
}
|
||||
|
||||
/// Load a value with layout.abi of scalar
|
||||
pub(crate) fn load_scalar<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value {
|
||||
pub(crate) fn load_scalar(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value {
|
||||
let layout = self.1;
|
||||
match self.0 {
|
||||
CValueInner::ByRef(ptr, None) => {
|
||||
@ -134,7 +134,7 @@ impl<'tcx> CValue<'tcx> {
|
||||
}
|
||||
|
||||
/// Load a value pair with layout.abi of scalar pair
|
||||
pub(crate) fn load_scalar_pair<'a>(
|
||||
pub(crate) fn load_scalar_pair(
|
||||
self,
|
||||
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
|
||||
) -> (Value, Value) {
|
||||
@ -158,7 +158,7 @@ impl<'tcx> CValue<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn value_field<'a>(
|
||||
pub(crate) fn value_field(
|
||||
self,
|
||||
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
|
||||
field: mir::Field,
|
||||
@ -187,7 +187,7 @@ impl<'tcx> CValue<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn unsize_value<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) {
|
||||
pub(crate) fn unsize_value(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) {
|
||||
crate::unsize::coerce_unsized_into(fx, self, dest);
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ fn build_vtable<'tcx>(
|
||||
data_id
|
||||
}
|
||||
|
||||
fn write_usize(tcx: TyCtxt, buf: &mut [u8], idx: usize, num: u64) {
|
||||
fn write_usize(tcx: TyCtxt<'_>, buf: &mut [u8], idx: usize, num: u64) {
|
||||
use byteorder::{BigEndian, LittleEndian, WriteBytesExt};
|
||||
|
||||
let usize_size = tcx
|
||||
|
Loading…
x
Reference in New Issue
Block a user