Skip to content

Commit

Permalink
librustc_typeck: deny(elided_lifetimes_in_paths)
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Feb 25, 2019
1 parent c1911ba commit e8ce56f
Show file tree
Hide file tree
Showing 22 changed files with 59 additions and 53 deletions.
8 changes: 4 additions & 4 deletions src/librustc_typeck/astconv.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/_match.rs
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/callee.rs
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/closure.rs
Expand Up @@ -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));
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/check/coercion.rs
Expand Up @@ -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 }]
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/compare_method.rs
Expand Up @@ -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>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/demand.rs
Expand Up @@ -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!(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/method/confirm.rs
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/method/probe.rs
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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(
Expand Down
17 changes: 9 additions & 8 deletions src/librustc_typeck/check/method/suggest.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_typeck/check/mod.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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, ..), ..
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/op.rs
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/upvar.rs
Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/wfcheck.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_typeck/check/writeback.rs
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/coherence/inherent_impls_overlap.rs
Expand Up @@ -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| {
Expand Down
14 changes: 11 additions & 3 deletions src/librustc_typeck/coherence/mod.rs
Expand Up @@ -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());
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit e8ce56f

Please sign in to comment.