diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index ee7367d408d5f..7e82d7ff77d96 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1964,7 +1964,7 @@ impl TyKind { } /// Syntax used to declare a trait object. -#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug)] +#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] pub enum TraitObjectSyntax { Dyn, None, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 44f05cbf4360a..f9872f84e125e 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1396,7 +1396,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { if kind != TraitObjectSyntax::Dyn { self.maybe_lint_bare_trait(t.span, t.id, false); } - hir::TyKind::TraitObject(bounds, lifetime_bound) + hir::TyKind::TraitObject(bounds, lifetime_bound, kind) } TyKind::ImplTrait(def_node_id, ref bounds) => { let span = t.span; @@ -2648,6 +2648,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { hir::TyKind::TraitObject( arena_vec![self; principal], self.elided_dyn_bound(span), + TraitObjectSyntax::None, ) } _ => hir::TyKind::Path(hir::QPath::Resolved(None, path)), diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 2b84d4658f90f..d03584d49a5bc 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -6,7 +6,7 @@ use crate::{itemlikevisit, LangItem}; use rustc_ast::util::parser::ExprPrecedence; use rustc_ast::{self as ast, CrateSugar, LlvmAsmDialect}; -use rustc_ast::{Attribute, FloatTy, IntTy, Label, LitKind, StrStyle, UintTy}; +use rustc_ast::{Attribute, FloatTy, IntTy, Label, LitKind, StrStyle, TraitObjectSyntax, UintTy}; pub use rustc_ast::{BorrowKind, ImplPolarity, IsAuto}; pub use rustc_ast::{CaptureBy, Movability, Mutability}; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; @@ -2327,7 +2327,7 @@ pub enum TyKind<'hir> { OpaqueDef(ItemId, &'hir [GenericArg<'hir>]), /// A trait object type `Bound1 + Bound2 + Bound3` /// where `Bound` is a trait or a lifetime. - TraitObject(&'hir [PolyTraitRef<'hir>], Lifetime), + TraitObject(&'hir [PolyTraitRef<'hir>], Lifetime, TraitObjectSyntax), /// Unused for now. Typeof(AnonConst), /// `TyKind::Infer` means the type should be inferred instead of it having been diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index 1ed8ab044fe53..701e4a6329394 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -709,7 +709,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) { visitor.visit_ty(ty); visitor.visit_anon_const(length) } - TyKind::TraitObject(bounds, ref lifetime) => { + TyKind::TraitObject(bounds, ref lifetime, _syntax) => { for bound in bounds { visitor.visit_poly_trait_ref(bound, TraitBoundModifier::None); } diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 9eab6cab64d41..b37a3e19b8408 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -410,7 +410,10 @@ impl<'a> State<'a> { } hir::TyKind::OpaqueDef(..) => self.s.word("/*impl Trait*/"), hir::TyKind::Path(ref qpath) => self.print_qpath(qpath, false), - hir::TyKind::TraitObject(bounds, ref lifetime) => { + hir::TyKind::TraitObject(bounds, ref lifetime, syntax) => { + if syntax == ast::TraitObjectSyntax::Dyn { + self.word_space("dyn"); + } let mut first = true; for bound in bounds { if first { diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs index d9ab831904551..35b9bc96f1339 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -99,7 +99,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> { return; } - hir::TyKind::TraitObject(bounds, _) => { + hir::TyKind::TraitObject(bounds, ..) => { for bound in bounds { self.current_index.shift_in(1); self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None); diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index fa0d5b8301349..1e926989263c9 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -292,7 +292,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { ); } } - TyKind::TraitObject(_, lt) => match lt.name { + TyKind::TraitObject(_, lt, _) => match lt.name { LifetimeName::ImplicitObjectLifetimeDefault => { err.span_suggestion_verbose( fn_return.span.shrink_to_hi(), @@ -498,6 +498,7 @@ impl<'tcx> Visitor<'tcx> for HirTraitObjectVisitor { if let TyKind::TraitObject( poly_trait_refs, Lifetime { name: LifetimeName::ImplicitObjectLifetimeDefault, .. }, + _, ) = t.kind { for ptr in poly_trait_refs { diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index f41bb7e6d6350..982c8a354b4ab 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -314,6 +314,7 @@ impl<'v> hir::intravisit::Visitor<'v> for TraitObjectVisitor<'v> { hir::LifetimeName::ImplicitObjectLifetimeDefault | hir::LifetimeName::Static, .. }, + _, ) => { self.0.push(ty); } diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs index 4f92532e3a698..2c61c0963ae28 100644 --- a/compiler/rustc_resolve/src/late/lifetimes.rs +++ b/compiler/rustc_resolve/src/late/lifetimes.rs @@ -540,7 +540,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { self.missing_named_lifetime_spots.pop(); self.is_in_fn_syntax = was_in_fn_syntax; } - hir::TyKind::TraitObject(bounds, ref lifetime) => { + hir::TyKind::TraitObject(bounds, ref lifetime, _) => { debug!("visit_ty: TraitObject(bounds={:?}, lifetime={:?})", bounds, lifetime); for bound in bounds { self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None); @@ -2299,7 +2299,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { self.outer_index.shift_in(1); } match ty.kind { - hir::TyKind::TraitObject(bounds, ref lifetime) => { + hir::TyKind::TraitObject(bounds, ref lifetime, _) => { for bound in bounds { self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None); } diff --git a/compiler/rustc_trait_selection/src/infer.rs b/compiler/rustc_trait_selection/src/infer.rs index da66fbc8587d7..a9ffb5542b6df 100644 --- a/compiler/rustc_trait_selection/src/infer.rs +++ b/compiler/rustc_trait_selection/src/infer.rs @@ -124,7 +124,7 @@ impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> { DUMMY_SP, canonical_key, |ref infcx, key, canonical_inference_vars| { - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); let value = operation(infcx, &mut *fulfill_cx, key)?; infcx.make_canonicalized_query_response( canonical_inference_vars, diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs index 68356ce73aacd..4f5476ca5d0dc 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs @@ -62,7 +62,7 @@ fn scrape_region_constraints<'tcx, R>( infcx: &InferCtxt<'_, 'tcx>, op: impl FnOnce() -> Fallible>, ) -> Fallible<(R, Option>>)> { - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); let dummy_body_id = ObligationCause::dummy().body_id; // During NLL, we expect that nobody will register region diff --git a/compiler/rustc_traits/src/dropck_outlives.rs b/compiler/rustc_traits/src/dropck_outlives.rs index cfcbc77c172fd..9d5b9d7357fc4 100644 --- a/compiler/rustc_traits/src/dropck_outlives.rs +++ b/compiler/rustc_traits/src/dropck_outlives.rs @@ -75,7 +75,7 @@ fn dropck_outlives<'tcx>( // Set used to detect infinite recursion. let mut ty_set = FxHashSet::default(); - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); let cause = ObligationCause::dummy(); let mut constraints = DtorckConstraint::empty(); diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index a973b56f7d62c..7c5398003f3e6 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -1608,6 +1608,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // the whole path. // Will fail except for `T::A` and `Self::A`; i.e., if `qself_ty`/`qself_def` are not a type // parameter or `Self`. + // NOTE: When this function starts resolving `Trait::AssocTy` successfully + // it should also start reportint the `BARE_TRAIT_OBJECTS` lint. pub fn associated_path_to_ty( &self, hir_ref_id: hir::HirId, @@ -2201,7 +2203,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { Some(ast_ty), )) } - hir::TyKind::TraitObject(ref bounds, ref lifetime) => { + hir::TyKind::TraitObject(ref bounds, ref lifetime, _) => { self.conv_object_ty_poly_trait_ref(ast_ty.span, bounds, lifetime, borrowed) } hir::TyKind::Path(hir::QPath::Resolved(ref maybe_qself, ref path)) => { diff --git a/compiler/rustc_typeck/src/check/coercion.rs b/compiler/rustc_typeck/src/check/coercion.rs index 32b3d0b059545..94aee87364a69 100644 --- a/compiler/rustc_typeck/src/check/coercion.rs +++ b/compiler/rustc_typeck/src/check/coercion.rs @@ -1554,7 +1554,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { if let hir::FnRetTy::Return(ty) = fn_output { // Get the return type. if let hir::TyKind::OpaqueDef(..) = ty.kind { - let ty = AstConv::ast_ty_to_ty(fcx, ty); + let ty = >::ast_ty_to_ty(fcx, ty); // Get the `impl Trait`'s `DefId`. if let ty::Opaque(def_id, _) = ty.kind() { let hir_id = fcx.tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); @@ -1616,7 +1616,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { fn is_return_ty_unsized(&self, fcx: &FnCtxt<'a, 'tcx>, blk_id: hir::HirId) -> bool { if let Some((fn_decl, _)) = fcx.get_fn_decl(blk_id) { if let hir::FnRetTy::Return(ty) = fn_decl.output { - let ty = AstConv::ast_ty_to_ty(fcx, ty); + let ty = >::ast_ty_to_ty(fcx, ty); if let ty::Dynamic(..) = ty.kind() { return true; } diff --git a/compiler/rustc_typeck/src/check/dropck.rs b/compiler/rustc_typeck/src/check/dropck.rs index 4c3c4fd447058..4d74962d28ed3 100644 --- a/compiler/rustc_typeck/src/check/dropck.rs +++ b/compiler/rustc_typeck/src/check/dropck.rs @@ -77,7 +77,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>( tcx.infer_ctxt().enter(|ref infcx| { let impl_param_env = tcx.param_env(self_type_did); let tcx = infcx.tcx; - let mut fulfillment_cx = TraitEngine::new(tcx); + let mut fulfillment_cx = >::new(tcx); let named_type = tcx.type_of(self_type_did); diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index 84ce6964f042f..dc8a804bfea98 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -6,6 +6,7 @@ use crate::check::callee::{self, DeferredCallResolution}; use crate::check::method::{self, MethodCallee, SelfSource}; use crate::check::{BreakableCtxt, Diverges, Expectation, FallbackMode, FnCtxt, LocalTy}; +use rustc_ast::TraitObjectSyntax; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{Applicability, DiagnosticBuilder, ErrorReported}; @@ -13,7 +14,7 @@ use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::lang_items::LangItem; -use rustc_hir::{ExprKind, GenericArg, Node, QPath}; +use rustc_hir::{ExprKind, GenericArg, Node, QPath, TyKind}; use rustc_infer::infer::canonical::{Canonical, OriginalQueryValues, QueryResponse}; use rustc_infer::infer::error_reporting::TypeAnnotationNeeded::E0282; use rustc_infer::infer::{InferOk, InferResult}; @@ -26,7 +27,9 @@ use rustc_middle::ty::{ self, AdtKind, CanonicalUserType, DefIdTree, GenericParamDefKind, ToPolyTraitRef, ToPredicate, Ty, UserType, }; -use rustc_session::{lint, parse::feature_err}; +use rustc_session::lint; +use rustc_session::lint::builtin::BARE_TRAIT_OBJECTS; +use rustc_session::parse::feature_err; use rustc_span::source_map::{original_sp, DUMMY_SP}; use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::{self, BytePos, MultiSpan, Span}; @@ -472,7 +475,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } pub fn to_ty(&self, ast_t: &hir::Ty<'_>) -> Ty<'tcx> { - let t = AstConv::ast_ty_to_ty(self, ast_t); + let t = >::ast_ty_to_ty(self, ast_t); self.register_wf_obligation(t.into(), ast_t.span, traits::MiscObligation); t } @@ -854,7 +857,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // out unconstrained or ambiguous, as we're // just trying to get hints here. self.save_and_restore_in_snapshot_flag(|_| { - let mut fulfill = TraitEngine::new(self.tcx); + let mut fulfill = >::new(self.tcx); for obligation in ok.obligations { fulfill.register_predicate_obligation(self, obligation); } @@ -947,6 +950,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { result }); + if result.is_ok() { + self.maybe_lint_bare_trait(qpath, hir_id); + } + // Write back the new resolution. self.write_resolution(hir_id, result); ( @@ -956,6 +963,29 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) } + fn maybe_lint_bare_trait(&self, qpath: &QPath<'_>, hir_id: hir::HirId) { + if let QPath::TypeRelative(self_ty, _) = qpath { + if let TyKind::TraitObject([poly_trait_ref, ..], _, TraitObjectSyntax::None) = + self_ty.kind + { + self.tcx.struct_span_lint_hir(BARE_TRAIT_OBJECTS, hir_id, self_ty.span, |lint| { + let mut db = lint + .build(&format!("trait objects without an explicit `dyn` are deprecated")); + let (sugg, app) = match self.tcx.sess.source_map().span_to_snippet(self_ty.span) + { + Ok(s) if poly_trait_ref.trait_ref.path.is_global() => { + (format!("", s), Applicability::MachineApplicable) + } + Ok(s) => (format!("", s), Applicability::MachineApplicable), + Err(_) => (">".to_string(), Applicability::HasPlaceholders), + }; + db.span_suggestion(self_ty.span, "use `dyn`", sugg, app); + db.emit() + }); + } + } + } + /// Given a function `Node`, return its `FnDecl` if it exists, or `None` otherwise. pub(in super::super) fn get_node_fn_decl( &self, @@ -1174,9 +1204,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let path_segs = match res { Res::Local(_) | Res::SelfCtor(_) => vec![], - Res::Def(kind, def_id) => { - AstConv::def_ids_for_value_path_segments(self, segments, self_ty, kind, def_id) - } + Res::Def(kind, def_id) => >::def_ids_for_value_path_segments( + self, segments, self_ty, kind, def_id, + ), _ => bug!("instantiate_value_path on {:?}", res), }; @@ -1219,7 +1249,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // errors if type parameters are provided in an inappropriate place. let generic_segs: FxHashSet<_> = path_segs.iter().map(|PathSeg(_, index)| index).collect(); - let generics_has_err = AstConv::prohibit_generics( + let generics_has_err = >::prohibit_generics( self, segments.iter().enumerate().filter_map(|(index, seg)| { if !generic_segs.contains(&index) || is_alias_variant_ctor { @@ -1262,7 +1292,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let GenericArgCountResult { correct: Err(GenericArgCountMismatch { reported: Some(_), .. }), .. - } = AstConv::check_generic_arg_count_for_call( + } = >::check_generic_arg_count_for_call( tcx, span, def_id, @@ -1370,7 +1400,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> subst::GenericArg<'tcx> { match (¶m.kind, arg) { (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => { - AstConv::ast_region_to_region(self.fcx, lt, Some(param)).into() + >::ast_region_to_region(self.fcx, lt, Some(param)).into() } (GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => { self.fcx.to_ty(ty).into() @@ -1423,7 +1453,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let substs = self_ctor_substs.unwrap_or_else(|| { - AstConv::create_substs_for_generic_args( + >::create_substs_for_generic_args( tcx, def_id, &[][..], diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 528a6d1bd52e2..c92c7f7ad0b9a 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -875,7 +875,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match *qpath { QPath::Resolved(ref maybe_qself, ref path) => { let self_ty = maybe_qself.as_ref().map(|qself| self.to_ty(qself)); - let ty = AstConv::res_to_ty(self, self_ty, path, true); + let ty = >::res_to_ty(self, self_ty, path, true); (path.res, ty) } QPath::TypeRelative(ref qself, ref segment) => { @@ -886,8 +886,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { Res::Err }; - let result = - AstConv::associated_path_to_ty(self, hir_id, path_span, ty, res, segment, true); + let result = >::associated_path_to_ty( + self, hir_id, path_span, ty, res, segment, true, + ); let ty = result.map(|(ty, _, _)| ty).unwrap_or_else(|_| self.tcx().ty_error()); let result = result.map(|(_, kind, def_id)| (kind, def_id)); @@ -1000,7 +1001,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // would trigger in `is_send::();` // from `typeck-default-trait-impl-assoc-type.rs`. } else { - let ty = AstConv::ast_ty_to_ty(self, hir_ty); + let ty = >::ast_ty_to_ty(self, hir_ty); let ty = self.resolve_vars_if_possible(ty); if ty == predicate.self_ty() { error.obligation.cause.make_mut().span = hir_ty.span; diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs index 9f15993e4718c..f90159efb5cd5 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs @@ -461,7 +461,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // are not, the expectation must have been caused by something else. debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.kind); let sp = ty.span; - let ty = AstConv::ast_ty_to_ty(self, ty); + let ty = >::ast_ty_to_ty(self, ty); debug!("suggest_missing_return_type: return type {:?}", ty); debug!("suggest_missing_return_type: expected type {:?}", ty); if ty.kind() == expected.kind() { @@ -486,7 +486,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let found = self.resolve_vars_with_obligations(found); if let hir::FnRetTy::Return(ty) = fn_decl.output { - let ty = AstConv::ast_ty_to_ty(self, ty); + let ty = >::ast_ty_to_ty(self, ty); let ty = self.tcx.erase_late_bound_regions(Binder::bind(ty)); let ty = self.normalize_associated_types_in(expr.span, ty); if self.can_coerce(found, ty) { diff --git a/compiler/rustc_typeck/src/check/inherited.rs b/compiler/rustc_typeck/src/check/inherited.rs index 0011a3fc71b59..1dacbade1bd32 100644 --- a/compiler/rustc_typeck/src/check/inherited.rs +++ b/compiler/rustc_typeck/src/check/inherited.rs @@ -117,7 +117,7 @@ impl Inherited<'a, 'tcx> { maybe_typeck_results: infcx.in_progress_typeck_results, }, infcx, - fulfillment_cx: RefCell::new(TraitEngine::new(tcx)), + fulfillment_cx: RefCell::new(>::new(tcx)), locals: RefCell::new(Default::default()), deferred_sized_obligations: RefCell::new(Vec::new()), deferred_call_resolutions: RefCell::new(Default::default()), diff --git a/compiler/rustc_typeck/src/check/method/confirm.rs b/compiler/rustc_typeck/src/check/method/confirm.rs index 7a80524f1b79a..4a2dd6faf0c32 100644 --- a/compiler/rustc_typeck/src/check/method/confirm.rs +++ b/compiler/rustc_typeck/src/check/method/confirm.rs @@ -314,7 +314,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { // variables. let generics = self.tcx.generics_of(pick.item.def_id); - let arg_count_correct = AstConv::check_generic_arg_count_for_call( + let arg_count_correct = >::check_generic_arg_count_for_call( self.tcx, self.span, pick.item.def_id, @@ -352,7 +352,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { ) -> subst::GenericArg<'tcx> { match (¶m.kind, arg) { (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => { - AstConv::ast_region_to_region(self.cfcx.fcx, lt, Some(param)).into() + >::ast_region_to_region(self.cfcx.fcx, lt, Some(param)) + .into() } (GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => { self.cfcx.to_ty(ty).into() @@ -373,7 +374,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { self.cfcx.var_for_def(self.cfcx.span, param) } } - AstConv::create_substs_for_generic_args( + >::create_substs_for_generic_args( self.tcx, pick.item.def_id, parent_substs, diff --git a/compiler/rustc_typeck/src/check/mod.rs b/compiler/rustc_typeck/src/check/mod.rs index 85bd45f0ca80d..ad9bb70377968 100644 --- a/compiler/rustc_typeck/src/check/mod.rs +++ b/compiler/rustc_typeck/src/check/mod.rs @@ -495,7 +495,7 @@ fn typeck_with_fallback<'tcx>( let fcx = if let (Some(header), Some(decl)) = (fn_header, fn_decl) { let fn_sig = if crate::collect::get_infer_ret_ty(&decl.output).is_some() { let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id); - AstConv::ty_of_fn( + >::ty_of_fn( &fcx, header.unsafety, header.abi, @@ -527,7 +527,7 @@ fn typeck_with_fallback<'tcx>( let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id); let expected_type = body_ty .and_then(|ty| match ty.kind { - hir::TyKind::Infer => Some(AstConv::ast_ty_to_ty(&fcx, ty)), + hir::TyKind::Infer => Some(>::ast_ty_to_ty(&fcx, ty)), _ => None, }) .unwrap_or_else(|| match tcx.hir().get(id) { diff --git a/compiler/rustc_typeck/src/coherence/builtin.rs b/compiler/rustc_typeck/src/coherence/builtin.rs index 5b44cb7eae516..8cae61e8c22f6 100644 --- a/compiler/rustc_typeck/src/coherence/builtin.rs +++ b/compiler/rustc_typeck/src/coherence/builtin.rs @@ -246,7 +246,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef )) .emit(); } else { - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); for field in coerced_fields { let predicate = predicate_for_trait_def( @@ -506,7 +506,7 @@ pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedI } }; - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); // Register an obligation for `A: Trait`. let cause = traits::ObligationCause::misc(span, impl_hir_id); diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index a175da3270638..e5136355ca982 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -310,7 +310,7 @@ impl ItemCtxt<'tcx> { } pub fn to_ty(&self, ast_ty: &hir::Ty<'_>) -> Ty<'tcx> { - AstConv::ast_ty_to_ty(self, ast_ty) + >::ast_ty_to_ty(self, ast_ty) } pub fn hir_id(&self) -> hir::HirId { @@ -1096,7 +1096,7 @@ fn super_predicates_that_define_assoc_type( // Convert the bounds that follow the colon, e.g., `Bar + Zed` in `trait Foo: Bar + Zed`. let self_param_ty = tcx.types.self_param; let superbounds1 = if let Some(assoc_name) = assoc_name { - AstConv::compute_bounds_that_match_assoc_type( + >::compute_bounds_that_match_assoc_type( &icx, self_param_ty, &bounds, @@ -1105,7 +1105,13 @@ fn super_predicates_that_define_assoc_type( assoc_name, ) } else { - AstConv::compute_bounds(&icx, self_param_ty, &bounds, SizedByDefault::No, item.span) + >::compute_bounds( + &icx, + self_param_ty, + &bounds, + SizedByDefault::No, + item.span, + ) }; let superbounds1 = superbounds1.predicates(tcx, self_param_ty); @@ -1689,7 +1695,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { ty::Binder::bind(fn_sig) } - None => AstConv::ty_of_fn( + None => >::ty_of_fn( &icx, sig.header.unsafety, sig.header.abi, @@ -1706,7 +1712,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { ident, generics, .. - }) => AstConv::ty_of_fn( + }) => >::ty_of_fn( &icx, header.unsafety, header.abi, @@ -1767,7 +1773,7 @@ fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option> { match tcx.hir().expect_item(hir_id).kind { hir::ItemKind::Impl(ref impl_) => impl_.of_trait.as_ref().map(|ast_trait_ref| { let selfty = tcx.type_of(def_id); - AstConv::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty) + >::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty) }), _ => bug!(), } @@ -2018,7 +2024,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP GenericParamKind::Lifetime { .. } => { param.bounds.iter().for_each(|bound| match bound { hir::GenericBound::Outlives(lt) => { - let bound = AstConv::ast_region_to_region(&icx, <, None); + let bound = >::ast_region_to_region(&icx, <, None); let outlives = ty::Binder::bind(ty::OutlivesPredicate(region, bound)); predicates.insert((outlives.to_predicate(tcx), lt.span)); } @@ -2041,8 +2047,13 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP index += 1; let sized = SizedByDefault::Yes; - let bounds = - AstConv::compute_bounds(&icx, param_ty, ¶m.bounds, sized, param.span); + let bounds = >::compute_bounds( + &icx, + param_ty, + ¶m.bounds, + sized, + param.span, + ); predicates.extend(bounds.predicates(tcx, param_ty)); } GenericParamKind::Const { .. } => { @@ -2091,7 +2102,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP }; let mut bounds = Bounds::default(); - let _ = AstConv::instantiate_poly_trait_ref( + let _ = >::instantiate_poly_trait_ref( &icx, &poly_trait_ref, constness, @@ -2103,7 +2114,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP &hir::GenericBound::LangItemTrait(lang_item, span, hir_id, args) => { let mut bounds = Bounds::default(); - AstConv::instantiate_lang_item_trait_ref( + >::instantiate_lang_item_trait_ref( &icx, lang_item, span, @@ -2116,7 +2127,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP } hir::GenericBound::Outlives(lifetime) => { - let region = AstConv::ast_region_to_region(&icx, lifetime, None); + let region = + >::ast_region_to_region(&icx, lifetime, None); predicates.insert(( ty::Binder::bind(ty::PredicateKind::TypeOutlives( ty::OutlivesPredicate(ty, region), @@ -2130,11 +2142,11 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP } hir::WherePredicate::RegionPredicate(region_pred) => { - let r1 = AstConv::ast_region_to_region(&icx, ®ion_pred.lifetime, None); + let r1 = >::ast_region_to_region(&icx, ®ion_pred.lifetime, None); predicates.extend(region_pred.bounds.iter().map(|bound| { let (r2, span) = match bound { hir::GenericBound::Outlives(lt) => { - (AstConv::ast_region_to_region(&icx, lt, None), lt.span) + (>::ast_region_to_region(&icx, lt, None), lt.span) } _ => bug!(), }; @@ -2377,7 +2389,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( } else { hir::Unsafety::Unsafe }; - let fty = AstConv::ty_of_fn( + let fty = >::ty_of_fn( &ItemCtxt::new(tcx, def_id), unsafety, abi, diff --git a/compiler/rustc_typeck/src/collect/item_bounds.rs b/compiler/rustc_typeck/src/collect/item_bounds.rs index fe18dc5ed0c69..a5b36445aae2e 100644 --- a/compiler/rustc_typeck/src/collect/item_bounds.rs +++ b/compiler/rustc_typeck/src/collect/item_bounds.rs @@ -25,7 +25,7 @@ fn associated_type_bounds<'tcx>( InternalSubsts::identity_for_item(tcx, assoc_item_def_id), ); - let bounds = AstConv::compute_bounds( + let bounds = >::compute_bounds( &ItemCtxt::new(tcx, assoc_item_def_id), item_ty, &bounds, @@ -66,7 +66,7 @@ fn opaque_type_bounds<'tcx>( let item_ty = tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id)); - let bounds = AstConv::compute_bounds( + let bounds = >::compute_bounds( &ItemCtxt::new(tcx, opaque_def_id), item_ty, &bounds, diff --git a/compiler/rustc_typeck/src/lib.rs b/compiler/rustc_typeck/src/lib.rs index 29d9df61906c7..88b47bf5b9cdd 100644 --- a/compiler/rustc_typeck/src/lib.rs +++ b/compiler/rustc_typeck/src/lib.rs @@ -142,7 +142,7 @@ fn require_same_types<'tcx>( ) -> bool { tcx.infer_ctxt().enter(|ref infcx| { let param_env = ty::ParamEnv::empty(); - let mut fulfill_cx = TraitEngine::new(infcx.tcx); + let mut fulfill_cx = >::new(infcx.tcx); match infcx.at(&cause, param_env).eq(expected, actual) { Ok(InferOk { obligations, .. }) => { fulfill_cx.register_predicate_obligations(infcx, obligations); @@ -444,7 +444,7 @@ pub fn hir_trait_to_predicates<'tcx>( let env_def_id = tcx.hir().local_def_id(env_hir_id); let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id.to_def_id()); let mut bounds = Bounds::default(); - let _ = AstConv::instantiate_poly_trait_ref_inner( + let _ = >::instantiate_poly_trait_ref_inner( &item_cx, hir_trait, DUMMY_SP, diff --git a/library/core/src/any.rs b/library/core/src/any.rs index eef8f2046d33e..98c34f344251e 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -285,7 +285,7 @@ impl dyn Any + Send { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn is(&self) -> bool { - Any::is::(self) + ::is::(self) } /// Forwards to the method defined on the type `Any`. @@ -309,7 +309,7 @@ impl dyn Any + Send { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn downcast_ref(&self) -> Option<&T> { - Any::downcast_ref::(self) + ::downcast_ref::(self) } /// Forwards to the method defined on the type `Any`. @@ -337,7 +337,7 @@ impl dyn Any + Send { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn downcast_mut(&mut self) -> Option<&mut T> { - Any::downcast_mut::(self) + ::downcast_mut::(self) } } @@ -363,7 +363,7 @@ impl dyn Any + Send + Sync { #[stable(feature = "any_send_sync_methods", since = "1.28.0")] #[inline] pub fn is(&self) -> bool { - Any::is::(self) + ::is::(self) } /// Forwards to the method defined on the type `Any`. @@ -387,7 +387,7 @@ impl dyn Any + Send + Sync { #[stable(feature = "any_send_sync_methods", since = "1.28.0")] #[inline] pub fn downcast_ref(&self) -> Option<&T> { - Any::downcast_ref::(self) + ::downcast_ref::(self) } /// Forwards to the method defined on the type `Any`. @@ -415,7 +415,7 @@ impl dyn Any + Send + Sync { #[stable(feature = "any_send_sync_methods", since = "1.28.0")] #[inline] pub fn downcast_mut(&mut self) -> Option<&mut T> { - Any::downcast_mut::(self) + ::downcast_mut::(self) } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ead9d7d664635..17a961a5f6655 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1477,7 +1477,7 @@ impl Clean for hir::Ty<'_> { } } TyKind::Path(_) => clean_qpath(&self, cx), - TyKind::TraitObject(ref bounds, ref lifetime) => { + TyKind::TraitObject(ref bounds, ref lifetime, _) => { match bounds[0].clean(cx).trait_ { ResolvedPath { path, param_names: None, did, is_generic } => { let mut bounds: Vec = bounds[1..] diff --git a/src/test/ui/lint/bare-trait-objects-path.rs b/src/test/ui/lint/bare-trait-objects-path.rs new file mode 100644 index 0000000000000..4c961e998df64 --- /dev/null +++ b/src/test/ui/lint/bare-trait-objects-path.rs @@ -0,0 +1,18 @@ +#![feature(associated_type_defaults)] + +trait Assoc { + fn func() {} + const CONST: u8 = 0; + type Ty = u8; +} + +trait Dyn {} + +impl Assoc for dyn Dyn {} + +fn main() { + Dyn::func(); //~ WARN trait objects without an explicit `dyn` are deprecated + ::Dyn::func(); //~ WARN trait objects without an explicit `dyn` are deprecated + Dyn::CONST; //~ WARN trait objects without an explicit `dyn` are deprecated + let _: Dyn::Ty; //~ ERROR ambiguous associated type +} diff --git a/src/test/ui/lint/bare-trait-objects-path.stderr b/src/test/ui/lint/bare-trait-objects-path.stderr new file mode 100644 index 0000000000000..0a2dc5858285a --- /dev/null +++ b/src/test/ui/lint/bare-trait-objects-path.stderr @@ -0,0 +1,29 @@ +error[E0223]: ambiguous associated type + --> $DIR/bare-trait-objects-path.rs:17:12 + | +LL | let _: Dyn::Ty; + | ^^^^^^^ help: use fully-qualified syntax: `::Ty` + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/bare-trait-objects-path.rs:14:5 + | +LL | Dyn::func(); + | ^^^ help: use `dyn`: `` + | + = note: `#[warn(bare_trait_objects)]` on by default + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/bare-trait-objects-path.rs:15:5 + | +LL | ::Dyn::func(); + | ^^^^^ help: use `dyn`: `` + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/bare-trait-objects-path.rs:16:5 + | +LL | Dyn::CONST; + | ^^^ help: use `dyn`: `` + +error: aborting due to previous error; 3 warnings emitted + +For more information about this error, try `rustc --explain E0223`. diff --git a/src/test/ui/traits/impl.rs b/src/test/ui/traits/impl.rs index 14796ce19c88e..f512d91ebeb4a 100644 --- a/src/test/ui/traits/impl.rs +++ b/src/test/ui/traits/impl.rs @@ -30,8 +30,8 @@ fn main() { let x: &dyn T = &42; x.foo(); - T::foo(x); - T::bar(); + ::foo(x); + ::bar(); unsafe { assert_eq!(COUNT, 12); } diff --git a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.rs b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.rs index 6aaef8a305bce..727897d20cb4c 100644 --- a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.rs +++ b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.rs @@ -31,7 +31,7 @@ fn with_trait(c: &C) -> bool { } fn with_ufcs1(c: &C) -> bool { - CompareToInts::same_as(c, 22) //~ ERROR `dyn CompareToInts: CompareTo` is not satisfied + ::same_as(c, 22) //~ ERROR `dyn CompareToInts: CompareTo` is not satisfi } fn with_ufcs2(c: &C) -> bool { diff --git a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr index 5353b5e2260d4..bb11f18e54505 100644 --- a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr +++ b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr @@ -21,8 +21,8 @@ error[E0277]: the trait bound `dyn CompareToInts: CompareTo` is not satisfi LL | fn same_as(&self, t: T) -> bool; | -------------------------------- required by `CompareTo::same_as` ... -LL | CompareToInts::same_as(c, 22) - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` +LL | ::same_as(c, 22) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` error[E0277]: the trait bound `C: CompareTo` is not satisfied --> $DIR/repeated-supertrait-ambig.rs:38:5 diff --git a/src/test/ui/traits/inheritance/repeated-supertrait.rs b/src/test/ui/traits/inheritance/repeated-supertrait.rs index 339f9c37eeae8..cb2581ffa99a5 100644 --- a/src/test/ui/traits/inheritance/repeated-supertrait.rs +++ b/src/test/ui/traits/inheritance/repeated-supertrait.rs @@ -31,7 +31,7 @@ fn with_trait(c: &C) -> bool { } fn with_ufcs1(c: &C) -> bool { - CompareToInts::same_as(c, 22_i64) && CompareToInts::same_as(c, 22_u64) + ::same_as(c, 22_i64) && ::same_as(c, 22_u64) } fn with_ufcs2(c: &C) -> bool { diff --git a/src/test/ui/traits/item-privacy.rs b/src/test/ui/traits/item-privacy.rs index 1ea1d65df627c..38d06b967bc79 100644 --- a/src/test/ui/traits/item-privacy.rs +++ b/src/test/ui/traits/item-privacy.rs @@ -81,8 +81,8 @@ fn check_method() { //~^ ERROR no function or associated item named `b` found S::c(&S); // OK // a, b, c are resolved as inherent items, their traits don't need to be in scope - C::a(&S); //~ ERROR associated function `a` is private - C::b(&S); // OK + ::a(&S); //~ ERROR associated function `a` is private + ::b(&S); // OK C::c(&S); // OK } @@ -98,9 +98,9 @@ fn check_assoc_const() { S::B; //~ ERROR no associated item named `B` found S::C; // OK // A, B, C are resolved as inherent items, their traits don't need to be in scope - C::A; //~ ERROR associated constant `A` is private - //~^ ERROR the trait `assoc_const::C` cannot be made into an object - C::B; // ERROR the trait `assoc_const::C` cannot be made into an object + ::A; //~ ERROR associated constant `A` is private + //~^ ERROR the trait `assoc_const::C` cannot be made into an object + ::B; // ERROR the trait `assoc_const::C` cannot be made into an object C::C; // OK } diff --git a/src/test/ui/traits/item-privacy.stderr b/src/test/ui/traits/item-privacy.stderr index b7dad54a6d3a9..68d527dc786aa 100644 --- a/src/test/ui/traits/item-privacy.stderr +++ b/src/test/ui/traits/item-privacy.stderr @@ -67,10 +67,10 @@ LL | use method::B; | error[E0624]: associated function `a` is private - --> $DIR/item-privacy.rs:84:8 + --> $DIR/item-privacy.rs:84:14 | -LL | C::a(&S); - | ^ private associated function +LL | ::a(&S); + | ^ private associated function error[E0599]: no associated item named `A` found for struct `S` in the current scope --> $DIR/item-privacy.rs:97:8 @@ -104,16 +104,16 @@ LL | use assoc_const::B; | error[E0624]: associated constant `A` is private - --> $DIR/item-privacy.rs:101:8 + --> $DIR/item-privacy.rs:101:14 | -LL | C::A; - | ^ private associated constant +LL | ::A; + | ^ private associated constant error[E0038]: the trait `assoc_const::C` cannot be made into an object - --> $DIR/item-privacy.rs:101:5 + --> $DIR/item-privacy.rs:101:6 | -LL | C::A; - | ^ `assoc_const::C` cannot be made into an object +LL | ::A; + | ^^^^^ `assoc_const::C` cannot be made into an object | = help: consider moving `C` to another trait = help: consider moving `B` to another trait diff --git a/src/tools/clippy/clippy_lints/src/lifetimes.rs b/src/tools/clippy/clippy_lints/src/lifetimes.rs index 33ff01a30e881..3ac6e6cbbefcf 100644 --- a/src/tools/clippy/clippy_lints/src/lifetimes.rs +++ b/src/tools/clippy/clippy_lints/src/lifetimes.rs @@ -387,7 +387,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> { self.nested_elision_site_lts.append(&mut sub_visitor.all_lts()); return; }, - TyKind::TraitObject(bounds, ref lt) => { + TyKind::TraitObject(bounds, ref lt, _) => { if !lt.is_elided() { self.unelided_trait_object_lifetime = true; } diff --git a/src/tools/clippy/clippy_lints/src/types/borrowed_box.rs b/src/tools/clippy/clippy_lints/src/types/borrowed_box.rs index a7a511b21cf59..81090040d92e0 100644 --- a/src/tools/clippy/clippy_lints/src/types/borrowed_box.rs +++ b/src/tools/clippy/clippy_lints/src/types/borrowed_box.rs @@ -50,7 +50,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, m // Originally reported as the issue #3128. let inner_snippet = snippet(cx, inner.span, ".."); let suggestion = match &inner.kind { - TyKind::TraitObject(bounds, lt_bound) if bounds.len() > 1 || !lt_bound.is_elided() => { + TyKind::TraitObject(bounds, lt_bound, _) if bounds.len() > 1 || !lt_bound.is_elided() => { format!("&{}({})", ltopt, &inner_snippet) }, TyKind::Path(qpath) @@ -86,7 +86,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, m // Returns true if given type is `Any` trait. fn is_any_trait(t: &hir::Ty<'_>) -> bool { if_chain! { - if let TyKind::TraitObject(ref traits, _) = t.kind; + if let TyKind::TraitObject(ref traits, ..) = t.kind; if !traits.is_empty(); // Only Send/Sync can be used as additional traits, so it is enough to // check only the first trait. diff --git a/src/tools/clippy/clippy_lints/src/types/mod.rs b/src/tools/clippy/clippy_lints/src/types/mod.rs index f7a6399a7f048..4a1a608e8ae62 100644 --- a/src/tools/clippy/clippy_lints/src/types/mod.rs +++ b/src/tools/clippy/clippy_lints/src/types/mod.rs @@ -911,7 +911,7 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor { // function types bring a lot of overhead TyKind::BareFn(ref bare) if bare.abi == Abi::Rust => (50 * self.nest, 1), - TyKind::TraitObject(ref param_bounds, _) => { + TyKind::TraitObject(ref param_bounds, ..) => { let has_lifetime_parameters = param_bounds.iter().any(|bound| { bound .bound_generic_params diff --git a/src/tools/clippy/clippy_utils/src/hir_utils.rs b/src/tools/clippy/clippy_utils/src/hir_utils.rs index af82f992d56f6..7f7d9c5f56a1e 100644 --- a/src/tools/clippy/clippy_utils/src/hir_utils.rs +++ b/src/tools/clippy/clippy_utils/src/hir_utils.rs @@ -892,7 +892,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { TyKind::OpaqueDef(_, arg_list) => { self.hash_generic_args(arg_list); }, - TyKind::TraitObject(_, lifetime) => { + TyKind::TraitObject(_, lifetime, _) => { self.hash_lifetime(lifetime); }, TyKind::Typeof(anon_const) => {