diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index f5ce02c9e618e..bb74cb2a59325 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -3049,10 +3049,17 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } &hir::TyKind::OpaqueDef(item_id, lifetimes, in_trait) => { let opaque_ty = tcx.hir().item(item_id); - let def_id = item_id.owner_id.to_def_id(); match opaque_ty.kind { hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => { + let local_def_id = item_id.owner_id.def_id; + let def_id = if in_trait + && tcx.sess.opts.unstable_opts.lower_impl_trait_in_trait_to_assoc_ty + { + tcx.associated_item_for_impl_trait_in_trait(local_def_id).to_def_id() + } else { + local_def_id.to_def_id() + }; self.impl_trait_ty_to_ty(def_id, lifetimes, origin, in_trait) } ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i), diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index b0dc6b1dcacc3..b337cf60685bc 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -831,7 +831,14 @@ impl<'tcx> TypeFolder> for ImplTraitInTraitCollector<'_, 'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { if let ty::Alias(ty::Projection, proj) = ty.kind() - && self.interner().def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder + && (self.interner().def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder + || self + .interner() + .sess + .opts + .unstable_opts + .lower_impl_trait_in_trait_to_assoc_ty + && self.interner().def_kind(proj.def_id) == DefKind::AssocTy) { if let Some((ty, _)) = self.types.get(&proj.def_id) { return *ty; @@ -1996,13 +2003,17 @@ pub(super) fn check_type_bounds<'tcx>( let infcx = tcx.infer_ctxt().build(); let ocx = ObligationCtxt::new(&infcx); - let impl_ty_span = match tcx.hir().get_by_def_id(impl_ty_def_id) { - hir::Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Type(_, Some(ty)), - .. - }) => ty.span, - hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Type(ty), .. }) => ty.span, - _ => bug!(), + let impl_ty_span = if tcx.opt_rpitit_info(impl_ty_def_id).is_some() { + tcx.def_span(impl_ty_def_id) + } else { + match tcx.hir().get_by_def_id(impl_ty_def_id) { + hir::Node::TraitItem(hir::TraitItem { + kind: hir::TraitItemKind::Type(_, Some(ty)), + .. + }) => ty.span, + hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Type(ty), .. }) => ty.span, + _ => bug!(), + } }; let assumed_wf_types = ocx.assumed_wf_types(param_env, impl_ty_span, impl_ty_def_id); diff --git a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs index 9cf3ff65a91ca..fc2eceede2a5b 100644 --- a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs +++ b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs @@ -3,7 +3,7 @@ use crate::astconv::AstConv; use rustc_hir as hir; use rustc_infer::traits::util; use rustc_middle::ty::subst::InternalSubsts; -use rustc_middle::ty::{self, DefIdTree, TyCtxt}; +use rustc_middle::ty::{self, DefIdTree, ImplTraitInTraitData, Ty, TyCtxt}; use rustc_span::def_id::DefId; use rustc_span::Span; @@ -58,17 +58,10 @@ fn opaque_type_bounds<'tcx>( tcx: TyCtxt<'tcx>, opaque_def_id: DefId, ast_bounds: &'tcx [hir::GenericBound<'tcx>], + item_ty: Ty<'tcx>, span: Span, - in_trait: bool, ) -> &'tcx [(ty::Predicate<'tcx>, Span)] { ty::print::with_no_queries!({ - let substs = InternalSubsts::identity_for_item(tcx, opaque_def_id); - let item_ty = if in_trait { - tcx.mk_projection(opaque_def_id, substs) - } else { - tcx.mk_opaque(opaque_def_id, substs) - }; - let icx = ItemCtxt::new(tcx, opaque_def_id); let mut bounds = icx.astconv().compute_bounds(item_ty, ast_bounds); // Opaque types are implicitly sized unless a `?Sized` bound is found @@ -83,7 +76,16 @@ pub(super) fn explicit_item_bounds( tcx: TyCtxt<'_>, def_id: DefId, ) -> &'_ [(ty::Predicate<'_>, Span)] { - let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); + let rpitit_info = if let Some(ImplTraitInTraitData::Trait { opaque_def_id, .. }) = + tcx.opt_rpitit_info(def_id) + { + Some(opaque_def_id) + } else { + None + }; + + let bounds_def_id = rpitit_info.unwrap_or(def_id); + let hir_id = tcx.hir().local_def_id_to_hir_id(bounds_def_id.expect_local()); match tcx.hir().get(hir_id) { hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Type(bounds, _), @@ -94,7 +96,15 @@ pub(super) fn explicit_item_bounds( kind: hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, in_trait, .. }), span, .. - }) => opaque_type_bounds(tcx, def_id, bounds, *span, *in_trait), + }) => { + let substs = InternalSubsts::identity_for_item(tcx, def_id); + let item_ty = if *in_trait && rpitit_info.is_none() { + tcx.mk_projection(def_id, substs) + } else { + tcx.mk_opaque(def_id, substs) + }; + opaque_type_bounds(tcx, bounds_def_id, bounds, item_ty, *span) + } _ => bug!("item_bounds called on {:?}", def_id), } } diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 50073d94ea5c9..6b97ec4662b26 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -9,7 +9,8 @@ use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::util::IntTypeExt; use rustc_middle::ty::{ - self, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeFolder, TypeSuperFoldable, TypeVisitableExt, + self, DefIdTree, ImplTraitInTraitData, IsSuggestable, Ty, TyCtxt, TypeFolder, + TypeSuperFoldable, TypeVisitableExt, }; use rustc_span::symbol::Ident; use rustc_span::{Span, DUMMY_SP}; @@ -244,6 +245,21 @@ fn get_path_containing_arg_in_pat<'hir>( } pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder> { + if let Some(ImplTraitInTraitData::Impl { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) { + match tcx.collect_return_position_impl_trait_in_trait_tys(fn_def_id) { + Ok(map) => { + let assoc_item = tcx.associated_item(def_id); + return ty::EarlyBinder(map[&assoc_item.trait_item_def_id.unwrap()]); + } + Err(_) => { + return ty::EarlyBinder(tcx.ty_error_with_message( + DUMMY_SP, + "Could not collect return position impl trait in trait tys", + )); + } + } + } + let def_id = def_id.expect_local(); use rustc_hir::*; diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 51feae3cf8a61..8cbc8aafd247a 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1324,6 +1324,7 @@ rustc_queries! { /// might want to use `reveal_all()` method to change modes. query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> { desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) } + feedable } /// Like `param_env`, but returns the `ParamEnv` in `Reveal::All` mode. diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index e2f858a34b6f8..57755231e2a3e 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -243,6 +243,11 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { continue; } + if self.tcx.opt_rpitit_info(id).is_some() { + self.live_symbols.insert(id); + continue; + } + // in the case of tuple struct constructors we want to check the item, not the generated // tuple struct constructor function let id = self.struct_constructors.get(&id).copied().unwrap_or(id); diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index 0648784b26570..ab923c91759aa 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -302,9 +302,6 @@ fn associated_item_for_impl_trait_in_trait( // There are no inferred outlives for the synthesized associated type. trait_assoc_ty.inferred_outlives_of(&[]); - // FIXME implement this. - trait_assoc_ty.explicit_item_bounds(&[]); - local_def_id } @@ -316,11 +313,12 @@ fn impl_associated_item_for_impl_trait_in_trait( trait_assoc_def_id: LocalDefId, impl_fn_def_id: LocalDefId, ) -> LocalDefId { - let impl_def_id = tcx.local_parent(impl_fn_def_id); + let impl_def_id = tcx.parent(impl_fn_def_id.to_def_id()); // FIXME fix the span, we probably want the def_id of the return type of the function let span = tcx.def_span(impl_fn_def_id); - let impl_assoc_ty = tcx.at(span).create_def(impl_def_id, DefPathData::ImplTraitAssocTy); + let impl_assoc_ty = + tcx.at(span).create_def(impl_def_id.expect_local(), DefPathData::ImplTraitAssocTy); let local_def_id = impl_assoc_ty.def_id(); let def_id = local_def_id.to_def_id(); @@ -345,13 +343,51 @@ fn impl_associated_item_for_impl_trait_in_trait( fn_has_self_parameter: false, }); + impl_assoc_ty.param_env(tcx.param_env(impl_fn_def_id)); + // Copy impl_defaultness of the containing function. impl_assoc_ty.impl_defaultness(tcx.impl_defaultness(impl_fn_def_id)); - // Copy generics_of the trait's associated item. - // FIXME: This is not correct, in particular the parent is going to be wrong. So we would need - // to copy from trait_assoc_def_id and adjust things. - impl_assoc_ty.generics_of(tcx.generics_of(trait_assoc_def_id).clone()); + // Copy generics_of the trait's associated item but the impl as the parent. + impl_assoc_ty.generics_of({ + let trait_assoc_generics = tcx.generics_of(trait_assoc_def_id); + let trait_assoc_parent_count = trait_assoc_generics.parent_count; + let mut params = trait_assoc_generics.params.clone(); + + let parent_generics = tcx.generics_of(impl_def_id); + let parent_count = parent_generics.parent_count + parent_generics.params.len(); + + let mut impl_fn_params = tcx.generics_of(impl_fn_def_id).params.clone(); + + for param in &mut params { + param.index = param.index + parent_count as u32 + impl_fn_params.len() as u32 + - trait_assoc_parent_count as u32; + } + + impl_fn_params.extend(params); + params = impl_fn_params; + + let param_def_id_to_index = + params.iter().map(|param| (param.def_id, param.index)).collect(); + + ty::Generics { + parent: Some(impl_def_id), + parent_count, + params, + param_def_id_to_index, + has_self: false, + has_late_bound_regions: trait_assoc_generics.has_late_bound_regions, + } + }); + + // There are no predicates for the synthesized associated type. + impl_assoc_ty.explicit_predicates_of(ty::GenericPredicates { + parent: Some(impl_def_id), + predicates: &[], + }); + + // There are no inferred outlives for the synthesized associated type. + impl_assoc_ty.inferred_outlives_of(&[]); local_def_id } diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 18159778a8e39..5a339c4429990 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -3,8 +3,8 @@ use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_index::bit_set::BitSet; use rustc_middle::ty::{ - self, Binder, EarlyBinder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt, - TypeSuperVisitable, TypeVisitable, TypeVisitor, + self, Binder, EarlyBinder, ImplTraitInTraitData, Predicate, PredicateKind, ToPredicate, Ty, + TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, }; use rustc_session::config::TraitSolver; use rustc_span::def_id::{DefId, CRATE_DEF_ID}; @@ -117,6 +117,13 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> &[Ty<'_>] { /// See `ParamEnv` struct definition for details. fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { + let def_id = + if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) { + fn_def_id + } else { + def_id + }; + // Compute the bounds on Self and the type parameters. let ty::InstantiatedPredicates { mut predicates, .. } = tcx.predicates_of(def_id).instantiate_identity(tcx); diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 7fe2e6257d9e7..9694a15bd5ec0 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -123,6 +123,7 @@ pub enum FailMode { pub enum CompareMode { Polonius, Chalk, + LowerImplTraitInTraitToAssocTy, NextSolver, SplitDwarf, SplitDwarfSingle, @@ -133,6 +134,7 @@ impl CompareMode { match *self { CompareMode::Polonius => "polonius", CompareMode::Chalk => "chalk", + CompareMode::LowerImplTraitInTraitToAssocTy => "lower-impl-trait-in-trait-to-assoc-ty", CompareMode::NextSolver => "next-solver", CompareMode::SplitDwarf => "split-dwarf", CompareMode::SplitDwarfSingle => "split-dwarf-single", @@ -143,6 +145,7 @@ impl CompareMode { match s.as_str() { "polonius" => CompareMode::Polonius, "chalk" => CompareMode::Chalk, + "lower-impl-trait-in-trait-to-assoc-ty" => CompareMode::LowerImplTraitInTraitToAssocTy, "next-solver" => CompareMode::NextSolver, "split-dwarf" => CompareMode::SplitDwarf, "split-dwarf-single" => CompareMode::SplitDwarfSingle, diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index d9b39927ca4bc..17c40da138d39 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -710,6 +710,7 @@ impl Config { match self.compare_mode { Some(CompareMode::Polonius) => name == "compare-mode-polonius", Some(CompareMode::Chalk) => name == "compare-mode-chalk", + Some(CompareMode::LowerImplTraitInTraitToAssocTy) => name == "compare-mode-lower-impl-trait-in-trait-to-assoc-ty", Some(CompareMode::NextSolver) => name == "compare-mode-next-solver", Some(CompareMode::SplitDwarf) => name == "compare-mode-split-dwarf", Some(CompareMode::SplitDwarfSingle) => name == "compare-mode-split-dwarf-single", diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 41c23ff86b25e..36d8b027c514f 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2030,6 +2030,9 @@ impl<'test> TestCx<'test> { Some(CompareMode::Chalk) => { rustc.args(&["-Ztrait-solver=chalk"]); } + Some(CompareMode::LowerImplTraitInTraitToAssocTy) => { + rustc.args(&["-Zlower-impl-trait-in-trait-to-assoc-ty"]); + } Some(CompareMode::NextSolver) => { rustc.args(&["-Ztrait-solver=next"]); } diff --git a/tests/ui/async-await/async-trait-fn.rs b/tests/ui/async-await/async-trait-fn.rs index e2062e82725c0..54e210003d016 100644 --- a/tests/ui/async-await/async-trait-fn.rs +++ b/tests/ui/async-await/async-trait-fn.rs @@ -1,3 +1,4 @@ +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty // edition:2018 trait T { async fn foo() {} //~ ERROR functions in traits cannot be declared `async` diff --git a/tests/ui/async-await/async-trait-fn.stderr b/tests/ui/async-await/async-trait-fn.stderr index afbe25cf7ab74..68ebe3507ac35 100644 --- a/tests/ui/async-await/async-trait-fn.stderr +++ b/tests/ui/async-await/async-trait-fn.stderr @@ -1,5 +1,5 @@ error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:3:5 + --> $DIR/async-trait-fn.rs:4:5 | LL | async fn foo() {} | -----^^^^^^^^^ @@ -12,7 +12,7 @@ LL | async fn foo() {} = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:4:5 + --> $DIR/async-trait-fn.rs:5:5 | LL | async fn bar(&self) {} | -----^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | async fn bar(&self) {} = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:5:5 + --> $DIR/async-trait-fn.rs:6:5 | LL | async fn baz() { | -----^^^^^^^^^ diff --git a/tests/ui/async-await/edition-deny-async-fns-2015.rs b/tests/ui/async-await/edition-deny-async-fns-2015.rs index 6bd6d879a4ace..f2c749b918904 100644 --- a/tests/ui/async-await/edition-deny-async-fns-2015.rs +++ b/tests/ui/async-await/edition-deny-async-fns-2015.rs @@ -1,4 +1,5 @@ // edition:2015 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 diff --git a/tests/ui/async-await/edition-deny-async-fns-2015.stderr b/tests/ui/async-await/edition-deny-async-fns-2015.stderr index ba918eb28def1..bd6f7d4761851 100644 --- a/tests/ui/async-await/edition-deny-async-fns-2015.stderr +++ b/tests/ui/async-await/edition-deny-async-fns-2015.stderr @@ -1,5 +1,5 @@ error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:3:1 + --> $DIR/edition-deny-async-fns-2015.rs:4:1 | LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -8,7 +8,7 @@ LL | async fn foo() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:5:12 + --> $DIR/edition-deny-async-fns-2015.rs:6:12 | LL | fn baz() { async fn foo() {} } | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -17,7 +17,7 @@ LL | fn baz() { async fn foo() {} } = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:7:1 + --> $DIR/edition-deny-async-fns-2015.rs:8:1 | LL | async fn async_baz() { | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -26,7 +26,7 @@ LL | async fn async_baz() { = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:8:5 + --> $DIR/edition-deny-async-fns-2015.rs:9:5 | LL | async fn bar() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -35,7 +35,7 @@ LL | async fn bar() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:14:5 + --> $DIR/edition-deny-async-fns-2015.rs:15:5 | LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -44,7 +44,7 @@ LL | async fn foo() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:18:5 + --> $DIR/edition-deny-async-fns-2015.rs:19:5 | LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -53,7 +53,7 @@ LL | async fn foo() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:36:9 + --> $DIR/edition-deny-async-fns-2015.rs:37:9 | LL | async fn bar() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -62,7 +62,7 @@ LL | async fn bar() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:26:9 + --> $DIR/edition-deny-async-fns-2015.rs:27:9 | LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -71,7 +71,7 @@ LL | async fn foo() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:31:13 + --> $DIR/edition-deny-async-fns-2015.rs:32:13 | LL | async fn bar() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -80,7 +80,7 @@ LL | async fn bar() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0706]: functions in traits cannot be declared `async` - --> $DIR/edition-deny-async-fns-2015.rs:18:5 + --> $DIR/edition-deny-async-fns-2015.rs:19:5 | LL | async fn foo() {} | -----^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs index 0fd1a2703db99..f58bfef656e80 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs @@ -1,5 +1,6 @@ // run-pass // edition:2021 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(async_fn_in_trait)] //~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.stderr b/tests/ui/async-await/in-trait/async-default-fn-overridden.stderr index 61a826258d09f..2c2cf5ef65530 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.stderr +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/async-default-fn-overridden.rs:4:12 + --> $DIR/async-default-fn-overridden.rs:5:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs index a73d55adfeced..036c5451af541 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs @@ -1,6 +1,7 @@ // check-fail // known-bug: #102682 // edition: 2021 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr index f1f0d7e5907d3..18d6e6242f31b 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr @@ -1,33 +1,33 @@ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:13:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ | note: the parameter type `U` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics-and-bounds.rs:12:18 + --> $DIR/async-generics-and-bounds.rs:13:18 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:13:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:13:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics-and-bounds.rs:12:18 + --> $DIR/async-generics-and-bounds.rs:13:18 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:13:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-generics.rs b/tests/ui/async-await/in-trait/async-generics.rs index 67000e5770ee8..8411ac2bd05fa 100644 --- a/tests/ui/async-await/in-trait/async-generics.rs +++ b/tests/ui/async-await/in-trait/async-generics.rs @@ -1,6 +1,7 @@ // check-fail // known-bug: #102682 // edition: 2021 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-generics.stderr b/tests/ui/async-await/in-trait/async-generics.stderr index 2f05564564cd2..c8046287d538b 100644 --- a/tests/ui/async-await/in-trait/async-generics.stderr +++ b/tests/ui/async-await/in-trait/async-generics.stderr @@ -1,33 +1,33 @@ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:10:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ | note: the parameter type `U` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics.rs:9:18 + --> $DIR/async-generics.rs:10:18 | LL | async fn foo(&self) -> &(T, U); | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:10:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:10:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics.rs:9:18 + --> $DIR/async-generics.rs:10:18 | LL | async fn foo(&self) -> &(T, U); | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:10:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..d3265f93df82a --- /dev/null +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,81 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/dont-project-to-specializable-projection.rs:4:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/dont-project-to-specializable-projection.rs:14:35 + | +LL | default async fn foo(_: T) -> &'static str { + | ^^^^^^^^^^^^ expected associated type, found future + | +note: type in trait + --> $DIR/dont-project-to-specializable-projection.rs:10:27 + | +LL | async fn foo(_: T) -> &'static str; + | ^^^^^^^^^^^^ + = note: expected signature `fn(_) -> MyTrait::{opaque#0}` + found signature `fn(_) -> impl Future` + +error[E0277]: the size for values of type `MyTrait::{opaque#0}` cannot be known at compilation time + --> $DIR/dont-project-to-specializable-projection.rs:33:37 + | +LL | >::foo(x).await + | --------------------------------^^^^^^ doesn't have a size known at compile-time + | | + | this call returns `MyTrait::{opaque#0}` + | + = help: the trait `Sized` is not implemented for `MyTrait::{opaque#0}` + = note: required for `MyTrait::{opaque#0}` to implement `IntoFuture` +help: remove the `.await` + | +LL - >::foo(x).await +LL + >::foo(x) + | +help: consider further restricting the associated type + | +LL | async fn indirection(x: T) -> &'static str where MyTrait::{opaque#0}: Sized { + | +++++++++++++++++++++++++++++++++++ + +error[E0277]: `MyTrait::{opaque#0}` is not a future + --> $DIR/dont-project-to-specializable-projection.rs:33:37 + | +LL | >::foo(x).await + | --------------------------------^^^^^^ `MyTrait::{opaque#0}` is not a future + | | + | this call returns `MyTrait::{opaque#0}` + | + = help: the trait `Future` is not implemented for `MyTrait::{opaque#0}` + = note: MyTrait::{opaque#0} must be a future or must implement `IntoFuture` to be awaited + = note: required for `MyTrait::{opaque#0}` to implement `IntoFuture` +help: remove the `.await` + | +LL - >::foo(x).await +LL + >::foo(x) + | +help: consider further restricting the associated type + | +LL | async fn indirection(x: T) -> &'static str where MyTrait::{opaque#0}: Future { + | ++++++++++++++++++++++++++++++++++++ + +error[E0277]: the size for values of type `MyTrait::{opaque#0}` cannot be known at compilation time + --> $DIR/dont-project-to-specializable-projection.rs:33:5 + | +LL | >::foo(x).await + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `MyTrait::{opaque#0}` + = note: the return type of a function must have a statically known size +help: consider further restricting the associated type + | +LL | async fn indirection(x: T) -> &'static str where MyTrait::{opaque#0}: Sized { + | +++++++++++++++++++++++++++++++++++ + +error: aborting due to 4 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0053, E0277. +For more information about an error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/issue-102310.rs b/tests/ui/async-await/in-trait/issue-102310.rs index 49c3e9feeb4c4..fe0be77861a12 100644 --- a/tests/ui/async-await/in-trait/issue-102310.rs +++ b/tests/ui/async-await/in-trait/issue-102310.rs @@ -1,5 +1,6 @@ // check-pass // edition:2021 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/issue-104678.rs b/tests/ui/async-await/in-trait/issue-104678.rs index e396df4e5d119..fa649949ea01a 100644 --- a/tests/ui/async-await/in-trait/issue-104678.rs +++ b/tests/ui/async-await/in-trait/issue-104678.rs @@ -1,5 +1,6 @@ // edition:2021 // check-pass +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.rs b/tests/ui/async-await/in-trait/lifetime-mismatch.rs index 45ede193c0fc6..2fd6fa7c8f70d 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.rs +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.rs @@ -1,4 +1,5 @@ // edition:2021 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(async_fn_in_trait)] //~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.stderr index d87adcc78b6c8..68dfb377cc582 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.stderr +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/lifetime-mismatch.rs:3:12 + --> $DIR/lifetime-mismatch.rs:4:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(async_fn_in_trait)] = note: `#[warn(incomplete_features)]` on by default error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration - --> $DIR/lifetime-mismatch.rs:12:17 + --> $DIR/lifetime-mismatch.rs:13:17 | LL | async fn foo<'a>(&self); | ---- lifetimes in impl do not match this method in trait diff --git a/tests/ui/async-await/in-trait/missing-send-bound.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/async-await/in-trait/missing-send-bound.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..1773dc64a487e --- /dev/null +++ b/tests/ui/async-await/in-trait/missing-send-bound.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,66 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/missing-send-bound.rs:3:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: the size for values of type `Foo::{opaque#0}` cannot be known at compilation time + --> $DIR/missing-send-bound.rs:11:13 + | +LL | T::bar().await; + | --------^^^^^^ doesn't have a size known at compile-time + | | + | this call returns `Foo::{opaque#0}` + | + = help: the trait `Sized` is not implemented for `Foo::{opaque#0}` + = note: required for `Foo::{opaque#0}` to implement `IntoFuture` +help: remove the `.await` + | +LL - T::bar().await; +LL + T::bar(); + | +help: consider further restricting the associated type + | +LL | async fn test() where Foo::{opaque#0}: Sized { + | ++++++++++++++++++++++++++++ + +error[E0277]: `Foo::{opaque#0}` is not a future + --> $DIR/missing-send-bound.rs:11:13 + | +LL | T::bar().await; + | --------^^^^^^ `Foo::{opaque#0}` is not a future + | | + | this call returns `Foo::{opaque#0}` + | + = help: the trait `Future` is not implemented for `Foo::{opaque#0}` + = note: Foo::{opaque#0} must be a future or must implement `IntoFuture` to be awaited + = note: required for `Foo::{opaque#0}` to implement `IntoFuture` +help: remove the `.await` + | +LL - T::bar().await; +LL + T::bar(); + | +help: consider further restricting the associated type + | +LL | async fn test() where Foo::{opaque#0}: Future { + | +++++++++++++++++++++++++++++ + +error[E0277]: the size for values of type `Foo::{opaque#0}` cannot be known at compilation time + --> $DIR/missing-send-bound.rs:11:5 + | +LL | T::bar().await; + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `Foo::{opaque#0}` + = note: the return type of a function must have a statically known size +help: consider further restricting the associated type + | +LL | async fn test() where Foo::{opaque#0}: Sized { + | ++++++++++++++++++++++++++++ + +error: aborting due to 3 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/in-trait/nested-rpit.rs b/tests/ui/async-await/in-trait/nested-rpit.rs index 41d72ebb4d4c5..69ab3398623f9 100644 --- a/tests/ui/async-await/in-trait/nested-rpit.rs +++ b/tests/ui/async-await/in-trait/nested-rpit.rs @@ -2,6 +2,7 @@ // known-bug: #105197 // failure-status:101 // dont-check-compiler-stderr +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/object-safety.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/async-await/in-trait/object-safety.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..d4472697aafd5 --- /dev/null +++ b/tests/ui/async-await/in-trait/object-safety.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,40 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/object-safety.rs:3:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0191]: the value of the associated type `` (from trait `Foo`) must be specified + --> $DIR/object-safety.rs:11:17 + | +LL | async fn foo(&self); + | - `` defined here +... +LL | let x: &dyn Foo = todo!(); + | ^^^ help: specify the associated type: `Foo< = Type>` + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety.rs:11:12 + | +LL | let x: &dyn Foo = todo!(); + | ^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/object-safety.rs:7:14 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | async fn foo(&self); + | ^^^ ^ ...because it contains the generic associated type `` + | | + | ...because method `foo` is `async` + = help: consider moving `foo` to another trait + = help: consider moving `` to another trait + +error: aborting due to 2 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0038, E0191. +For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.rs b/tests/ui/async-await/in-trait/return-type-suggestion.rs index 3446761d119da..4d15e75024fb7 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.rs +++ b/tests/ui/async-await/in-trait/return-type-suggestion.rs @@ -1,4 +1,5 @@ // edition: 2021 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(async_fn_in_trait)] //~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.stderr index b8d83d0f28a31..799686539dcd5 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.stderr +++ b/tests/ui/async-await/in-trait/return-type-suggestion.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/return-type-suggestion.rs:3:12 + --> $DIR/return-type-suggestion.rs:4:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(async_fn_in_trait)] = note: `#[warn(incomplete_features)]` on by default error[E0308]: mismatched types - --> $DIR/return-type-suggestion.rs:8:9 + --> $DIR/return-type-suggestion.rs:9:9 | LL | Ok(()) | ^^^^^^- help: consider using a semicolon here: `;` diff --git a/tests/ui/crate-loading/crateresolve1.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/crate-loading/crateresolve1.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..490f0bc09e4c1 --- /dev/null +++ b/tests/ui/crate-loading/crateresolve1.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,13 @@ +error[E0464]: multiple candidates for `rlib` dependency `crateresolve1` found + --> $DIR/crateresolve1.rs:11:1 + | +LL | extern crate crateresolve1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: candidate #1: $TEST_BUILD_DIR/crate-loading/crateresolve1.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve1-1.somelib + = note: candidate #2: $TEST_BUILD_DIR/crate-loading/crateresolve1.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve1-2.somelib + = note: candidate #3: $TEST_BUILD_DIR/crate-loading/crateresolve1.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve1-3.somelib + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0464`. diff --git a/tests/ui/crate-loading/crateresolve2.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/crate-loading/crateresolve2.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..55fa1f7494294 --- /dev/null +++ b/tests/ui/crate-loading/crateresolve2.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,13 @@ +error[E0464]: multiple candidates for `rmeta` dependency `crateresolve2` found + --> $DIR/crateresolve2.rs:10:1 + | +LL | extern crate crateresolve2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: candidate #1: $TEST_BUILD_DIR/crate-loading/crateresolve2.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve2-1.rmeta + = note: candidate #2: $TEST_BUILD_DIR/crate-loading/crateresolve2.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve2-2.rmeta + = note: candidate #3: $TEST_BUILD_DIR/crate-loading/crateresolve2.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve2-3.rmeta + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0464`. diff --git a/tests/ui/diagnostic-width/E0271.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/diagnostic-width/E0271.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..af41aa1efdca4 --- /dev/null +++ b/tests/ui/diagnostic-width/E0271.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,23 @@ +error[E0271]: type mismatch resolving `>, ...>>, ...>>, ...> as Future>::Error == Foo` + --> $DIR/E0271.rs:18:5 + | +LL | / Box::new( +LL | | Ok::<_, ()>( +LL | | Err::<(), _>( +LL | | Ok::<_, ()>( +... | +LL | | ) +LL | | ) + | |_____^ type mismatch resolving `, ...>>, ...> as Future>::Error == Foo` + | +note: expected this to be `Foo` + --> $DIR/E0271.rs:8:18 + | +LL | type Error = E; + | ^ + = note: required for the cast from `Result, ...>` to the object type `dyn Future` + = note: the full name for the casted type has been written to '$TEST_BUILD_DIR/diagnostic-width/E0271.lower-impl-trait-in-trait-to-assoc-ty/E0271.long-type-hash.txt' + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/diagnostic-width/long-E0308.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/diagnostic-width/long-E0308.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..6013afda08d04 --- /dev/null +++ b/tests/ui/diagnostic-width/long-E0308.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,80 @@ +error[E0308]: mismatched types + --> $DIR/long-E0308.rs:44:9 + | +LL | let x: Atype< + | _____________- +LL | | Btype< +LL | | Ctype< +LL | | Atype< +... | +LL | | i32 +LL | | > = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok... + | | _____-___^ + | ||_____| + | | expected due to this +LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok... +LL | | Ok("") +LL | | )))))))))))))))))))))))))))))) +LL | | )))))))))))))))))))))))))))))); + | |__________________________________^ expected `Atype, ...>`, found `Result, ...>` + | + = note: expected struct `Atype, ...>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.lower-impl-trait-in-trait-to-assoc-ty/long-E0308.long-type-hash.txt' + found enum `Result, ...>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.lower-impl-trait-in-trait-to-assoc-ty/long-E0308.long-type-hash.txt' + +error[E0308]: mismatched types + --> $DIR/long-E0308.rs:57:26 + | +LL | ))))))))))))))))) == Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O... + | __________________________^ +LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(... +LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok(""))))))) +LL | | )))))))))))))))))))))))))))))) +LL | | )))))))))))))))))))))))); + | |____________________________^ expected `Option>`, found `Result, ...>` + | + = note: expected enum `Option>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.lower-impl-trait-in-trait-to-assoc-ty/long-E0308.long-type-hash.txt' + found enum `Result, ...>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.lower-impl-trait-in-trait-to-assoc-ty/long-E0308.long-type-hash.txt' + +error[E0308]: mismatched types + --> $DIR/long-E0308.rs:88:9 + | +LL | let x: Atype< + | ____________- +LL | | Btype< +LL | | Ctype< +LL | | Atype< +... | +LL | | i32 +LL | | > = (); + | | - ^^ expected `Atype, ...>`, found `()` + | |_____| + | expected due to this + | + = note: expected struct `Atype, ...>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.lower-impl-trait-in-trait-to-assoc-ty/long-E0308.long-type-hash.txt' + found unit type `()` + +error[E0308]: mismatched types + --> $DIR/long-E0308.rs:91:17 + | +LL | let _: () = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O... + | ____________--___^ + | | | + | | expected due to this +LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(... +LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok(""))))))) +LL | | )))))))))))))))))))))))))))))) +LL | | )))))))))))))))))))))))); + | |____________________________^ expected `()`, found `Result, ...>` + | + = note: expected unit type `()` + found enum `Result, ...>` + the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.lower-impl-trait-in-trait-to-assoc-ty/long-E0308.long-type-hash.txt' + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/error-codes/E0275.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/error-codes/E0275.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..9d6fb3e39a4bf --- /dev/null +++ b/tests/ui/error-codes/E0275.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,19 @@ +error[E0275]: overflow evaluating the requirement `Bar>>>>>>: Foo` + --> $DIR/E0275.rs:6:33 + | +LL | impl Foo for T where Bar: Foo {} + | ^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`E0275`) +note: required for `Bar>>>>>>>>>>>>>>>>>>>>` to implement `Foo` + --> $DIR/E0275.rs:6:9 + | +LL | impl Foo for T where Bar: Foo {} + | ^^^ ^ --- unsatisfied trait bound introduced here + = note: the full type name has been written to '$TEST_BUILD_DIR/error-codes/E0275.lower-impl-trait-in-trait-to-assoc-ty/E0275.long-type-hash.txt' + = note: 127 redundant requirements hidden + = note: required for `Bar` to implement `Foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/error-codes/E0462.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/error-codes/E0462.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..46d93795e368c --- /dev/null +++ b/tests/ui/error-codes/E0462.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,13 @@ +error[E0462]: found staticlib `found_staticlib` instead of rlib or dylib + --> $DIR/E0462.rs:7:1 + | +LL | extern crate found_staticlib; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the following crate versions were found: + crate `found_staticlib`: $TEST_BUILD_DIR/error-codes/E0462.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libfound_staticlib.somelib + = help: please recompile that crate using --crate-type lib + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0462`. diff --git a/tests/ui/error-codes/E0464.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/error-codes/E0464.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..f93cb3bf9871a --- /dev/null +++ b/tests/ui/error-codes/E0464.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,13 @@ +error[E0464]: multiple candidates for `rlib` dependency `crateresolve1` found + --> $DIR/E0464.rs:11:1 + | +LL | extern crate crateresolve1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: candidate #1: $TEST_BUILD_DIR/error-codes/E0464.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve1-1.somelib + = note: candidate #2: $TEST_BUILD_DIR/error-codes/E0464.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve1-2.somelib + = note: candidate #3: $TEST_BUILD_DIR/error-codes/E0464.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve1-3.somelib + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0464`. diff --git a/tests/ui/error-codes/E0523.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/error-codes/E0523.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..69957f2b69318 --- /dev/null +++ b/tests/ui/error-codes/E0523.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,13 @@ +error[E0464]: multiple candidates for `rlib` dependency `crateresolve1` found + --> $DIR/E0523.rs:11:1 + | +LL | extern crate crateresolve1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: candidate #1: $TEST_BUILD_DIR/error-codes/E0523.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve1-1.somelib + = note: candidate #2: $TEST_BUILD_DIR/error-codes/E0523.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve1-2.somelib + = note: candidate #3: $TEST_BUILD_DIR/error-codes/E0523.lower-impl-trait-in-trait-to-assoc-ty/auxiliary/libcrateresolve1-3.somelib + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0464`. diff --git a/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..24c1fdd71968b --- /dev/null +++ b/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/hang-on-deeply-nested-dyn.rs:12:5 + | +LL | ) -> &dyn Fn( + | ______- +LL | | &dyn Fn( +LL | | &dyn Fn( +LL | | &dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(u32))))))))), +LL | | ), +LL | | ), +LL | | ) { + | |_- expected `&dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn for<'a> Fn(&'a (dyn Fn(u32) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a)) + 'a))` because of return type +LL | f + | ^ expected `&dyn Fn(&dyn Fn(&dyn Fn(&...)))`, found `&dyn Fn(u32)` + | + = note: expected reference `&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&...)))))))))))` + the full type name has been written to '$TEST_BUILD_DIR/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.lower-impl-trait-in-trait-to-assoc-ty/hang-on-deeply-nested-dyn.long-type-hash.txt' + found reference `&dyn Fn(u32)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/higher-rank-trait-bounds/issue-30786.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/higher-rank-trait-bounds/issue-30786.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..48af88b81d7a6 --- /dev/null +++ b/tests/ui/higher-rank-trait-bounds/issue-30786.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,46 @@ +error[E0599]: the method `filterx` exists for struct `Map`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:120:22 + | +LL | pub struct Map { + | -------------------- + | | + | method `filterx` not found for this struct + | doesn't satisfy `_: StreamExt` +... +LL | let filter = map.filterx(|x: &_| true); + | ^^^^^^^ method cannot be called on `Map` due to unsatisfied trait bounds + | +note: the following trait bounds were not satisfied: + `&'a mut &Map: Stream` + `&'a mut &mut Map: Stream` + `&'a mut Map: Stream` + --> $DIR/issue-30786.rs:98:50 + | +LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} + | --------- - ^^^^^^ unsatisfied trait bound introduced here + +error[E0599]: the method `countx` exists for struct `Filter &u64 {identity::}>, [closure@issue-30786.rs:131:30]>`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:132:24 + | +LL | pub struct Filter { + | ----------------------- + | | + | method `countx` not found for this struct + | doesn't satisfy `_: StreamExt` +... +LL | let count = filter.countx(); + | ^^^^^^ method cannot be called due to unsatisfied trait bounds + | + = note: the full type name has been written to '$TEST_BUILD_DIR/higher-rank-trait-bounds/issue-30786.lower-impl-trait-in-trait-to-assoc-ty/issue-30786.long-type-hash.txt' +note: the following trait bounds were not satisfied: + `&'a mut &Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream` + `&'a mut &mut Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream` + `&'a mut Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream` + --> $DIR/issue-30786.rs:98:50 + | +LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} + | --------- - ^^^^^^ unsatisfied trait bound introduced here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs index a4d483dee7a53..ff6d0b26adb39 100644 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs @@ -1,4 +1,5 @@ // check-pass +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(return_position_impl_trait_in_trait)] //~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr index d681ecf25e8af..6a24cf89af511 100644 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr @@ -1,5 +1,5 @@ warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/box-coerce-span-in-default.rs:3:12 + --> $DIR/box-coerce-span-in-default.rs:4:12 | LL | #![feature(return_position_impl_trait_in_trait)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/deep-match-works.rs b/tests/ui/impl-trait/in-trait/deep-match-works.rs index 772da845ee1f7..a2d0e7c070e7d 100644 --- a/tests/ui/impl-trait/in-trait/deep-match-works.rs +++ b/tests/ui/impl-trait/in-trait/deep-match-works.rs @@ -1,4 +1,5 @@ // check-pass +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] @@ -10,7 +11,9 @@ trait Foo { } impl Foo for () { - fn bar() -> Wrapper { Wrapper(0) } + fn bar() -> Wrapper { + Wrapper(0) + } } fn main() {} diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs index 45ae2b8ad3a69..b997c5f2bfe19 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs @@ -1,4 +1,5 @@ // edition:2021 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![allow(incomplete_features)] #![feature(async_fn_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr index cc3bdf0e5717e..238527d0ac446 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/default-body-type-err-2.rs:8:9 + --> $DIR/default-body-type-err-2.rs:9:9 | LL | 42 | ^^- help: try using a conversion method: `.to_string()` diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..c6d20c73427fd --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,31 @@ +error[E0308]: mismatched types + --> $DIR/default-body-type-err.rs:9:9 + | +LL | fn lol(&self) -> impl Deref { + | --------------------------- expected `Foo::{opaque#0}` because of return type +LL | +LL | &1i32 + | ^^^^^ expected associated type, found `&i32` + | + = note: expected associated type `Foo::{opaque#0}` + found reference `&i32` + = help: consider constraining the associated type `Foo::{opaque#0}` to `&i32` or calling a method that returns `Foo::{opaque#0}` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + +error[E0277]: the size for values of type `Foo::{opaque#0}` cannot be known at compilation time + --> $DIR/default-body-type-err.rs:7:22 + | +LL | fn lol(&self) -> impl Deref { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `Foo::{opaque#0}` + = note: the return type of a function must have a statically known size +help: consider further restricting the associated type + | +LL | fn lol(&self) -> impl Deref where Foo::{opaque#0}: Sized { + | ++++++++++++++++++++++++++++ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs index ad3cc7c2524b9..55e7220e64d5e 100644 --- a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs +++ b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs @@ -1,5 +1,6 @@ // check-pass // edition:2021 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/default-body.rs b/tests/ui/impl-trait/in-trait/default-body.rs index b0baf5bb10dd2..c6ea22bc8ebf4 100644 --- a/tests/ui/impl-trait/in-trait/default-body.rs +++ b/tests/ui/impl-trait/in-trait/default-body.rs @@ -1,5 +1,6 @@ // check-pass // edition:2021 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.rs b/tests/ui/impl-trait/in-trait/default-method-constraint.rs index 8c50cc2958645..09f2b72c8196d 100644 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.rs +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.rs @@ -1,4 +1,5 @@ // check-pass +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty // This didn't work in the previous default RPITIT method hack attempt diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.stderr b/tests/ui/impl-trait/in-trait/default-method-constraint.stderr index 5e18605aa4cb2..01a87cf55f2e2 100644 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.stderr +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.stderr @@ -1,5 +1,5 @@ warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/default-method-constraint.rs:5:12 + --> $DIR/default-method-constraint.rs:6:12 | LL | #![feature(return_position_impl_trait_in_trait)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs b/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs index bb4e0d44f3eff..c0e4dab222152 100644 --- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs +++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs @@ -1,3 +1,5 @@ +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr index aa5492d285ed6..2d516082fbeac 100644 --- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr +++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr @@ -1,5 +1,5 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/doesnt-satisfy.rs:9:17 + --> $DIR/doesnt-satisfy.rs:11:17 | LL | fn bar() -> () {} | ^^ `()` cannot be formatted with the default formatter @@ -7,7 +7,7 @@ LL | fn bar() -> () {} = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Foo::bar::{opaque#0}` - --> $DIR/doesnt-satisfy.rs:5:22 + --> $DIR/doesnt-satisfy.rs:7:22 | LL | fn bar() -> impl std::fmt::Display; | ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::bar::{opaque#0}` diff --git a/tests/ui/impl-trait/in-trait/early.rs b/tests/ui/impl-trait/in-trait/early.rs index 9c1c2b5033904..a4e2d2aa360e1 100644 --- a/tests/ui/impl-trait/in-trait/early.rs +++ b/tests/ui/impl-trait/in-trait/early.rs @@ -1,5 +1,6 @@ // check-pass // edition:2021 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/foreign.rs b/tests/ui/impl-trait/in-trait/foreign.rs index 6341f5b428429..ea21cd9c3e071 100644 --- a/tests/ui/impl-trait/in-trait/foreign.rs +++ b/tests/ui/impl-trait/in-trait/foreign.rs @@ -1,5 +1,6 @@ // check-pass // aux-build: rpitit.rs +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty extern crate rpitit; diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.rs b/tests/ui/impl-trait/in-trait/generics-mismatch.rs index cc0fc720ebbfd..9d4752d6d0bbd 100644 --- a/tests/ui/impl-trait/in-trait/generics-mismatch.rs +++ b/tests/ui/impl-trait/in-trait/generics-mismatch.rs @@ -1,3 +1,5 @@ +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.stderr b/tests/ui/impl-trait/in-trait/generics-mismatch.stderr index cd42683e0224d..83befdd42fe26 100644 --- a/tests/ui/impl-trait/in-trait/generics-mismatch.stderr +++ b/tests/ui/impl-trait/in-trait/generics-mismatch.stderr @@ -1,5 +1,5 @@ error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters - --> $DIR/generics-mismatch.rs:11:12 + --> $DIR/generics-mismatch.rs:13:12 | LL | fn bar(&self) -> impl Sized; | - expected 0 type parameters diff --git a/tests/ui/impl-trait/in-trait/issue-102140.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/impl-trait/in-trait/issue-102140.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..a144b517b41be --- /dev/null +++ b/tests/ui/impl-trait/in-trait/issue-102140.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,12 @@ +error[E0191]: the value of the associated type `` (from trait `MyTrait`) must be specified + --> $DIR/issue-102140.rs:21:10 + | +LL | fn foo(&self) -> impl Marker + | ----------- `` defined here +... +LL | impl dyn MyTrait { + | ^^^^^^^ help: specify the associated type: `MyTrait< = Type>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0191`. diff --git a/tests/ui/impl-trait/in-trait/issue-102301.rs b/tests/ui/impl-trait/in-trait/issue-102301.rs index a93714a658ef0..4c8d1bfa0a6eb 100644 --- a/tests/ui/impl-trait/in-trait/issue-102301.rs +++ b/tests/ui/impl-trait/in-trait/issue-102301.rs @@ -1,4 +1,5 @@ // check-pass +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/issue-102571.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/impl-trait/in-trait/issue-102571.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..85f965cc33506 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/issue-102571.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/issue-102571.rs:20:9 + | +LL | let () = t.bar(); + | ^^ ------- this expression has type `Foo::{opaque#1}` + | | + | expected associated type, found `()` + | + = note: expected associated type `Foo::{opaque#1}` + found unit type `()` +help: a method is available that returns `Foo::{opaque#1}` + --> $DIR/issue-102571.rs:8:5 + | +LL | fn bar(self) -> impl Deref; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider calling `Foo::bar` +help: consider constraining the associated type `Foo::{opaque#1}` to `()` + | +LL | fn foo>(t: T) { + | +++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..0a1d0a5e44067 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,83 @@ +error[E0053]: method `owo` has an incompatible type for trait + --> $DIR/method-signature-matches.rs:11:15 + | +LL | fn owo(_: u8) {} + | ^^ + | | + | expected `()`, found `u8` + | help: change the parameter type to match the trait: `()` + | +note: type in trait + --> $DIR/method-signature-matches.rs:7:15 + | +LL | fn owo(x: ()) -> impl Sized; + | ^^ + = note: expected signature `fn(())` + found signature `fn(u8)` + +error[E0053]: method `owo` has an incompatible type for trait + --> $DIR/method-signature-matches.rs:20:21 + | +LL | async fn owo(_: u8) {} + | ^^ + | | + | expected `()`, found `u8` + | help: change the parameter type to match the trait: `()` + | +note: type in trait + --> $DIR/method-signature-matches.rs:16:21 + | +LL | async fn owo(x: ()) {} + | ^^ + = note: expected signature `fn(()) -> _` + found signature `fn(u8) -> _` + +error[E0053]: method `calm_down_please` has an incompatible type for trait + --> $DIR/method-signature-matches.rs:29:46 + | +LL | fn calm_down_please(_: (), _: (), _: ()) {} + | ^ incorrect number of function parameters + | +note: type in trait + --> $DIR/method-signature-matches.rs:25:5 + | +LL | fn calm_down_please() -> impl Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: expected signature `fn()` + found signature `fn((), (), ())` + +error[E0053]: method `come_on_a_little_more_effort` has an incompatible type for trait + --> $DIR/method-signature-matches.rs:38:39 + | +LL | fn come_on_a_little_more_effort() {} + | ^ incorrect number of function parameters + | +note: type in trait + --> $DIR/method-signature-matches.rs:34:5 + | +LL | fn come_on_a_little_more_effort(_: (), _: (), _: ()) -> impl Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: expected signature `fn((), (), ())` + found signature `fn()` + +error[E0053]: method `early` has an incompatible type for trait + --> $DIR/method-signature-matches.rs:47:27 + | +LL | fn early<'late, T>(_: &'late ()) {} + | - ^^^^^^^^^ + | | | + | | expected type parameter `T`, found `()` + | | help: change the parameter type to match the trait: `&'early T` + | this type parameter + | +note: type in trait + --> $DIR/method-signature-matches.rs:43:28 + | +LL | fn early<'early, T>(x: &'early T) -> impl Sized; + | ^^^^^^^^^ + = note: expected signature `fn(&'early T)` + found signature `fn(&())` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/nested-rpitit.rs b/tests/ui/impl-trait/in-trait/nested-rpitit.rs index 65285e3a3ccaf..0e97c57f0d520 100644 --- a/tests/ui/impl-trait/in-trait/nested-rpitit.rs +++ b/tests/ui/impl-trait/in-trait/nested-rpitit.rs @@ -1,4 +1,5 @@ // check-pass +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/new-lowering-strategy/simple-impl-trait.rs b/tests/ui/impl-trait/in-trait/new-lowering-strategy/simple-impl-trait.rs new file mode 100644 index 0000000000000..ae09d20f6f5b7 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/new-lowering-strategy/simple-impl-trait.rs @@ -0,0 +1,17 @@ +// check-pass +// compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty + +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +trait Foo { + fn foo() -> impl Sized; +} + +impl Foo for String { + fn foo() -> i32 { + 22 + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/object-safety.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/impl-trait/in-trait/object-safety.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..d401c763e04bb --- /dev/null +++ b/tests/ui/impl-trait/in-trait/object-safety.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,23 @@ +error[E0191]: the value of the associated type `` (from trait `Foo`) must be specified + --> $DIR/object-safety.rs:17:41 + | +LL | fn baz(&self) -> impl Debug; + | ---------- `` defined here +... +LL | let i = Box::new(42_u32) as Box; + | ^^^ help: specify the associated type: `Foo< = Type>` + +error[E0277]: the size for values of type `Foo::{opaque#0}` cannot be known at compilation time + --> $DIR/object-safety.rs:20:9 + | +LL | let s = i.baz(); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `Foo::{opaque#0}` + = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0191, E0277. +For more information about an error, try `rustc --explain E0191`. diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl.rs b/tests/ui/impl-trait/in-trait/opaque-in-impl.rs index 2e06629699aad..3b987abe5de24 100644 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl.rs +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl.rs @@ -1,4 +1,5 @@ // check-pass +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.rs b/tests/ui/impl-trait/in-trait/specialization-broken.rs index 2fcffdf3f9a29..46c9aa403bb55 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.rs +++ b/tests/ui/impl-trait/in-trait/specialization-broken.rs @@ -1,3 +1,5 @@ +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty + // FIXME(compiler-errors): I'm not exactly sure if this is expected to pass or not. // But we fixed an ICE anyways. diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.stderr index dc621d6b8a848..f7c3349eddf88 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.stderr +++ b/tests/ui/impl-trait/in-trait/specialization-broken.stderr @@ -1,5 +1,5 @@ error[E0053]: method `bar` has an incompatible type for trait - --> $DIR/specialization-broken.rs:16:22 + --> $DIR/specialization-broken.rs:18:22 | LL | default impl Foo for U | - this type parameter @@ -11,7 +11,7 @@ LL | fn bar(&self) -> U { | help: change the output type to match the trait: `impl Sized` | note: type in trait - --> $DIR/specialization-broken.rs:9:22 + --> $DIR/specialization-broken.rs:11:22 | LL | fn bar(&self) -> impl Sized; | ^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | fn bar(&self) -> impl Sized; found signature `fn(&U) -> U` error: method with return-position `impl Trait` in trait cannot be specialized - --> $DIR/specialization-broken.rs:16:5 + --> $DIR/specialization-broken.rs:18:5 | LL | fn bar(&self) -> U { | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/success.rs b/tests/ui/impl-trait/in-trait/success.rs index 4cbe682b46f73..96c8dfe5b803f 100644 --- a/tests/ui/impl-trait/in-trait/success.rs +++ b/tests/ui/impl-trait/in-trait/success.rs @@ -1,4 +1,5 @@ // check-pass +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs index 0bbe50ea6fd37..60ba91125c8c9 100644 --- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs +++ b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs @@ -1,3 +1,5 @@ +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr index 8ff54cad95139..1475552a9b36f 100644 --- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr +++ b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr @@ -1,5 +1,5 @@ error[E0049]: method `bar` has 0 type parameters but its trait declaration has 1 type parameter - --> $DIR/trait-more-generics-than-impl.rs:11:11 + --> $DIR/trait-more-generics-than-impl.rs:13:11 | LL | fn bar() -> impl Sized; | - expected 1 type parameter diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.rs b/tests/ui/impl-trait/in-trait/wf-bounds.rs index 2c71583b31236..9158954b3019d 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.rs +++ b/tests/ui/impl-trait/in-trait/wf-bounds.rs @@ -1,4 +1,5 @@ // issue #101663 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.stderr index 03cc4c2b93bed..339329a677025 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.stderr +++ b/tests/ui/impl-trait/in-trait/wf-bounds.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:9:22 + --> $DIR/wf-bounds.rs:10:22 | LL | fn nya() -> impl Wf>; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -9,14 +9,14 @@ note: required by a bound in `Vec` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:12:23 + --> $DIR/wf-bounds.rs:13:23 | LL | fn nya2() -> impl Wf<[u8]>; | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `Wf` - --> $DIR/wf-bounds.rs:6:10 + --> $DIR/wf-bounds.rs:7:10 | LL | trait Wf {} | ^ required by this bound in `Wf` diff --git a/tests/ui/impl-trait/in-trait/where-clause.rs b/tests/ui/impl-trait/in-trait/where-clause.rs index 87bac519cf304..87b127572cfc9 100644 --- a/tests/ui/impl-trait/in-trait/where-clause.rs +++ b/tests/ui/impl-trait/in-trait/where-clause.rs @@ -1,5 +1,6 @@ // check-pass // edition: 2021 +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/infinite/infinite-instantiation.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/infinite/infinite-instantiation.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..386077fe7ebb3 --- /dev/null +++ b/tests/ui/infinite/infinite-instantiation.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,15 @@ +error: reached the recursion limit while instantiating `function::>>>>>` + --> $DIR/infinite-instantiation.rs:22:9 + | +LL | function(counter - 1, t.to_option()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `function` defined here + --> $DIR/infinite-instantiation.rs:20:1 + | +LL | fn function(counter: usize, t: T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the full type name has been written to '$TEST_BUILD_DIR/infinite/infinite-instantiation.lower-impl-trait-in-trait-to-assoc-ty/infinite-instantiation.long-type.txt' + +error: aborting due to previous error + diff --git a/tests/ui/issues/issue-20413.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/issues/issue-20413.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..aa7f0e730aea1 --- /dev/null +++ b/tests/ui/issues/issue-20413.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,73 @@ +error[E0392]: parameter `T` is never used + --> $DIR/issue-20413.rs:6:15 + | +LL | struct NoData; + | ^ unused parameter + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `T` to be a const parameter, use `const T: usize` instead + +error[E0275]: overflow evaluating the requirement `NoData>>>>>>: Foo` + --> $DIR/issue-20413.rs:9:36 + | +LL | impl Foo for T where NoData: Foo { + | ^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) +note: required for `NoData>>>>>>>>>>>>` to implement `Foo` + --> $DIR/issue-20413.rs:9:9 + | +LL | impl Foo for T where NoData: Foo { + | ^^^ ^ --- unsatisfied trait bound introduced here + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413.lower-impl-trait-in-trait-to-assoc-ty/issue-20413.long-type-hash.txt' + = note: 127 redundant requirements hidden + = note: required for `NoData` to implement `Foo` + +error[E0275]: overflow evaluating the requirement `EvenLessData>>>>>>: Baz` + --> $DIR/issue-20413.rs:28:42 + | +LL | impl Bar for T where EvenLessData: Baz { + | ^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) +note: required for `AlmostNoData>>>>>>` to implement `Bar` + --> $DIR/issue-20413.rs:28:9 + | +LL | impl Bar for T where EvenLessData: Baz { + | ^^^ ^ --- unsatisfied trait bound introduced here + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413.lower-impl-trait-in-trait-to-assoc-ty/issue-20413.long-type-hash.txt' +note: required for `EvenLessData>>>>>>` to implement `Baz` + --> $DIR/issue-20413.rs:35:9 + | +LL | impl Baz for T where AlmostNoData: Bar { + | ^^^ ^ --- unsatisfied trait bound introduced here + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413.lower-impl-trait-in-trait-to-assoc-ty/issue-20413.long-type-hash.txt' + = note: 126 redundant requirements hidden + = note: required for `EvenLessData` to implement `Baz` + +error[E0275]: overflow evaluating the requirement `AlmostNoData>>>>>>: Bar` + --> $DIR/issue-20413.rs:35:42 + | +LL | impl Baz for T where AlmostNoData: Bar { + | ^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) +note: required for `EvenLessData>>>>>>` to implement `Baz` + --> $DIR/issue-20413.rs:35:9 + | +LL | impl Baz for T where AlmostNoData: Bar { + | ^^^ ^ --- unsatisfied trait bound introduced here + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413.lower-impl-trait-in-trait-to-assoc-ty/issue-20413.long-type-hash.txt' +note: required for `AlmostNoData>>>>>>` to implement `Bar` + --> $DIR/issue-20413.rs:28:9 + | +LL | impl Bar for T where EvenLessData: Baz { + | ^^^ ^ --- unsatisfied trait bound introduced here + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413.lower-impl-trait-in-trait-to-assoc-ty/issue-20413.long-type-hash.txt' + = note: 126 redundant requirements hidden + = note: required for `AlmostNoData` to implement `Bar` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0275, E0392. +For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/issues/issue-23122-2.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/issues/issue-23122-2.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..fae5c5599e350 --- /dev/null +++ b/tests/ui/issues/issue-23122-2.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,19 @@ +error[E0275]: overflow evaluating the requirement `<<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` + --> $DIR/issue-23122-2.rs:11:17 + | +LL | type Next = as Next>::Next; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_23122_2`) +note: required for `GetNext<<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` to implement `Next` + --> $DIR/issue-23122-2.rs:10:15 + | +LL | impl Next for GetNext { + | - ^^^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-23122-2.lower-impl-trait-in-trait-to-assoc-ty/issue-23122-2.long-type-hash.txt' + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..7e4fd89bfb627 --- /dev/null +++ b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,15 @@ +error: reached the recursion limit while instantiating `<(&(&(..., ...), ...), ...) as Foo>::recurse` + --> $DIR/issue-37311.rs:17:9 + | +LL | (self, self).recurse(); + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: `::recurse` defined here + --> $DIR/issue-37311.rs:16:5 + | +LL | fn recurse(&self) { + | ^^^^^^^^^^^^^^^^^ + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-37311-type-length-limit/issue-37311.lower-impl-trait-in-trait-to-assoc-ty/issue-37311.long-type.txt' + +error: aborting due to previous error + diff --git a/tests/ui/issues/issue-67552.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/issues/issue-67552.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..82b682b759176 --- /dev/null +++ b/tests/ui/issues/issue-67552.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,17 @@ +error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut ...>` + --> $DIR/issue-67552.rs:29:9 + | +LL | rec(identity(&mut it)) + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: `rec` defined here + --> $DIR/issue-67552.rs:22:1 + | +LL | / fn rec(mut it: T) +LL | | where +LL | | T: Iterator, + | |________________^ + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-67552.lower-impl-trait-in-trait-to-assoc-ty/issue-67552.long-type.txt' + +error: aborting due to previous error + diff --git a/tests/ui/issues/issue-8727.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/issues/issue-8727.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..2971ea53f9250 --- /dev/null +++ b/tests/ui/issues/issue-8727.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,26 @@ +warning: function cannot return without recursing + --> $DIR/issue-8727.rs:7:1 + | +LL | fn generic() { + | ^^^^^^^^^^^^^^^ cannot return without recursing +LL | generic::>(); + | ---------------------- recursive call site + | + = help: a `loop` may express intention better if this is on purpose + = note: `#[warn(unconditional_recursion)]` on by default + +error: reached the recursion limit while instantiating `generic::>>>>>` + --> $DIR/issue-8727.rs:8:5 + | +LL | generic::>(); + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: `generic` defined here + --> $DIR/issue-8727.rs:7:1 + | +LL | fn generic() { + | ^^^^^^^^^^^^^^^ + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-8727.lower-impl-trait-in-trait-to-assoc-ty/issue-8727.long-type.txt' + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/json/json-multiple.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/json/json-multiple.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..4f182ec52dd24 --- /dev/null +++ b/tests/ui/json/json-multiple.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1 @@ +{"artifact":"$TEST_BUILD_DIR/json/json-multiple.lower-impl-trait-in-trait-to-assoc-ty/libjson_multiple.rlib","emit":"link"} diff --git a/tests/ui/json/json-options.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/json/json-options.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..e291267003ec7 --- /dev/null +++ b/tests/ui/json/json-options.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1 @@ +{"artifact":"$TEST_BUILD_DIR/json/json-options.lower-impl-trait-in-trait-to-assoc-ty/libjson_options.rlib","emit":"link"} diff --git a/tests/ui/meta/meta-expected-error-wrong-rev.a.stderr b/tests/ui/meta/meta-expected-error-wrong-rev.a.stderr index 87330155eacca..012071df2bb52 100644 --- a/tests/ui/meta/meta-expected-error-wrong-rev.a.stderr +++ b/tests/ui/meta/meta-expected-error-wrong-rev.a.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/meta-expected-error-wrong-rev.rs:13:18 + --> $DIR/meta-expected-error-wrong-rev.rs:14:18 | LL | let x: u32 = 22_usize; | --- ^^^^^^^^ expected `u32`, found `usize` diff --git a/tests/ui/meta/meta-expected-error-wrong-rev.rs b/tests/ui/meta/meta-expected-error-wrong-rev.rs index c30d4fe0a13c5..be015bc55c389 100644 --- a/tests/ui/meta/meta-expected-error-wrong-rev.rs +++ b/tests/ui/meta/meta-expected-error-wrong-rev.rs @@ -1,4 +1,5 @@ // ignore-compare-mode-polonius +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty // revisions: a // should-fail @@ -13,4 +14,4 @@ fn foo() { let x: u32 = 22_usize; //[b]~ ERROR mismatched types } -fn main() { } +fn main() {} diff --git a/tests/ui/recursion/issue-83150.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/recursion/issue-83150.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..98ccd527006cf --- /dev/null +++ b/tests/ui/recursion/issue-83150.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,22 @@ +warning: function cannot return without recursing + --> $DIR/issue-83150.rs:11:1 + | +LL | fn func>(iter: &mut T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing +LL | func(&mut iter.map(|x| x + 1)) + | ------------------------------ recursive call site + | + = help: a `loop` may express intention better if this is on purpose + = note: `#[warn(unconditional_recursion)]` on by default + +error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:12:24: 12:27]>: Iterator` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`) + = note: required for `&mut Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:12:24: 12:27]>` to implement `Iterator` + = note: 65 redundant requirements hidden + = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<..., ...>, ...>, ...>, ...>, ...>, ...>, ...>` to implement `Iterator` + = note: the full type name has been written to '$TEST_BUILD_DIR/recursion/issue-83150.lower-impl-trait-in-trait-to-assoc-ty/issue-83150.long-type-hash.txt' + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/recursion/recursion.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/recursion/recursion.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..b5db6d4357fc9 --- /dev/null +++ b/tests/ui/recursion/recursion.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,15 @@ +error: reached the recursion limit while instantiating `test::>>>>>` + --> $DIR/recursion.rs:18:11 + | +LL | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `test` defined here + --> $DIR/recursion.rs:16:1 + | +LL | fn test (n:isize, i:isize, first:T, second:T) ->isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the full type name has been written to '$TEST_BUILD_DIR/recursion/recursion.lower-impl-trait-in-trait-to-assoc-ty/recursion.long-type.txt' + +error: aborting due to previous error + diff --git a/tests/ui/regions/issue-102374.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/regions/issue-102374.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..31c3c02221289 --- /dev/null +++ b/tests/ui/regions/issue-102374.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/issue-102374.rs:17:5 + | +LL | ) -> i32 { + | --- expected `i32` because of return type +LL | f + | ^ expected `i32`, found fn pointer + | + = note: expected type `i32` + found fn pointer `fn(Cell<...>)` + the full type name has been written to '$TEST_BUILD_DIR/regions/issue-102374.lower-impl-trait-in-trait-to-assoc-ty/issue-102374.long-type-hash.txt' + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfc-1937-termination-trait/issue-103052-2.rs b/tests/ui/rfc-1937-termination-trait/issue-103052-2.rs index fa9182b6deeb7..79958941b92ab 100644 --- a/tests/ui/rfc-1937-termination-trait/issue-103052-2.rs +++ b/tests/ui/rfc-1937-termination-trait/issue-103052-2.rs @@ -1,3 +1,5 @@ +// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] @@ -9,7 +11,8 @@ mod child { struct Something; impl Main for () { - fn main() -> Something { //~ ERROR the trait bound `Something: Termination` is not satisfied + fn main() -> Something { + //~^ ERROR the trait bound `Something: Termination` is not satisfied Something } } diff --git a/tests/ui/rfc-1937-termination-trait/issue-103052-2.stderr b/tests/ui/rfc-1937-termination-trait/issue-103052-2.stderr index a700c72ea689f..672a97cbdb931 100644 --- a/tests/ui/rfc-1937-termination-trait/issue-103052-2.stderr +++ b/tests/ui/rfc-1937-termination-trait/issue-103052-2.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `Something: Termination` is not satisfied - --> $DIR/issue-103052-2.rs:12:22 + --> $DIR/issue-103052-2.rs:14:22 | LL | fn main() -> Something { | ^^^^^^^^^ the trait `Termination` is not implemented for `Something` | note: required by a bound in `Main::main::{opaque#0}` - --> $DIR/issue-103052-2.rs:6:27 + --> $DIR/issue-103052-2.rs:8:27 | LL | fn main() -> impl std::process::Termination; | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::main::{opaque#0}` diff --git a/tests/ui/rmeta/emit-artifact-notifications.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/rmeta/emit-artifact-notifications.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..00737d48196c8 --- /dev/null +++ b/tests/ui/rmeta/emit-artifact-notifications.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1 @@ +{"artifact":"$TEST_BUILD_DIR/rmeta/emit-artifact-notifications.lower-impl-trait-in-trait-to-assoc-ty/libemit_artifact_notifications.rmeta","emit":"metadata"} diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/traits/issue-91949-hangs-on-recursion.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..b1827cc3bd15f --- /dev/null +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,25 @@ +warning: function cannot return without recursing + --> $DIR/issue-91949-hangs-on-recursion.rs:23:1 + | +LL | / fn recurse(elements: T) -> Vec +LL | | where +LL | | T: Iterator, + | |___________________________^ cannot return without recursing +LL | { +LL | recurse(IteratorOfWrapped(elements).map(|t| t.0)) + | ------------------------------------------------- recursive call site + | + = help: a `loop` may express intention better if this is on purpose + = note: `#[warn(unconditional_recursion)]` on by default + +error[E0275]: overflow evaluating the requirement `(): Sized` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "512"]` attribute to your crate (`issue_91949_hangs_on_recursion`) + = note: required for `std::iter::Empty<()>` to implement `Iterator` + = note: 171 redundant requirements hidden + = note: required for `IteratorOfWrapped<(), Map>, ...>>, ...>>` to implement `Iterator` + = note: the full type name has been written to '$TEST_BUILD_DIR/traits/issue-91949-hangs-on-recursion.lower-impl-trait-in-trait-to-assoc-ty/issue-91949-hangs-on-recursion.long-type-hash.txt' + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/type_length_limit.lower-impl-trait-in-trait-to-assoc-ty.stderr b/tests/ui/type_length_limit.lower-impl-trait-in-trait-to-assoc-ty.stderr new file mode 100644 index 0000000000000..640a3f8fbba07 --- /dev/null +++ b/tests/ui/type_length_limit.lower-impl-trait-in-trait-to-assoc-ty.stderr @@ -0,0 +1,8 @@ +error: reached the type-length limit while instantiating `std::mem::drop::>` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + | + = help: consider adding a `#![type_length_limit="10"]` attribute to your crate + = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit.lower-impl-trait-in-trait-to-assoc-ty/type_length_limit.long-type.txt' + +error: aborting due to previous error +