librustc_typeck: deny(elided_lifetimes_in_paths)

This commit is contained in:
Mazdak Farrokhzad 2019-02-25 09:09:02 +01:00
parent c1911babed
commit e8ce56f126
22 changed files with 59 additions and 53 deletions

View File

@ -196,7 +196,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
/// Report error if there is an explicit type parameter when using `impl Trait`.
fn check_impl_trait(
tcx: TyCtxt,
tcx: TyCtxt<'_, '_, '_>,
span: Span,
seg: &hir::PathSegment,
generics: &ty::Generics,
@ -227,7 +227,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
/// Checks that the correct number of generic arguments have been provided.
/// Used specifically for function calls.
pub fn check_generic_arg_count_for_call(
tcx: TyCtxt,
tcx: TyCtxt<'_, '_, '_>,
span: Span,
def: &ty::Generics,
seg: &hir::PathSegment,
@ -259,7 +259,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
/// Checks that the correct number of generic arguments have been provided.
/// This is used both for datatypes and function calls.
fn check_generic_arg_count(
tcx: TyCtxt,
tcx: TyCtxt<'_, '_, '_>,
span: Span,
def: &ty::Generics,
args: &hir::GenericArgs,
@ -1502,7 +1502,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
has_err
}
pub fn prohibit_assoc_ty_binding(tcx: TyCtxt, span: Span) {
pub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_, '_, '_>, span: Span) {
let mut err = struct_span_err!(tcx.sess, span, E0229,
"associated type bindings are not allowed here");
err.span_label(span, "associated type not allowed here").emit();

View File

@ -183,7 +183,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let rhs_ty = self.check_expr(end);
// Check that both end-points are of numeric or char type.
let numeric_or_char = |ty: Ty| ty.is_numeric() || ty.is_char();
let numeric_or_char = |ty: Ty<'_>| ty.is_numeric() || ty.is_char();
let lhs_compat = numeric_or_char(lhs_ty);
let rhs_compat = numeric_or_char(rhs_ty);

View File

@ -18,7 +18,7 @@ use rustc::hir;
/// Checks that it is legal to call methods of the trait corresponding
/// to `trait_id` (this only cares about the trait, not the specific
/// method that is called).
pub fn check_legal_trait_for_method_call(tcx: TyCtxt, span: Span, trait_id: DefId) {
pub fn check_legal_trait_for_method_call(tcx: TyCtxt<'_, '_, '_>, span: Span, trait_id: DefId) {
if tcx.lang_items().drop_trait() == Some(trait_id) {
struct_span_err!(tcx.sess, span, E0040, "explicit use of destructor method")
.span_label(span, "explicit destructor calls not allowed")

View File

@ -574,7 +574,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
expr_def_id: DefId,
decl: &hir::FnDecl,
) -> ty::PolyFnSig<'tcx> {
let astconv: &dyn AstConv = self;
let astconv: &dyn AstConv<'_, '_> = self;
// First, convert the types that the user supplied (if any).
let supplied_arguments = decl.inputs.iter().map(|a| astconv.ast_ty_to_ty(a));
@ -606,7 +606,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
/// so should yield an error, but returns back a signature where
/// all parameters are of type `TyErr`.
fn error_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> {
let astconv: &dyn AstConv = self;
let astconv: &dyn AstConv<'_, '_> = self;
let supplied_arguments = decl.inputs.iter().map(|a| {
// Convert the types that the user supplied (if any), but ignore them.

View File

@ -101,7 +101,7 @@ fn coerce_mutbls<'tcx>(from_mutbl: hir::Mutability,
}
}
fn identity(_: Ty) -> Vec<Adjustment> { vec![] }
fn identity(_: Ty<'_>) -> Vec<Adjustment<'_>> { vec![] }
fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>> {
move |target| vec![Adjustment { kind, target }]
@ -1084,7 +1084,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
pub fn coerce_forced_unit<'a>(&mut self,
fcx: &FnCtxt<'a, 'gcx, 'tcx>,
cause: &ObligationCause<'tcx>,
augment_error: &mut dyn FnMut(&mut DiagnosticBuilder),
augment_error: &mut dyn FnMut(&mut DiagnosticBuilder<'_>),
label_unit_as_expected: bool)
{
self.coerce_inner(fcx,
@ -1103,7 +1103,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
cause: &ObligationCause<'tcx>,
expression: Option<&'gcx hir::Expr>,
mut expression_ty: Ty<'tcx>,
augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder)>,
augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder<'_>)>,
label_expression_as_expected: bool)
{
// Incorporate whatever type inference information we have

View File

@ -408,7 +408,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
terr: &TypeError,
terr: &TypeError<'_>,
cause: &ObligationCause<'tcx>,
impl_m: &ty::AssociatedItem,
impl_sig: ty::FnSig<'tcx>,

View File

@ -544,7 +544,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
};
let into_sugg = into_suggestion.clone();
let suggest_to_change_suffix_or_into = |err: &mut DiagnosticBuilder,
let suggest_to_change_suffix_or_into = |err: &mut DiagnosticBuilder<'_>,
note: Option<&str>| {
let suggest_msg = if literal_is_ty_suffixed(expr) {
format!(

View File

@ -598,7 +598,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
})
}
fn enforce_illegal_method_limitations(&self, pick: &probe::Pick) {
fn enforce_illegal_method_limitations(&self, pick: &probe::Pick<'_>) {
// Disallow calls to the method `drop` defined in the `Drop` trait.
match pick.item.container {
ty::TraitContainer(trait_def_id) => {

View File

@ -388,7 +388,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
}
pub fn provide(providers: &mut ty::query::Providers) {
pub fn provide(providers: &mut ty::query::Providers<'_>) {
providers.method_autoderef_steps = method_autoderef_steps;
}
@ -1180,7 +1180,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
fn emit_unstable_name_collision_hint(
&self,
stable_pick: &Pick,
stable_pick: &Pick<'_>,
unstable_candidates: &[(&Candidate<'tcx>, Symbol)],
) {
let mut diag = self.tcx.struct_span_lint_hir(

View File

@ -72,7 +72,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
return;
}
let report_candidates = |err: &mut DiagnosticBuilder, mut sources: Vec<CandidateSource>| {
let report_candidates = |err: &mut DiagnosticBuilder<'_>,
mut sources: Vec<CandidateSource>| {
sources.sort();
sources.dedup();
// Dynamic limit to avoid hiding just one candidate, which is silly.
@ -497,7 +498,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
fn suggest_use_candidates(&self,
err: &mut DiagnosticBuilder,
err: &mut DiagnosticBuilder<'_>,
mut msg: String,
candidates: Vec<DefId>) {
let module_did = self.tcx.hir().get_module_parent_by_hir_id(self.body_id);
@ -549,7 +550,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
fn suggest_valid_traits(&self,
err: &mut DiagnosticBuilder,
err: &mut DiagnosticBuilder<'_>,
valid_out_of_scope_traits: Vec<DefId>) -> bool {
if !valid_out_of_scope_traits.is_empty() {
let mut candidates = valid_out_of_scope_traits;
@ -577,7 +578,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
fn suggest_traits_to_import<'b>(&self,
err: &mut DiagnosticBuilder,
err: &mut DiagnosticBuilder<'_>,
span: Span,
rcvr_ty: Ty<'tcx>,
item_name: ast::Ident,
@ -648,8 +649,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
fn type_derefs_to_local(&self,
span: Span,
rcvr_ty: Ty<'tcx>,
source: SelfSource) -> bool {
fn is_local(ty: Ty) -> bool {
source: SelfSource<'_>) -> bool {
fn is_local(ty: Ty<'_>) -> bool {
match ty.sty {
ty::Adt(def, _) => def.did.is_local(),
ty::Foreign(did) => did.is_local(),
@ -749,7 +750,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec<DefId>
// Cross-crate:
let mut external_mods = FxHashSet::default();
fn handle_external_def(tcx: TyCtxt,
fn handle_external_def(tcx: TyCtxt<'_, '_, '_>,
traits: &mut Vec<DefId>,
external_mods: &mut FxHashSet<DefId>,
def: Def) {
@ -779,7 +780,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec<DefId>
traits
}
pub fn provide(providers: &mut ty::query::Providers) {
pub fn provide(providers: &mut ty::query::Providers<'_>) {
providers.all_traits = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
Lrc::new(compute_all_traits(tcx))

View File

@ -738,7 +738,7 @@ fn check_impl_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: De
wfcheck::check_impl_item(tcx, def_id);
}
pub fn provide(providers: &mut Providers) {
pub fn provide(providers: &mut Providers<'_>) {
method::provide(providers);
*providers = Providers {
typeck_item_bodies,
@ -1437,7 +1437,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite
}
}
fn maybe_check_static_with_link_section(tcx: TyCtxt, id: DefId, span: Span) {
fn maybe_check_static_with_link_section(tcx: TyCtxt<'_, '_, '_>, id: DefId, span: Span) {
// Only restricted on wasm32 target for now
if !tcx.sess.opts.target_triple.triple().starts_with("wasm32") {
return
@ -2122,7 +2122,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
pub fn tag(&self) -> String {
let self_ptr: *const FnCtxt = self;
let self_ptr: *const FnCtxt<'_, '_, '_> = self;
format!("{:?}", self_ptr)
}
@ -3369,7 +3369,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// (`only_has_type`); otherwise, we just go with a
// fresh type variable.
let coerce_to_ty = expected.coercion_target_type(self, sp);
let mut coerce: DynamicCoerceMany = CoerceMany::new(coerce_to_ty);
let mut coerce: DynamicCoerceMany<'_, '_> = CoerceMany::new(coerce_to_ty);
coerce.coerce(self, &self.misc(sp), then_expr, then_ty);
@ -5043,7 +5043,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
/// Given a function `Node`, return its `FnDecl` if it exists, or `None` otherwise.
fn get_node_fn_decl(&self, node: Node) -> Option<(hir::FnDecl, ast::Ident, bool)> {
fn get_node_fn_decl(&self, node: Node<'_>) -> Option<(hir::FnDecl, ast::Ident, bool)> {
match node {
Node::Item(&hir::Item {
ident, node: hir::ItemKind::Fn(ref decl, ..), ..

View File

@ -416,7 +416,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
rhs_expr: &'gcx hir::Expr,
lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>,
err: &mut errors::DiagnosticBuilder,
err: &mut errors::DiagnosticBuilder<'_>,
is_assign: bool,
) -> bool {
let source_map = self.tcx.sess.source_map();
@ -688,7 +688,7 @@ enum Op {
/// Reason #2 is the killer. I tried for a while to always use
/// overloaded logic and just check the types in constants/codegen after
/// the fact, and it worked fine, except for SIMD types. -nmatsakis
fn is_builtin_binop(lhs: Ty, rhs: Ty, op: hir::BinOp) -> bool {
fn is_builtin_binop(lhs: Ty<'_>, rhs: Ty<'_>, op: hir::BinOp) -> bool {
match BinOpCategory::from(op) {
BinOpCategory::Shortcircuit => {
true

View File

@ -649,6 +649,6 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
}
}
fn var_name(tcx: TyCtxt, var_hir_id: hir::HirId) -> ast::Name {
fn var_name(tcx: TyCtxt<'_, '_, '_>, var_hir_id: hir::HirId) -> ast::Name {
tcx.hir().name_by_hir_id(var_hir_id)
}

View File

@ -938,7 +938,7 @@ fn report_bivariance<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
err.emit();
}
fn reject_shadowing_parameters(tcx: TyCtxt, def_id: DefId) {
fn reject_shadowing_parameters(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) {
let generics = tcx.generics_of(def_id);
let parent = tcx.generics_of(generics.parent.unwrap());
let impl_params: FxHashMap<_, _> = parent.params.iter().flat_map(|param| match param.kind {
@ -1093,7 +1093,7 @@ fn error_392<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span, param_name: ast:
err
}
fn error_194(tcx: TyCtxt, span: Span, trait_decl_span: Span, name: &str) {
fn error_194(tcx: TyCtxt<'_, '_, '_>, span: Span, trait_decl_span: Span, name: &str) {
struct_span_err!(tcx.sess, span, E0194,
"type parameter `{}` shadows another type parameter of the same name",
name)

View File

@ -729,30 +729,30 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
}
trait Locatable {
fn to_span(&self, tcx: &TyCtxt) -> Span;
fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span;
}
impl Locatable for Span {
fn to_span(&self, _: &TyCtxt) -> Span {
fn to_span(&self, _: &TyCtxt<'_, '_, '_>) -> Span {
*self
}
}
impl Locatable for ast::NodeId {
fn to_span(&self, tcx: &TyCtxt) -> Span {
fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span {
tcx.hir().span(*self)
}
}
impl Locatable for DefIndex {
fn to_span(&self, tcx: &TyCtxt) -> Span {
fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span {
let hir_id = tcx.hir().def_index_to_hir_id(*self);
tcx.hir().span_by_hir_id(hir_id)
}
}
impl Locatable for hir::HirId {
fn to_span(&self, tcx: &TyCtxt) -> Span {
fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span {
tcx.hir().span_by_hir_id(*self)
}
}

View File

@ -20,7 +20,7 @@ struct InherentOverlapChecker<'a, 'tcx: 'a> {
impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
fn check_for_common_items_in_impls(&self, impl1: DefId, impl2: DefId,
overlap: traits::OverlapResult,
overlap: traits::OverlapResult<'_>,
used_to_be_allowed: bool) {
let name_and_namespace = |def_id| {

View File

@ -41,7 +41,11 @@ fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
}
}
fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_def_id: DefId) {
fn enforce_trait_manually_implementable(
tcx: TyCtxt<'_, '_, '_>,
impl_def_id: DefId,
trait_def_id: DefId
) {
let did = Some(trait_def_id);
let li = tcx.lang_items();
let span = tcx.sess.source_map().def_span(tcx.span_of_impl(impl_def_id).unwrap());
@ -93,7 +97,11 @@ fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_d
/// We allow impls of marker traits to overlap, so they can't override impls
/// as that could make it ambiguous which associated item to use.
fn enforce_empty_impls_for_marker_traits(tcx: TyCtxt, impl_def_id: DefId, trait_def_id: DefId) {
fn enforce_empty_impls_for_marker_traits(
tcx: TyCtxt<'_, '_, '_>,
impl_def_id: DefId,
trait_def_id: DefId
) {
if !tcx.trait_def(trait_def_id).is_marker {
return;
}
@ -110,7 +118,7 @@ fn enforce_empty_impls_for_marker_traits(tcx: TyCtxt, impl_def_id: DefId, trait_
.emit();
}
pub fn provide(providers: &mut Providers) {
pub fn provide(providers: &mut Providers<'_>) {
use self::builtin::coerce_unsized_info;
use self::inherent_impls::{crate_inherent_impls, inherent_impls};
use self::inherent_impls_overlap::crate_inherent_impls_overlap_check;

View File

@ -1406,7 +1406,7 @@ fn find_existential_constraints<'a, 'tcx>(
ty::Param(p) => Some(*index_map.get(p).unwrap()),
_ => None,
}).collect();
let is_param = |ty: ty::Ty| match ty.sty {
let is_param = |ty: ty::Ty<'_>| match ty.sty {
ty::Param(_) => true,
_ => false,
};
@ -2216,7 +2216,7 @@ fn compute_sig_of_foreign_fn_decl<'a, 'tcx>(
&& abi != abi::Abi::PlatformIntrinsic
&& !tcx.features().simd_ffi
{
let check = |ast_ty: &hir::Ty, ty: Ty| {
let check = |ast_ty: &hir::Ty, ty: Ty<'_>| {
if ty.is_simd() {
tcx.sess
.struct_span_err(
@ -2251,7 +2251,7 @@ fn is_foreign_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool
}
fn from_target_feature(
tcx: TyCtxt,
tcx: TyCtxt<'_, '_, '_>,
id: DefId,
attr: &ast::Attribute,
whitelist: &FxHashMap<String, Option<String>>,

View File

@ -74,8 +74,6 @@ This API is completely unstable and subject to change.
#![deny(rust_2018_idioms)]
#![allow(explicit_outlives_requirements)]
#![allow(elided_lifetimes_in_paths)] // WIP
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;

View File

@ -27,7 +27,7 @@ pub mod test;
/// Code for transforming variances.
mod xform;
pub fn provide(providers: &mut Providers) {
pub fn provide(providers: &mut Providers<'_>) {
*providers = Providers {
variances_of,
crate_variances,
@ -91,4 +91,3 @@ fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId)
.unwrap_or(&crate_map.empty_variance)
.clone()
}

View File

@ -23,7 +23,7 @@ struct SolveContext<'a, 'tcx: 'a> {
solutions: Vec<ty::Variance>,
}
pub fn solve_constraints(constraints_cx: ConstraintContext) -> ty::CrateVariancesMap {
pub fn solve_constraints(constraints_cx: ConstraintContext<'_, '_>) -> ty::CrateVariancesMap {
let ConstraintContext { terms_cx, constraints, .. } = constraints_cx;
let mut solutions = vec![ty::Bivariant; terms_cx.inferred_terms.len()];

View File

@ -32,7 +32,7 @@ pub enum VarianceTerm<'a> {
}
impl<'a> fmt::Debug for VarianceTerm<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ConstantTerm(c1) => write!(f, "{:?}", c1),
TransformTerm(v1, v2) => write!(f, "({:?} \u{00D7} {:?})", v1, v2),
@ -86,7 +86,7 @@ pub fn determine_parameters_to_be_inferred<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>
terms_cx
}
fn lang_items(tcx: TyCtxt) -> Vec<(ast::NodeId, Vec<ty::Variance>)> {
fn lang_items(tcx: TyCtxt<'_, '_, '_>) -> Vec<(ast::NodeId, Vec<ty::Variance>)> {
let lang_items = tcx.lang_items();
let all = vec![
(lang_items.phantom_data(), vec![ty::Covariant]),