From 4e49e67c446538aa2000ed768308054f61c308e7 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sun, 10 May 2020 11:57:58 +0100 Subject: [PATCH] Stop special casing top level TAIT --- src/librustc_ast/ast.rs | 9 - src/librustc_ast_lowering/item.rs | 56 ++--- src/librustc_ast_lowering/lib.rs | 9 +- src/librustc_lint/builtin.rs | 4 + src/librustc_middle/hir/map/mod.rs | 8 +- src/librustc_passes/layout_test.rs | 7 +- src/librustc_resolve/build_reduced_graph.rs | 11 +- src/librustc_resolve/late/lifetimes.rs | 29 +-- src/librustc_trait_selection/opaque_types.rs | 69 +++--- src/librustc_typeck/astconv.rs | 22 +- src/librustc_typeck/check/writeback.rs | 2 +- src/librustc_typeck/collect.rs | 17 +- .../ui/associated-type-bounds/duplicate.rs | 6 - .../associated-type-bounds/duplicate.stderr | 200 +++++++----------- .../feature-gate-type_alias_impl_trait.rs | 24 ++- .../feature-gate-type_alias_impl_trait.stderr | 70 ++---- src/test/ui/impl-trait/auto-trait.rs | 14 +- src/test/ui/impl-trait/auto-trait.stderr | 8 +- src/test/ui/impl-trait/issue-55872-1.stderr | 8 +- src/test/ui/impl-trait/issue-55872-2.stderr | 4 +- src/test/ui/impl-trait/negative-reasoning.rs | 15 +- .../ui/impl-trait/negative-reasoning.stderr | 10 +- src/test/ui/impl-trait/where-allowed.stderr | 16 +- src/test/ui/issues/issue-60662.stdout | 2 +- .../inline-trait-and-foreign-items.stderr | 4 +- src/test/ui/lint/opaque-ty-ffi-unsafe.rs | 3 +- src/test/ui/lint/opaque-ty-ffi-unsafe.stderr | 6 +- .../ui/privacy/private-in-public-assoc-ty.rs | 9 +- .../privacy/private-in-public-assoc-ty.stderr | 25 +-- src/test/ui/save-analysis/issue-68621.stderr | 4 +- .../bound_reduction2.stderr | 4 +- .../declared_but_never_defined.stderr | 4 +- .../declared_but_not_defined_in_scope.stderr | 4 +- ...eric_type_does_not_live_long_enough.stderr | 8 +- .../generic_underconstrained.stderr | 4 +- .../generic_underconstrained2.stderr | 8 +- .../issue-57611-trait-alias.stderr | 8 +- .../type-alias-impl-trait/issue-60371.stderr | 8 +- .../type-alias-impl-trait/issue-63279.stderr | 6 +- .../never_reveal_concrete_type.stderr | 6 +- .../no_inferrable_concrete_type.stderr | 4 +- ...o_revealing_outside_defining_module.stderr | 10 +- ...e-alias-impl-trait-with-cycle-error.stderr | 4 +- ...-alias-impl-trait-with-cycle-error2.stderr | 4 +- 44 files changed, 326 insertions(+), 427 deletions(-) diff --git a/src/librustc_ast/ast.rs b/src/librustc_ast/ast.rs index 672ef108969e..489e01e805c2 100644 --- a/src/librustc_ast/ast.rs +++ b/src/librustc_ast/ast.rs @@ -1858,15 +1858,6 @@ impl TyKind { pub fn is_unit(&self) -> bool { if let TyKind::Tup(ref tys) = *self { tys.is_empty() } else { false } } - - /// HACK(type_alias_impl_trait, Centril): A temporary crutch used - /// in lowering to avoid making larger changes there and beyond. - pub fn opaque_top_hack(&self) -> Option<&GenericBounds> { - match self { - Self::ImplTrait(_, bounds) => Some(bounds), - _ => None, - } - } } /// Syntax used to declare a trait object. diff --git a/src/librustc_ast_lowering/item.rs b/src/librustc_ast_lowering/item.rs index 47d10f86d03e..f8a5120b72a1 100644 --- a/src/librustc_ast_lowering/item.rs +++ b/src/librustc_ast_lowering/item.rs @@ -1,5 +1,5 @@ use super::{AnonymousLifetimeMode, LoweringContext, ParamMode}; -use super::{ImplTraitContext, ImplTraitPosition, ImplTraitTypeIdVisitor}; +use super::{ImplTraitContext, ImplTraitPosition}; use crate::Arena; use rustc_ast::ast::*; @@ -165,13 +165,6 @@ impl<'hir> LoweringContext<'_, 'hir> { } ItemKind::MacroDef(..) => SmallVec::new(), ItemKind::Fn(..) | ItemKind::Impl { of_trait: None, .. } => smallvec![i.id], - ItemKind::Static(ref ty, ..) | ItemKind::Const(_, ref ty, ..) => { - let mut ids = smallvec![i.id]; - if self.sess.features_untracked().impl_trait_in_bindings { - ImplTraitTypeIdVisitor { ids: &mut ids }.visit_ty(ty); - } - ids - } _ => smallvec![i.id], }; @@ -292,23 +285,12 @@ impl<'hir> LoweringContext<'_, 'hir> { ItemKind::Mod(ref m) => hir::ItemKind::Mod(self.lower_mod(m)), ItemKind::ForeignMod(ref nm) => hir::ItemKind::ForeignMod(self.lower_foreign_mod(nm)), ItemKind::GlobalAsm(ref ga) => hir::ItemKind::GlobalAsm(self.lower_global_asm(ga)), - ItemKind::TyAlias(_, ref gen, _, Some(ref ty)) => match ty.kind.opaque_top_hack() { - None => { - let ty = self.lower_ty(ty, ImplTraitContext::disallowed()); - let generics = self.lower_generics(gen, ImplTraitContext::disallowed()); - hir::ItemKind::TyAlias(ty, generics) - } - Some(bounds) => { - let ctx = || ImplTraitContext::OpaqueTy(None, hir::OpaqueTyOrigin::Misc); - let ty = hir::OpaqueTy { - generics: self.lower_generics(gen, ctx()), - bounds: self.lower_param_bounds(bounds, ctx()), - impl_trait_fn: None, - origin: hir::OpaqueTyOrigin::TypeAlias, - }; - hir::ItemKind::OpaqueTy(ty) - } - }, + ItemKind::TyAlias(_, ref gen, _, Some(ref ty)) => { + let ty = + self.lower_ty(ty, ImplTraitContext::OpaqueTy(None, hir::OpaqueTyOrigin::Misc)); + let generics = self.lower_generics(gen, ImplTraitContext::disallowed()); + hir::ItemKind::TyAlias(ty, generics) + } ItemKind::TyAlias(_, ref generics, _, None) => { let ty = self.arena.alloc(self.ty(span, hir::TyKind::Err)); let generics = self.lower_generics(generics, ImplTraitContext::disallowed()); @@ -844,16 +826,13 @@ impl<'hir> LoweringContext<'_, 'hir> { let ty = self.arena.alloc(self.ty(i.span, hir::TyKind::Err)); hir::ImplItemKind::TyAlias(ty) } - Some(ty) => match ty.kind.opaque_top_hack() { - None => { - let ty = self.lower_ty(ty, ImplTraitContext::disallowed()); - hir::ImplItemKind::TyAlias(ty) - } - Some(bs) => { - let bs = self.lower_param_bounds(bs, ImplTraitContext::disallowed()); - hir::ImplItemKind::OpaqueTy(bs) - } - }, + Some(ty) => { + let ty = self.lower_ty( + ty, + ImplTraitContext::OpaqueTy(None, hir::OpaqueTyOrigin::Misc), + ); + hir::ImplItemKind::TyAlias(ty) + } }; (generics, kind) } @@ -887,12 +866,7 @@ impl<'hir> LoweringContext<'_, 'hir> { defaultness, kind: match &i.kind { AssocItemKind::Const(..) => hir::AssocItemKind::Const, - AssocItemKind::TyAlias(.., ty) => { - match ty.as_deref().and_then(|ty| ty.kind.opaque_top_hack()) { - None => hir::AssocItemKind::Type, - Some(_) => hir::AssocItemKind::OpaqueTy, - } - } + AssocItemKind::TyAlias(..) => hir::AssocItemKind::Type, AssocItemKind::Fn(_, sig, ..) => { hir::AssocItemKind::Fn { has_self: sig.decl.has_self() } } diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index 1f8c68f75e94..0154e10112b4 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -1371,8 +1371,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let hir_bounds = self.with_hir_id_owner(opaque_ty_node_id, lower_bounds); - let (lifetimes, lifetime_defs) = - self.lifetimes_from_impl_trait_bounds(opaque_ty_node_id, opaque_ty_def_id, &hir_bounds); + let (lifetimes, lifetime_defs): (&[_], &[_]) = if fn_def_id.is_some() { + self.lifetimes_from_impl_trait_bounds(opaque_ty_node_id, opaque_ty_def_id, &hir_bounds) + } else { + // Non return-position impl trait captures all of the lifetimes of + // the parent item. + (&[], &[]) + }; debug!("lower_opaque_impl_trait: lifetimes={:#?}", lifetimes,); diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index e17e8b7b9640..e9f5956a4169 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1102,6 +1102,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds { hir::ItemKind::TyAlias(ref ty, ref generics) => (&*ty, generics), _ => return, }; + if let hir::TyKind::Def(..) = ty.kind { + // Bounds are respected for `type X = impl Trait` + return; + } let mut suggested_changing_assoc_types = false; // There must not be a where clause if !type_alias_generics.where_clause.predicates.is_empty() { diff --git a/src/librustc_middle/hir/map/mod.rs b/src/librustc_middle/hir/map/mod.rs index b1dafb3c8858..e8e92646bf46 100644 --- a/src/librustc_middle/hir/map/mod.rs +++ b/src/librustc_middle/hir/map/mod.rs @@ -672,6 +672,8 @@ impl<'hir> Map<'hir> { if let Node::Item(Item { kind: ItemKind::Fn(..) + | ItemKind::Const(..) + | ItemKind::Static(..) | ItemKind::Mod(..) | ItemKind::Enum(..) | ItemKind::Struct(..) @@ -700,11 +702,7 @@ impl<'hir> Map<'hir> { return CRATE_HIR_ID; } match self.get(scope) { - Node::Item(Item { - kind: ItemKind::OpaqueTy(OpaqueTy { impl_trait_fn: None, .. }), - .. - }) - | Node::Block(_) => {} + Node::Block(_) => {} _ => break, } } diff --git a/src/librustc_passes/layout_test.rs b/src/librustc_passes/layout_test.rs index c0826f8cc605..2419e6965968 100644 --- a/src/librustc_passes/layout_test.rs +++ b/src/librustc_passes/layout_test.rs @@ -27,8 +27,7 @@ impl ItemLikeVisitor<'tcx> for LayoutTest<'tcx> { ItemKind::TyAlias(..) | ItemKind::Enum(..) | ItemKind::Struct(..) - | ItemKind::Union(..) - | ItemKind::OpaqueTy(..) => { + | ItemKind::Union(..) => { for attr in self.tcx.get_attrs(item_def_id.to_def_id()).iter() { if attr.check_name(sym::rustc_layout) { self.dump_layout_of(item_def_id, item, attr); @@ -83,9 +82,11 @@ impl LayoutTest<'tcx> { } sym::debug => { + let normalized_ty = + self.tcx.normalize_erasing_regions(param_env.with_reveal_all(), ty); self.tcx.sess.span_err( item.span, - &format!("layout_of({:?}) = {:#?}", ty, *ty_layout), + &format!("layout_of({:?}) = {:#?}", normalized_ty, *ty_layout), ); } diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 2ae063660e38..53ec7f67f190 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -746,12 +746,11 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { } // These items live in the type namespace. - ItemKind::TyAlias(_, _, _, ref ty) => { - let def_kind = match ty.as_deref().and_then(|ty| ty.kind.opaque_top_hack()) { - None => DefKind::TyAlias, - Some(_) => DefKind::OpaqueTy, - }; - let res = Res::Def(def_kind, self.r.definitions.local_def_id(item.id).to_def_id()); + ItemKind::TyAlias(..) => { + let res = Res::Def( + DefKind::TyAlias, + self.r.definitions.local_def_id(item.id).to_def_id(), + ); self.r.define(parent, ident, TypeNS, (res, vis, sp, expansion)); } diff --git a/src/librustc_resolve/late/lifetimes.rs b/src/librustc_resolve/late/lifetimes.rs index a3fbb28f22a5..02193dcec901 100644 --- a/src/librustc_resolve/late/lifetimes.rs +++ b/src/librustc_resolve/late/lifetimes.rs @@ -396,15 +396,12 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { let scope = Scope::Elision { elide: Elide::Exact(Region::Static), s: ROOT_SCOPE }; self.with(scope, |_, this| intravisit::walk_item(this, item)); } - hir::ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn: Some(_), .. }) => { - // Currently opaque type declarations are just generated from `impl Trait` - // items. Doing anything on this node is irrelevant, as we currently don't need - // it. + hir::ItemKind::OpaqueTy(hir::OpaqueTy { .. }) => { + // Opaque types are visited when we visit the `TyKind::Def`, so + // that they have the lifetimes from their parent opaque_ty in + // scope. } hir::ItemKind::TyAlias(_, ref generics) - | hir::ItemKind::OpaqueTy(hir::OpaqueTy { - impl_trait_fn: None, ref generics, .. - }) | hir::ItemKind::Enum(_, ref generics) | hir::ItemKind::Struct(_, ref generics) | hir::ItemKind::Union(_, ref generics) @@ -563,17 +560,22 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { // `type MyAnonTy<'b> = impl MyTrait<'b>;` // ^ ^ this gets resolved in the scope of // the opaque_ty generics - let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).kind { + let opaque_ty = self.tcx.hir().expect_item(item_id.id); + let (generics, bounds) = match opaque_ty.kind { // Named opaque `impl Trait` types are reached via `TyKind::Path`. // This arm is for `impl Trait` in the types of statics, constants and locals. hir::ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn: None, .. }) => { intravisit::walk_ty(self, ty); + intravisit::walk_item(this, opaque_ty); return; } // RPIT (return position impl trait) - hir::ItemKind::OpaqueTy(hir::OpaqueTy { ref generics, bounds, .. }) => { - (generics, bounds) - } + hir::ItemKind::OpaqueTy(hir::OpaqueTy { + impl_trait_fn: Some(_), + ref generics, + bounds, + .. + }) => (generics, bounds), ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i), }; @@ -2667,8 +2669,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { // going to make a fresh name, so we cannot // necessarily replace a single-use lifetime with // `'_`. - Scope::Elision { elide: Elide::Exact(_), .. } => break false, - Scope::Elision { elide: Elide::Error(_), .. } => break false, + Scope::Elision { + elide: Elide::Exact(_) | Elide::Error(_) | Elide::Forbid, .. + } => break false, Scope::ObjectLifetimeDefault { s, .. } => scope = s, } diff --git a/src/librustc_trait_selection/opaque_types.rs b/src/librustc_trait_selection/opaque_types.rs index 19caf64c63f1..51b1db390b92 100644 --- a/src/librustc_trait_selection/opaque_types.rs +++ b/src/librustc_trait_selection/opaque_types.rs @@ -133,9 +133,9 @@ pub trait InferCtxtExt<'tcx> { fn generate_member_constraint( &self, concrete_ty: Ty<'tcx>, - opaque_type_generics: &ty::Generics, opaque_defn: &OpaqueTypeDecl<'tcx>, opaque_type_def_id: DefId, + first_own_region_index: usize, ); /*private*/ @@ -405,7 +405,16 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { debug!("constrain_opaque_type: concrete_ty={:?}", concrete_ty); - let opaque_type_generics = tcx.generics_of(def_id); + let first_own_region = match opaque_defn.origin { + hir::OpaqueTyOrigin::FnReturn | hir::OpaqueTyOrigin::AsyncFn => { + // For these opaque types, only the item's own lifetime + // parameters are considered. + tcx.generics_of(def_id).parent_count + } + // These opaque type inherit all lifetime parameters from their + // parent. + hir::OpaqueTyOrigin::Misc => 0, + }; let span = tcx.def_span(def_id); @@ -427,12 +436,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { }); } if let GenerateMemberConstraints::IfNoStaticBound = mode { - self.generate_member_constraint( - concrete_ty, - opaque_type_generics, - opaque_defn, - def_id, - ); + self.generate_member_constraint(concrete_ty, opaque_defn, def_id, first_own_region); } return; } @@ -445,29 +449,27 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { // `['a]` for the first impl trait and `'b` for the // second. let mut least_region = None; - for param in &opaque_type_generics.params { - match param.kind { - GenericParamDefKind::Lifetime => {} - _ => continue, - } - // Get the value supplied for this region from the substs. - let subst_arg = opaque_defn.substs.region_at(param.index as usize); + for subst_arg in &opaque_defn.substs[first_own_region..] { + let subst_region = match subst_arg.unpack() { + GenericArgKind::Lifetime(r) => r, + GenericArgKind::Type(_) | GenericArgKind::Const(_) => continue, + }; // Compute the least upper bound of it with the other regions. debug!("constrain_opaque_types: least_region={:?}", least_region); - debug!("constrain_opaque_types: subst_arg={:?}", subst_arg); + debug!("constrain_opaque_types: subst_region={:?}", subst_region); match least_region { - None => least_region = Some(subst_arg), + None => least_region = Some(subst_region), Some(lr) => { - if free_region_relations.sub_free_regions(self.tcx, lr, subst_arg) { + if free_region_relations.sub_free_regions(self.tcx, lr, subst_region) { // keep the current least region - } else if free_region_relations.sub_free_regions(self.tcx, subst_arg, lr) { - // switch to `subst_arg` - least_region = Some(subst_arg); + } else if free_region_relations.sub_free_regions(self.tcx, subst_region, lr) { + // switch to `subst_region` + least_region = Some(subst_region); } else { // There are two regions (`lr` and - // `subst_arg`) which are not relatable. We + // `subst_region`) which are not relatable. We // can't find a best choice. Therefore, // instead of creating a single bound like // `'r: 'a` (which is our preferred choice), @@ -476,13 +478,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { // regions that appear in the impl trait. // For now, enforce a feature gate outside of async functions. - self.member_constraint_feature_gate(opaque_defn, def_id, lr, subst_arg); + self.member_constraint_feature_gate(opaque_defn, def_id, lr, subst_region); return self.generate_member_constraint( concrete_ty, - opaque_type_generics, opaque_defn, def_id, + first_own_region, ); } } @@ -494,12 +496,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { if let GenerateMemberConstraints::IfNoStaticBound = mode { if least_region != tcx.lifetimes.re_static { - self.generate_member_constraint( - concrete_ty, - opaque_type_generics, - opaque_defn, - def_id, - ); + self.generate_member_constraint(concrete_ty, opaque_defn, def_id, first_own_region); } } concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor { @@ -518,22 +515,20 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { fn generate_member_constraint( &self, concrete_ty: Ty<'tcx>, - opaque_type_generics: &ty::Generics, opaque_defn: &OpaqueTypeDecl<'tcx>, opaque_type_def_id: DefId, + first_own_region: usize, ) { // Create the set of choice regions: each region in the hidden // type can be equal to any of the region parameters of the // opaque type definition. let choice_regions: Lrc>> = Lrc::new( - opaque_type_generics - .params + opaque_defn.substs[first_own_region..] .iter() - .filter(|param| match param.kind { - GenericParamDefKind::Lifetime => true, - GenericParamDefKind::Type { .. } | GenericParamDefKind::Const => false, + .filter_map(|arg| match arg.unpack() { + GenericArgKind::Lifetime(r) => Some(r), + GenericArgKind::Type(_) | GenericArgKind::Const(_) => None, }) - .map(|param| opaque_defn.substs.region_at(param.index as usize)) .chain(std::iter::once(self.tcx.lifetimes.re_static)) .collect(), ); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index f1dc7e539062..24e38cc42ef6 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -2839,8 +2839,26 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { self.res_to_ty(opt_self_ty, path, false) } hir::TyKind::Def(item_id, ref lifetimes) => { - let did = tcx.hir().local_def_id(item_id.id); - self.impl_trait_ty_to_ty(did.to_def_id(), lifetimes) + let opaque_ty = tcx.hir().expect_item(item_id.id); + let def_id = tcx.hir().local_def_id(item_id.id).to_def_id(); + + match opaque_ty.kind { + // RPIT (return position impl trait) + // Only lifetimes mentioned in the impl Trait predicate are + // captured by the opaque type, so the lifetime parameters + // from the parent item need to be replaced with `'static`. + hir::ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn: Some(_), .. }) => { + self.impl_trait_ty_to_ty(def_id, lifetimes) + } + // This arm is for `impl Trait` in the types of statics, + // constants, locals and type aliases. These capture all + // parent lifetimes, so they can use their identity subst. + hir::ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn: None, .. }) => { + let substs = InternalSubsts::identity_for_item(tcx, def_id); + tcx.mk_opaque(def_id, substs) + } + ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i), + } } hir::TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => { debug!("ast_ty_to_ty: qself={:?} segment={:?}", qself, segment); diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 3473dc7a58d0..159d3d7a538a 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -460,7 +460,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { let mut skip_add = false; if let ty::Opaque(defin_ty_def_id, _substs) = definition_ty.kind { - if let hir::OpaqueTyOrigin::TypeAlias = opaque_defn.origin { + if let hir::OpaqueTyOrigin::Misc = opaque_defn.origin { if def_id == defin_ty_def_id { debug!( "skipping adding concrete definition for opaque type {:?} {:?}", diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 355b4fc413f4..7038caf4367e 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1202,22 +1202,11 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics { ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn, .. }) => { impl_trait_fn.or_else(|| { let parent_id = tcx.hir().get_parent_item(hir_id); - if parent_id != hir_id && parent_id != CRATE_HIR_ID { + assert!(parent_id != hir_id && parent_id != CRATE_HIR_ID); debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent_id); - // If this 'impl Trait' is nested inside another 'impl Trait' - // (e.g. `impl Foo>`), we need to use the 'parent' - // 'impl Trait' for its generic parameters, since we can reference them - // from the 'child' 'impl Trait' - if let Node::Item(hir::Item { kind: ItemKind::OpaqueTy(..), .. }) = - tcx.hir().get(parent_id) - { + // Opaque types are always nested within another item, and + // inherit the generics of the item. Some(tcx.hir().local_def_id(parent_id).to_def_id()) - } else { - None - } - } else { - None - } }) } _ => None, diff --git a/src/test/ui/associated-type-bounds/duplicate.rs b/src/test/ui/associated-type-bounds/duplicate.rs index 8b396f23efd5..8b5c5219430b 100644 --- a/src/test/ui/associated-type-bounds/duplicate.rs +++ b/src/test/ui/associated-type-bounds/duplicate.rs @@ -108,18 +108,12 @@ type TAW3 where T: Iterator = T; type ETAI1> = impl Copy; //~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses -//~| ERROR could not find defining uses -//~| ERROR could not find defining uses type ETAI2> = impl Copy; //~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses -//~| ERROR could not find defining uses -//~| ERROR could not find defining uses type ETAI3> = impl Copy; //~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses -//~| ERROR could not find defining uses -//~| ERROR could not find defining uses type ETAI4 = impl Iterator; //~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses diff --git a/src/test/ui/associated-type-bounds/duplicate.stderr b/src/test/ui/associated-type-bounds/duplicate.stderr index 71f6e4ff8b62..712211e60cba 100644 --- a/src/test/ui/associated-type-bounds/duplicate.stderr +++ b/src/test/ui/associated-type-bounds/duplicate.stderr @@ -223,30 +223,6 @@ LL | fn FAPIT3(_: impl Iterator) {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:62:42 - | -LL | fn FRPIT1() -> impl Iterator { iter::empty() } - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:64:42 - | -LL | fn FRPIT2() -> impl Iterator { iter::empty() } - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:66:45 - | -LL | fn FRPIT3() -> impl Iterator { iter::empty() } - | ------------- ^^^^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:75:39 | @@ -367,12 +343,6 @@ LL | type TAW3 where T: Iterator = T; | | | `Item` bound here first -error: could not find defining uses - --> $DIR/duplicate.rs:108:1 - | -LL | type ETAI1> = impl Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:108:36 | @@ -381,14 +351,38 @@ LL | type ETAI1> = impl Copy; | | | `Item` bound here first -error: could not find defining uses - --> $DIR/duplicate.rs:113:1 +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified + --> $DIR/duplicate.rs:62:42 | -LL | type ETAI2> = impl Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn FRPIT1() -> impl Iterator { iter::empty() } + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:113:36 + --> $DIR/duplicate.rs:64:42 + | +LL | fn FRPIT2() -> impl Iterator { iter::empty() } + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified + --> $DIR/duplicate.rs:66:45 + | +LL | fn FRPIT3() -> impl Iterator { iter::empty() } + | ------------- ^^^^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error: could not find defining uses + --> $DIR/duplicate.rs:108:51 + | +LL | type ETAI1> = impl Copy; + | ^^^^^^^^^ + +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified + --> $DIR/duplicate.rs:111:36 | LL | type ETAI2> = impl Copy; | ---------- ^^^^^^^^^^ re-bound here @@ -396,13 +390,13 @@ LL | type ETAI2> = impl Copy; | `Item` bound here first error: could not find defining uses - --> $DIR/duplicate.rs:118:1 + --> $DIR/duplicate.rs:111:51 | -LL | type ETAI3> = impl Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type ETAI2> = impl Copy; + | ^^^^^^^^^ error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:118:39 + --> $DIR/duplicate.rs:114:39 | LL | type ETAI3> = impl Copy; | ------------- ^^^^^^^^^^^^^ re-bound here @@ -410,13 +404,19 @@ LL | type ETAI3> = impl Copy; | `Item` bound here first error: could not find defining uses - --> $DIR/duplicate.rs:123:1 + --> $DIR/duplicate.rs:114:57 + | +LL | type ETAI3> = impl Copy; + | ^^^^^^^^^ + +error: could not find defining uses + --> $DIR/duplicate.rs:117:14 | LL | type ETAI4 = impl Iterator; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:123:40 + --> $DIR/duplicate.rs:117:40 | LL | type ETAI4 = impl Iterator; | ---------- ^^^^^^^^^^ re-bound here @@ -424,13 +424,13 @@ LL | type ETAI4 = impl Iterator; | `Item` bound here first error: could not find defining uses - --> $DIR/duplicate.rs:128:1 + --> $DIR/duplicate.rs:122:14 | LL | type ETAI5 = impl Iterator; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:128:40 + --> $DIR/duplicate.rs:122:40 | LL | type ETAI5 = impl Iterator; | ---------- ^^^^^^^^^^ re-bound here @@ -438,13 +438,13 @@ LL | type ETAI5 = impl Iterator; | `Item` bound here first error: could not find defining uses - --> $DIR/duplicate.rs:133:1 + --> $DIR/duplicate.rs:127:14 | LL | type ETAI6 = impl Iterator; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:133:43 + --> $DIR/duplicate.rs:127:43 | LL | type ETAI6 = impl Iterator; | ------------- ^^^^^^^^^^^^^ re-bound here @@ -452,7 +452,7 @@ LL | type ETAI6 = impl Iterator; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:139:36 + --> $DIR/duplicate.rs:133:36 | LL | trait TRI1> {} | ---------- ^^^^^^^^^^ re-bound here @@ -460,7 +460,7 @@ LL | trait TRI1> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:141:36 + --> $DIR/duplicate.rs:135:36 | LL | trait TRI2> {} | ---------- ^^^^^^^^^^ re-bound here @@ -468,7 +468,7 @@ LL | trait TRI2> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:143:39 + --> $DIR/duplicate.rs:137:39 | LL | trait TRI3> {} | ------------- ^^^^^^^^^^^^^ re-bound here @@ -476,7 +476,7 @@ LL | trait TRI3> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:145:34 + --> $DIR/duplicate.rs:139:34 | LL | trait TRS1: Iterator {} | ---------- ^^^^^^^^^^ re-bound here @@ -484,7 +484,7 @@ LL | trait TRS1: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:147:34 + --> $DIR/duplicate.rs:141:34 | LL | trait TRS2: Iterator {} | ---------- ^^^^^^^^^^ re-bound here @@ -492,7 +492,7 @@ LL | trait TRS2: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:149:37 + --> $DIR/duplicate.rs:143:37 | LL | trait TRS3: Iterator {} | ------------- ^^^^^^^^^^^^^ re-bound here @@ -500,7 +500,7 @@ LL | trait TRS3: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:151:45 + --> $DIR/duplicate.rs:145:45 | LL | trait TRW1 where T: Iterator {} | ---------- ^^^^^^^^^^ re-bound here @@ -508,7 +508,7 @@ LL | trait TRW1 where T: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:153:45 + --> $DIR/duplicate.rs:147:45 | LL | trait TRW2 where T: Iterator {} | ---------- ^^^^^^^^^^ re-bound here @@ -516,7 +516,7 @@ LL | trait TRW2 where T: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:155:48 + --> $DIR/duplicate.rs:149:48 | LL | trait TRW3 where T: Iterator {} | ------------- ^^^^^^^^^^^^^ re-bound here @@ -524,7 +524,7 @@ LL | trait TRW3 where T: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:157:46 + --> $DIR/duplicate.rs:151:46 | LL | trait TRSW1 where Self: Iterator {} | ---------- ^^^^^^^^^^ re-bound here @@ -532,7 +532,7 @@ LL | trait TRSW1 where Self: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:157:46 + --> $DIR/duplicate.rs:151:46 | LL | trait TRSW1 where Self: Iterator {} | ---------- ^^^^^^^^^^ re-bound here @@ -540,7 +540,7 @@ LL | trait TRSW1 where Self: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:160:46 + --> $DIR/duplicate.rs:154:46 | LL | trait TRSW2 where Self: Iterator {} | ---------- ^^^^^^^^^^ re-bound here @@ -548,7 +548,7 @@ LL | trait TRSW2 where Self: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:160:46 + --> $DIR/duplicate.rs:154:46 | LL | trait TRSW2 where Self: Iterator {} | ---------- ^^^^^^^^^^ re-bound here @@ -556,7 +556,7 @@ LL | trait TRSW2 where Self: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:163:49 + --> $DIR/duplicate.rs:157:49 | LL | trait TRSW3 where Self: Iterator {} | ------------- ^^^^^^^^^^^^^ re-bound here @@ -564,7 +564,7 @@ LL | trait TRSW3 where Self: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:163:49 + --> $DIR/duplicate.rs:157:49 | LL | trait TRSW3 where Self: Iterator {} | ------------- ^^^^^^^^^^^^^ re-bound here @@ -572,7 +572,7 @@ LL | trait TRSW3 where Self: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:166:43 + --> $DIR/duplicate.rs:160:43 | LL | trait TRA1 { type A: Iterator; } | ---------- ^^^^^^^^^^ re-bound here @@ -580,7 +580,7 @@ LL | trait TRA1 { type A: Iterator; } | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:168:43 + --> $DIR/duplicate.rs:162:43 | LL | trait TRA2 { type A: Iterator; } | ---------- ^^^^^^^^^^ re-bound here @@ -588,7 +588,7 @@ LL | trait TRA2 { type A: Iterator; } | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:170:46 + --> $DIR/duplicate.rs:164:46 | LL | trait TRA3 { type A: Iterator; } | ------------- ^^^^^^^^^^^^^ re-bound here @@ -596,7 +596,7 @@ LL | trait TRA3 { type A: Iterator; } | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:173:40 + --> $DIR/duplicate.rs:167:40 | LL | type TADyn1 = dyn Iterator; | ---------- ^^^^^^^^^^ re-bound here @@ -604,7 +604,7 @@ LL | type TADyn1 = dyn Iterator; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:177:44 + --> $DIR/duplicate.rs:171:44 | LL | type TADyn2 = Box>; | ---------- ^^^^^^^^^^ re-bound here @@ -612,7 +612,7 @@ LL | type TADyn2 = Box>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified - --> $DIR/duplicate.rs:181:43 + --> $DIR/duplicate.rs:175:43 | LL | type TADyn3 = dyn Iterator; | ------------- ^^^^^^^^^^^^^ re-bound here @@ -620,113 +620,77 @@ LL | type TADyn3 = dyn Iterator; | `Item` bound here first error: could not find defining uses - --> $DIR/duplicate.rs:108:24 - | -LL | type ETAI1> = impl Copy; - | ^^^^^^^^^^ - -error: could not find defining uses - --> $DIR/duplicate.rs:108:36 - | -LL | type ETAI1> = impl Copy; - | ^^^^^^^^^^ - -error: could not find defining uses - --> $DIR/duplicate.rs:113:24 - | -LL | type ETAI2> = impl Copy; - | ^^^^^^^^^^ - -error: could not find defining uses - --> $DIR/duplicate.rs:113:36 - | -LL | type ETAI2> = impl Copy; - | ^^^^^^^^^^ - -error: could not find defining uses - --> $DIR/duplicate.rs:118:24 - | -LL | type ETAI3> = impl Copy; - | ^^^^^^^^^^^^^ - -error: could not find defining uses - --> $DIR/duplicate.rs:118:39 - | -LL | type ETAI3> = impl Copy; - | ^^^^^^^^^^^^^ - -error: could not find defining uses - --> $DIR/duplicate.rs:123:28 + --> $DIR/duplicate.rs:117:28 | LL | type ETAI4 = impl Iterator; | ^^^^^^^^^^ error: could not find defining uses - --> $DIR/duplicate.rs:123:40 + --> $DIR/duplicate.rs:117:40 | LL | type ETAI4 = impl Iterator; | ^^^^^^^^^^ error: could not find defining uses - --> $DIR/duplicate.rs:128:28 + --> $DIR/duplicate.rs:122:28 | LL | type ETAI5 = impl Iterator; | ^^^^^^^^^^ error: could not find defining uses - --> $DIR/duplicate.rs:128:40 + --> $DIR/duplicate.rs:122:40 | LL | type ETAI5 = impl Iterator; | ^^^^^^^^^^ error: could not find defining uses - --> $DIR/duplicate.rs:133:28 + --> $DIR/duplicate.rs:127:28 | LL | type ETAI6 = impl Iterator; | ^^^^^^^^^^^^^ error: could not find defining uses - --> $DIR/duplicate.rs:133:43 + --> $DIR/duplicate.rs:127:43 | LL | type ETAI6 = impl Iterator; | ^^^^^^^^^^^^^ error: could not find defining uses - --> $DIR/duplicate.rs:173:28 + --> $DIR/duplicate.rs:167:28 | LL | type TADyn1 = dyn Iterator; | ^^^^^^^^^^ error: could not find defining uses - --> $DIR/duplicate.rs:173:40 + --> $DIR/duplicate.rs:167:40 | LL | type TADyn1 = dyn Iterator; | ^^^^^^^^^^ error: could not find defining uses - --> $DIR/duplicate.rs:177:32 + --> $DIR/duplicate.rs:171:32 | LL | type TADyn2 = Box>; | ^^^^^^^^^^ error: could not find defining uses - --> $DIR/duplicate.rs:177:44 + --> $DIR/duplicate.rs:171:44 | LL | type TADyn2 = Box>; | ^^^^^^^^^^ error: could not find defining uses - --> $DIR/duplicate.rs:181:28 + --> $DIR/duplicate.rs:175:28 | LL | type TADyn3 = dyn Iterator; | ^^^^^^^^^^^^^ error: could not find defining uses - --> $DIR/duplicate.rs:181:43 + --> $DIR/duplicate.rs:175:43 | LL | type TADyn3 = dyn Iterator; | ^^^^^^^^^^^^^ -error: aborting due to 96 previous errors; 1 warning emitted +error: aborting due to 90 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0719`. diff --git a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs index 6088331cded7..3b6c9791722b 100644 --- a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs +++ b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs @@ -9,10 +9,14 @@ trait Bar { impl Bar for () { type Baa = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable - fn define() -> Self::Baa { 0 } + fn define() -> Self::Baa { + 0 + } } -fn define() -> Foo { 0 } +fn define() -> Foo { + 0 +} trait TraitWithDefault { type Assoc = impl Debug; @@ -26,20 +30,20 @@ type NestedFree = (Vec, impl Debug, impl Iterator //~| ERROR `impl Trait` in type aliases is unstable //~| ERROR `impl Trait` in type aliases is unstable //~| ERROR `impl Trait` in type aliases is unstable -//~| ERROR `impl Trait` not allowed outside of function -//~| ERROR `impl Trait` not allowed outside of function -//~| ERROR `impl Trait` not allowed outside of function + +fn define_multiple() -> NestedFree { + (vec![true], 0u8, 0i32..1) +} impl Bar for u8 { - type Baa = (Vec, impl Debug, impl Iterator); + type Baa = (Vec, impl Debug, impl Iterator + Debug); //~^ ERROR `impl Trait` in type aliases is unstable //~| ERROR `impl Trait` in type aliases is unstable //~| ERROR `impl Trait` in type aliases is unstable //~| ERROR `impl Trait` in type aliases is unstable - //~| ERROR `impl Trait` not allowed outside of function - //~| ERROR `impl Trait` not allowed outside of function - //~| ERROR `impl Trait` not allowed outside of function - fn define() -> Self::Baa { (vec![true], 0u8, 0i32..1) } + fn define() -> Self::Baa { + (vec![true], 0u8, 0i32..1) + } } fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr index 55cd2984ab66..8bab0d0c4a95 100644 --- a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr +++ b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr @@ -17,7 +17,7 @@ LL | type Baa = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: associated type defaults are unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:18:5 + --> $DIR/feature-gate-type_alias_impl_trait.rs:22:5 | LL | type Assoc = impl Debug; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | type Assoc = impl Debug; = help: add `#![feature(associated_type_defaults)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:18:18 + --> $DIR/feature-gate-type_alias_impl_trait.rs:22:18 | LL | type Assoc = impl Debug; | ^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | type Assoc = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:24:24 + --> $DIR/feature-gate-type_alias_impl_trait.rs:28:24 | LL | type NestedFree = (Vec, impl Debug, impl Iterator); | ^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | type NestedFree = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:24:37 + --> $DIR/feature-gate-type_alias_impl_trait.rs:28:37 | LL | type NestedFree = (Vec, impl Debug, impl Iterator); | ^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | type NestedFree = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:24:49 + --> $DIR/feature-gate-type_alias_impl_trait.rs:28:49 | LL | type NestedFree = (Vec, impl Debug, impl Iterator); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -62,7 +62,7 @@ LL | type NestedFree = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:24:70 + --> $DIR/feature-gate-type_alias_impl_trait.rs:28:70 | LL | type NestedFree = (Vec, impl Debug, impl Iterator); | ^^^^^^^^^^ @@ -71,84 +71,48 @@ LL | type NestedFree = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:34:21 + --> $DIR/feature-gate-type_alias_impl_trait.rs:39:21 | -LL | type Baa = (Vec, impl Debug, impl Iterator); +LL | type Baa = (Vec, impl Debug, impl Iterator + Debug); | ^^^^^^^^^^ | = note: see issue #63063 for more information = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:34:34 + --> $DIR/feature-gate-type_alias_impl_trait.rs:39:34 | -LL | type Baa = (Vec, impl Debug, impl Iterator); +LL | type Baa = (Vec, impl Debug, impl Iterator + Debug); | ^^^^^^^^^^ | = note: see issue #63063 for more information = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:34:46 + --> $DIR/feature-gate-type_alias_impl_trait.rs:39:46 | -LL | type Baa = (Vec, impl Debug, impl Iterator); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Baa = (Vec, impl Debug, impl Iterator + Debug); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #63063 for more information = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:34:67 + --> $DIR/feature-gate-type_alias_impl_trait.rs:39:67 | -LL | type Baa = (Vec, impl Debug, impl Iterator); +LL | type Baa = (Vec, impl Debug, impl Iterator + Debug); | ^^^^^^^^^^ | = note: see issue #63063 for more information = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-type_alias_impl_trait.rs:18:18 + --> $DIR/feature-gate-type_alias_impl_trait.rs:22:18 | LL | type Assoc = impl Debug; | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-type_alias_impl_trait.rs:24:24 - | -LL | type NestedFree = (Vec, impl Debug, impl Iterator); - | ^^^^^^^^^^ - -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-type_alias_impl_trait.rs:24:37 - | -LL | type NestedFree = (Vec, impl Debug, impl Iterator); - | ^^^^^^^^^^ - -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-type_alias_impl_trait.rs:24:49 - | -LL | type NestedFree = (Vec, impl Debug, impl Iterator); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-type_alias_impl_trait.rs:34:21 - | -LL | type Baa = (Vec, impl Debug, impl Iterator); - | ^^^^^^^^^^ - -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-type_alias_impl_trait.rs:34:34 - | -LL | type Baa = (Vec, impl Debug, impl Iterator); - | ^^^^^^^^^^ - -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-type_alias_impl_trait.rs:34:46 - | -LL | type Baa = (Vec, impl Debug, impl Iterator); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 19 previous errors +error: aborting due to 13 previous errors Some errors have detailed explanations: E0562, E0658. For more information about an error, try `rustc --explain E0562`. diff --git a/src/test/ui/impl-trait/auto-trait.rs b/src/test/ui/impl-trait/auto-trait.rs index c76757812088..cf2773f4ef59 100644 --- a/src/test/ui/impl-trait/auto-trait.rs +++ b/src/test/ui/impl-trait/auto-trait.rs @@ -2,22 +2,24 @@ // the purposes of coherence checking #![feature(type_alias_impl_trait)] -trait OpaqueTrait { } -impl OpaqueTrait for T { } +trait OpaqueTrait {} +impl OpaqueTrait for T {} type OpaqueType = impl OpaqueTrait; -fn mk_opaque() -> OpaqueType { () } +fn mk_opaque() -> OpaqueType { + () +} #[derive(Debug)] struct D(T); -trait AnotherTrait { } -impl AnotherTrait for T { } +trait AnotherTrait {} +impl AnotherTrait for T {} // This is in error, because we cannot assume that `OpaqueType: !Send`. // (We treat opaque types as "foreign types" that could grow more impls // in the future.) impl AnotherTrait for D { - //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D` + //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D` } fn main() {} diff --git a/src/test/ui/impl-trait/auto-trait.stderr b/src/test/ui/impl-trait/auto-trait.stderr index 5e72ca7a47ba..16fe1b56b50c 100644 --- a/src/test/ui/impl-trait/auto-trait.stderr +++ b/src/test/ui/impl-trait/auto-trait.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D`: - --> $DIR/auto-trait.rs:19:1 +error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D`: + --> $DIR/auto-trait.rs:21:1 | -LL | impl AnotherTrait for T { } +LL | impl AnotherTrait for T {} | -------------------------------- first implementation here ... LL | impl AnotherTrait for D { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D` error: aborting due to previous error diff --git a/src/test/ui/impl-trait/issue-55872-1.stderr b/src/test/ui/impl-trait/issue-55872-1.stderr index 6cb2c9fb892f..5131509cdf03 100644 --- a/src/test/ui/impl-trait/issue-55872-1.stderr +++ b/src/test/ui/impl-trait/issue-55872-1.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `S: std::marker::Copy` is not satisfied in `(S, T)` - --> $DIR/issue-55872-1.rs:12:5 + --> $DIR/issue-55872-1.rs:12:14 | LL | type E = impl Copy; - | ^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `S` + | ^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `S` | = note: required because it appears within the type `(S, T)` = note: the return type of a function must have a statically known size @@ -12,10 +12,10 @@ LL | impl Bar for S { | ^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied in `(S, T)` - --> $DIR/issue-55872-1.rs:12:5 + --> $DIR/issue-55872-1.rs:12:14 | LL | type E = impl Copy; - | ^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `T` + | ^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `T` | = note: required because it appears within the type `(S, T)` = note: the return type of a function must have a statically known size diff --git a/src/test/ui/impl-trait/issue-55872-2.stderr b/src/test/ui/impl-trait/issue-55872-2.stderr index 01371b4d5c61..649109e4c932 100644 --- a/src/test/ui/impl-trait/issue-55872-2.stderr +++ b/src/test/ui/impl-trait/issue-55872-2.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `impl std::future::Future: std::marker::Copy` is not satisfied - --> $DIR/issue-55872-2.rs:13:5 + --> $DIR/issue-55872-2.rs:13:14 | LL | type E = impl Copy; - | ^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `impl std::future::Future` + | ^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `impl std::future::Future` | = note: the return type of a function must have a statically known size diff --git a/src/test/ui/impl-trait/negative-reasoning.rs b/src/test/ui/impl-trait/negative-reasoning.rs index 4977f9bdbacd..d173fe83fb79 100644 --- a/src/test/ui/impl-trait/negative-reasoning.rs +++ b/src/test/ui/impl-trait/negative-reasoning.rs @@ -2,21 +2,22 @@ // other trait #![feature(type_alias_impl_trait)] -trait OpaqueTrait { } -impl OpaqueTrait for T { } +trait OpaqueTrait {} +impl OpaqueTrait for T {} type OpaqueType = impl OpaqueTrait; -fn mk_opaque() -> OpaqueType { () } +fn mk_opaque() -> OpaqueType { + () +} #[derive(Debug)] struct D(T); -trait AnotherTrait { } -impl AnotherTrait for T { } - +trait AnotherTrait {} +impl AnotherTrait for T {} // This is in error, because we cannot assume that `OpaqueType: !Debug` impl AnotherTrait for D { - //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D` + //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D` } fn main() {} diff --git a/src/test/ui/impl-trait/negative-reasoning.stderr b/src/test/ui/impl-trait/negative-reasoning.stderr index 526a664726ac..e43d8c857b25 100644 --- a/src/test/ui/impl-trait/negative-reasoning.stderr +++ b/src/test/ui/impl-trait/negative-reasoning.stderr @@ -1,13 +1,13 @@ -error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D`: - --> $DIR/negative-reasoning.rs:18:1 +error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D`: + --> $DIR/negative-reasoning.rs:19:1 | -LL | impl AnotherTrait for T { } +LL | impl AnotherTrait for T {} | ------------------------------------------- first implementation here ... LL | impl AnotherTrait for D { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D` | - = note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `OpaqueType` in future versions + = note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `impl OpaqueTrait` in future versions error: aborting due to previous error diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index 5d9ae6a03018..7addc006e190 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -256,16 +256,16 @@ LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ error: could not find defining uses - --> $DIR/where-allowed.rs:155:1 - | -LL | type InTypeAlias = impl Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: could not find defining uses - --> $DIR/where-allowed.rs:119:5 + --> $DIR/where-allowed.rs:119:16 | LL | type Out = impl Debug; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ + +error: could not find defining uses + --> $DIR/where-allowed.rs:155:23 + | +LL | type InTypeAlias = impl Debug; + | ^^^^^^^^^^ error: aborting due to 42 previous errors diff --git a/src/test/ui/issues/issue-60662.stdout b/src/test/ui/issues/issue-60662.stdout index 5a4b49cfa1e7..cebe834824a6 100644 --- a/src/test/ui/issues/issue-60662.stdout +++ b/src/test/ui/issues/issue-60662.stdout @@ -10,5 +10,5 @@ extern crate std; trait Animal { } fn main() { - pub type ServeFut = impl Animal; + pub type ServeFut = /*impl Trait*/; } diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.stderr b/src/test/ui/lint/inline-trait-and-foreign-items.stderr index 15aaf8961b7b..ae04612a4dd6 100644 --- a/src/test/ui/lint/inline-trait-and-foreign-items.stderr +++ b/src/test/ui/lint/inline-trait-and-foreign-items.stderr @@ -62,10 +62,10 @@ LL | type U = impl Trait; | -------------------- not a function or closure error: could not find defining uses - --> $DIR/inline-trait-and-foreign-items.rs:26:5 + --> $DIR/inline-trait-and-foreign-items.rs:26:14 | LL | type U = impl Trait; - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ error: aborting due to 6 previous errors; 2 warnings emitted diff --git a/src/test/ui/lint/opaque-ty-ffi-unsafe.rs b/src/test/ui/lint/opaque-ty-ffi-unsafe.rs index 25d5f8ec68aa..3cbc084ecae7 100644 --- a/src/test/ui/lint/opaque-ty-ffi-unsafe.rs +++ b/src/test/ui/lint/opaque-ty-ffi-unsafe.rs @@ -1,5 +1,4 @@ #![feature(type_alias_impl_trait)] - #![deny(improper_ctypes)] type A = impl Fn(); @@ -10,7 +9,7 @@ pub fn ret_closure() -> A { extern "C" { pub fn a(_: A); - //~^ ERROR `extern` block uses type `A`, which is not FFI-safe +//~^ ERROR `extern` block uses type `impl std::ops::Fn<()>`, which is not FFI-safe } fn main() {} diff --git a/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr b/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr index 712095e3208b..06dfb7b8fbec 100644 --- a/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr +++ b/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr @@ -1,11 +1,11 @@ -error: `extern` block uses type `A`, which is not FFI-safe - --> $DIR/opaque-ty-ffi-unsafe.rs:12:17 +error: `extern` block uses type `impl std::ops::Fn<()>`, which is not FFI-safe + --> $DIR/opaque-ty-ffi-unsafe.rs:11:17 | LL | pub fn a(_: A); | ^ not FFI-safe | note: the lint level is defined here - --> $DIR/opaque-ty-ffi-unsafe.rs:3:9 + --> $DIR/opaque-ty-ffi-unsafe.rs:2:9 | LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ diff --git a/src/test/ui/privacy/private-in-public-assoc-ty.rs b/src/test/ui/privacy/private-in-public-assoc-ty.rs index 62faae1f399e..cd7c37cb04b2 100644 --- a/src/test/ui/privacy/private-in-public-assoc-ty.rs +++ b/src/test/ui/privacy/private-in-public-assoc-ty.rs @@ -9,7 +9,9 @@ mod m { trait PrivTr {} impl PrivTr for Priv {} pub trait PubTrAux1 {} - pub trait PubTrAux2 { type A; } + pub trait PubTrAux2 { + type A; + } impl PubTrAux1 for u8 {} impl PubTrAux2 for u8 { type A = Priv; @@ -41,8 +43,9 @@ mod m { type Exist = impl PrivTr; //~^ ERROR private trait `m::PrivTr` in public interface - //~| ERROR private trait `m::PrivTr` in public interface - fn infer_exist() -> Self::Exist { Priv } + fn infer_exist() -> Self::Exist { + Priv + } } } diff --git a/src/test/ui/privacy/private-in-public-assoc-ty.stderr b/src/test/ui/privacy/private-in-public-assoc-ty.stderr index dd2ea7481f33..1a3ca3f16ed4 100644 --- a/src/test/ui/privacy/private-in-public-assoc-ty.stderr +++ b/src/test/ui/privacy/private-in-public-assoc-ty.stderr @@ -1,5 +1,5 @@ error[E0446]: private type `m::Priv` in public interface - --> $DIR/private-in-public-assoc-ty.rs:15:9 + --> $DIR/private-in-public-assoc-ty.rs:17:9 | LL | struct Priv; | - `m::Priv` declared as private @@ -8,7 +8,7 @@ LL | type A = Priv; | ^^^^^^^^^^^^^^ can't leak private type warning: private trait `m::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-assoc-ty.rs:21:5 + --> $DIR/private-in-public-assoc-ty.rs:23:5 | LL | / pub trait PubTr { LL | | @@ -24,7 +24,7 @@ LL | | } = note: for more information, see issue #34537 warning: private type `m::Priv` in public interface (error E0446) - --> $DIR/private-in-public-assoc-ty.rs:21:5 + --> $DIR/private-in-public-assoc-ty.rs:23:5 | LL | / pub trait PubTr { LL | | @@ -39,7 +39,7 @@ LL | | } = note: for more information, see issue #34537 warning: private type `m::Priv` in public interface (error E0446) - --> $DIR/private-in-public-assoc-ty.rs:21:5 + --> $DIR/private-in-public-assoc-ty.rs:23:5 | LL | / pub trait PubTr { LL | | @@ -54,7 +54,7 @@ LL | | } = note: for more information, see issue #34537 error[E0446]: private type `m::Priv` in public interface - --> $DIR/private-in-public-assoc-ty.rs:32:9 + --> $DIR/private-in-public-assoc-ty.rs:34:9 | LL | struct Priv; | - `m::Priv` declared as private @@ -63,7 +63,7 @@ LL | type Alias4 = Priv; | ^^^^^^^^^^^^^^^^^^^ can't leak private type error[E0446]: private type `m::Priv` in public interface - --> $DIR/private-in-public-assoc-ty.rs:39:9 + --> $DIR/private-in-public-assoc-ty.rs:41:9 | LL | struct Priv; | - `m::Priv` declared as private @@ -72,7 +72,7 @@ LL | type Alias1 = Priv; | ^^^^^^^^^^^^^^^^^^^ can't leak private type error[E0445]: private trait `m::PrivTr` in public interface - --> $DIR/private-in-public-assoc-ty.rs:42:9 + --> $DIR/private-in-public-assoc-ty.rs:44:9 | LL | trait PrivTr {} | - `m::PrivTr` declared as private @@ -80,16 +80,7 @@ LL | trait PrivTr {} LL | type Exist = impl PrivTr; | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait -error[E0445]: private trait `m::PrivTr` in public interface - --> $DIR/private-in-public-assoc-ty.rs:42:9 - | -LL | trait PrivTr {} - | - `m::PrivTr` declared as private -... -LL | type Exist = impl PrivTr; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait - -error: aborting due to 5 previous errors; 3 warnings emitted +error: aborting due to 4 previous errors; 3 warnings emitted Some errors have detailed explanations: E0445, E0446. For more information about an error, try `rustc --explain E0445`. diff --git a/src/test/ui/save-analysis/issue-68621.stderr b/src/test/ui/save-analysis/issue-68621.stderr index 2c5bbd7782b3..3af6d0a3e076 100644 --- a/src/test/ui/save-analysis/issue-68621.stderr +++ b/src/test/ui/save-analysis/issue-68621.stderr @@ -1,8 +1,8 @@ error: could not find defining uses - --> $DIR/issue-68621.rs:14:5 + --> $DIR/issue-68621.rs:14:19 | LL | type Future = impl Trait; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr b/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr index b871f79aa1dc..9ebf63468e77 100644 --- a/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr +++ b/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: TraitWithAssoc` is not satisfied - --> $DIR/bound_reduction2.rs:10:1 + --> $DIR/bound_reduction2.rs:10:15 | LL | type Foo = impl Trait; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TraitWithAssoc` is not implemented for `T` + | ^^^^^^^^^^^^^ the trait `TraitWithAssoc` is not implemented for `T` | help: consider further restricting this bound | diff --git a/src/test/ui/type-alias-impl-trait/declared_but_never_defined.stderr b/src/test/ui/type-alias-impl-trait/declared_but_never_defined.stderr index ae0fee4333b5..21c2e8a9db61 100644 --- a/src/test/ui/type-alias-impl-trait/declared_but_never_defined.stderr +++ b/src/test/ui/type-alias-impl-trait/declared_but_never_defined.stderr @@ -1,8 +1,8 @@ error: could not find defining uses - --> $DIR/declared_but_never_defined.rs:6:1 + --> $DIR/declared_but_never_defined.rs:6:12 | LL | type Bar = impl std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr index 0642407aba3c..c0cb94b15d03 100644 --- a/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr +++ b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr @@ -1,8 +1,8 @@ error: could not find defining uses - --> $DIR/declared_but_not_defined_in_scope.rs:7:5 + --> $DIR/declared_but_not_defined_in_scope.rs:7:20 | LL | pub type Boo = impl ::std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr index e2540e424cb1..18d8daa05e63 100644 --- a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr @@ -13,16 +13,16 @@ LL | let z: i32 = x; | expected due to this ... LL | type WrongGeneric = impl 'static; - | ------------------------------------ the found opaque type + | ------------ the found opaque type | = note: expected type `i32` - found opaque type `WrongGeneric::<&{integer}>` + found opaque type `impl Sized` error[E0310]: the parameter type `T` may not live long enough - --> $DIR/generic_type_does_not_live_long_enough.rs:9:1 + --> $DIR/generic_type_does_not_live_long_enough.rs:9:24 | LL | type WrongGeneric = impl 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds ... LL | fn wrong_generic(t: T) -> WrongGeneric { | - help: consider adding an explicit lifetime bound...: `T: 'static` diff --git a/src/test/ui/type-alias-impl-trait/generic_underconstrained.stderr b/src/test/ui/type-alias-impl-trait/generic_underconstrained.stderr index f7a04263259f..911f592f73f2 100644 --- a/src/test/ui/type-alias-impl-trait/generic_underconstrained.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_underconstrained.stderr @@ -5,10 +5,10 @@ LL | type Underconstrained = impl 'static; | ^^^^^^^^^^^^ error[E0277]: the trait bound `T: Trait` is not satisfied - --> $DIR/generic_underconstrained.rs:6:1 + --> $DIR/generic_underconstrained.rs:6:35 | LL | type Underconstrained = impl 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` + | ^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` | = note: the return type of a function must have a statically known size help: consider restricting type parameter `T` diff --git a/src/test/ui/type-alias-impl-trait/generic_underconstrained2.stderr b/src/test/ui/type-alias-impl-trait/generic_underconstrained2.stderr index ad160abcbd57..247d68ef2a1f 100644 --- a/src/test/ui/type-alias-impl-trait/generic_underconstrained2.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_underconstrained2.stderr @@ -11,10 +11,10 @@ LL | type Underconstrained2 = impl 'static; | ^^^^^^^^^^^^ error[E0277]: `U` doesn't implement `std::fmt::Debug` - --> $DIR/generic_underconstrained2.rs:5:1 + --> $DIR/generic_underconstrained2.rs:5:45 | LL | type Underconstrained = impl 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | ^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` ... LL | 5u32 | ---- this returned value is of type `u32` @@ -27,10 +27,10 @@ LL | fn underconstrained(_: U) -> Underconstrained { | ^^^^^^^^^^^^^^^^^ error[E0277]: `V` doesn't implement `std::fmt::Debug` - --> $DIR/generic_underconstrained2.rs:14:1 + --> $DIR/generic_underconstrained2.rs:14:46 | LL | type Underconstrained2 = impl 'static; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | ^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` ... LL | 5u32 | ---- this returned value is of type `u32` diff --git a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr index f648b7bfc991..cc121ac89fb8 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr @@ -1,8 +1,8 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/issue-57611-trait-alias.rs:17:5 + --> $DIR/issue-57611-trait-alias.rs:17:16 | LL | type Bar = impl Baz; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r X) -> _` + | ^^^^^^^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r X) -> _` ... LL | |x| x | ----- found signature of `fn(_) -> _` @@ -10,10 +10,10 @@ LL | |x| x = note: the return type of a function must have a statically known size error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-57611-trait-alias.rs:21:9: 21:14] as std::ops::FnOnce<(&'r X,)>>::Output == &'r X` - --> $DIR/issue-57611-trait-alias.rs:17:5 + --> $DIR/issue-57611-trait-alias.rs:17:16 | LL | type Bar = impl Baz; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter, found concrete lifetime + | ^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter, found concrete lifetime | = note: the return type of a function must have a statically known size diff --git a/src/test/ui/type-alias-impl-trait/issue-60371.stderr b/src/test/ui/type-alias-impl-trait/issue-60371.stderr index 2796c77baa1c..bf2d612fcdb4 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60371.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-60371.stderr @@ -8,20 +8,20 @@ LL | type Item = impl Bug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0277]: the trait bound `(): Bug` is not satisfied - --> $DIR/issue-60371.rs:8:5 + --> $DIR/issue-60371.rs:8:17 | LL | type Item = impl Bug; - | ^^^^^^^^^^^^^^^^^^^^^ the trait `Bug` is not implemented for `()` + | ^^^^^^^^ the trait `Bug` is not implemented for `()` | = help: the following implementations were found: <&() as Bug> = note: the return type of a function must have a statically known size error: could not find defining uses - --> $DIR/issue-60371.rs:8:5 + --> $DIR/issue-60371.rs:8:17 | LL | type Item = impl Bug; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-impl-trait/issue-63279.stderr b/src/test/ui/type-alias-impl-trait/issue-63279.stderr index bef4d01093c6..d07f64c3312d 100644 --- a/src/test/ui/type-alias-impl-trait/issue-63279.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-63279.stderr @@ -1,10 +1,10 @@ error[E0271]: type mismatch resolving `<[closure@$DIR/issue-63279.rs:8:5: 8:28] as std::ops::FnOnce<()>>::Output == ()` - --> $DIR/issue-63279.rs:5:1 + --> $DIR/issue-63279.rs:5:16 | LL | type Closure = impl FnOnce(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found `()` + | ^^^^^^^^^^^^^ expected opaque type, found `()` | - = note: expected opaque type `Closure` + = note: expected opaque type `impl std::ops::FnOnce<()>` found unit type `()` = note: the return type of a function must have a statically known size diff --git a/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr index 70c99c944d65..4fbbf3475280 100644 --- a/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr +++ b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/never_reveal_concrete_type.rs:13:27 | LL | type NoReveal = impl std::fmt::Debug; - | ------------------------------------- the found opaque type + | -------------------- the found opaque type ... LL | let _: &'static str = x; | ------------ ^ expected `&str`, found opaque type @@ -10,9 +10,9 @@ LL | let _: &'static str = x; | expected due to this | = note: expected reference `&'static str` - found opaque type `NoReveal` + found opaque type `impl std::fmt::Debug` -error[E0605]: non-primitive cast: `NoReveal` as `&'static str` +error[E0605]: non-primitive cast: `impl std::fmt::Debug` as `&'static str` --> $DIR/never_reveal_concrete_type.rs:14:13 | LL | let _ = x as &'static str; diff --git a/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr b/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr index 444e6e8214ff..61025e846921 100644 --- a/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr +++ b/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr @@ -1,8 +1,8 @@ error: could not find defining uses - --> $DIR/no_inferrable_concrete_type.rs:6:1 + --> $DIR/no_inferrable_concrete_type.rs:6:12 | LL | type Foo = impl Copy; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr index 375c0bc7fe2e..d237cc6238ae 100644 --- a/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr +++ b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/no_revealing_outside_defining_module.rs:15:19 | LL | pub type Boo = impl ::std::fmt::Debug; - | -------------------------------------- the found opaque type + | ---------------------- the found opaque type ... LL | let _: &str = bomp(); | ---- ^^^^^^ expected `&str`, found opaque type @@ -10,20 +10,20 @@ LL | let _: &str = bomp(); | expected due to this | = note: expected reference `&str` - found opaque type `Boo` + found opaque type `impl std::fmt::Debug` error[E0308]: mismatched types --> $DIR/no_revealing_outside_defining_module.rs:19:5 | LL | pub type Boo = impl ::std::fmt::Debug; - | -------------------------------------- the expected opaque type + | ---------------------- the expected opaque type ... LL | fn bomp() -> boo::Boo { - | -------- expected `Boo` because of return type + | -------- expected `impl std::fmt::Debug` because of return type LL | "" | ^^ expected opaque type, found `&str` | - = note: expected opaque type `Boo` + = note: expected opaque type `impl std::fmt::Debug` found reference `&'static str` error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr index 02ab3399ea6f..726f4ea6e00f 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr @@ -1,8 +1,8 @@ error: could not find defining uses - --> $DIR/type-alias-impl-trait-with-cycle-error.rs:3:1 + --> $DIR/type-alias-impl-trait-with-cycle-error.rs:3:12 | LL | type Foo = impl Fn() -> Foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr index e9abb7958868..3947cc4d2705 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr @@ -1,8 +1,8 @@ error: could not find defining uses - --> $DIR/type-alias-impl-trait-with-cycle-error2.rs:7:1 + --> $DIR/type-alias-impl-trait-with-cycle-error2.rs:7:12 | LL | type Foo = impl Bar; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error