From 0daab3ad6a9c458a66df97c99b30f2b4aaa6b0b2 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Mon, 2 Mar 2026 15:29:02 +0300 Subject: [PATCH] Implement AST -> HIR generics propagation in delegation --- compiler/rustc_ast_lowering/src/delegation.rs | 147 +- .../src/delegation/generics.rs | 578 ++++++ compiler/rustc_ast_lowering/src/item.rs | 2 +- compiler/rustc_ast_lowering/src/lib.rs | 17 +- compiler/rustc_hir/src/hir.rs | 29 +- .../src/collect/generics_of.rs | 7 - compiler/rustc_hir_analysis/src/delegation.rs | 635 ++++--- .../src/hir_ty_lowering/mod.rs | 51 +- tests/pretty/delegation-inherit-attributes.pp | 2 +- tests/pretty/hir-delegation.pp | 2 +- .../delegation/generics/auxiliary/generics.rs | 7 + .../delegation/generics/free-fn-to-free-fn.rs | 4 +- .../generics/free-fn-to-free-fn.stderr | 35 +- .../generics/free-fn-to-trait-infer.rs | 20 + .../generics/free-fn-to-trait-infer.stderr | 40 + .../generics/free-fn-to-trait-method.rs | 14 - .../generics/free-fn-to-trait-method.stderr | 49 +- .../generics/generic-params-defaults.rs | 1 - .../generics/generic-params-defaults.stderr | 14 +- .../generics/generic-params-same-names.rs | 1 - .../generics/generic-params-same-names.stderr | 22 +- .../delegation/generics/generics-aux-pass.rs | 63 + .../generics/generics-gen-args-errors.rs | 12 +- .../generics/generics-gen-args-errors.stderr | 338 ++-- .../generics/impl-trait-wrong-args-count.rs | 4 +- .../impl-trait-wrong-args-count.stderr | 47 +- .../{free-to-free.rs => free-to-free-pass.rs} | 13 +- .../generics/mapping/free-to-free.stderr | 213 --- ...free-to-trait.rs => free-to-trait-pass.rs} | 24 +- .../generics/mapping/free-to-trait.stderr | 401 ----- ...-to-free.rs => impl-trait-to-free-pass.rs} | 31 +- .../mapping/impl-trait-to-free.stderr | 131 -- ...o-trait.rs => impl-trait-to-trait-pass.rs} | 14 +- .../mapping/impl-trait-to-trait.stderr | 43 - ...-free.rs => inherent-impl-to-free-pass.rs} | 20 +- .../mapping/inherent-impl-to-free.stderr | 213 --- ...rait.rs => inherent-impl-to-trait-pass.rs} | 18 +- .../mapping/inherent-impl-to-trait.stderr | 106 -- ...trait-to-free.rs => trait-to-free-pass.rs} | 12 +- .../generics/mapping/trait-to-free.stderr | 166 -- ...ait-to-trait.rs => trait-to-trait-pass.rs} | 101 +- .../generics/mapping/trait-to-trait.stderr | 1544 ----------------- 42 files changed, 1626 insertions(+), 3565 deletions(-) create mode 100644 compiler/rustc_ast_lowering/src/delegation/generics.rs create mode 100644 tests/ui/delegation/generics/auxiliary/generics.rs create mode 100644 tests/ui/delegation/generics/free-fn-to-trait-infer.rs create mode 100644 tests/ui/delegation/generics/free-fn-to-trait-infer.stderr create mode 100644 tests/ui/delegation/generics/generics-aux-pass.rs rename tests/ui/delegation/generics/mapping/{free-to-free.rs => free-to-free-pass.rs} (86%) delete mode 100644 tests/ui/delegation/generics/mapping/free-to-free.stderr rename tests/ui/delegation/generics/mapping/{free-to-trait.rs => free-to-trait-pass.rs} (76%) delete mode 100644 tests/ui/delegation/generics/mapping/free-to-trait.stderr rename tests/ui/delegation/generics/mapping/{impl-trait-to-free.rs => impl-trait-to-free-pass.rs} (88%) delete mode 100644 tests/ui/delegation/generics/mapping/impl-trait-to-free.stderr rename tests/ui/delegation/generics/mapping/{impl-trait-to-trait.rs => impl-trait-to-trait-pass.rs} (89%) delete mode 100644 tests/ui/delegation/generics/mapping/impl-trait-to-trait.stderr rename tests/ui/delegation/generics/mapping/{inherent-impl-to-free.rs => inherent-impl-to-free-pass.rs} (84%) delete mode 100644 tests/ui/delegation/generics/mapping/inherent-impl-to-free.stderr rename tests/ui/delegation/generics/mapping/{inherent-impl-to-trait.rs => inherent-impl-to-trait-pass.rs} (88%) delete mode 100644 tests/ui/delegation/generics/mapping/inherent-impl-to-trait.stderr rename tests/ui/delegation/generics/mapping/{trait-to-free.rs => trait-to-free-pass.rs} (87%) delete mode 100644 tests/ui/delegation/generics/mapping/trait-to-free.stderr rename tests/ui/delegation/generics/mapping/{trait-to-trait.rs => trait-to-trait-pass.rs} (80%) delete mode 100644 tests/ui/delegation/generics/mapping/trait-to-trait.stderr diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index f20b979588c57..1d634c03255ea 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -46,7 +46,6 @@ use rustc_ast::*; use rustc_attr_parsing::{AttributeParser, ShouldEmit}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::ErrorGuaranteed; -use rustc_hir::Target; use rustc_hir::attrs::{AttributeKind, InlineAttr}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::span_bug; @@ -56,9 +55,14 @@ use rustc_span::{DUMMY_SP, Ident, Span, Symbol}; use smallvec::SmallVec; use {rustc_ast as ast, rustc_hir as hir}; -use super::{GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode}; +use crate::delegation::generics::{GenericsGenerationResult, GenericsGenerationResults}; use crate::errors::{CycleInDelegationSignatureResolution, UnresolvedDelegationCallee}; -use crate::{AllowReturnTypeNotation, ImplTraitPosition, ResolverAstLoweringExt}; +use crate::{ + AllowReturnTypeNotation, GenericArgsMode, ImplTraitContext, ImplTraitPosition, LoweringContext, + ParamMode, ResolverAstLoweringExt, +}; + +mod generics; pub(crate) struct DelegationResults<'hir> { pub body_id: hir::BodyId, @@ -184,18 +188,48 @@ impl<'hir> LoweringContext<'_, 'hir> { // we need a function to extract this information let (param_count, c_variadic) = self.param_count(root_function_id); + let mut generics = self.lower_delegation_generics( + delegation, + ids.root_function_id(), + item_id, + span, + ); + + let body_id = self.lower_delegation_body( + delegation, + item_id, + is_method, + param_count, + &mut generics, + span, + ); + // Here we use `delegee_id`, as this id will then be used to calculate parent for generics // inheritance, and we want this id to point on a delegee, not on the original // function (see https://github.com/rust-lang/rust/issues/150152#issuecomment-3674834654) - let decl = self.lower_delegation_decl(delegee_id, param_count, c_variadic, span); + let decl = self.lower_delegation_decl( + delegee_id, + param_count, + c_variadic, + span, + &generics, + ); // Here we pass `root_function_id` as we want to inherit signature (including consts, async) // from the root function that started delegation let sig = self.lower_delegation_sig(root_function_id, decl, span); - - let body_id = self.lower_delegation_body(delegation, is_method, param_count, span); let ident = self.lower_ident(delegation.ident); - let generics = self.lower_delegation_generics(span); + + let generics = self.arena.alloc(hir::Generics { + has_where_clause_predicates: false, + params: self.arena.alloc_from_iter(generics.all_params(item_id, span, self)), + predicates: self + .arena + .alloc_from_iter(generics.all_predicates(item_id, span, self)), + span, + where_clause_span: span, + }); + DelegationResults { body_id, sig, ident, generics } } Err(err) => self.generate_delegation_error(err, span, delegation), @@ -295,7 +329,7 @@ impl<'hir> LoweringContext<'_, 'hir> { self.tcx.sess, attrs, None, - Target::Fn, + hir::Target::Fn, DUMMY_SP, DUMMY_NODE_ID, Some(self.tcx.features()), @@ -364,16 +398,6 @@ impl<'hir> LoweringContext<'_, 'hir> { self.resolver.get_partial_res(node_id).and_then(|r| r.expect_full_res().opt_def_id()) } - fn lower_delegation_generics(&mut self, span: Span) -> &'hir hir::Generics<'hir> { - self.arena.alloc(hir::Generics { - params: &[], - predicates: &[], - has_where_clause_predicates: false, - where_clause_span: span, - span, - }) - } - // Function parameter count, including C variadic `...` if present. fn param_count(&self, def_id: DefId) -> (usize, bool /*c_variadic*/) { if let Some(local_sig_id) = def_id.as_local() { @@ -393,6 +417,7 @@ impl<'hir> LoweringContext<'_, 'hir> { param_count: usize, c_variadic: bool, span: Span, + generics: &GenericsGenerationResults<'hir>, ) -> &'hir hir::FnDecl<'hir> { // The last parameter in C variadic functions is skipped in the signature, // like during regular lowering. @@ -405,7 +430,13 @@ impl<'hir> LoweringContext<'_, 'hir> { let output = self.arena.alloc(hir::Ty { hir_id: self.next_id(), - kind: hir::TyKind::InferDelegation(sig_id, hir::InferDelegationKind::Output), + kind: hir::TyKind::InferDelegation( + sig_id, + hir::InferDelegationKind::Output(self.arena.alloc(hir::DelegationGenerics { + child_args_segment_id: generics.child.args_segment_id, + parent_args_segment_id: generics.parent.args_segment_id, + })), + ), span, }); @@ -460,6 +491,7 @@ impl<'hir> LoweringContext<'_, 'hir> { abi: sig.abi, } }; + hir::FnSig { decl, header, span } } @@ -501,6 +533,7 @@ impl<'hir> LoweringContext<'_, 'hir> { } else { Symbol::intern(&format!("arg{idx}")) }; + let segments = self.arena.alloc_from_iter(iter::once(hir::PathSegment { ident: Ident::with_dummy_span(name), hir_id: self.next_id(), @@ -516,8 +549,10 @@ impl<'hir> LoweringContext<'_, 'hir> { fn lower_delegation_body( &mut self, delegation: &Delegation, + item_id: NodeId, is_method: bool, param_count: usize, + generics: &mut GenericsGenerationResults<'hir>, span: Span, ) -> BodyId { let block = delegation.body.as_deref(); @@ -548,7 +583,8 @@ impl<'hir> LoweringContext<'_, 'hir> { args.push(arg); } - let final_expr = this.finalize_body_lowering(delegation, args, span); + let final_expr = this.finalize_body_lowering(delegation, item_id, args, generics, span); + (this.arena.alloc_from_iter(parameters), final_expr) }) } @@ -584,7 +620,9 @@ impl<'hir> LoweringContext<'_, 'hir> { fn finalize_body_lowering( &mut self, delegation: &Delegation, + item_id: NodeId, args: Vec>, + generics: &mut GenericsGenerationResults<'hir>, span: Span, ) -> hir::Expr<'hir> { let args = self.arena.alloc_from_iter(args); @@ -609,6 +647,10 @@ impl<'hir> LoweringContext<'_, 'hir> { ImplTraitContext::Disallowed(ImplTraitPosition::Path), None, ); + + // FIXME(fn_delegation): proper support for parent generics propagation + // in method call scenario. + let segment = self.process_segment(item_id, span, &segment, &mut generics.child, false); let segment = self.arena.alloc(segment); self.arena.alloc(hir::Expr { @@ -627,9 +669,41 @@ impl<'hir> LoweringContext<'_, 'hir> { None, ); - let callee_path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(path), span)); + let new_path = match path { + hir::QPath::Resolved(ty, path) => { + let mut new_path = path.clone(); + let len = new_path.segments.len(); + + new_path.segments = self.arena.alloc_from_iter( + new_path.segments.iter().enumerate().map(|(idx, segment)| { + let mut process_segment = |result, add_lifetimes| { + self.process_segment(item_id, span, segment, result, add_lifetimes) + }; + + if idx + 2 == len { + process_segment(&mut generics.parent, true) + } else if idx + 1 == len { + process_segment(&mut generics.child, false) + } else { + segment.clone() + } + }), + ); + + hir::QPath::Resolved(ty, self.arena.alloc(new_path)) + } + hir::QPath::TypeRelative(ty, segment) => { + let segment = + self.process_segment(item_id, span, segment, &mut generics.child, false); + + hir::QPath::TypeRelative(ty, self.arena.alloc(segment)) + } + }; + + let callee_path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(new_path), span)); self.arena.alloc(self.mk_expr(hir::ExprKind::Call(callee_path, args), span)) }; + let block = self.arena.alloc(hir::Block { stmts: &[], expr: Some(call), @@ -642,14 +716,40 @@ impl<'hir> LoweringContext<'_, 'hir> { self.mk_expr(hir::ExprKind::Block(block, None), span) } + fn process_segment( + &mut self, + item_id: NodeId, + span: Span, + segment: &hir::PathSegment<'hir>, + result: &mut GenericsGenerationResult<'hir>, + add_lifetimes: bool, + ) -> hir::PathSegment<'hir> { + // The first condition is needed when there is SelfAndUserSpecified case, + // we don't want to propagate generics params in this situation. + let segment = if !result.generics.is_user_specified() + && let Some(args) = result + .generics + .into_hir_generics(self, item_id, span) + .into_generic_args(self, add_lifetimes, span) + { + hir::PathSegment { args: Some(args), ..segment.clone() } + } else { + segment.clone() + }; + + if result.generics.is_user_specified() { + result.args_segment_id = Some(segment.hir_id); + } + + segment + } + fn generate_delegation_error( &mut self, err: ErrorGuaranteed, span: Span, delegation: &Delegation, ) -> DelegationResults<'hir> { - let generics = self.lower_delegation_generics(span); - let decl = self.arena.alloc(hir::FnDecl { inputs: &[], output: hir::FnRetTy::DefaultReturn(span), @@ -696,6 +796,7 @@ impl<'hir> LoweringContext<'_, 'hir> { (&[], this.mk_expr(body_expr, span)) }); + let generics = hir::Generics::empty(); DelegationResults { ident, generics, body_id, sig } } diff --git a/compiler/rustc_ast_lowering/src/delegation/generics.rs b/compiler/rustc_ast_lowering/src/delegation/generics.rs new file mode 100644 index 0000000000000..9e7ec04d38fb7 --- /dev/null +++ b/compiler/rustc_ast_lowering/src/delegation/generics.rs @@ -0,0 +1,578 @@ +use hir::HirId; +use hir::def::{DefKind, Res}; +use rustc_ast::*; +use rustc_hir as hir; +use rustc_hir::def_id::DefId; +use rustc_middle::ty::GenericParamDefKind; +use rustc_middle::{bug, ty}; +use rustc_span::sym::{self}; +use rustc_span::symbol::kw; +use rustc_span::{DUMMY_SP, Ident, Span}; +use thin_vec::{ThinVec, thin_vec}; + +use crate::{AstOwner, LoweringContext}; + +pub(super) enum DelegationGenerics { + /// User-specified args are present: `reuse foo::;`. + UserSpecified, + /// The default case when no user-specified args are present: `reuse Trait::foo;`. + Default(Option), + /// In free-to-trait reuse, when user specified args for trait `reuse Trait::::foo;` + /// in this case we need to both generate `Self` and process user args. + SelfAndUserSpecified(Option), +} + +/// Used for storing either AST generics or their lowered HIR version. Firstly we obtain +/// AST generics either from local function from AST index or from external function +/// through `tcx`. Next, at some point of generics processing we need to lower those +/// generics to HIR, for this purpose we use `into_hir_generics` that lowers AST generics +/// and replaces Ast variant with Hir. Such approach is useful as we can call this method +/// at any time knowing that lowering will occur at most only once. Then, in order to obtain generic +/// params or args we use `hir_generics_or_empty` or `into_generic_args` functions. +/// There also may be situations when we obtained AST generics but never lowered them to HIR, +/// meaning we did not propagate them and thus we do not need to generate generic params +/// (i.e., method call scenarios), in such a case this approach helps +/// a lot as if `into_hir_generics` will not be called then lowering will not happen. +pub(super) enum HirOrAstGenerics<'hir> { + Ast(DelegationGenerics), + Hir(DelegationGenerics<&'hir hir::Generics<'hir>>), +} + +pub(super) struct GenericsGenerationResult<'hir> { + pub(super) generics: HirOrAstGenerics<'hir>, + pub(super) args_segment_id: Option, +} + +pub(super) struct GenericsGenerationResults<'hir> { + pub(super) parent: GenericsGenerationResult<'hir>, + pub(super) child: GenericsGenerationResult<'hir>, +} + +impl DelegationGenerics { + fn is_user_specified(&self) -> bool { + matches!( + self, + DelegationGenerics::UserSpecified | DelegationGenerics::SelfAndUserSpecified { .. } + ) + } +} + +impl<'hir> HirOrAstGenerics<'hir> { + pub(super) fn into_hir_generics( + &mut self, + ctx: &mut LoweringContext<'_, 'hir>, + item_id: NodeId, + span: Span, + ) -> &mut HirOrAstGenerics<'hir> { + if let HirOrAstGenerics::Ast(generics) = self { + let process_params = |generics: &mut Generics| { + ctx.lower_delegation_generic_params(item_id, span, &mut generics.params) + }; + + let hir_generics = match generics { + DelegationGenerics::UserSpecified => DelegationGenerics::UserSpecified, + DelegationGenerics::Default(generics) => { + DelegationGenerics::Default(generics.as_mut().map(process_params)) + } + DelegationGenerics::SelfAndUserSpecified(generics) => { + DelegationGenerics::SelfAndUserSpecified(generics.as_mut().map(process_params)) + } + }; + + *self = HirOrAstGenerics::Hir(hir_generics); + } + + self + } + + fn hir_generics_or_empty(&self) -> &'hir hir::Generics<'hir> { + match self { + HirOrAstGenerics::Ast(_) => hir::Generics::empty(), + HirOrAstGenerics::Hir(hir_generics) => match hir_generics { + DelegationGenerics::UserSpecified => hir::Generics::empty(), + DelegationGenerics::Default(generics) + | DelegationGenerics::SelfAndUserSpecified(generics) => { + generics.unwrap_or(hir::Generics::empty()) + } + }, + } + } + + pub(super) fn into_generic_args( + &self, + ctx: &mut LoweringContext<'_, 'hir>, + add_lifetimes: bool, + span: Span, + ) -> Option<&'hir hir::GenericArgs<'hir>> { + match self { + HirOrAstGenerics::Ast(_) => { + bug!("Attempting to get generic args before lowering to HIR") + } + HirOrAstGenerics::Hir(hir_generics) => match hir_generics { + DelegationGenerics::UserSpecified => None, + DelegationGenerics::Default(generics) + | DelegationGenerics::SelfAndUserSpecified(generics) => generics.map(|generics| { + ctx.create_generics_args_from_params(generics.params, add_lifetimes, span) + }), + }, + } + } + + pub(super) fn is_user_specified(&self) -> bool { + match self { + HirOrAstGenerics::Ast(ast_generics) => ast_generics.is_user_specified(), + HirOrAstGenerics::Hir(hir_generics) => hir_generics.is_user_specified(), + } + } +} + +impl<'a> GenericsGenerationResult<'a> { + fn new(generics: DelegationGenerics) -> GenericsGenerationResult<'a> { + GenericsGenerationResult { + generics: HirOrAstGenerics::Ast(generics), + args_segment_id: None, + } + } +} + +impl<'hir> GenericsGenerationResults<'hir> { + pub(super) fn all_params( + &mut self, + item_id: NodeId, + span: Span, + ctx: &mut LoweringContext<'_, 'hir>, + ) -> impl Iterator> { + // Now we always call `into_hir_generics` both on child and parent, + // however in future we would not do that, when scenarios like + // method call will be supported (if HIR generics were not obtained + // then it means that we did not propagated them, thus we do not need + // to generate params). + let parent = self + .parent + .generics + .into_hir_generics(ctx, item_id, span) + .hir_generics_or_empty() + .params; + + let child = self + .child + .generics + .into_hir_generics(ctx, item_id, span) + .hir_generics_or_empty() + .params; + + // Order generics, firstly we have parent and child lifetimes, + // then parent and child types and consts. + // `generics_of` in `rustc_hir_analysis` will order them anyway, + // however we want the order to be consistent in HIR too. + parent + .iter() + .filter(|p| p.is_lifetime()) + .chain(child.iter().filter(|p| p.is_lifetime())) + .chain(parent.iter().filter(|p| !p.is_lifetime())) + .chain(child.iter().filter(|p| !p.is_lifetime())) + .copied() + } + + /// As we add hack predicates(`'a: 'a`) for all lifetimes (see `lower_delegation_generic_params` + /// and `generate_lifetime_predicate` functions) we need to add them to delegation generics. + /// Those predicates will not affect resulting predicate inheritance and folding + /// in `rustc_hir_analysis`, as we inherit all predicates from delegation signature. + pub(super) fn all_predicates( + &mut self, + item_id: NodeId, + span: Span, + ctx: &mut LoweringContext<'_, 'hir>, + ) -> impl Iterator> { + // Now we always call `into_hir_generics` both on child and parent, + // however in future we would not do that, when scenarios like + // method call will be supported (if HIR generics were not obtained + // then it means that we did not propagated them, thus we do not need + // to generate predicates). + self.parent + .generics + .into_hir_generics(ctx, item_id, span) + .hir_generics_or_empty() + .predicates + .into_iter() + .chain( + self.child + .generics + .into_hir_generics(ctx, item_id, span) + .hir_generics_or_empty() + .predicates + .into_iter(), + ) + .copied() + } +} + +impl<'hir> LoweringContext<'_, 'hir> { + pub(super) fn lower_delegation_generics( + &mut self, + delegation: &Delegation, + root_fn_id: DefId, + item_id: NodeId, + span: Span, + ) -> GenericsGenerationResults<'hir> { + let delegation_in_free_ctx = !matches!( + self.tcx.def_kind(self.tcx.local_parent(self.local_def_id(item_id))), + DefKind::Trait | DefKind::Impl { .. } + ); + + let root_function_in_trait = + matches!(self.tcx.def_kind(self.tcx.parent(root_fn_id)), DefKind::Trait); + + let generate_self = delegation_in_free_ctx && root_function_in_trait; + + let parent_generics_factory = |this: &mut Self, user_specified: bool| { + this.get_parent_generics( + this.tcx.parent(root_fn_id), + generate_self, + user_specified, + span, + ) + }; + + let segments = &delegation.path.segments; + let len = segments.len(); + + let can_add_generics_to_parent = len >= 2 + && self.get_resolution_id(segments[len - 2].id).is_some_and(|def_id| { + matches!(self.tcx.def_kind(def_id), DefKind::Trait | DefKind::TraitAlias) + }); + + let parent_generics = if can_add_generics_to_parent { + if segments[len - 2].args.is_some() { + if generate_self { + DelegationGenerics::SelfAndUserSpecified(parent_generics_factory(self, true)) + } else { + DelegationGenerics::UserSpecified + } + } else { + DelegationGenerics::Default(parent_generics_factory(self, false)) + } + } else { + DelegationGenerics::Default(None) + }; + + let child_generics = if segments[len - 1].args.is_some() { + DelegationGenerics::UserSpecified + } else { + DelegationGenerics::Default(self.get_fn_like_generics(root_fn_id, span)) + }; + + GenericsGenerationResults { + parent: GenericsGenerationResult::new(parent_generics), + child: GenericsGenerationResult::new(child_generics), + } + } + + fn lower_delegation_generic_params( + &mut self, + item_id: NodeId, + span: Span, + params: &mut ThinVec, + ) -> &'hir hir::Generics<'hir> { + for p in params.iter_mut() { + // We want to create completely new params, so we generate + // a new id, otherwise assertions will be triggered. + p.id = self.next_node_id(); + + // Remove default params, as they are not supported on functions + // and there will duplicate DefId when we try to lower them later. + match &mut p.kind { + GenericParamKind::Lifetime => {} + GenericParamKind::Type { default } => *default = None, + GenericParamKind::Const { default, .. } => *default = None, + } + + // Note that we use self.disambiguator here, if we will create new every time + // we will get ICE if params have the same name. + self.resolver.node_id_to_def_id.insert( + p.id, + self.tcx + .create_def( + self.resolver.node_id_to_def_id[&item_id], + Some(p.ident.name), + match p.kind { + GenericParamKind::Lifetime => DefKind::LifetimeParam, + GenericParamKind::Type { .. } => DefKind::TyParam, + GenericParamKind::Const { .. } => DefKind::ConstParam, + }, + None, + &mut self.disambiguator, + ) + .def_id(), + ); + } + + // Fallback to default generic param lowering, we modified them in the loop above. + let params = self.arena.alloc_from_iter( + params.iter().map(|p| self.lower_generic_param(p, hir::GenericParamSource::Generics)), + ); + + // HACK: for now we generate predicates such that all lifetimes are early bound, + // we can not not generate early-bound lifetimes, but we can't know which of them + // are late-bound at this level of compilation. + // FIXME(fn_delegation): proper support for late bound lifetimes. + self.arena.alloc(hir::Generics { + params, + predicates: self.arena.alloc_from_iter( + params + .iter() + .filter_map(|p| p.is_lifetime().then(|| self.generate_lifetime_predicate(p))), + ), + has_where_clause_predicates: false, + where_clause_span: span, + span, + }) + } + + fn generate_lifetime_predicate( + &mut self, + p: &hir::GenericParam<'hir>, + ) -> hir::WherePredicate<'hir> { + let create_lifetime = |this: &mut Self| -> &'hir hir::Lifetime { + this.arena.alloc(hir::Lifetime { + hir_id: this.next_id(), + ident: p.name.ident(), + kind: rustc_hir::LifetimeKind::Param(p.def_id), + source: rustc_hir::LifetimeSource::Path { + angle_brackets: rustc_hir::AngleBrackets::Full, + }, + syntax: rustc_hir::LifetimeSyntax::ExplicitBound, + }) + }; + + hir::WherePredicate { + hir_id: self.next_id(), + span: DUMMY_SP, + kind: self.arena.alloc(hir::WherePredicateKind::RegionPredicate( + hir::WhereRegionPredicate { + in_where_clause: true, + lifetime: create_lifetime(self), + bounds: self + .arena + .alloc_slice(&[hir::GenericBound::Outlives(create_lifetime(self))]), + }, + )), + } + } + + fn create_generics_args_from_params( + &mut self, + params: &[hir::GenericParam<'hir>], + add_lifetimes: bool, + span: Span, + ) -> &'hir hir::GenericArgs<'hir> { + self.arena.alloc(hir::GenericArgs { + args: self.arena.alloc_from_iter(params.iter().filter_map(|p| { + // Skip self generic arg, we do not need to propagate it. + if p.name.ident().name == kw::SelfUpper { + return None; + } + + let create_path = |this: &mut Self| { + let res = Res::Def( + match p.kind { + hir::GenericParamKind::Lifetime { .. } => DefKind::LifetimeParam, + hir::GenericParamKind::Type { .. } => DefKind::TyParam, + hir::GenericParamKind::Const { .. } => DefKind::ConstParam, + }, + p.def_id.to_def_id(), + ); + + hir::QPath::Resolved( + None, + self.arena.alloc(hir::Path { + segments: this.arena.alloc_slice(&[hir::PathSegment { + args: None, + hir_id: this.next_id(), + ident: p.name.ident(), + infer_args: false, + res, + }]), + res, + span: p.span, + }), + ) + }; + + match p.kind { + hir::GenericParamKind::Lifetime { .. } => match add_lifetimes { + true => Some(hir::GenericArg::Lifetime(self.arena.alloc(hir::Lifetime { + hir_id: self.next_id(), + ident: p.name.ident(), + kind: hir::LifetimeKind::Param(p.def_id), + source: hir::LifetimeSource::Path { + angle_brackets: hir::AngleBrackets::Full, + }, + syntax: hir::LifetimeSyntax::ExplicitBound, + }))), + false => None, + }, + hir::GenericParamKind::Type { .. } => { + Some(hir::GenericArg::Type(self.arena.alloc(hir::Ty { + hir_id: self.next_id(), + span: p.span, + kind: hir::TyKind::Path(create_path(self)), + }))) + } + hir::GenericParamKind::Const { .. } => { + Some(hir::GenericArg::Const(self.arena.alloc(hir::ConstArg { + hir_id: self.next_id(), + kind: hir::ConstArgKind::Path(create_path(self)), + span: p.span, + }))) + } + } + })), + constraints: &[], + parenthesized: hir::GenericArgsParentheses::No, + span_ext: span, + }) + } + + fn get_fn_like_generics(&mut self, id: DefId, span: Span) -> Option { + if let Some(local_id) = id.as_local() { + match self.ast_index.get(local_id) { + Some(AstOwner::Item(item)) if let ItemKind::Fn(f) = &item.kind => { + Some(f.generics.clone()) + } + Some(AstOwner::AssocItem(item, _)) if let AssocItemKind::Fn(f) = &item.kind => { + Some(f.generics.clone()) + } + _ => None, + } + } else { + self.get_external_generics(id, false, span) + } + } + + fn get_external_generics( + &mut self, + id: DefId, + processing_parent: bool, + span: Span, + ) -> Option { + let generics = self.tcx.generics_of(id); + if generics.own_params.is_empty() { + return None; + } + + // Skip first Self parameter if we are in trait, it will be added later. + let to_skip = (processing_parent && generics.has_self) as usize; + + Some(Generics { + params: generics + .own_params + .iter() + .skip(to_skip) + .map(|p| GenericParam { + attrs: Default::default(), + bounds: Default::default(), + colon_span: None, + id: self.next_node_id(), + ident: Ident::with_dummy_span(p.name), + is_placeholder: false, + kind: match p.kind { + GenericParamDefKind::Lifetime => GenericParamKind::Lifetime, + GenericParamDefKind::Type { .. } => { + GenericParamKind::Type { default: None } + } + GenericParamDefKind::Const { .. } => self.map_const_kind(p, span), + }, + }) + .collect(), + where_clause: Default::default(), + span: DUMMY_SP, + }) + } + + fn map_const_kind(&mut self, p: &ty::GenericParamDef, span: Span) -> GenericParamKind { + let const_type = self.tcx.type_of(p.def_id).instantiate_identity(); + + let (type_symbol, res) = match const_type.kind() { + ty::Bool => (sym::bool, Res::PrimTy(hir::PrimTy::Bool)), + ty::Uint(uint) => (uint.name(), Res::PrimTy(hir::PrimTy::Uint(*uint))), + ty::Int(int) => (int.name(), Res::PrimTy(hir::PrimTy::Int(*int))), + ty::Char => (sym::char, Res::PrimTy(hir::PrimTy::Char)), + _ => { + self.tcx + .dcx() + .span_delayed_bug(span, format!("Unexpected const type: {}", const_type)); + + (sym::dummy, Res::Err) + } + }; + + let node_id = self.next_node_id(); + + self.resolver.partial_res_map.insert(node_id, hir::def::PartialRes::new(res)); + + GenericParamKind::Const { + ty: Box::new(Ty { + id: node_id, + kind: TyKind::Path( + None, + Path { + segments: thin_vec![PathSegment { + ident: Ident::with_dummy_span(type_symbol), + id: self.next_node_id(), + args: None + }], + span: DUMMY_SP, + tokens: None, + }, + ), + span: DUMMY_SP, + tokens: None, + }), + span: DUMMY_SP, + default: None, + } + } + + fn get_parent_generics( + &mut self, + id: DefId, + add_self: bool, + user_specified: bool, + span: Span, + ) -> Option { + // If args are user-specified we still maybe need to add self. + let mut generics = if user_specified { + None + } else { + if let Some(local_id) = id.as_local() { + if let Some(AstOwner::Item(item)) = self.ast_index.get(local_id) + && matches!(item.kind, ItemKind::Trait(..)) + { + item.opt_generics().cloned() + } else { + None + } + } else { + self.get_external_generics(id, true, span) + } + }; + + if add_self { + generics.get_or_insert_default().params.insert( + 0, + GenericParam { + id: self.next_node_id(), + ident: Ident::new(kw::SelfUpper, DUMMY_SP), + attrs: Default::default(), + bounds: vec![], + is_placeholder: false, + kind: GenericParamKind::Type { default: None }, + colon_span: None, + }, + ); + } + + generics + } +} diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index d56a75097acd4..d853a5d0558e1 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -57,7 +57,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> { owner: NodeId, f: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::OwnerNode<'hir>, ) { - let mut lctx = LoweringContext::new(self.tcx, self.resolver); + let mut lctx = LoweringContext::new(self.tcx, self.ast_index, self.resolver); lctx.with_hir_id_owner(owner, |lctx| f(lctx)); for (def_id, info) in lctx.children { diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 24a7215ddb385..5dea3c1014ed3 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -33,6 +33,7 @@ // tidy-alphabetical-start #![cfg_attr(bootstrap, feature(if_let_guard))] #![feature(box_patterns)] +#![recursion_limit = "256"] // tidy-alphabetical-end use std::mem; @@ -89,6 +90,15 @@ pub mod stability; struct LoweringContext<'a, 'hir> { tcx: TyCtxt<'hir>, + + // During lowering of delegation we need to access AST of other functions + // in order to properly propagate generics, we could have done it at resolve + // stage, however it will require either to firstly identify functions that + // are being reused and store their generics, or to store generics of all functions + // in resolver. This approach helps with those problems, as functions that are reused + // will be in AST index. + ast_index: &'a IndexSlice>, + resolver: &'a mut ResolverAstLowering, disambiguator: DisambiguatorState, @@ -149,11 +159,16 @@ struct LoweringContext<'a, 'hir> { } impl<'a, 'hir> LoweringContext<'a, 'hir> { - fn new(tcx: TyCtxt<'hir>, resolver: &'a mut ResolverAstLowering) -> Self { + fn new( + tcx: TyCtxt<'hir>, + ast_index: &'a IndexSlice>, + resolver: &'a mut ResolverAstLowering, + ) -> Self { let registered_tools = tcx.registered_tools(()).iter().map(|x| x.name).collect(); Self { // Pseudo-globals. tcx, + ast_index, resolver, disambiguator: DisambiguatorState::new(), arena: tcx.hir_arena, diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 960fd206041a8..469a745d1e454 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -861,6 +861,10 @@ impl<'hir> GenericParam<'hir> { pub fn is_elided_lifetime(&self) -> bool { matches!(self.kind, GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) }) } + + pub fn is_lifetime(&self) -> bool { + matches!(self.kind, GenericParamKind::Lifetime { .. }) + } } /// Records where the generic parameter originated from. @@ -3753,10 +3757,18 @@ pub enum OpaqueTyOrigin { }, } +// Ids of parent (or child) path segment that contains user-specified args +#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable_Generic)] +pub struct DelegationGenerics { + pub parent_args_segment_id: Option, + pub child_args_segment_id: Option, +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable_Generic)] -pub enum InferDelegationKind { +pub enum InferDelegationKind<'hir> { Input(usize), - Output, + // Place generics info here, as we always specify output type for delegations. + Output(&'hir DelegationGenerics), } /// The various kinds of types recognized by the compiler. @@ -3768,7 +3780,7 @@ pub enum InferDelegationKind { #[derive(Debug, Clone, Copy, HashStable_Generic)] pub enum TyKind<'hir, Unambig = ()> { /// Actual type should be inherited from `DefId` signature - InferDelegation(DefId, InferDelegationKind), + InferDelegation(DefId, InferDelegationKind<'hir>), /// A variable length slice (i.e., `[T]`). Slice(&'hir Ty<'hir>), /// A fixed length array (i.e., `[T; n]`). @@ -3921,6 +3933,17 @@ impl<'hir> FnDecl<'hir> { } None } + + pub fn opt_delegation_generics(&self) -> Option<&'hir DelegationGenerics> { + if let FnRetTy::Return(ty) = self.output + && let TyKind::InferDelegation(_, kind) = ty.kind + && let InferDelegationKind::Output(generics) = kind + { + return Some(generics); + } + + None + } } /// Represents what type of implicit self a function has, if any. diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index 0723418d8ddfe..b4c264c3a2364 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -11,7 +11,6 @@ use rustc_session::lint; use rustc_span::{Span, Symbol, kw}; use tracing::{debug, instrument}; -use crate::delegation::inherit_generics_for_delegation_item; use crate::middle::resolve_bound_vars as rbv; #[instrument(level = "debug", skip(tcx), ret)] @@ -56,13 +55,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { } let hir_id = tcx.local_def_id_to_hir_id(def_id); - let node = tcx.hir_node(hir_id); - if let Some(sig) = node.fn_sig() - && let Some(sig_id) = sig.decl.opt_delegation_sig_id() - { - return inherit_generics_for_delegation_item(tcx, def_id, sig_id); - } let parent_def_id = match node { Node::ImplItem(_) diff --git a/compiler/rustc_hir_analysis/src/delegation.rs b/compiler/rustc_hir_analysis/src/delegation.rs index f64341d755f8c..b1c03b824866e 100644 --- a/compiler/rustc_hir_analysis/src/delegation.rs +++ b/compiler/rustc_hir_analysis/src/delegation.rs @@ -6,10 +6,14 @@ use rustc_data_structures::debug_assert_matches; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; +use rustc_hir::{HirId, PathSegment}; use rustc_middle::ty::{ - self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, + self, EarlyBinder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, }; -use rustc_span::{ErrorGuaranteed, Span}; +use rustc_span::{ErrorGuaranteed, Span, kw}; + +use crate::collect::ItemCtxt; +use crate::hir_ty_lowering::{GenericArgPosition, HirTyLowerer}; type RemapTable = FxHashMap; @@ -59,6 +63,25 @@ impl<'tcx> TypeFolder> for ParamIndexRemapper<'tcx> { } } +enum SelfPositionKind { + AfterLifetimes, + Zero, + None, +} + +fn create_self_position_kind(caller_kind: FnKind, callee_kind: FnKind) -> SelfPositionKind { + match (caller_kind, callee_kind) { + (FnKind::AssocInherentImpl, FnKind::AssocTrait) + | (FnKind::AssocTraitImpl, FnKind::AssocTrait) + | (FnKind::AssocTrait, FnKind::AssocTrait) + | (FnKind::AssocTrait, FnKind::Free) => SelfPositionKind::Zero, + + (FnKind::Free, FnKind::AssocTrait) => SelfPositionKind::AfterLifetimes, + + _ => SelfPositionKind::None, + } +} + #[derive(Clone, Copy, Debug, PartialEq)] enum FnKind { Free, @@ -67,7 +90,9 @@ enum FnKind { AssocTraitImpl, } -fn fn_kind<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> FnKind { +fn fn_kind<'tcx>(tcx: TyCtxt<'tcx>, def_id: impl Into) -> FnKind { + let def_id = def_id.into(); + debug_assert_matches!(tcx.def_kind(def_id), DefKind::Fn | DefKind::AssocFn); let parent = tcx.parent(def_id); @@ -99,197 +124,109 @@ enum InheritanceKind { Own, } -fn build_generics<'tcx>( +/// Maps sig generics into generic args of delegation. Delegation generics has the following pattern: +/// +/// [SELF | maybe self in the beginning] +/// [PARENT | args of delegation parent] +/// [SIG PARENT LIFETIMES] +/// [SIG LIFETIMES] +/// [SELF | maybe self after lifetimes, when we reuse trait fn in free context] +/// [SIG PARENT TYPES/CONSTS] +/// [SIG TYPES/CONSTS] +fn create_mapping<'tcx>( tcx: TyCtxt<'tcx>, sig_id: DefId, - parent: Option, - inh_kind: InheritanceKind, -) -> ty::Generics { - let mut own_params = vec![]; + def_id: LocalDefId, + args: &[ty::GenericArg<'tcx>], +) -> FxHashMap { + let mut mapping: FxHashMap = Default::default(); + + let (caller_kind, callee_kind) = (fn_kind(tcx, def_id), fn_kind(tcx, sig_id)); + let self_pos_kind = create_self_position_kind(caller_kind, callee_kind); + let is_self_at_zero = matches!(self_pos_kind, SelfPositionKind::Zero); + + // Is self at zero? If so insert mapping, self in sig parent is always at 0. + if is_self_at_zero { + mapping.insert(0, 0); + } + + let mut args_index = 0; + + args_index += is_self_at_zero as usize; + args_index += get_delegation_parent_args_count_without_self(tcx, def_id, sig_id); let sig_generics = tcx.generics_of(sig_id); - if let InheritanceKind::WithParent(has_self) = inh_kind - && let Some(parent_def_id) = sig_generics.parent - { - let sig_parent_generics = tcx.generics_of(parent_def_id); - own_params.append(&mut sig_parent_generics.own_params.clone()); - if !has_self { - own_params.remove(0); + let process_sig_parent_generics = matches!(callee_kind, FnKind::AssocTrait); + + if process_sig_parent_generics { + for i in (sig_generics.has_self as usize)..sig_generics.parent_count { + let param = sig_generics.param_at(i, tcx); + if !param.kind.is_ty_or_const() { + mapping.insert(param.index, args_index as u32); + args_index += 1; + } } } - own_params.append(&mut sig_generics.own_params.clone()); - - // Lifetime parameters must be declared before type and const parameters. - // Therefore, When delegating from a free function to a associated function, - // generic parameters need to be reordered: - // - // trait Trait<'a, A> { - // fn foo<'b, B>(...) {...} - // } - // - // reuse Trait::foo; - // desugaring: - // fn foo<'a, 'b, This: Trait<'a, A>, A, B>(...) { - // Trait::foo(...) - // } - own_params.sort_by_key(|key| key.kind.is_ty_or_const()); - - let (parent_count, has_self) = if let Some(def_id) = parent { - let parent_generics = tcx.generics_of(def_id); - let parent_kind = tcx.def_kind(def_id); - (parent_generics.count(), parent_kind == DefKind::Trait) - } else { - (0, false) - }; - for (idx, param) in own_params.iter_mut().enumerate() { - param.index = (idx + parent_count) as u32; - // FIXME(fn_delegation): Default parameters are not inherited, because they are - // not permitted in functions. Therefore, there are 2 options here: - // - // - We can create non-default generic parameters. - // - We can substitute default parameters into the signature. - // - // At the moment, first option has been selected as the most general. - if let ty::GenericParamDefKind::Type { has_default, .. } - | ty::GenericParamDefKind::Const { has_default, .. } = &mut param.kind - { - *has_default = false; + for param in &sig_generics.own_params { + if !param.kind.is_ty_or_const() { + mapping.insert(param.index, args_index as u32); + args_index += 1; } } - let param_def_id_to_index = - own_params.iter().map(|param| (param.def_id, param.index)).collect(); - - ty::Generics { - parent, - parent_count, - own_params, - param_def_id_to_index, - has_self, - has_late_bound_regions: sig_generics.has_late_bound_regions, + // If there are still unmapped lifetimes left and we are to map types and maybe self + // then skip them, now it is the case when we generated more lifetimes then needed. + // FIXME(fn_delegation): proper support for late bound lifetimes. + while args_index < args.len() && args[args_index].as_region().is_some() { + args_index += 1; } -} -fn build_predicates<'tcx>( - tcx: TyCtxt<'tcx>, - sig_id: DefId, - parent: Option, - inh_kind: InheritanceKind, - args: ty::GenericArgsRef<'tcx>, -) -> ty::GenericPredicates<'tcx> { - struct PredicatesCollector<'tcx> { - tcx: TyCtxt<'tcx>, - preds: Vec<(ty::Clause<'tcx>, Span)>, - args: ty::GenericArgsRef<'tcx>, + // If self after lifetimes insert mapping, relying that self is at 0 in sig parent. + if matches!(self_pos_kind, SelfPositionKind::AfterLifetimes) { + mapping.insert(0, args_index as u32); + args_index += 1; } - impl<'tcx> PredicatesCollector<'tcx> { - fn new(tcx: TyCtxt<'tcx>, args: ty::GenericArgsRef<'tcx>) -> PredicatesCollector<'tcx> { - PredicatesCollector { tcx, preds: vec![], args } - } - - fn with_own_preds( - mut self, - f: impl Fn(DefId) -> ty::GenericPredicates<'tcx>, - def_id: DefId, - ) -> Self { - let preds = f(def_id).instantiate_own(self.tcx, self.args); - self.preds.extend(preds); - self - } - - fn with_preds( - mut self, - f: impl Fn(DefId) -> ty::GenericPredicates<'tcx> + Copy, - def_id: DefId, - ) -> Self { - let preds = f(def_id); - if let Some(parent_def_id) = preds.parent { - self = self.with_own_preds(f, parent_def_id); + if process_sig_parent_generics { + for i in (sig_generics.has_self as usize)..sig_generics.parent_count { + let param = sig_generics.param_at(i, tcx); + if param.kind.is_ty_or_const() { + mapping.insert(param.index, args_index as u32); + args_index += 1; } - self.with_own_preds(f, def_id) } } - let collector = PredicatesCollector::new(tcx, args); - // `explicit_predicates_of` is used here to avoid copying `Self: Trait` predicate. - // Note: `predicates_of` query can also add inferred outlives predicates, but that - // is not the case here as `sig_id` is either a trait or a function. - let preds = match inh_kind { - InheritanceKind::WithParent(false) => { - collector.with_preds(|def_id| tcx.explicit_predicates_of(def_id), sig_id) - } - InheritanceKind::WithParent(true) => { - collector.with_preds(|def_id| tcx.predicates_of(def_id), sig_id) - } - InheritanceKind::Own => { - collector.with_own_preds(|def_id| tcx.predicates_of(def_id), sig_id) + for param in &sig_generics.own_params { + if param.kind.is_ty_or_const() { + mapping.insert(param.index, args_index as u32); + args_index += 1; } } - .preds; - ty::GenericPredicates { parent, predicates: tcx.arena.alloc_from_iter(preds) } + mapping } -fn build_generic_args<'tcx>( +fn get_delegation_parent_args_count_without_self<'tcx>( tcx: TyCtxt<'tcx>, + delegation_id: LocalDefId, sig_id: DefId, - def_id: LocalDefId, - args: ty::GenericArgsRef<'tcx>, -) -> ty::GenericArgsRef<'tcx> { - let caller_generics = tcx.generics_of(def_id); - let callee_generics = tcx.generics_of(sig_id); - - let mut remap_table = FxHashMap::default(); - for caller_param in &caller_generics.own_params { - let callee_index = callee_generics.param_def_id_to_index(tcx, caller_param.def_id).unwrap(); - remap_table.insert(callee_index, caller_param.index); - } +) -> usize { + let delegation_parent_args_count = tcx.generics_of(delegation_id).parent_count; - let mut folder = ParamIndexRemapper { tcx, remap_table }; - args.fold_with(&mut folder) -} - -fn create_generic_args<'tcx>( - tcx: TyCtxt<'tcx>, - def_id: LocalDefId, - sig_id: DefId, -) -> ty::GenericArgsRef<'tcx> { - let caller_kind = fn_kind(tcx, def_id.into()); - let callee_kind = fn_kind(tcx, sig_id); - match (caller_kind, callee_kind) { + match (fn_kind(tcx, delegation_id), fn_kind(tcx, sig_id)) { (FnKind::Free, FnKind::Free) | (FnKind::Free, FnKind::AssocTrait) - | (FnKind::AssocInherentImpl, FnKind::Free) - | (FnKind::AssocTrait, FnKind::Free) - | (FnKind::AssocTrait, FnKind::AssocTrait) => { - let args = ty::GenericArgs::identity_for_item(tcx, sig_id); - build_generic_args(tcx, sig_id, def_id, args) - } - - (FnKind::AssocTraitImpl, FnKind::AssocTrait) => { - let callee_generics = tcx.generics_of(sig_id); - let parent = tcx.parent(def_id.into()); - let parent_args = tcx.impl_trait_header(parent).trait_ref.instantiate_identity().args; - - let trait_args = ty::GenericArgs::identity_for_item(tcx, sig_id); - let method_args = tcx.mk_args(&trait_args[callee_generics.parent_count..]); - let method_args = build_generic_args(tcx, sig_id, def_id, method_args); + | (FnKind::AssocTraitImpl, FnKind::AssocTrait) => 0, - tcx.mk_args_from_iter(parent_args.iter().chain(method_args)) + (FnKind::AssocInherentImpl, FnKind::Free) + | (FnKind::AssocInherentImpl, FnKind::AssocTrait) => { + delegation_parent_args_count /* No Self in AssocInherentImpl */ } - (FnKind::AssocInherentImpl, FnKind::AssocTrait) => { - let parent = tcx.parent(def_id.into()); - let self_ty = tcx.type_of(parent).instantiate_identity(); - let generic_self_ty = ty::GenericArg::from(self_ty); - - let trait_args = ty::GenericArgs::identity_for_item(tcx, sig_id); - let trait_args = build_generic_args(tcx, sig_id, def_id, trait_args); - - let args = std::iter::once(generic_self_ty).chain(trait_args.iter().skip(1)); - tcx.mk_args_from_iter(args) + (FnKind::AssocTrait, FnKind::Free) | (FnKind::AssocTrait, FnKind::AssocTrait) => { + delegation_parent_args_count - 1 /* Without Self */ } // For trait impl's `sig_id` is always equal to the corresponding trait method. @@ -300,42 +237,26 @@ fn create_generic_args<'tcx>( } } -// FIXME(fn_delegation): Move generics inheritance to the AST->HIR lowering. -// For now, generic parameters are not propagated to the generated call, -// which leads to inference errors: -// -// fn foo(x: i32) {} -// -// reuse foo as bar; -// desugaring: -// fn bar() { -// foo::<_>() // ERROR: type annotations needed -// } -pub(crate) fn inherit_generics_for_delegation_item<'tcx>( +fn get_parent_and_inheritance_kind<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, sig_id: DefId, -) -> ty::Generics { - let caller_kind = fn_kind(tcx, def_id.into()); - let callee_kind = fn_kind(tcx, sig_id); - match (caller_kind, callee_kind) { +) -> (Option, InheritanceKind) { + match (fn_kind(tcx, def_id), fn_kind(tcx, sig_id)) { (FnKind::Free, FnKind::Free) | (FnKind::Free, FnKind::AssocTrait) => { - build_generics(tcx, sig_id, None, InheritanceKind::WithParent(true)) + (None, InheritanceKind::WithParent(true)) } (FnKind::AssocTraitImpl, FnKind::AssocTrait) => { - build_generics(tcx, sig_id, Some(tcx.parent(def_id.into())), InheritanceKind::Own) + (Some(tcx.parent(def_id.to_def_id())), InheritanceKind::Own) } (FnKind::AssocInherentImpl, FnKind::AssocTrait) | (FnKind::AssocTrait, FnKind::AssocTrait) | (FnKind::AssocInherentImpl, FnKind::Free) - | (FnKind::AssocTrait, FnKind::Free) => build_generics( - tcx, - sig_id, - Some(tcx.parent(def_id.into())), - InheritanceKind::WithParent(false), - ), + | (FnKind::AssocTrait, FnKind::Free) => { + (Some(tcx.parent(def_id.to_def_id())), InheritanceKind::WithParent(false)) + } // For trait impl's `sig_id` is always equal to the corresponding trait method. // For inherent methods delegation is not yet supported. @@ -345,44 +266,249 @@ pub(crate) fn inherit_generics_for_delegation_item<'tcx>( } } -pub(crate) fn inherit_predicates_for_delegation_item<'tcx>( - tcx: TyCtxt<'tcx>, - def_id: LocalDefId, - sig_id: DefId, -) -> ty::GenericPredicates<'tcx> { - let args = create_generic_args(tcx, def_id, sig_id); - let caller_kind = fn_kind(tcx, def_id.into()); - let callee_kind = fn_kind(tcx, sig_id); +fn get_delegation_self_ty<'tcx>(tcx: TyCtxt<'tcx>, delegation_id: LocalDefId) -> Option> { + let sig_id = tcx.hir_opt_delegation_sig_id(delegation_id).expect("Delegation must have sig_id"); + let (caller_kind, callee_kind) = (fn_kind(tcx, delegation_id), fn_kind(tcx, sig_id)); + match (caller_kind, callee_kind) { - (FnKind::Free, FnKind::Free) | (FnKind::Free, FnKind::AssocTrait) => { - build_predicates(tcx, sig_id, None, InheritanceKind::WithParent(true), args) + (FnKind::Free, FnKind::AssocTrait) + | (FnKind::AssocInherentImpl, FnKind::Free) + | (FnKind::Free, FnKind::Free) + | (FnKind::AssocTrait, FnKind::Free) + | (FnKind::AssocTrait, FnKind::AssocTrait) => { + match create_self_position_kind(caller_kind, callee_kind) { + SelfPositionKind::None => None, + SelfPositionKind::AfterLifetimes => { + // Both sig parent and child lifetimes are in included in this count. + Some(tcx.generics_of(delegation_id).own_counts().lifetimes) + } + SelfPositionKind::Zero => Some(0), + } + .map(|self_index| Ty::new_param(tcx, self_index as u32, kw::SelfUpper)) } - (FnKind::AssocTraitImpl, FnKind::AssocTrait) => build_predicates( - tcx, - sig_id, - Some(tcx.parent(def_id.into())), - InheritanceKind::Own, - args, - ), + (FnKind::AssocTraitImpl, FnKind::AssocTrait) + | (FnKind::AssocInherentImpl, FnKind::AssocTrait) => { + Some(tcx.type_of(tcx.local_parent(delegation_id)).instantiate_identity()) + } - (FnKind::AssocInherentImpl, FnKind::AssocTrait) - | (FnKind::AssocTrait, FnKind::AssocTrait) + // For trait impl's `sig_id` is always equal to the corresponding trait method. + // For inherent methods delegation is not yet supported. + (FnKind::AssocTraitImpl, _) + | (_, FnKind::AssocTraitImpl) + | (_, FnKind::AssocInherentImpl) => unreachable!(), + } +} + +/// Creates generic arguments for further delegation signature and predicates instantiation. +/// Arguments can be user-specified (in this case they are in `parent_args` and `child_args`) +/// or propagated. User can specify either both `parent_args` and `child_args`, one of them or none, +/// that is why we firstly create generic arguments from generic params and then adjust them with +/// user-specified args. +/// +/// The order of produced list is important, it must be of this pattern: +/// +/// [SELF | maybe self in the beginning] +/// [PARENT | args of delegation parent] +/// [SIG PARENT LIFETIMES] <- `lifetimes_end_pos` +/// [SIG LIFETIMES] +/// [SELF | maybe self after lifetimes, when we reuse trait fn in free context] +/// [SIG PARENT TYPES/CONSTS] +/// [SIG TYPES/CONSTS] +fn create_generic_args<'tcx>( + tcx: TyCtxt<'tcx>, + sig_id: DefId, + delegation_id: LocalDefId, + mut parent_args: &[ty::GenericArg<'tcx>], + child_args: &[ty::GenericArg<'tcx>], +) -> Vec> { + let (caller_kind, callee_kind) = (fn_kind(tcx, delegation_id), fn_kind(tcx, sig_id)); + + let delegation_args = ty::GenericArgs::identity_for_item(tcx, delegation_id); + let delegation_parent_args_count = tcx.generics_of(delegation_id).parent_count; + + let deleg_parent_args_without_self_count = + get_delegation_parent_args_count_without_self(tcx, delegation_id, sig_id); + + let args = match (caller_kind, callee_kind) { + (FnKind::Free, FnKind::Free) + | (FnKind::Free, FnKind::AssocTrait) | (FnKind::AssocInherentImpl, FnKind::Free) - | (FnKind::AssocTrait, FnKind::Free) => build_predicates( - tcx, - sig_id, - Some(tcx.parent(def_id.into())), - InheritanceKind::WithParent(false), - args, - ), + | (FnKind::AssocTrait, FnKind::Free) + | (FnKind::AssocTrait, FnKind::AssocTrait) => delegation_args, + + (FnKind::AssocTraitImpl, FnKind::AssocTrait) => { + // Special case, as user specifies Trait args in impl trait header, we want to treat + // them as parent args. + let parent = tcx.local_parent(delegation_id); + parent_args = tcx.impl_trait_header(parent).trait_ref.instantiate_identity().args; + tcx.mk_args(&delegation_args[delegation_parent_args_count..]) + } + + (FnKind::AssocInherentImpl, FnKind::AssocTrait) => { + let self_ty = tcx.type_of(tcx.local_parent(delegation_id)).instantiate_identity(); + + tcx.mk_args_from_iter( + std::iter::once(ty::GenericArg::from(self_ty)).chain(delegation_args.iter()), + ) + } // For trait impl's `sig_id` is always equal to the corresponding trait method. // For inherent methods delegation is not yet supported. (FnKind::AssocTraitImpl, _) | (_, FnKind::AssocTraitImpl) | (_, FnKind::AssocInherentImpl) => unreachable!(), + }; + + let mut new_args = vec![]; + + let self_pos_kind = create_self_position_kind(caller_kind, callee_kind); + let mut lifetimes_end_pos; + + if !parent_args.is_empty() { + let parent_args_lifetimes_count = + parent_args.iter().filter(|a| a.as_region().is_some()).count(); + + match self_pos_kind { + SelfPositionKind::AfterLifetimes => { + new_args.extend(&parent_args[1..1 + parent_args_lifetimes_count]); + + lifetimes_end_pos = parent_args_lifetimes_count; + + new_args.push(parent_args[0]); + + new_args.extend(&parent_args[1 + parent_args_lifetimes_count..]); + } + SelfPositionKind::Zero => { + lifetimes_end_pos = 1 /* Self */ + parent_args_lifetimes_count; + new_args.extend_from_slice(parent_args); + + for i in 0..deleg_parent_args_without_self_count { + new_args.insert(1 + i, args[1 + i]); + } + + lifetimes_end_pos += deleg_parent_args_without_self_count; + } + // If we have parent args then we obtained them from trait, then self must be somewhere + SelfPositionKind::None => unreachable!(), + }; + } else { + let self_impact = matches!(self_pos_kind, SelfPositionKind::Zero) as usize; + + lifetimes_end_pos = self_impact + + deleg_parent_args_without_self_count + + &args[self_impact + deleg_parent_args_without_self_count..] + .iter() + .filter(|a| a.as_region().is_some()) + .count(); + + new_args.extend_from_slice(args); + } + + if !child_args.is_empty() { + let child_lifetimes_count = child_args.iter().filter(|a| a.as_region().is_some()).count(); + + for i in 0..child_lifetimes_count { + new_args.insert(lifetimes_end_pos + i, child_args[i]); + } + + new_args.extend_from_slice(&child_args[child_lifetimes_count..]); + } else if !parent_args.is_empty() { + let child_args = &delegation_args[delegation_parent_args_count..]; + + let child_lifetimes_count = + child_args.iter().take_while(|a| a.as_region().is_some()).count(); + + for i in 0..child_lifetimes_count { + new_args.insert(lifetimes_end_pos + i, child_args[i]); + } + + let skip_self = matches!(self_pos_kind, SelfPositionKind::AfterLifetimes); + new_args.extend(&child_args[child_lifetimes_count + skip_self as usize..]); + } + + new_args +} + +pub(crate) fn inherit_predicates_for_delegation_item<'tcx>( + tcx: TyCtxt<'tcx>, + def_id: LocalDefId, + sig_id: DefId, +) -> ty::GenericPredicates<'tcx> { + struct PredicatesCollector<'tcx> { + tcx: TyCtxt<'tcx>, + preds: Vec<(ty::Clause<'tcx>, Span)>, + args: Vec>, + folder: ParamIndexRemapper<'tcx>, + } + + impl<'tcx> PredicatesCollector<'tcx> { + fn with_own_preds( + mut self, + f: impl Fn(DefId) -> ty::GenericPredicates<'tcx>, + def_id: DefId, + ) -> Self { + let preds = f(def_id); + let args = self.args.as_slice(); + + for pred in preds.predicates { + let new_pred = pred.0.fold_with(&mut self.folder); + self.preds.push((EarlyBinder::bind(new_pred).instantiate(self.tcx, args), pred.1)); + } + + self + } + + fn with_preds( + mut self, + f: impl Fn(DefId) -> ty::GenericPredicates<'tcx> + Copy, + def_id: DefId, + ) -> Self { + let preds = f(def_id); + if let Some(parent_def_id) = preds.parent { + self = self.with_own_preds(f, parent_def_id); + } + + self.with_own_preds(f, def_id) + } } + + let (parent_args, child_args) = get_delegation_user_specified_args(tcx, def_id); + let (folder, args) = create_folder_and_args(tcx, def_id, sig_id, parent_args, child_args); + let collector = PredicatesCollector { tcx, preds: vec![], args, folder }; + + let (parent, inh_kind) = get_parent_and_inheritance_kind(tcx, def_id, sig_id); + + // `explicit_predicates_of` is used here to avoid copying `Self: Trait` predicate. + // Note: `predicates_of` query can also add inferred outlives predicates, but that + // is not the case here as `sig_id` is either a trait or a function. + let preds = match inh_kind { + InheritanceKind::WithParent(false) => { + collector.with_preds(|def_id| tcx.explicit_predicates_of(def_id), sig_id) + } + InheritanceKind::WithParent(true) => { + collector.with_preds(|def_id| tcx.predicates_of(def_id), sig_id) + } + InheritanceKind::Own => { + collector.with_own_preds(|def_id| tcx.predicates_of(def_id), sig_id) + } + } + .preds; + + ty::GenericPredicates { parent, predicates: tcx.arena.alloc_from_iter(preds) } +} + +fn create_folder_and_args<'tcx>( + tcx: TyCtxt<'tcx>, + def_id: LocalDefId, + sig_id: DefId, + parent_args: &'tcx [ty::GenericArg<'tcx>], + child_args: &'tcx [ty::GenericArg<'tcx>], +) -> (ParamIndexRemapper<'tcx>, Vec>) { + let args = create_generic_args(tcx, sig_id, def_id, parent_args, child_args); + let remap_table = create_mapping(tcx, sig_id, def_id, &args); + + (ParamIndexRemapper { tcx, remap_table }, args) } fn check_constraints<'tcx>( @@ -412,18 +538,91 @@ pub(crate) fn inherit_sig_for_delegation_item<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, ) -> &'tcx [Ty<'tcx>] { - let sig_id = tcx.hir_opt_delegation_sig_id(def_id).unwrap(); + let sig_id = tcx.hir_opt_delegation_sig_id(def_id).expect("Delegation must have sig_id"); let caller_sig = tcx.fn_sig(sig_id); + if let Err(err) = check_constraints(tcx, def_id, sig_id) { let sig_len = caller_sig.instantiate_identity().skip_binder().inputs().len() + 1; let err_type = Ty::new_error(tcx, err); return tcx.arena.alloc_from_iter((0..sig_len).map(|_| err_type)); } - let args = create_generic_args(tcx, def_id, sig_id); - // Bound vars are also inherited from `sig_id`. - // They will be rebound later in `lower_fn_ty`. - let sig = caller_sig.instantiate(tcx, args).skip_binder(); + let (parent_args, child_args) = get_delegation_user_specified_args(tcx, def_id); + let (mut folder, args) = create_folder_and_args(tcx, def_id, sig_id, parent_args, child_args); + let caller_sig = EarlyBinder::bind(caller_sig.skip_binder().fold_with(&mut folder)); + + let sig = caller_sig.instantiate(tcx, args.as_slice()).skip_binder(); let sig_iter = sig.inputs().iter().cloned().chain(std::iter::once(sig.output())); tcx.arena.alloc_from_iter(sig_iter) } + +// Creates user-specified generic arguments from delegation path, +// they will be used during delegation signature and predicates inheritance. +// Example: reuse Trait::<'static, i32, 1>::foo:: +// we want to extract [Self, 'static, i32, 1] for parent and [A, B] for child. +fn get_delegation_user_specified_args<'tcx>( + tcx: TyCtxt<'tcx>, + delegation_id: LocalDefId, +) -> (&'tcx [ty::GenericArg<'tcx>], &'tcx [ty::GenericArg<'tcx>]) { + let info = tcx + .hir_node(tcx.local_def_id_to_hir_id(delegation_id)) + .fn_sig() + .expect("Lowering delegation") + .decl + .opt_delegation_generics() + .expect("Lowering delegation"); + + let get_segment = |hir_id: HirId| -> (&'tcx PathSegment<'tcx>, DefId) { + let segment = tcx.hir_node(hir_id).expect_path_segment(); + let def_id = segment.res.def_id(); + + (segment, def_id) + }; + + let ctx = ItemCtxt::new(tcx, delegation_id); + let lowerer = ctx.lowerer(); + + let parent_args = info.parent_args_segment_id.map(get_segment).map(|(segment, def_id)| { + let self_ty = get_delegation_self_ty(tcx, delegation_id); + + lowerer + .lower_generic_args_of_path( + segment.ident.span, + def_id, + &[], + segment, + self_ty, + GenericArgPosition::Type, + ) + .0 + .as_slice() + }); + + let child_args = info.child_args_segment_id.map(get_segment).map(|(segment, def_id)| { + let parent_args = if let Some(parent_args) = parent_args { + parent_args + } else { + let parent = tcx.parent(def_id); + if matches!(tcx.def_kind(parent), DefKind::Trait) { + ty::GenericArgs::identity_for_item(tcx, parent).as_slice() + } else { + &[] + } + }; + + let args = lowerer + .lower_generic_args_of_path( + segment.ident.span, + def_id, + parent_args, + segment, + None, + GenericArgPosition::Value, + ) + .0; + + &args[parent_args.len()..] + }); + + (parent_args.unwrap_or_default(), child_args.unwrap_or_default()) +} diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 3f82375308927..74836076fdf9f 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -319,7 +319,7 @@ pub enum IsMethodCall { /// Denotes the "position" of a generic argument, indicating if it is a generic type, /// generic function or generic method call. -#[derive(Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq)] pub(crate) enum GenericArgPosition { Type, Value, // e.g., functions @@ -550,7 +550,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { def_id: DefId, item_segment: &hir::PathSegment<'tcx>, ) -> GenericArgsRef<'tcx> { - let (args, _) = self.lower_generic_args_of_path(span, def_id, &[], item_segment, None); + let (args, _) = self.lower_generic_args_of_path( + span, + def_id, + &[], + item_segment, + None, + GenericArgPosition::Type, + ); if let Some(c) = item_segment.args().constraints.first() { prohibit_assoc_item_constraint(self, c, Some((def_id, item_segment, span))); } @@ -592,13 +599,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { /// type itself: `['a]`. The returned `GenericArgsRef` concatenates these two /// lists: `[Vec, u8, 'a]`. #[instrument(level = "debug", skip(self, span), ret)] - fn lower_generic_args_of_path( + pub(crate) fn lower_generic_args_of_path( &self, span: Span, def_id: DefId, parent_args: &[ty::GenericArg<'tcx>], segment: &hir::PathSegment<'tcx>, self_ty: Option>, + pos: GenericArgPosition, ) -> (GenericArgsRef<'tcx>, GenericArgCountResult) { // If the type is parameterized by this region, then replace this // region with the current anon region binding (in other words, @@ -621,14 +629,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { assert!(self_ty.is_none()); } - let arg_count = check_generic_arg_count( - self, - def_id, - segment, - generics, - GenericArgPosition::Type, - self_ty.is_some(), - ); + let arg_count = + check_generic_arg_count(self, def_id, segment, generics, pos, self_ty.is_some()); // Skip processing if type has no generic parameters. // Traits always have `Self` as a generic parameter, which means they will not return early @@ -791,6 +793,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { infer_args: segment.infer_args, incorrect_args: &arg_count.correct, }; + let args = lower_generic_args( self, def_id, @@ -812,8 +815,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { item_segment: &hir::PathSegment<'tcx>, parent_args: GenericArgsRef<'tcx>, ) -> GenericArgsRef<'tcx> { - let (args, _) = - self.lower_generic_args_of_path(span, item_def_id, parent_args, item_segment, None); + let (args, _) = self.lower_generic_args_of_path( + span, + item_def_id, + parent_args, + item_segment, + None, + GenericArgPosition::Type, + ); if let Some(c) = item_segment.args().constraints.first() { prohibit_assoc_item_constraint(self, c, Some((item_def_id, item_segment, span))); } @@ -925,6 +934,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { &[], segment, Some(self_ty), + GenericArgPosition::Type, ); let constraints = segment.args().constraints; @@ -1100,8 +1110,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { ) -> ty::TraitRef<'tcx> { self.report_internal_fn_trait(span, trait_def_id, trait_segment, is_impl); - let (generic_args, _) = - self.lower_generic_args_of_path(span, trait_def_id, &[], trait_segment, Some(self_ty)); + let (generic_args, _) = self.lower_generic_args_of_path( + span, + trait_def_id, + &[], + trait_segment, + Some(self_ty), + GenericArgPosition::Type, + ); if let Some(c) = trait_segment.args().constraints.first() { prohibit_assoc_item_constraint(self, c, Some((trait_def_id, trait_segment, span))); } @@ -2886,11 +2902,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } } - fn lower_delegation_ty(&self, idx: hir::InferDelegationKind) -> Ty<'tcx> { + fn lower_delegation_ty(&self, idx: hir::InferDelegationKind<'tcx>) -> Ty<'tcx> { let delegation_sig = self.tcx().inherit_sig_for_delegation_item(self.item_def_id()); + match idx { hir::InferDelegationKind::Input(idx) => delegation_sig[idx], - hir::InferDelegationKind::Output => *delegation_sig.last().unwrap(), + hir::InferDelegationKind::Output { .. } => *delegation_sig.last().unwrap(), } } diff --git a/tests/pretty/delegation-inherit-attributes.pp b/tests/pretty/delegation-inherit-attributes.pp index 26ca5e99b885d..a5c33aaf406aa 100644 --- a/tests/pretty/delegation-inherit-attributes.pp +++ b/tests/pretty/delegation-inherit-attributes.pp @@ -114,7 +114,7 @@ #[attr = MustUse {reason: "some reason"}] #[attr = Inline(Hint)] - fn foo(self: _, arg1: _) -> _ { ::foo(self + 1, arg1) } + fn foo(self: _, arg1: _) -> _ { ::foo(self + 1, arg1) } #[attr = MustUse {reason: "some reason"}] #[attr = Inline(Hint)] fn bar(self: _, arg1: _) -> _ { foo(self + 1, arg1) } diff --git a/tests/pretty/hir-delegation.pp b/tests/pretty/hir-delegation.pp index 59491b6ebd7c1..9886ffc83a48d 100644 --- a/tests/pretty/hir-delegation.pp +++ b/tests/pretty/hir-delegation.pp @@ -12,7 +12,7 @@ trait G { #[attr = Inline(Hint)] - fn b(arg0: _) -> _ { b({ }) } + fn b(arg0: _) -> _ { b::({ }) } } mod m { diff --git a/tests/ui/delegation/generics/auxiliary/generics.rs b/tests/ui/delegation/generics/auxiliary/generics.rs new file mode 100644 index 0000000000000..907700d738c03 --- /dev/null +++ b/tests/ui/delegation/generics/auxiliary/generics.rs @@ -0,0 +1,7 @@ +pub fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + +pub trait Trait<'b, T, const N: usize>: Sized { + fn foo<'d: 'd, U, const M: bool>(self) {} +} + +impl Trait<'static, i32, 1> for u8 {} diff --git a/tests/ui/delegation/generics/free-fn-to-free-fn.rs b/tests/ui/delegation/generics/free-fn-to-free-fn.rs index 3741ad664852a..285059e63a75f 100644 --- a/tests/ui/delegation/generics/free-fn-to-free-fn.rs +++ b/tests/ui/delegation/generics/free-fn-to-free-fn.rs @@ -11,15 +11,13 @@ mod to_reuse { pub fn bounds(_: T) {} } -// FIXME(fn_delegation): this is supposed to work eventually reuse to_reuse::consts; -//~^ ERROR type annotations needed reuse to_reuse::late; reuse to_reuse::bounds; fn main() { + // FIXME(fn_delegation): proper support for late bound lifetimes. late::<'static>(&0u8); - //~^ ERROR cannot specify lifetime arguments explicitly if late bound lifetime parameters are present struct S; bounds(S); diff --git a/tests/ui/delegation/generics/free-fn-to-free-fn.stderr b/tests/ui/delegation/generics/free-fn-to-free-fn.stderr index 5ba56ce1718f0..6b6acfc3afff6 100644 --- a/tests/ui/delegation/generics/free-fn-to-free-fn.stderr +++ b/tests/ui/delegation/generics/free-fn-to-free-fn.stderr @@ -1,33 +1,5 @@ -error[E0284]: type annotations needed - --> $DIR/free-fn-to-free-fn.rs:15:17 - | -LL | reuse to_reuse::consts; - | ^^^^^^ cannot infer the value of the const parameter `N` declared on the function `consts` - | -note: required by a const generic parameter in `to_reuse::consts` - --> $DIR/free-fn-to-free-fn.rs:5:19 - | -LL | pub fn consts() -> i32 { - | ^^^^^^^^^^^^ required by this const generic parameter in `consts` -help: consider specifying the generic argument - | -LL | reuse to_reuse::consts::; - | +++++ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/free-fn-to-free-fn.rs:21:12 - | -LL | late::<'static>(&0u8); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/free-fn-to-free-fn.rs:8:17 - | -LL | pub fn late<'a>(x: &'a u8) -> u8 { - | ^^ - error[E0277]: the trait bound `S: Clone` is not satisfied - --> $DIR/free-fn-to-free-fn.rs:25:12 + --> $DIR/free-fn-to-free-fn.rs:23:12 | LL | bounds(S); | ------ ^ the trait `Clone` is not implemented for `S` @@ -48,7 +20,6 @@ LL + #[derive(Clone)] LL | struct S; | -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0277, E0284, E0794. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/delegation/generics/free-fn-to-trait-infer.rs b/tests/ui/delegation/generics/free-fn-to-trait-infer.rs new file mode 100644 index 0000000000000..905fc8cf21d7d --- /dev/null +++ b/tests/ui/delegation/generics/free-fn-to-trait-infer.rs @@ -0,0 +1,20 @@ +//@ compile-flags: -Z deduplicate-diagnostics=yes + +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +trait Trait { + fn foo(&self, _: U, _: T) {} +} + +impl Trait for u8 {} + +reuse Trait::<_>::foo:: as generic_arguments1; +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions +reuse >::foo as generic_arguments2; +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions +//~| ERROR mismatched types +reuse <_ as Trait<_>>::foo as generic_arguments3; +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + +fn main() {} diff --git a/tests/ui/delegation/generics/free-fn-to-trait-infer.stderr b/tests/ui/delegation/generics/free-fn-to-trait-infer.stderr new file mode 100644 index 0000000000000..ead3c30a6886c --- /dev/null +++ b/tests/ui/delegation/generics/free-fn-to-trait-infer.stderr @@ -0,0 +1,40 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/free-fn-to-trait-infer.rs:12:15 + | +LL | reuse Trait::<_>::foo:: as generic_arguments1; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/free-fn-to-trait-infer.rs:14:20 + | +LL | reuse >::foo as generic_arguments2; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/free-fn-to-trait-infer.rs:17:19 + | +LL | reuse <_ as Trait<_>>::foo as generic_arguments3; + | ^ not allowed in type signatures + +error[E0308]: mismatched types + --> $DIR/free-fn-to-trait-infer.rs:14:25 + | +LL | reuse >::foo as generic_arguments2; + | ^^^ + | | + | expected `&u8`, found `&Self` + | found this type parameter + | arguments to this function are incorrect + | + = note: expected reference `&u8` + found reference `&Self` +note: method defined here + --> $DIR/free-fn-to-trait-infer.rs:7:8 + | +LL | fn foo(&self, _: U, _: T) {} + | ^^^ ----- + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0121, E0308. +For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/delegation/generics/free-fn-to-trait-method.rs b/tests/ui/delegation/generics/free-fn-to-trait-method.rs index 70be1a4ace7c0..eb3a941c8f484 100644 --- a/tests/ui/delegation/generics/free-fn-to-trait-method.rs +++ b/tests/ui/delegation/generics/free-fn-to-trait-method.rs @@ -26,20 +26,6 @@ mod bounds { impl Trait for u8 {} } -mod generic_arguments { - trait Trait { - fn foo(&self, _: U, _: T) {} - } - - impl Trait for u8 {} - - reuse Trait::<_>::foo:: as generic_arguments1; - //~^ ERROR mismatched types - reuse >::foo as generic_arguments2; - //~^ ERROR mismatched types - reuse <_ as Trait<_>>::foo as generic_arguments3; // OK -} - reuse default_param::Trait::foo as default_param; reuse types_and_lifetimes::Trait::foo as types_and_lifetimes; reuse bounds::Trait::foo as bounds; diff --git a/tests/ui/delegation/generics/free-fn-to-trait-method.stderr b/tests/ui/delegation/generics/free-fn-to-trait-method.stderr index d8299d00c7e94..b35a3188dd94b 100644 --- a/tests/ui/delegation/generics/free-fn-to-trait-method.stderr +++ b/tests/ui/delegation/generics/free-fn-to-trait-method.stderr @@ -1,45 +1,5 @@ -error[E0308]: mismatched types - --> $DIR/free-fn-to-trait-method.rs:36:23 - | -LL | fn foo(&self, _: U, _: T) {} - | - found this type parameter -... -LL | reuse Trait::<_>::foo:: as generic_arguments1; - | ^^^ - | | - | expected `i32`, found type parameter `U` - | arguments to this function are incorrect - | - = note: expected type `i32` - found type parameter `U` -note: method defined here - --> $DIR/free-fn-to-trait-method.rs:31:12 - | -LL | fn foo(&self, _: U, _: T) {} - | ^^^ ---- - -error[E0308]: mismatched types - --> $DIR/free-fn-to-trait-method.rs:38:29 - | -LL | trait Trait { - | -------------- found this type parameter -... -LL | reuse >::foo as generic_arguments2; - | ^^^ - | | - | expected `&u8`, found `&Self` - | arguments to this function are incorrect - | - = note: expected reference `&u8` - found reference `&Self` -note: method defined here - --> $DIR/free-fn-to-trait-method.rs:31:12 - | -LL | fn foo(&self, _: U, _: T) {} - | ^^^ ----- - error[E0277]: the trait bound `S: Copy` is not satisfied - --> $DIR/free-fn-to-trait-method.rs:53:18 + --> $DIR/free-fn-to-trait-method.rs:39:18 | LL | bounds(&0u8, S, U); | ------ ^ the trait `Copy` is not implemented for `S` @@ -61,7 +21,7 @@ LL | struct S; | error[E0277]: the trait bound `U: Clone` is not satisfied - --> $DIR/free-fn-to-trait-method.rs:53:21 + --> $DIR/free-fn-to-trait-method.rs:39:21 | LL | bounds(&0u8, S, U); | ------ ^ the trait `Clone` is not implemented for `U` @@ -82,7 +42,6 @@ LL + #[derive(Clone)] LL | struct U; | -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/delegation/generics/generic-params-defaults.rs b/tests/ui/delegation/generics/generic-params-defaults.rs index b6d70a557abdd..66a9195551337 100644 --- a/tests/ui/delegation/generics/generic-params-defaults.rs +++ b/tests/ui/delegation/generics/generic-params-defaults.rs @@ -9,6 +9,5 @@ trait Trait<'a, 'b, 'c, A = usize, B = u32, C = String, const N: usize = 123> { } reuse Trait::foo; -//~^ ERROR: type annotations needed fn main() {} diff --git a/tests/ui/delegation/generics/generic-params-defaults.stderr b/tests/ui/delegation/generics/generic-params-defaults.stderr index 43eb840c95915..76fc3fde4753c 100644 --- a/tests/ui/delegation/generics/generic-params-defaults.stderr +++ b/tests/ui/delegation/generics/generic-params-defaults.stderr @@ -8,20 +8,8 @@ LL | fn foo(&self) { = note: for more information, see issue #36887 = note: `#[deny(invalid_type_param_default)]` (part of `#[deny(future_incompatible)]`) on by default -error[E0282]: type annotations needed - --> $DIR/generic-params-defaults.rs:11:14 - | -LL | reuse Trait::foo; - | ^^^ cannot infer type of the type parameter `T` declared on the method `foo` - | -help: consider specifying the generic argument - | -LL | reuse Trait::foo::; - | +++++ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0282`. Future incompatibility report: Future breakage diagnostic: error: defaults for generic parameters are not allowed here --> $DIR/generic-params-defaults.rs:5:12 diff --git a/tests/ui/delegation/generics/generic-params-same-names.rs b/tests/ui/delegation/generics/generic-params-same-names.rs index 14b1276941d22..ff1d5aa2b3f6a 100644 --- a/tests/ui/delegation/generics/generic-params-same-names.rs +++ b/tests/ui/delegation/generics/generic-params-same-names.rs @@ -14,6 +14,5 @@ trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { } reuse Trait::foo; -//~^ ERROR: type annotations needed fn main() {} diff --git a/tests/ui/delegation/generics/generic-params-same-names.stderr b/tests/ui/delegation/generics/generic-params-same-names.stderr index 6fc31553123e1..71ac05fcada01 100644 --- a/tests/ui/delegation/generics/generic-params-same-names.stderr +++ b/tests/ui/delegation/generics/generic-params-same-names.stderr @@ -54,23 +54,7 @@ LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { | ^ already used -error[E0284]: type annotations needed - --> $DIR/generic-params-same-names.rs:16:14 - | -LL | reuse Trait::foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the method `foo` - | -note: required by a const generic parameter in `Trait::foo` - --> $DIR/generic-params-same-names.rs:5:33 - | -LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { - | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::foo::; - | ++++++++++++++ - -error: aborting due to 8 previous errors +error: aborting due to 7 previous errors -Some errors have detailed explanations: E0284, E0403, E0496. -For more information about an error, try `rustc --explain E0284`. +Some errors have detailed explanations: E0403, E0496. +For more information about an error, try `rustc --explain E0403`. diff --git a/tests/ui/delegation/generics/generics-aux-pass.rs b/tests/ui/delegation/generics/generics-aux-pass.rs new file mode 100644 index 0000000000000..a2cfe91dc4033 --- /dev/null +++ b/tests/ui/delegation/generics/generics-aux-pass.rs @@ -0,0 +1,63 @@ +//@ aux-crate:generics=generics.rs +//@ run-pass + +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +reuse generics::foo as bar; +reuse generics::Trait::foo as trait_foo; + +reuse generics::foo::<'static, 'static, i32, i32, 1> as bar1; +reuse generics::Trait::<'static, i32, 1>::foo::<'static, i32, false> as trait_foo1; + +#[derive(Clone, Copy)] +struct X; + +impl generics::Trait<'static, i32, 1> for X {} + +impl X { + reuse generics::foo as bar; + reuse generics::Trait::foo as trait_foo; + + reuse generics::foo::<'static, 'static, i32, i32, 1> as bar1; + reuse generics::Trait::<'static, i32, 1>::foo::<'static, i32, false> as trait_foo1; +} + +trait LocalTrait { + fn get() -> u8 { 123 } + fn get_self(&self) -> u8 { 123 } + + reuse generics::foo as bar; + reuse generics::foo::<'static, 'static, i32, i32, 1> as bar1; + + reuse generics::Trait::foo as trait_foo { Self::get() } + reuse generics::Trait::<'static, i32, 1>::foo::<'static, i32, false> as trait_foo1 { + Self::get_self(&self) + } +} + +impl LocalTrait for usize {} + +fn main() { + bar::(); + bar::<'static, 'static, i32, i32, 1>(); + trait_foo::<'static, 'static, u8, i32, 1, String, true>(123); + + bar1(); + trait_foo1::(123); + + let x = X{}; + + X::bar::(); + X::bar::<'static, 'static, i32, i32, 1>(); + X::bar1(); + x.trait_foo::<'static, 'static, i32, 1, String, true>(); + x.trait_foo1(); + + ::bar::(); + ::bar::<'static, 'static, i32, i32, 1>(); + ::bar1(); + + 1usize.trait_foo::<'static, 'static, i32, 1, String, true>(); + 1usize.trait_foo1(); +} diff --git a/tests/ui/delegation/generics/generics-gen-args-errors.rs b/tests/ui/delegation/generics/generics-gen-args-errors.rs index 045fc7c75dea9..3edcc70420145 100644 --- a/tests/ui/delegation/generics/generics-gen-args-errors.rs +++ b/tests/ui/delegation/generics/generics-gen-args-errors.rs @@ -6,7 +6,6 @@ mod test_1 { fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} reuse foo as bar; - //~^ ERROR: type annotations needed fn check() { bar::<1, 2, 3, 4, 5, 6>(); @@ -44,7 +43,7 @@ mod test_2 { fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} reuse foo::<> as bar1; - //~^ ERROR: type annotations needed + //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions reuse foo:: as bar2; //~^ ERROR: function takes 3 generic arguments but 2 generic arguments were supplied @@ -85,18 +84,23 @@ mod test_3 { //~| ERROR: cannot find type `asd` in this scope //~| ERROR: cannot find type `asd` in this scope //~| ERROR: cannot find type `asdasa` in this scope + //~| ERROR: trait takes 3 lifetime arguments but 0 lifetime arguments were supplied //~| ERROR: trait takes 2 generic arguments but 6 generic arguments were supplied reuse Trait::<'static, 'static>::foo as bar2; //~^ ERROR: trait takes 3 lifetime arguments but 2 lifetime arguments were supplied + //~| ERROR: the placeholder `_` is not allowed within types on item signatures for functions reuse Trait::<1, 2, 3, 4, 5>::foo as bar3; - //~^ ERROR: trait takes 2 generic arguments but 5 generic arguments were supplied + //~^ ERROR: trait takes 3 lifetime arguments but 0 lifetime arguments were supplied + //~| ERROR: trait takes 2 generic arguments but 5 generic arguments were supplied reuse Trait::<1, 2, true>::foo as bar4; - //~^ ERROR: trait takes 2 generic arguments but 3 generic arguments were supplied + //~^ ERROR: trait takes 3 lifetime arguments but 0 lifetime arguments were supplied + //~| ERROR: trait takes 2 generic arguments but 3 generic arguments were supplied reuse Trait::<'static>::foo as bar5; //~^ ERROR: trait takes 3 lifetime arguments but 1 lifetime argument was supplied + //~| ERROR: the placeholder `_` is not allowed within types on item signatures for functions reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; //~^ ERROR: cannot find type `DDDD` in this scope [E0425] diff --git a/tests/ui/delegation/generics/generics-gen-args-errors.stderr b/tests/ui/delegation/generics/generics-gen-args-errors.stderr index 5c04fa2c23248..78aefbc6604cc 100644 --- a/tests/ui/delegation/generics/generics-gen-args-errors.stderr +++ b/tests/ui/delegation/generics/generics-gen-args-errors.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/generics-gen-args-errors.rs:35:21 + --> $DIR/generics-gen-args-errors.rs:34:21 | LL | fn check() { | - type parameter from outer item @@ -12,7 +12,7 @@ LL | reuse foo:: as xd; = note: nested items are independent from their parent item for everything except for privacy and name resolution error[E0401]: can't use generic parameters from outer item - --> $DIR/generics-gen-args-errors.rs:35:24 + --> $DIR/generics-gen-args-errors.rs:34:24 | LL | fn check() { | - type parameter from outer item @@ -25,7 +25,7 @@ LL | reuse foo:: as xd; = note: nested items are independent from their parent item for everything except for privacy and name resolution error[E0401]: can't use generic parameters from outer item - --> $DIR/generics-gen-args-errors.rs:35:27 + --> $DIR/generics-gen-args-errors.rs:34:27 | LL | fn check() { | - type parameter from outer item @@ -38,7 +38,7 @@ LL | reuse foo:: as xd; = note: nested items are independent from their parent item for everything except for privacy and name resolution error[E0261]: use of undeclared lifetime name `'asdasd` - --> $DIR/generics-gen-args-errors.rs:52:29 + --> $DIR/generics-gen-args-errors.rs:51:29 | LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; | ^^^^^^^ undeclared lifetime @@ -49,7 +49,7 @@ LL | reuse foo'asdasd, ::<'static, _, 'asdasd, 'static, 'static, 'static, _> | ++++++++ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/generics-gen-args-errors.rs:67:50 + --> $DIR/generics-gen-args-errors.rs:66:50 | LL | reuse foo::<"asdasd", asd, "askdn", 'static, 'a> as bar7; | ^^ undeclared lifetime @@ -60,7 +60,7 @@ LL | reuse foo'a, ::<"asdasd", asd, "askdn", 'static, 'a> as bar7; | +++ error[E0106]: missing lifetime specifiers - --> $DIR/generics-gen-args-errors.rs:107:19 + --> $DIR/generics-gen-args-errors.rs:111:19 | LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; | ^^^^^ expected 3 lifetime parameters @@ -71,7 +71,7 @@ LL | reuse Trait::, Clone, _, 'static, dyn Send, _>::foo'a | ++++++++++++ +++ error[E0423]: expected value, found struct `String` - --> $DIR/generics-gen-args-errors.rs:15:33 + --> $DIR/generics-gen-args-errors.rs:14:33 | LL | bar::(); | ^^^^^^ @@ -81,7 +81,7 @@ LL | bar::(); = note: `String` defined here error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:29:15 + --> $DIR/generics-gen-args-errors.rs:28:15 | LL | bar::(); | ^^^ not found in this scope @@ -92,7 +92,7 @@ LL | fn check() { | +++++ error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:29:20 + --> $DIR/generics-gen-args-errors.rs:28:20 | LL | bar::(); | ^^^ not found in this scope @@ -103,7 +103,7 @@ LL | fn check() { | +++++ error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:29:25 + --> $DIR/generics-gen-args-errors.rs:28:25 | LL | bar::(); | ^^^ not found in this scope @@ -114,148 +114,67 @@ LL | fn check() { | +++++ error[E0425]: cannot find type `asdasd` in this scope - --> $DIR/generics-gen-args-errors.rs:56:39 + --> $DIR/generics-gen-args-errors.rs:55:39 | LL | reuse foo:: as bar4; | ^^^^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:63:22 + --> $DIR/generics-gen-args-errors.rs:62:22 | LL | reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:67:27 + --> $DIR/generics-gen-args-errors.rs:66:27 | LL | reuse foo::<"asdasd", asd, "askdn", 'static, 'a> as bar7; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:81:19 + --> $DIR/generics-gen-args-errors.rs:80:19 | LL | reuse Trait::::foo as bar1; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:81:24 + --> $DIR/generics-gen-args-errors.rs:80:24 | LL | reuse Trait::::foo as bar1; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:81:29 + --> $DIR/generics-gen-args-errors.rs:80:29 | LL | reuse Trait::::foo as bar1; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:81:34 + --> $DIR/generics-gen-args-errors.rs:80:34 | LL | reuse Trait::::foo as bar1; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:81:39 + --> $DIR/generics-gen-args-errors.rs:80:39 | LL | reuse Trait::::foo as bar1; | ^^^ not found in this scope error[E0425]: cannot find type `asdasa` in this scope - --> $DIR/generics-gen-args-errors.rs:81:44 + --> $DIR/generics-gen-args-errors.rs:80:44 | LL | reuse Trait::::foo as bar1; | ^^^^^^ not found in this scope error[E0425]: cannot find type `DDDD` in this scope - --> $DIR/generics-gen-args-errors.rs:101:34 + --> $DIR/generics-gen-args-errors.rs:105:34 | LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | ^^^^ not found in this scope -error[E0284]: type annotations needed - --> $DIR/generics-gen-args-errors.rs:8:11 - | -LL | reuse foo as bar; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_1::foo` - --> $DIR/generics-gen-args-errors.rs:7:48 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo:: as bar; - | +++++++++++ - -error[E0107]: function takes 3 generic arguments but 6 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:12:9 - | -LL | bar::<1, 2, 3, 4, 5, 6>(); - | ^^^ --------- help: remove the unnecessary generic arguments - | | - | expected 3 generic arguments - | -note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:8:18 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | - - -------------- -LL | reuse foo as bar; - | ^^^ - -error[E0107]: function takes 2 lifetime arguments but 5 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:18:9 - | -LL | bar::<'static, 'static, 'static, 'static, 'static>(); - | ^^^ --------------------------- help: remove the lifetime arguments - | | - | expected 2 lifetime arguments - | -note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/generics-gen-args-errors.rs:8:18 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | -- -- -LL | reuse foo as bar; - | ^^^ - -error[E0747]: constant provided when a type was expected - --> $DIR/generics-gen-args-errors.rs:21:23 - | -LL | bar::(); - | ^ - -error[E0107]: function takes 3 generic arguments but 5 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:26:9 - | -LL | bar::<_, _, _, _, _>(); - | ^^^ ------ help: remove the unnecessary generic arguments - | | - | expected 3 generic arguments - | -note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:8:18 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | - - -------------- -LL | reuse foo as bar; - | ^^^ - error[E0747]: unresolved item provided when a constant was expected - --> $DIR/generics-gen-args-errors.rs:29:25 - | -LL | bar::(); - | ^^^ - | -help: if this generic argument was intended as a const parameter, surround it with braces - | -LL | bar::(); - | + + - -error[E0747]: unresolved item provided when a constant was expected - --> $DIR/generics-gen-args-errors.rs:35:27 + --> $DIR/generics-gen-args-errors.rs:34:27 | LL | reuse foo:: as xd; | ^ @@ -265,24 +184,14 @@ help: if this generic argument was intended as a const parameter, surround it wi LL | reuse foo:: as xd; | + + -error[E0284]: type annotations needed - --> $DIR/generics-gen-args-errors.rs:46:11 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/generics-gen-args-errors.rs:45:11 | LL | reuse foo::<> as bar1; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_2::foo` - --> $DIR/generics-gen-args-errors.rs:44:48 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo:: as bar1; - | +++++++ + | ^^^ not allowed in type signatures error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:49:11 + --> $DIR/generics-gen-args-errors.rs:48:11 | LL | reuse foo:: as bar2; | ^^^ ------ ------ supplied 2 generic arguments @@ -290,7 +199,7 @@ LL | reuse foo:: as bar2; | expected 3 generic arguments | note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ - - -------------- @@ -300,7 +209,7 @@ LL | reuse foo:: as bar2; | +++ error[E0107]: function takes 2 lifetime arguments but 5 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:52:11 + --> $DIR/generics-gen-args-errors.rs:51:11 | LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; | ^^^ --------------------------- help: remove the lifetime arguments @@ -308,19 +217,19 @@ LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; | expected 2 lifetime arguments | note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ -- -- error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:52:11 + --> $DIR/generics-gen-args-errors.rs:51:11 | LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; | ^^^ expected 3 generic arguments ------- - supplied 2 generic arguments | note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ - - -------------- @@ -330,7 +239,7 @@ LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _, N> as ba | +++ error[E0107]: function takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/generics-gen-args-errors.rs:56:11 + --> $DIR/generics-gen-args-errors.rs:55:11 | LL | reuse foo:: as bar4; | ^^^ ------ supplied 1 lifetime argument @@ -338,7 +247,7 @@ LL | reuse foo:: as bar4; | expected 2 lifetime arguments | note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ -- -- @@ -348,7 +257,7 @@ LL | reuse foo:: as bar4; | +++++++++ error[E0107]: function takes 3 generic arguments but 6 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:60:11 + --> $DIR/generics-gen-args-errors.rs:59:11 | LL | reuse foo::<1, 2, _, 4, 5, _> as bar5; | ^^^ --------- help: remove the unnecessary generic arguments @@ -356,13 +265,13 @@ LL | reuse foo::<1, 2, _, 4, 5, _> as bar5; | expected 3 generic arguments | note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ - - -------------- error[E0107]: function takes 3 generic arguments but 5 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:63:11 + --> $DIR/generics-gen-args-errors.rs:62:11 | LL | reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6; | ^^^ ----------------------- help: remove the unnecessary generic arguments @@ -370,25 +279,41 @@ LL | reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6; | expected 3 generic arguments | note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ - - -------------- error[E0747]: constant provided when a type was expected - --> $DIR/generics-gen-args-errors.rs:67:17 + --> $DIR/generics-gen-args-errors.rs:66:17 | LL | reuse foo::<"asdasd", asd, "askdn", 'static, 'a> as bar7; | ^^^^^^^^ error[E0747]: constant provided when a type was expected - --> $DIR/generics-gen-args-errors.rs:72:17 + --> $DIR/generics-gen-args-errors.rs:71:17 | LL | reuse foo::<{}, {}, {}> as bar8; | ^^ +error[E0107]: trait takes 3 lifetime arguments but 0 lifetime arguments were supplied + --> $DIR/generics-gen-args-errors.rs:80:11 + | +LL | reuse Trait::::foo as bar1; + | ^^^^^ expected 3 lifetime arguments + | +note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` + --> $DIR/generics-gen-args-errors.rs:76:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ -- -- -- +help: add missing lifetime arguments + | +LL | reuse Trait::<'b, 'c, 'a, asd, asd, asd, asd, asd, asdasa>::foo as bar1; + | +++++++++++ + error[E0107]: trait takes 2 generic arguments but 6 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | reuse Trait::::foo as bar1; | ^^^^^ ----------------------- help: remove the unnecessary generic arguments @@ -396,7 +321,7 @@ LL | reuse Trait::::foo as bar1; | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `T`, `N` - --> $DIR/generics-gen-args-errors.rs:77:11 + --> $DIR/generics-gen-args-errors.rs:76:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ - -------------- @@ -410,7 +335,7 @@ LL | reuse Trait::<'static, 'static>::foo as bar2; | expected 3 lifetime arguments | note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` - --> $DIR/generics-gen-args-errors.rs:77:11 + --> $DIR/generics-gen-args-errors.rs:76:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ -- -- -- @@ -419,8 +344,30 @@ help: add missing lifetime argument LL | reuse Trait::<'static, 'static, 'static>::foo as bar2; | +++++++++ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/generics-gen-args-errors.rs:90:11 + | +LL | reuse Trait::<'static, 'static>::foo as bar2; + | ^^^^^ not allowed in type signatures + +error[E0107]: trait takes 3 lifetime arguments but 0 lifetime arguments were supplied + --> $DIR/generics-gen-args-errors.rs:93:11 + | +LL | reuse Trait::<1, 2, 3, 4, 5>::foo as bar3; + | ^^^^^ expected 3 lifetime arguments + | +note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` + --> $DIR/generics-gen-args-errors.rs:76:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ -- -- -- +help: add missing lifetime arguments + | +LL | reuse Trait::<'b, 'c, 'a, 1, 2, 3, 4, 5>::foo as bar3; + | +++++++++++ + error[E0107]: trait takes 2 generic arguments but 5 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:92:11 + --> $DIR/generics-gen-args-errors.rs:93:11 | LL | reuse Trait::<1, 2, 3, 4, 5>::foo as bar3; | ^^^^^ --------- help: remove the unnecessary generic arguments @@ -428,13 +375,29 @@ LL | reuse Trait::<1, 2, 3, 4, 5>::foo as bar3; | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `T`, `N` - --> $DIR/generics-gen-args-errors.rs:77:11 + --> $DIR/generics-gen-args-errors.rs:76:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ - -------------- +error[E0107]: trait takes 3 lifetime arguments but 0 lifetime arguments were supplied + --> $DIR/generics-gen-args-errors.rs:97:11 + | +LL | reuse Trait::<1, 2, true>::foo as bar4; + | ^^^^^ expected 3 lifetime arguments + | +note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` + --> $DIR/generics-gen-args-errors.rs:76:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ -- -- -- +help: add missing lifetime arguments + | +LL | reuse Trait::<'b, 'c, 'a, 1, 2, true>::foo as bar4; + | +++++++++++ + error[E0107]: trait takes 2 generic arguments but 3 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:95:11 + --> $DIR/generics-gen-args-errors.rs:97:11 | LL | reuse Trait::<1, 2, true>::foo as bar4; | ^^^^^ ------ help: remove the unnecessary generic argument @@ -442,13 +405,13 @@ LL | reuse Trait::<1, 2, true>::foo as bar4; | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `T`, `N` - --> $DIR/generics-gen-args-errors.rs:77:11 + --> $DIR/generics-gen-args-errors.rs:76:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ - -------------- error[E0107]: trait takes 3 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/generics-gen-args-errors.rs:98:11 + --> $DIR/generics-gen-args-errors.rs:101:11 | LL | reuse Trait::<'static>::foo as bar5; | ^^^^^ ------- supplied 1 lifetime argument @@ -456,7 +419,7 @@ LL | reuse Trait::<'static>::foo as bar5; | expected 3 lifetime arguments | note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` - --> $DIR/generics-gen-args-errors.rs:77:11 + --> $DIR/generics-gen-args-errors.rs:76:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ -- -- -- @@ -465,16 +428,22 @@ help: add missing lifetime arguments LL | reuse Trait::<'static, 'static, 'static>::foo as bar5; | ++++++++++++++++++ -error[E0107]: trait takes 3 lifetime arguments but 1 lifetime argument was supplied +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/generics-gen-args-errors.rs:101:11 | +LL | reuse Trait::<'static>::foo as bar5; + | ^^^^^ not allowed in type signatures + +error[E0107]: trait takes 3 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/generics-gen-args-errors.rs:105:11 + | LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | ^^^^^ - supplied 1 lifetime argument | | | expected 3 lifetime arguments | note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` - --> $DIR/generics-gen-args-errors.rs:77:11 + --> $DIR/generics-gen-args-errors.rs:76:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ -- -- -- @@ -484,7 +453,7 @@ LL | reuse Trait::<1, 'static, 'static, 2, 'static, DDDD>::foo::<1, 2, 3, 4, | ++++++++++++++++++ error[E0107]: trait takes 2 generic arguments but 3 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:101:11 + --> $DIR/generics-gen-args-errors.rs:105:11 | LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | ^^^^^ --------------- help: remove the unnecessary generic argument @@ -492,13 +461,13 @@ LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `T`, `N` - --> $DIR/generics-gen-args-errors.rs:77:11 + --> $DIR/generics-gen-args-errors.rs:76:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ - -------------- error[E0107]: method takes 2 generic arguments but 6 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:101:41 + --> $DIR/generics-gen-args-errors.rs:105:41 | LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | ^^^ ------------ help: remove the unnecessary generic arguments @@ -506,13 +475,13 @@ LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | expected 2 generic arguments | note: method defined here, with 2 generic parameters: `U`, `M` - --> $DIR/generics-gen-args-errors.rs:78:12 + --> $DIR/generics-gen-args-errors.rs:77:12 | LL | fn foo<'d: 'd, U, const M: bool>(self) {} | ^^^ - ------------- error[E0107]: trait takes 3 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/generics-gen-args-errors.rs:107:11 + --> $DIR/generics-gen-args-errors.rs:111:11 | LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; | ^^^^^ ----- supplied 1 lifetime argument @@ -520,7 +489,7 @@ LL | reuse Trait::::foo::<1, 2, 3, _, | expected 3 lifetime arguments | note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` - --> $DIR/generics-gen-args-errors.rs:77:11 + --> $DIR/generics-gen-args-errors.rs:76:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ -- -- -- @@ -530,7 +499,7 @@ LL | reuse Trait::: | ++++++++++++++++++ error[E0107]: trait takes 2 generic arguments but 5 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:107:11 + --> $DIR/generics-gen-args-errors.rs:111:11 | LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; | ^^^^^ --- help: remove the unnecessary generic argument @@ -538,13 +507,13 @@ LL | reuse Trait::::foo::<1, 2, 3, _, | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `T`, `N` - --> $DIR/generics-gen-args-errors.rs:77:11 + --> $DIR/generics-gen-args-errors.rs:76:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ - -------------- error[E0107]: method takes 2 generic arguments but 5 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:107:59 + --> $DIR/generics-gen-args-errors.rs:111:59 | LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; | ^^^ --------- help: remove the unnecessary generic arguments @@ -552,12 +521,77 @@ LL | reuse Trait::::foo::<1, 2, 3, _, | expected 2 generic arguments | note: method defined here, with 2 generic parameters: `U`, `M` - --> $DIR/generics-gen-args-errors.rs:78:12 + --> $DIR/generics-gen-args-errors.rs:77:12 | LL | fn foo<'d: 'd, U, const M: bool>(self) {} | ^^^ - ------------- -error: aborting due to 47 previous errors +error[E0107]: function takes 3 generic arguments but 6 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:11:9 + | +LL | bar::<1, 2, 3, 4, 5, 6>(); + | ^^^ --------- help: remove the unnecessary generic arguments + | | + | expected 3 generic arguments + | +note: function defined here, with 3 generic parameters: `T`, `U`, `N` + --> $DIR/generics-gen-args-errors.rs:8:18 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | - - -------------- +LL | reuse foo as bar; + | ^^^ + +error[E0107]: function takes 2 lifetime arguments but 5 lifetime arguments were supplied + --> $DIR/generics-gen-args-errors.rs:17:9 + | +LL | bar::<'static, 'static, 'static, 'static, 'static>(); + | ^^^ --------------------------- help: remove the lifetime arguments + | | + | expected 2 lifetime arguments + | +note: function defined here, with 2 lifetime parameters: `'a`, `'b` + --> $DIR/generics-gen-args-errors.rs:8:18 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | -- -- +LL | reuse foo as bar; + | ^^^ + +error[E0747]: constant provided when a type was expected + --> $DIR/generics-gen-args-errors.rs:20:23 + | +LL | bar::(); + | ^ + +error[E0107]: function takes 3 generic arguments but 5 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:25:9 + | +LL | bar::<_, _, _, _, _>(); + | ^^^ ------ help: remove the unnecessary generic arguments + | | + | expected 3 generic arguments + | +note: function defined here, with 3 generic parameters: `T`, `U`, `N` + --> $DIR/generics-gen-args-errors.rs:8:18 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | - - -------------- +LL | reuse foo as bar; + | ^^^ + +error[E0747]: unresolved item provided when a constant was expected + --> $DIR/generics-gen-args-errors.rs:28:25 + | +LL | bar::(); + | ^^^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | bar::(); + | + + + +error: aborting due to 51 previous errors -Some errors have detailed explanations: E0106, E0107, E0261, E0284, E0401, E0423, E0425, E0747. +Some errors have detailed explanations: E0106, E0107, E0121, E0261, E0401, E0423, E0425, E0747. For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/delegation/generics/impl-trait-wrong-args-count.rs b/tests/ui/delegation/generics/impl-trait-wrong-args-count.rs index 08236f7cb9247..8c9b7d5a9e4e9 100644 --- a/tests/ui/delegation/generics/impl-trait-wrong-args-count.rs +++ b/tests/ui/delegation/generics/impl-trait-wrong-args-count.rs @@ -21,9 +21,10 @@ type XX = X::<'static, 'static, 'static, 'static, i32, i32, 3>; impl<'a, 'b, 'c, A, B, const N: usize> Trait<'a, 'b, 'c, A, B, N> for XX { reuse to_reuse::bar; - //~^ ERROR: type annotations needed + //~^ ERROR: function takes at most 2 generic arguments but 3 generic arguments were supplied reuse to_reuse::bar1; + //~^ ERROR: function takes 0 generic arguments but 3 generic arguments were supplied reuse to_reuse::bar2; //~^ ERROR: type annotations needed @@ -32,6 +33,7 @@ impl<'a, 'b, 'c, A, B, const N: usize> Trait<'a, 'b, 'c, A, B, N> for XX { reuse to_reuse::bar2:: as bar3; reuse to_reuse::bar2:: as bar4; + //~^ ERROR: method `bar4` has 0 type parameters but its trait declaration has 3 type parameters } fn main() { diff --git a/tests/ui/delegation/generics/impl-trait-wrong-args-count.stderr b/tests/ui/delegation/generics/impl-trait-wrong-args-count.stderr index e70d920a922d4..2a94ac0bfe03f 100644 --- a/tests/ui/delegation/generics/impl-trait-wrong-args-count.stderr +++ b/tests/ui/delegation/generics/impl-trait-wrong-args-count.stderr @@ -1,16 +1,43 @@ -error[E0282]: type annotations needed +error[E0049]: method `bar4` has 0 type parameters but its trait declaration has 3 type parameters + --> $DIR/impl-trait-wrong-args-count.rs:35:21 + | +LL | fn bar4(&self) {} + | - - - + | | + | expected 3 type parameters +... +LL | reuse to_reuse::bar2:: as bar4; + | ^^^^ found 0 type parameters + +error[E0107]: function takes at most 2 generic arguments but 3 generic arguments were supplied --> $DIR/impl-trait-wrong-args-count.rs:23:21 | +LL | fn bar<'x: 'x, 'y: 'y, AA, BB, const NN: usize>(&self) {} + | ----------------- help: remove the unnecessary generic argument +... LL | reuse to_reuse::bar; - | ^^^ cannot infer type of the type parameter `A` declared on the function `bar` + | ^^^ expected at most 2 generic arguments | -help: consider specifying the generic arguments +note: function defined here, with at most 2 generic parameters: `A`, `B` + --> $DIR/impl-trait-wrong-args-count.rs:5:12 + | +LL | pub fn bar<'a: 'a, 'b: 'b, A, B>(x: &super::XX) {} + | ^^^ - - + +error[E0107]: function takes 0 generic arguments but 3 generic arguments were supplied + --> $DIR/impl-trait-wrong-args-count.rs:26:21 + | +LL | reuse to_reuse::bar1; + | ^^^^ expected 0 generic arguments + | +note: function defined here, with 0 generic parameters + --> $DIR/impl-trait-wrong-args-count.rs:6:12 | -LL | reuse to_reuse::bar::; - | ++++++++ +LL | pub fn bar1(x: &super::XX) {} + | ^^^^ error[E0284]: type annotations needed - --> $DIR/impl-trait-wrong-args-count.rs:28:21 + --> $DIR/impl-trait-wrong-args-count.rs:29:21 | LL | reuse to_reuse::bar2; | ^^^^ cannot infer the value of the const parameter `X` declared on the function `bar2` @@ -26,7 +53,7 @@ LL | reuse to_reuse::bar2::; | ++++++++++++++++++++++++++ error[E0284]: type annotations needed - --> $DIR/impl-trait-wrong-args-count.rs:28:21 + --> $DIR/impl-trait-wrong-args-count.rs:29:21 | LL | reuse to_reuse::bar2; | ^^^^ cannot infer the value of the const parameter `Y` declared on the function `bar2` @@ -41,7 +68,7 @@ help: consider specifying the generic arguments LL | reuse to_reuse::bar2::; | ++++++++++++++++++++++++++ -error: aborting due to 3 previous errors +error: aborting due to 5 previous errors -Some errors have detailed explanations: E0282, E0284. -For more information about an error, try `rustc --explain E0282`. +Some errors have detailed explanations: E0049, E0107, E0284. +For more information about an error, try `rustc --explain E0049`. diff --git a/tests/ui/delegation/generics/mapping/free-to-free.rs b/tests/ui/delegation/generics/mapping/free-to-free-pass.rs similarity index 86% rename from tests/ui/delegation/generics/mapping/free-to-free.rs rename to tests/ui/delegation/generics/mapping/free-to-free-pass.rs index 375b0bfa901ff..aafdd5617d023 100644 --- a/tests/ui/delegation/generics/mapping/free-to-free.rs +++ b/tests/ui/delegation/generics/mapping/free-to-free-pass.rs @@ -1,3 +1,5 @@ +//@ run-pass + #![feature(fn_delegation)] #![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] @@ -15,7 +17,6 @@ mod test_1 { pub fn check() { reuse foo as bar; - //~^ ERROR: type annotations needed [E0284] bar::(); } } @@ -27,7 +28,6 @@ mod test_2 { pub fn check() { reuse foo as bar; - //~^ ERROR: type annotations needed [E0284] bar::(); } } @@ -39,7 +39,6 @@ mod test_3 { pub fn check() { reuse foo as bar; - //~^ ERROR: type annotations needed [E0284] bar::(); } } @@ -52,7 +51,6 @@ mod test_4 { pub fn check() { reuse foo as bar; - //~^ ERROR: type annotations needed [E0284] bar::(&1, &2); } } @@ -65,7 +63,6 @@ mod test_5 { pub fn check() { reuse foo as bar; - //~^ ERROR: type annotations needed [E0284] bar::(&1, &2); } } @@ -77,9 +74,7 @@ mod test_6 { pub fn check() { reuse foo:: as bar; - //~^ ERROR: arguments to this function are incorrect [E0308] bar(&"".to_string(), &"".to_string()); - //~^ ERROR: type annotations needed [E0284] } } @@ -104,9 +99,7 @@ mod test_8 { fn foo<'a, 'b, const N: usize, T: Clone, U: Clone>(_t: &'a T, _u: &'b U) {} reuse foo::<1, String, String> as bar; - //~^ ERROR: arguments to this function are incorrect [E0308] bar(&"".to_string(), &"".to_string()); - //~^ ERROR: type annotations needed [E0284] } } @@ -119,9 +112,7 @@ mod test_9 { fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} reuse foo:: as bar; - //~^ ERROR: arguments to this function are incorrect [E0308] bar(&"".to_string(), &"".to_string()); - //~^ ERROR: type annotations needed [E0284] }; closure(); diff --git a/tests/ui/delegation/generics/mapping/free-to-free.stderr b/tests/ui/delegation/generics/mapping/free-to-free.stderr deleted file mode 100644 index 0ecdb5f42e733..0000000000000 --- a/tests/ui/delegation/generics/mapping/free-to-free.stderr +++ /dev/null @@ -1,213 +0,0 @@ -error[E0284]: type annotations needed - --> $DIR/free-to-free.rs:17:15 - | -LL | reuse foo as bar; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_1::foo` - --> $DIR/free-to-free.rs:14:48 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo:: as bar; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/free-to-free.rs:29:15 - | -LL | reuse foo as bar; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_2::foo` - --> $DIR/free-to-free.rs:26:48 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo:: as bar; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/free-to-free.rs:41:15 - | -LL | reuse foo as bar; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_3::foo` - --> $DIR/free-to-free.rs:38:48 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo:: as bar; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/free-to-free.rs:54:15 - | -LL | reuse foo as bar; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_4::foo` - --> $DIR/free-to-free.rs:51:40 - | -LL | fn foo<'a, 'b, T: Clone, U: Clone, const N: usize>(_t: &'a T, _u: &'b U) {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo:: as bar; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/free-to-free.rs:67:15 - | -LL | reuse foo as bar; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_5::foo` - --> $DIR/free-to-free.rs:64:30 - | -LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo:: as bar; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/free-to-free.rs:81:9 - | -LL | bar(&"".to_string(), &"".to_string()); - | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` - | -note: required by a const generic parameter in `test_6::check::bar` - --> $DIR/free-to-free.rs:76:30 - | -LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` -... -LL | reuse foo:: as bar; - | --- required by a bound in this function -help: consider specifying the generic arguments - | -LL | bar::(&"".to_string(), &"".to_string()); - | +++++++++++++++++++++ - -error[E0308]: arguments to this function are incorrect - --> $DIR/free-to-free.rs:79:15 - | -LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} - | - - found this type parameter - | | - | found this type parameter -... -LL | reuse foo:: as bar; - | ^^^ - | | - | expected `&String`, found `&T` - | expected `&String`, found `&U` - | - = note: expected reference `&String` - found reference `&'a T` - = note: expected reference `&String` - found reference `&'b U` -note: function defined here - --> $DIR/free-to-free.rs:76:8 - | -LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} - | ^^^ --------- --------- - -error[E0284]: type annotations needed - --> $DIR/free-to-free.rs:108:9 - | -LL | bar(&"".to_string(), &"".to_string()); - | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` - | -note: required by a const generic parameter in `test_8::check::bar` - --> $DIR/free-to-free.rs:104:24 - | -LL | fn foo<'a, 'b, const N: usize, T: Clone, U: Clone>(_t: &'a T, _u: &'b U) {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` -LL | -LL | reuse foo::<1, String, String> as bar; - | --- required by a bound in this function -help: consider specifying the generic arguments - | -LL | bar::(&"".to_string(), &"".to_string()); - | +++++++++++++++++++++ - -error[E0308]: arguments to this function are incorrect - --> $DIR/free-to-free.rs:106:15 - | -LL | fn foo<'a, 'b, const N: usize, T: Clone, U: Clone>(_t: &'a T, _u: &'b U) {} - | - - found this type parameter - | | - | found this type parameter -LL | -LL | reuse foo::<1, String, String> as bar; - | ^^^ - | | - | expected `&String`, found `&T` - | expected `&String`, found `&U` - | - = note: expected reference `&String` - found reference `&'a T` - = note: expected reference `&String` - found reference `&'b U` -note: function defined here - --> $DIR/free-to-free.rs:104:12 - | -LL | fn foo<'a, 'b, const N: usize, T: Clone, U: Clone>(_t: &'a T, _u: &'b U) {} - | ^^^ --------- --------- - -error[E0284]: type annotations needed - --> $DIR/free-to-free.rs:123:13 - | -LL | bar(&"".to_string(), &"".to_string()); - | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` - | -note: required by a const generic parameter in `test_9::check::{closure#0}::bar` - --> $DIR/free-to-free.rs:119:38 - | -LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` -LL | -LL | reuse foo:: as bar; - | --- required by a bound in this function -help: consider specifying the generic arguments - | -LL | bar::(&"".to_string(), &"".to_string()); - | +++++++++++++++++++++ - -error[E0308]: arguments to this function are incorrect - --> $DIR/free-to-free.rs:121:19 - | -LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} - | - - found this type parameter - | | - | found this type parameter -LL | -LL | reuse foo:: as bar; - | ^^^ - | | - | expected `&String`, found `&T` - | expected `&String`, found `&U` - | - = note: expected reference `&String` - found reference `&'a T` - = note: expected reference `&String` - found reference `&'b U` -note: function defined here - --> $DIR/free-to-free.rs:119:16 - | -LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} - | ^^^ --------- --------- - -error: aborting due to 11 previous errors - -Some errors have detailed explanations: E0284, E0308. -For more information about an error, try `rustc --explain E0284`. diff --git a/tests/ui/delegation/generics/mapping/free-to-trait.rs b/tests/ui/delegation/generics/mapping/free-to-trait-pass.rs similarity index 76% rename from tests/ui/delegation/generics/mapping/free-to-trait.rs rename to tests/ui/delegation/generics/mapping/free-to-trait-pass.rs index b0404a4aeef83..04c8da0c81a95 100644 --- a/tests/ui/delegation/generics/mapping/free-to-trait.rs +++ b/tests/ui/delegation/generics/mapping/free-to-trait-pass.rs @@ -1,3 +1,5 @@ +//@ run-pass + #![feature(fn_delegation)] #![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] @@ -20,13 +22,11 @@ mod test_1 { pub fn check() { fn no_ctx() { reuse Trait::foo as bar; - //~^ ERROR: type annotations needed [E0284] bar::<'static, 'static, 'static, 'static, u8, i32, 1, String, true>(123); } fn with_ctx<'a, 'b, 'c, A, B, C, const N: usize, const M: bool>() { reuse Trait::foo as bar; - //~^ ERROR: type annotations needed [E0284] bar::<'static, 'static, 'static, 'a, u8, i32, 1, A, M>(123); } @@ -45,11 +45,8 @@ mod test_2 { pub fn check() { reuse Trait::<'static, i32, 1>::foo as bar; - //~^ ERROR: the trait bound `Self: test_2::Trait<'static, i32, 1>` is not satisfied [E0277] bar::<'static, u8, String, true>(123); - //~^ ERROR: function takes 5 generic arguments but 3 generic arguments were supplied [E0107] - //~| ERROR: function takes 2 lifetime arguments but 1 lifetime argument was supplied [E0107] } } @@ -66,8 +63,6 @@ mod test_3 { reuse Trait::foo::<'static, i32, true> as bar; bar::<'static, u8, String, 1>(123); - //~^ ERROR: function takes 5 generic arguments but 3 generic arguments were supplied [E0107] - //~| ERROR: function takes 2 lifetime arguments but 1 lifetime argument was supplied [E0107] } } @@ -84,7 +79,6 @@ mod test_4 { reuse Trait::foo::<'static, i32, true> as bar; bar::(123); - //~^ ERROR: function takes 5 generic arguments but 3 generic arguments were supplied [E0107] } } @@ -100,7 +94,6 @@ mod test_5 { reuse Trait::foo::<'static, i32, true> as bar; bar::(123); - //~^ ERROR: function takes 4 generic arguments but 2 generic arguments were supplied [E0107] } } @@ -117,7 +110,6 @@ mod test_6 { reuse Trait::foo::<'static, i32, true> as bar; bar::(123); - //~^ ERROR: function takes 3 generic arguments but 1 generic argument was supplied [E0107] } } @@ -132,10 +124,8 @@ mod test_7 { pub fn check() { reuse Trait::<'static, i32, 1>::foo as bar; - //~^ ERROR: the trait bound `Self: test_7::Trait<'static, i32, 1>` is not satisfied [E0277] bar::(123); - //~^ ERROR: function takes 5 generic arguments but 3 generic arguments were supplied [E0107] } } @@ -149,10 +139,8 @@ mod test_8 { pub fn check() { reuse Trait::<'static, i32, 1>::foo as bar; - //~^ ERROR: the trait bound `Self: test_8::Trait<'static, i32, 1>` is not satisfied [E0277] bar::(123); - //~^ ERROR: function takes 4 generic arguments but 2 generic arguments were supplied [E0107] } } @@ -166,10 +154,8 @@ mod test_9 { pub fn check() { reuse Trait::<'static, i32, 1>::foo as bar; - //~^ ERROR: the trait bound `Self: test_9::Trait<'static, i32, 1>` is not satisfied [E0277] bar::(123); - //~^ ERROR: function takes 3 generic arguments but 1 generic argument was supplied [E0107] } } @@ -186,19 +172,14 @@ mod test_10 { pub fn check() { fn with_ctx<'a, 'b, 'c, A, B, C, const N: usize, const M: bool>() { reuse ::foo as bar; - //~^ ERROR: missing generics for trait `test_10::Trait` [E0107] bar::<'a, 'b, 'c, u8, C, A, M>(); bar::<'static, 'static, 'static, u8, i32, i32, false>(); reuse >::foo as bar1; - //~^ ERROR: type annotations needed [E0284] bar1::<'static, u8, i32, true>(); - //~^ ERROR: function takes 4 generic arguments but 3 generic arguments were supplied [E0107] - //~| ERROR: function takes 3 lifetime arguments but 1 lifetime argument was supplied [E0107] reuse >::foo::<'static, u32, true> as bar2; bar2::(); - //~^ ERROR: function takes 4 generic arguments but 1 generic argument was supplied [E0107] } with_ctx::(); @@ -231,7 +212,6 @@ mod test_11 { pub fn check<'b>() { reuse ::foo; - //~^ ERROR: missing generics for trait `test_11::Trait` [E0107] foo::<'static, 'b, usize, u32, Struct, String, false>(); } } diff --git a/tests/ui/delegation/generics/mapping/free-to-trait.stderr b/tests/ui/delegation/generics/mapping/free-to-trait.stderr deleted file mode 100644 index b364d7fb22511..0000000000000 --- a/tests/ui/delegation/generics/mapping/free-to-trait.stderr +++ /dev/null @@ -1,401 +0,0 @@ -error[E0284]: type annotations needed - --> $DIR/free-to-trait.rs:22:26 - | -LL | reuse Trait::foo as bar; - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_1::Trait::foo` - --> $DIR/free-to-trait.rs:15:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::foo:: as bar; - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/free-to-trait.rs:28:26 - | -LL | reuse Trait::foo as bar; - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_1::Trait::foo` - --> $DIR/free-to-trait.rs:15:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::foo:: as bar; - | ++++++++ - -error[E0107]: function takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/free-to-trait.rs:50:9 - | -LL | bar::<'static, u8, String, true>(123); - | ^^^ ------- supplied 1 lifetime argument - | | - | expected 2 lifetime arguments - | -note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/free-to-trait.rs:47:48 - | -LL | trait Trait<'a, T, const N: usize>: Sized { - | -- -LL | fn foo<'b: 'b, U, const M: bool>(self) {} - | -- -... -LL | reuse Trait::<'static, i32, 1>::foo as bar; - | ^^^ -help: add missing lifetime argument - | -LL | bar::<'static, 'static, u8, String, true>(123); - | +++++++++ - -error[E0107]: function takes 5 generic arguments but 3 generic arguments were supplied - --> $DIR/free-to-trait.rs:50:9 - | -LL | bar::<'static, u8, String, true>(123); - | ^^^ -- ------ ---- supplied 3 generic arguments - | | - | expected 5 generic arguments - | -note: function defined here, with 5 generic parameters: `Self`, `T`, `N`, `U`, `M` - --> $DIR/free-to-trait.rs:47:48 - | -LL | trait Trait<'a, T, const N: usize>: Sized { - | ----------------------------------------- -LL | fn foo<'b: 'b, U, const M: bool>(self) {} - | - ------------- -... -LL | reuse Trait::<'static, i32, 1>::foo as bar; - | ^^^ -help: add missing generic arguments - | -LL | bar::<'static, u8, String, true, U, M>(123); - | ++++++ - -error[E0277]: the trait bound `Self: test_2::Trait<'static, i32, 1>` is not satisfied - --> $DIR/free-to-trait.rs:47:41 - | -LL | reuse Trait::<'static, i32, 1>::foo as bar; - | ^^^ the trait `test_2::Trait<'static, i32, 1>` is not implemented for `Self` - -error[E0107]: function takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/free-to-trait.rs:68:9 - | -LL | bar::<'static, u8, String, 1>(123); - | ^^^ ------- supplied 1 lifetime argument - | | - | expected 2 lifetime arguments - | -note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/free-to-trait.rs:66:51 - | -LL | trait Trait<'a, T, const N: usize>: Sized { - | -- -LL | fn foo<'b: 'b, U, const M: bool>(self) {} - | -- -... -LL | reuse Trait::foo::<'static, i32, true> as bar; - | ^^^ -help: add missing lifetime argument - | -LL | bar::<'static, 'static, u8, String, 1>(123); - | +++++++++ - -error[E0107]: function takes 5 generic arguments but 3 generic arguments were supplied - --> $DIR/free-to-trait.rs:68:9 - | -LL | bar::<'static, u8, String, 1>(123); - | ^^^ -- ------ - supplied 3 generic arguments - | | - | expected 5 generic arguments - | -note: function defined here, with 5 generic parameters: `Self`, `T`, `N`, `U`, `M` - --> $DIR/free-to-trait.rs:66:51 - | -LL | trait Trait<'a, T, const N: usize>: Sized { - | ----------------------------------------- -LL | fn foo<'b: 'b, U, const M: bool>(self) {} - | - ------------- -... -LL | reuse Trait::foo::<'static, i32, true> as bar; - | ^^^ -help: add missing generic arguments - | -LL | bar::<'static, u8, String, 1, U, M>(123); - | ++++++ - -error[E0107]: function takes 5 generic arguments but 3 generic arguments were supplied - --> $DIR/free-to-trait.rs:86:9 - | -LL | bar::(123); - | ^^^ -- ------ - supplied 3 generic arguments - | | - | expected 5 generic arguments - | -note: function defined here, with 5 generic parameters: `Self`, `T`, `N`, `U`, `M` - --> $DIR/free-to-trait.rs:84:51 - | -LL | trait Trait: Sized { - | ------------------------------------- -LL | fn foo<'b: 'b, U, const M: bool>(self) {} - | - ------------- -... -LL | reuse Trait::foo::<'static, i32, true> as bar; - | ^^^ -help: add missing generic arguments - | -LL | bar::(123); - | ++++++ - -error[E0107]: function takes 4 generic arguments but 2 generic arguments were supplied - --> $DIR/free-to-trait.rs:102:9 - | -LL | bar::(123); - | ^^^ -- - supplied 2 generic arguments - | | - | expected 4 generic arguments - | -note: function defined here, with 4 generic parameters: `Self`, `N`, `U`, `M` - --> $DIR/free-to-trait.rs:100:51 - | -LL | trait Trait: Sized { - | ---------------------------------- -LL | fn foo<'b: 'b, U, const M: bool>(self) {} - | - ------------- -... -LL | reuse Trait::foo::<'static, i32, true> as bar; - | ^^^ -help: add missing generic arguments - | -LL | bar::(123); - | ++++++ - -error[E0107]: function takes 3 generic arguments but 1 generic argument was supplied - --> $DIR/free-to-trait.rs:119:9 - | -LL | bar::(123); - | ^^^ -- supplied 1 generic argument - | | - | expected 3 generic arguments - | -note: function defined here, with 3 generic parameters: `Self`, `U`, `M` - --> $DIR/free-to-trait.rs:117:51 - | -LL | trait Trait: Sized { - | ------------------ -LL | fn foo<'b: 'b, U, const M: bool>(self) {} - | - ------------- -... -LL | reuse Trait::foo::<'static, i32, true> as bar; - | ^^^ -help: add missing generic arguments - | -LL | bar::(123); - | ++++++ - -error[E0107]: function takes 5 generic arguments but 3 generic arguments were supplied - --> $DIR/free-to-trait.rs:137:9 - | -LL | bar::(123); - | ^^^ -- ------ ---- supplied 3 generic arguments - | | - | expected 5 generic arguments - | -note: function defined here, with 5 generic parameters: `Self`, `T`, `N`, `U`, `M` - --> $DIR/free-to-trait.rs:134:48 - | -LL | trait Trait<'a, T, const N: usize>: Sized { - | ----------------------------------------- -LL | fn foo(self) {} - | - ------------- -... -LL | reuse Trait::<'static, i32, 1>::foo as bar; - | ^^^ -help: add missing generic arguments - | -LL | bar::(123); - | ++++++ - -error[E0277]: the trait bound `Self: test_7::Trait<'static, i32, 1>` is not satisfied - --> $DIR/free-to-trait.rs:134:41 - | -LL | reuse Trait::<'static, i32, 1>::foo as bar; - | ^^^ the trait `test_7::Trait<'static, i32, 1>` is not implemented for `Self` - -error[E0107]: function takes 4 generic arguments but 2 generic arguments were supplied - --> $DIR/free-to-trait.rs:154:9 - | -LL | bar::(123); - | ^^^ -- ---- supplied 2 generic arguments - | | - | expected 4 generic arguments - | -note: function defined here, with 4 generic parameters: `Self`, `T`, `N`, `M` - --> $DIR/free-to-trait.rs:151:48 - | -LL | trait Trait<'a, T, const N: usize>: Sized { - | ----------------------------------------- -LL | fn foo(self) {} - | ------------- -... -LL | reuse Trait::<'static, i32, 1>::foo as bar; - | ^^^ -help: add missing generic arguments - | -LL | bar::(123); - | ++++++ - -error[E0277]: the trait bound `Self: test_8::Trait<'static, i32, 1>` is not satisfied - --> $DIR/free-to-trait.rs:151:41 - | -LL | reuse Trait::<'static, i32, 1>::foo as bar; - | ^^^ the trait `test_8::Trait<'static, i32, 1>` is not implemented for `Self` - -error[E0107]: function takes 3 generic arguments but 1 generic argument was supplied - --> $DIR/free-to-trait.rs:171:9 - | -LL | bar::(123); - | ^^^ -- supplied 1 generic argument - | | - | expected 3 generic arguments - | -note: function defined here, with 3 generic parameters: `Self`, `T`, `N` - --> $DIR/free-to-trait.rs:168:48 - | -LL | trait Trait<'a, T, const N: usize>: Sized { - | ----------------------------------------- -... -LL | reuse Trait::<'static, i32, 1>::foo as bar; - | ^^^ -help: add missing generic arguments - | -LL | bar::(123); - | ++++++ - -error[E0277]: the trait bound `Self: test_9::Trait<'static, i32, 1>` is not satisfied - --> $DIR/free-to-trait.rs:168:41 - | -LL | reuse Trait::<'static, i32, 1>::foo as bar; - | ^^^ the trait `test_9::Trait<'static, i32, 1>` is not implemented for `Self` - -error[E0107]: function takes 3 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/free-to-trait.rs:195:13 - | -LL | bar1::<'static, u8, i32, true>(); - | ^^^^ ------- supplied 1 lifetime argument - | | - | expected 3 lifetime arguments - | -note: function defined here, with 3 lifetime parameters: `'b`, `'c`, `'d` - --> $DIR/free-to-trait.rs:193:66 - | -LL | trait Trait<'b, 'c, T> { - | -- -- -LL | fn foo<'d: 'd, U, const M: bool>() {} - | -- -... -LL | reuse >::foo as bar1; - | ^^^^ -help: add missing lifetime arguments - | -LL | bar1::<'static, 'static, 'static, u8, i32, true>(); - | ++++++++++++++++++ - -error[E0107]: function takes 4 generic arguments but 3 generic arguments were supplied - --> $DIR/free-to-trait.rs:195:13 - | -LL | bar1::<'static, u8, i32, true>(); - | ^^^^ -- --- ---- supplied 3 generic arguments - | | - | expected 4 generic arguments - | -note: function defined here, with 4 generic parameters: `Self`, `T`, `U`, `M` - --> $DIR/free-to-trait.rs:193:66 - | -LL | trait Trait<'b, 'c, T> { - | ---------------------- -LL | fn foo<'d: 'd, U, const M: bool>() {} - | - ------------- -... -LL | reuse >::foo as bar1; - | ^^^^ -help: add missing generic argument - | -LL | bar1::<'static, u8, i32, true, M>(); - | +++ - -error[E0107]: function takes 4 generic arguments but 1 generic argument was supplied - --> $DIR/free-to-trait.rs:200:13 - | -LL | bar2::(); - | ^^^^ -- supplied 1 generic argument - | | - | expected 4 generic arguments - | -note: function defined here, with 4 generic parameters: `Self`, `T`, `U`, `M` - --> $DIR/free-to-trait.rs:199:88 - | -LL | trait Trait<'b, 'c, T> { - | ---------------------- -LL | fn foo<'d: 'd, U, const M: bool>() {} - | - ------------- -... -LL | reuse >::foo::<'static, u32, true> as bar2; - | ^^^^ -help: add missing generic arguments - | -LL | bar2::(); - | +++++++++ - -error[E0107]: missing generics for trait `test_10::Trait` - --> $DIR/free-to-trait.rs:188:26 - | -LL | reuse ::foo as bar; - | ^^^^^ expected 1 generic argument - | -note: trait defined here, with 1 generic parameter: `T` - --> $DIR/free-to-trait.rs:180:11 - | -LL | trait Trait<'b, 'c, T> { - | ^^^^^ - -help: add missing generic argument - | -LL | reuse >::foo as bar; - | +++ - -error[E0284]: type annotations needed - --> $DIR/free-to-trait.rs:193:59 - | -LL | reuse >::foo as bar1; - | ^^^ cannot infer the value of the const parameter `M` declared on the associated function `foo` - | -note: required by a const generic parameter in `test_10::Trait::foo` - --> $DIR/free-to-trait.rs:181:27 - | -LL | fn foo<'d: 'd, U, const M: bool>() {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0107]: missing generics for trait `test_11::Trait` - --> $DIR/free-to-trait.rs:233:25 - | -LL | reuse ::foo; - | ^^^^^ expected 2 generic arguments - | -note: trait defined here, with 2 generic parameters: `T`, `P` - --> $DIR/free-to-trait.rs:216:11 - | -LL | trait Trait<'a: 'static, T, P> - | ^^^^^ - - -help: add missing generic arguments - | -LL | reuse >::foo; - | ++++++ - -error: aborting due to 22 previous errors - -Some errors have detailed explanations: E0107, E0277, E0284. -For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/delegation/generics/mapping/impl-trait-to-free.rs b/tests/ui/delegation/generics/mapping/impl-trait-to-free-pass.rs similarity index 88% rename from tests/ui/delegation/generics/mapping/impl-trait-to-free.rs rename to tests/ui/delegation/generics/mapping/impl-trait-to-free-pass.rs index 2a7add215dedb..53947c41cf570 100644 --- a/tests/ui/delegation/generics/mapping/impl-trait-to-free.rs +++ b/tests/ui/delegation/generics/mapping/impl-trait-to-free-pass.rs @@ -1,3 +1,5 @@ +//@ run-pass + #![feature(fn_delegation)] #![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] @@ -13,7 +15,7 @@ mod test_1 { mod to_reuse { pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} - pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(x: &super::XX) {} + pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(_x: &super::XX) {} } trait Trait<'a, 'b, 'c, A, B, const N: usize>: Sized { @@ -23,15 +25,14 @@ mod test_1 { fn rab(&self) {} } + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct X<'x1, 'x2, 'x3, 'x4, X1, X2, const X3: usize>( &'x1 X1, &'x2 X2, &'x3 X1, &'x4 [usize; X3]); type XX = X::<'static, 'static, 'static, 'static, i32, i32, 3>; impl<'a, 'b, 'c, A, B, const N: usize> Trait<'a, 'b, 'c, A, B, N> for XX { reuse to_reuse::foo; - //~^ ERROR: type annotations needed [E0284] reuse to_reuse::bar; - //~^ ERROR: type annotations needed [E0284] reuse to_reuse::foo::<'a, 'c, A, String, 322> as oof; reuse to_reuse::bar::<'a, 'c, A, B, 223> as rab; @@ -54,7 +55,7 @@ mod test_1 { mod test_2 { mod to_reuse { pub fn foo() {} - pub fn bar(x: &super::X) {} + pub fn bar(_x: &super::X) {} } trait Trait<'a, 'b, 'c, A, B, const N: usize>: Sized { @@ -67,9 +68,7 @@ mod test_2 { struct X; impl<'a, A, B, const N: usize> Trait<'a, 'static, 'static, A, B, N> for X { reuse to_reuse::foo; - //~^ ERROR: type annotations needed [E0284] reuse to_reuse::bar; - //~^ ERROR: type annotations needed [E0284] reuse to_reuse::foo:: as oof; reuse to_reuse::bar:: as rab; @@ -88,7 +87,7 @@ mod test_2 { mod test_3 { mod to_reuse { pub fn foo() {} - pub fn bar(x: &super::X) {} + pub fn bar(_x: &super::X) {} } trait Trait<'a, 'b, 'c, A, B, const N: usize>: Sized { @@ -113,7 +112,7 @@ mod test_3 { mod test_4 { mod to_reuse { pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} - pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(x: &super::X) {} + pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(_x: &super::X) {} } trait Trait: Sized { @@ -126,9 +125,7 @@ mod test_4 { struct X; impl<'a, 'c, A, B, const N: usize> Trait for X { reuse to_reuse::foo; - //~^ ERROR: type annotations needed [E0284] reuse to_reuse::bar; - //~^ ERROR: type annotations needed [E0284] reuse to_reuse::foo::<'a, 'c, A, String, 322> as oof; reuse to_reuse::bar::<'a, 'c, i32, B, 223> as rab; @@ -147,23 +144,25 @@ mod test_4 { mod test_5 { mod to_reuse { pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} - pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(x: &super::X::) {} + pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(_x: &super::X::) {} } trait Trait: Sized { fn foo<'x: 'x, 'y: 'y, AA, BB, const NN: usize>() {} - fn bar<'x: 'x, 'y: 'y, AA, BB, const NN: usize>(&self) {} fn oof() {} fn rab(&self) {} } struct X(A, B); impl<'a, 'c, A, B> Trait for X { + reuse to_reuse::foo; + reuse to_reuse::foo::<'a, 'c, A, B, 322> as oof; reuse to_reuse::bar::<'a, 'c, A, B, 223> as rab; } pub fn check() { + as Trait>::foo::<'static, 'static, i8, i16, 123>(); as Trait>::oof(); as Trait>::rab(&X(1, 2)); } @@ -174,7 +173,7 @@ mod test_5 { mod test_6 { mod to_reuse { pub fn foo() {} - pub fn bar(x: &super::X) {} + pub fn bar(_x: &super::X) {} } trait Trait: Sized { @@ -187,9 +186,7 @@ mod test_6 { struct X; impl<'a, 'c, A, B, const N: usize> Trait for X { reuse to_reuse::foo; - //~^ ERROR: type annotations needed [E0284] reuse to_reuse::bar; - //~^ ERROR: type annotations needed [E0284] reuse to_reuse::foo:: as oof; reuse to_reuse::bar:: as rab; @@ -208,7 +205,7 @@ mod test_6 { mod test_7 { mod to_reuse { pub fn foo() {} - pub fn bar(x: &super::X) {} + pub fn bar(_x: &super::X) {} } trait Trait: Sized { @@ -232,7 +229,7 @@ mod test_7 { mod test_8 { mod to_reuse { pub fn foo() {} - pub fn bar(x: &super::X) {} + pub fn bar(_x: &super::X) {} } trait Trait: Sized { diff --git a/tests/ui/delegation/generics/mapping/impl-trait-to-free.stderr b/tests/ui/delegation/generics/mapping/impl-trait-to-free.stderr deleted file mode 100644 index 37c45e11b7978..0000000000000 --- a/tests/ui/delegation/generics/mapping/impl-trait-to-free.stderr +++ /dev/null @@ -1,131 +0,0 @@ -error[E0284]: type annotations needed - --> $DIR/impl-trait-to-free.rs:31:25 - | -LL | reuse to_reuse::foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_1::to_reuse::foo` - --> $DIR/impl-trait-to-free.rs:15:42 - | -LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse to_reuse::foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/impl-trait-to-free.rs:33:25 - | -LL | reuse to_reuse::bar; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` - | -note: required by a const generic parameter in `test_1::to_reuse::bar` - --> $DIR/impl-trait-to-free.rs:16:42 - | -LL | pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(x: &super::XX) {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` -help: consider specifying the generic arguments - | -LL | reuse to_reuse::bar::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/impl-trait-to-free.rs:69:25 - | -LL | reuse to_reuse::foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_2::to_reuse::foo` - --> $DIR/impl-trait-to-free.rs:56:26 - | -LL | pub fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse to_reuse::foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/impl-trait-to-free.rs:71:25 - | -LL | reuse to_reuse::bar; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` - | -note: required by a const generic parameter in `test_2::to_reuse::bar` - --> $DIR/impl-trait-to-free.rs:57:26 - | -LL | pub fn bar(x: &super::X) {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` -help: consider specifying the generic arguments - | -LL | reuse to_reuse::bar::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/impl-trait-to-free.rs:128:25 - | -LL | reuse to_reuse::foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_4::to_reuse::foo` - --> $DIR/impl-trait-to-free.rs:115:42 - | -LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse to_reuse::foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/impl-trait-to-free.rs:130:25 - | -LL | reuse to_reuse::bar; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` - | -note: required by a const generic parameter in `test_4::to_reuse::bar` - --> $DIR/impl-trait-to-free.rs:116:42 - | -LL | pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(x: &super::X) {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` -help: consider specifying the generic arguments - | -LL | reuse to_reuse::bar::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/impl-trait-to-free.rs:189:25 - | -LL | reuse to_reuse::foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_6::to_reuse::foo` - --> $DIR/impl-trait-to-free.rs:176:26 - | -LL | pub fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse to_reuse::foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/impl-trait-to-free.rs:191:25 - | -LL | reuse to_reuse::bar; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` - | -note: required by a const generic parameter in `test_6::to_reuse::bar` - --> $DIR/impl-trait-to-free.rs:177:26 - | -LL | pub fn bar(x: &super::X) {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` -help: consider specifying the generic arguments - | -LL | reuse to_reuse::bar::; - | +++++++++++ - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/delegation/generics/mapping/impl-trait-to-trait.rs b/tests/ui/delegation/generics/mapping/impl-trait-to-trait-pass.rs similarity index 89% rename from tests/ui/delegation/generics/mapping/impl-trait-to-trait.rs rename to tests/ui/delegation/generics/mapping/impl-trait-to-trait-pass.rs index 1bbedf9cb2222..2f556f81c1ef0 100644 --- a/tests/ui/delegation/generics/mapping/impl-trait-to-trait.rs +++ b/tests/ui/delegation/generics/mapping/impl-trait-to-trait-pass.rs @@ -1,3 +1,5 @@ +//@ run-pass + #![feature(fn_delegation)] #![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] @@ -26,11 +28,11 @@ mod test_1 { struct F; impl Trait1 for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, T, A, B> Trait1 for S<'a, 'b, 'c, A, B> { reuse Trait1::::foo { &self.0 } - //~^ ERROR: type annotations needed [E0283] } impl Trait0 for u16 {} @@ -51,6 +53,7 @@ mod test_2 { struct F; impl Trait for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B, const C: bool> Trait for S<'a, 'b, 'c, A, B, C> { @@ -73,6 +76,7 @@ mod test_3 { struct F; impl<'a, 'b, 'c, X, Y, Z> Trait<'a, 'b, 'c, X, Y, Z> for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B, const C: bool> Trait<'a, 'b, 'static, A, String, bool> @@ -97,12 +101,12 @@ mod test_4 { struct F; impl<'a, 'b, 'c, X, Y, Z> Trait<'a, 'b, 'c, X, Y, Z> for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B, const C: bool> Trait<'a, 'b, 'static, A, String, bool> for S<'a, 'b, 'c, A, B, C> { reuse Trait::<'a, 'b, 'static, A, String, bool>::foo { &self.0 } - //~^ ERROR: type annotations needed [E0284] } pub fn check() { @@ -123,6 +127,7 @@ mod test_5 { struct F; impl Trait for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B, const C: bool> Trait for S<'a, 'b, 'c, A, B, C> { @@ -147,11 +152,11 @@ mod test_6 { struct F; impl Trait for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B, const C: bool> Trait for S<'a, 'b, 'c, A, B, C> { reuse Trait::::foo { &self.0 } - //~^ ERROR: type annotations needed [E0282] } pub fn check() { @@ -170,6 +175,7 @@ mod test_7 { struct F; impl Trait for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B, const C: bool> Trait for S<'a, 'b, 'c, A, B, C> { @@ -192,6 +198,7 @@ mod test_8 { struct F; impl<'a, 'b, 'c> Trait<'a, 'b, 'c> for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B, const C: bool> Trait<'a, 'b, 'c> for S<'a, 'b, 'c, A, B, C> { @@ -214,6 +221,7 @@ mod test_9 { struct F; impl<'a, 'b, 'c> Trait<'a, 'b, 'c> for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B, const C: bool> Trait<'a, 'b, 'c> for S<'a, 'b, 'c, A, B, C> { diff --git a/tests/ui/delegation/generics/mapping/impl-trait-to-trait.stderr b/tests/ui/delegation/generics/mapping/impl-trait-to-trait.stderr deleted file mode 100644 index 8e7118b1bd273..0000000000000 --- a/tests/ui/delegation/generics/mapping/impl-trait-to-trait.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0283]: type annotations needed - --> $DIR/impl-trait-to-trait.rs:32:28 - | -LL | reuse Trait1::::foo { &self.0 } - | ^^^ cannot infer type of the type parameter `U` declared on the method `foo` - | - = note: cannot satisfy `_: Trait0` -help: the trait `Trait0` is implemented for `u16` - --> $DIR/impl-trait-to-trait.rs:36:5 - | -LL | impl Trait0 for u16 {} - | ^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `Trait1::foo` - --> $DIR/impl-trait-to-trait.rs:21:16 - | -LL | fn foo(&self) - | --- required by a bound in this associated function -... -LL | U: Trait0, - | ^^^^^^ required by this bound in `Trait1::foo` - -error[E0284]: type annotations needed - --> $DIR/impl-trait-to-trait.rs:104:58 - | -LL | reuse Trait::<'a, 'b, 'static, A, String, bool>::foo { &self.0 } - | ^^^ cannot infer the value of the const parameter `XX` declared on the method `foo` - | -note: required by a const generic parameter in `test_4::Trait::foo` - --> $DIR/impl-trait-to-trait.rs:94:49 - | -LL | fn foo<'x: 'x, 'y: 'y, 'z: 'z, A, B, C, const XX: usize>(&self) {} - | ^^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0282]: type annotations needed - --> $DIR/impl-trait-to-trait.rs:153:41 - | -LL | reuse Trait::::foo { &self.0 } - | ^^^ cannot infer type of the type parameter `A` declared on the method `foo` - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0282, E0283, E0284. -For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/delegation/generics/mapping/inherent-impl-to-free.rs b/tests/ui/delegation/generics/mapping/inherent-impl-to-free-pass.rs similarity index 84% rename from tests/ui/delegation/generics/mapping/inherent-impl-to-free.rs rename to tests/ui/delegation/generics/mapping/inherent-impl-to-free-pass.rs index f55bab484f132..69e0523a0c995 100644 --- a/tests/ui/delegation/generics/mapping/inherent-impl-to-free.rs +++ b/tests/ui/delegation/generics/mapping/inherent-impl-to-free-pass.rs @@ -1,3 +1,5 @@ +//@ run-pass + #![feature(fn_delegation)] #![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] @@ -16,24 +18,23 @@ mod test_1 { pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} } + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct X1<'a, 'b, T, X, const N: usize>(&'a T, &'b X, &'a [i32; N]); impl<'a, 'b, T, E, const N: usize> X1<'a, 'b, T, E, N> { reuse to_reuse::foo; - //~^ ERROR: type annotations needed [E0284] reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; } + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct X2(T, X, &'static [i32; N]); impl X2 { reuse to_reuse::foo; - //~^ ERROR: type annotations needed [E0284] reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; } struct X3; impl X3 { reuse to_reuse::foo; - //~^ ERROR: type annotations needed [E0284] reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; } @@ -41,15 +42,12 @@ mod test_1 { X1::<'static, 'static, i32, i32, 1> ::foo::<'static, 'static, String, String, 123>(); X1::<'static, 'static, i32, i32, 1>::bar(); - //~^ ERROR: type annotations needed [E0284] X2::::foo::<'static, 'static, String, String, 123>(); X2::::bar(); - //~^ ERROR: type annotations needed [E0284] X3::foo::<'static, 'static, String, String, 123>(); X3::bar(); - //~^ ERROR: type annotations needed [E0284] } } @@ -58,39 +56,35 @@ mod test_1 { mod test_2 { fn foo() {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct X1<'a, 'b, T, X, const N: usize>(&'a T, &'b X, &'a [i32; N]); impl<'a, 'b, T, E, const N: usize> X1<'a, 'b, T, E, N> { reuse foo; - //~^ ERROR: type annotations needed [E0284] reuse foo:: as bar; } + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct X2(T, X, &'static [i32; N]); impl X2 { reuse foo; - //~^ ERROR: type annotations needed [E0284] reuse foo:: as bar; } struct X3; impl X3 { reuse foo; - //~^ ERROR: type annotations needed [E0284] reuse foo:: as bar; } pub fn check() { X1::<'static, 'static, i32, i32, 1>::foo::(); X1::<'static, 'static, i32, i32, 1>::bar(); - //~^ ERROR: type annotations needed [E0284] X2::::foo::(); X2::::bar(); - //~^ ERROR: type annotations needed [E0284] X3::foo::(); X3::bar(); - //~^ ERROR: type annotations needed [E0284] } } @@ -99,11 +93,13 @@ mod test_2 { mod test_3 { fn foo() {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct X1<'a, 'b, T, X, const N: usize>(&'a T, &'b X, &'a [i32; N]); impl<'a, 'b, T, E, const N: usize> X1<'a, 'b, T, E, N> { reuse foo; } + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct X2(T, X, &'static [i32; N]); impl X2 { reuse foo; diff --git a/tests/ui/delegation/generics/mapping/inherent-impl-to-free.stderr b/tests/ui/delegation/generics/mapping/inherent-impl-to-free.stderr deleted file mode 100644 index a8ccc88263eb3..0000000000000 --- a/tests/ui/delegation/generics/mapping/inherent-impl-to-free.stderr +++ /dev/null @@ -1,213 +0,0 @@ -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:21:25 - | -LL | reuse to_reuse::foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `to_reuse::foo` - --> $DIR/inherent-impl-to-free.rs:16:42 - | -LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse to_reuse::foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:28:25 - | -LL | reuse to_reuse::foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `to_reuse::foo` - --> $DIR/inherent-impl-to-free.rs:16:42 - | -LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse to_reuse::foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:35:25 - | -LL | reuse to_reuse::foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `to_reuse::foo` - --> $DIR/inherent-impl-to-free.rs:16:42 - | -LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse to_reuse::foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:43:9 - | -LL | X1::<'static, 'static, i32, i32, 1>::bar(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` - | -note: required by a const generic parameter in `test_1::X1::<'a, 'b, T, E, N>::bar` - --> $DIR/inherent-impl-to-free.rs:16:42 - | -LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `X1::<'a, 'b, T, E, N>::bar` -... -LL | reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; - | --- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | X1::<'static, 'static, i32, i32, 1>::bar::(); - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:47:9 - | -LL | X2::::bar(); - | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` - | -note: required by a const generic parameter in `test_1::X2::::bar` - --> $DIR/inherent-impl-to-free.rs:16:42 - | -LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `X2::::bar` -... -LL | reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; - | --- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | X2::::bar::(); - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:51:9 - | -LL | X3::bar(); - | ^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` - | -note: required by a const generic parameter in `test_1::X3::bar` - --> $DIR/inherent-impl-to-free.rs:16:42 - | -LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `X3::bar` -... -LL | reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; - | --- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | X3::bar::(); - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:63:15 - | -LL | reuse foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_2::foo` - --> $DIR/inherent-impl-to-free.rs:59:18 - | -LL | fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:70:15 - | -LL | reuse foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_2::foo` - --> $DIR/inherent-impl-to-free.rs:59:18 - | -LL | fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:77:15 - | -LL | reuse foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_2::foo` - --> $DIR/inherent-impl-to-free.rs:59:18 - | -LL | fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:84:9 - | -LL | X1::<'static, 'static, i32, i32, 1>::bar(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` - | -note: required by a const generic parameter in `test_2::X1::<'a, 'b, T, E, N>::bar` - --> $DIR/inherent-impl-to-free.rs:59:18 - | -LL | fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `X1::<'a, 'b, T, E, N>::bar` -... -LL | reuse foo:: as bar; - | --- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | X1::<'static, 'static, i32, i32, 1>::bar::(); - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:88:9 - | -LL | X2::::bar(); - | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` - | -note: required by a const generic parameter in `test_2::X2::::bar` - --> $DIR/inherent-impl-to-free.rs:59:18 - | -LL | fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `X2::::bar` -... -LL | reuse foo:: as bar; - | --- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | X2::::bar::(); - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-free.rs:92:9 - | -LL | X3::bar(); - | ^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` - | -note: required by a const generic parameter in `test_2::X3::bar` - --> $DIR/inherent-impl-to-free.rs:59:18 - | -LL | fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `X3::bar` -... -LL | reuse foo:: as bar; - | --- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | X3::bar::(); - | +++++++++++ - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/delegation/generics/mapping/inherent-impl-to-trait.rs b/tests/ui/delegation/generics/mapping/inherent-impl-to-trait-pass.rs similarity index 88% rename from tests/ui/delegation/generics/mapping/inherent-impl-to-trait.rs rename to tests/ui/delegation/generics/mapping/inherent-impl-to-trait-pass.rs index a490ce46b9ac1..9e85a7c07c3a3 100644 --- a/tests/ui/delegation/generics/mapping/inherent-impl-to-trait.rs +++ b/tests/ui/delegation/generics/mapping/inherent-impl-to-trait-pass.rs @@ -1,3 +1,5 @@ +//@ run-pass + #![feature(fn_delegation)] #![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] @@ -19,6 +21,7 @@ mod test_1 { struct F; impl Trait for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { reuse Trait::::foo { &self.0 } @@ -27,7 +30,6 @@ mod test_1 { pub fn check() { let s = S(F, &123, &123, &123); S::<'static, 'static, 'static, i32, i32>::foo(&s); - //~^ ERROR: type annotations needed [E0283] s.foo(); } } @@ -42,6 +44,7 @@ mod test_2 { struct F; impl<'x, 'y, T, const B: bool> Trait<'x, 'y, T, B> for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { reuse Trait::<'a, 'b, String, true>::foo { &self.0 } @@ -50,9 +53,7 @@ mod test_2 { pub fn check() { let s = S(F, &123, &123, &123); S::<'static, 'static, 'static, i32, i32>::foo(&s); - //~^ ERROR: type annotations needed [E0284] s.foo(); - //~^ ERROR: type annotations needed [E0284] } } @@ -66,6 +67,7 @@ mod test_3 { struct F; impl<'x, 'y> Trait<'x, 'y> for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { reuse Trait::<'a, 'b>::foo { &self.0 } @@ -88,6 +90,7 @@ mod test_4 { struct F; impl Trait for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { reuse Trait::foo { &self.0 } @@ -110,6 +113,7 @@ mod test_5 { struct F; impl Trait for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { reuse Trait::foo::<'a, 'b> { &self.0 } @@ -132,6 +136,7 @@ mod test_6 { struct F; impl Trait for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { reuse Trait::foo::<'a, 'b, A, B, String> { &self.0 } @@ -140,7 +145,6 @@ mod test_6 { pub fn check() { let s = S(F, &123, &123, &123); S::<'static, 'static, 'static, i32, i32>::foo(&s); - //~^ ERROR: type annotations needed [E0282] s.foo(); } } @@ -155,6 +159,7 @@ mod test_7 { struct F; impl<'a, 'b, 'c> Trait<'a, 'b, 'c> for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { reuse Trait::<'a, 'b, 'c>::foo::<'a, 'b, A, B, String> { &self.0 } @@ -163,7 +168,6 @@ mod test_7 { pub fn check() { let s = S(F, &123, &123, &123); S::<'static, 'static, 'static, i32, i32>::foo(&s); - //~^ ERROR: type annotations needed [E0282] s.foo(); } } @@ -178,6 +182,7 @@ mod test_8 { struct F; impl<'a, 'b, 'c, X, Y, Z> Trait<'a, 'b, 'c, X, Y, Z> for F {} + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { reuse Trait::<'a, 'b, 'c, B, A, i32>::foo::<'a, 'b, A, B, String> { &self.0 } @@ -186,7 +191,6 @@ mod test_8 { pub fn check() { let s = S(F, &123, &123, &123); S::<'static, 'static, 'static, i32, i32>::foo(&s); - //~^ ERROR: type annotations needed [E0282] s.foo(); } } @@ -203,6 +207,7 @@ mod test_9 { impl<'a, 'b, 'c, X, Y, Z> Trait<'a, 'b, 'c, X, Y, Z> for F {} pub fn check() { + #[allow(dead_code)] // Fields are used instead of phantom data for generics use struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { reuse Trait::<'a, 'b, 'c, B, A, i32>::foo::<'a, 'b, A, B, String> { &self.0 } @@ -210,7 +215,6 @@ mod test_9 { let s = S(F, &123, &123, &123); S::<'static, 'static, 'static, i32, i32>::foo(&s); - //~^ ERROR: type annotations needed [E0282] s.foo(); } } diff --git a/tests/ui/delegation/generics/mapping/inherent-impl-to-trait.stderr b/tests/ui/delegation/generics/mapping/inherent-impl-to-trait.stderr deleted file mode 100644 index 4d7fe3139bc98..0000000000000 --- a/tests/ui/delegation/generics/mapping/inherent-impl-to-trait.stderr +++ /dev/null @@ -1,106 +0,0 @@ -error[E0283]: type annotations needed - --> $DIR/inherent-impl-to-trait.rs:29:9 - | -LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the method `foo` - | - = note: cannot satisfy `_: ToString` -note: required by a bound in `test_1::S::<'a, 'b, 'c, A, B>::foo` - --> $DIR/inherent-impl-to-trait.rs:15:20 - | -LL | trait Trait { - | ^^^^^^^^ required by this bound in `S::<'a, 'b, 'c, A, B>::foo` -... -LL | reuse Trait::::foo { &self.0 } - | --- required by a bound in this associated function -help: consider specifying the generic argument - | -LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); - | +++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-trait.rs:52:9 - | -LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `B` declared on the method `foo` - | -note: required by a const generic parameter in `test_2::S::<'a, 'b, 'c, A, B>::foo` - --> $DIR/inherent-impl-to-trait.rs:38:28 - | -LL | trait Trait<'x, 'y, T, const B: bool> { - | ^^^^^^^^^^^^^ required by this const generic parameter in `S::<'a, 'b, 'c, A, B>::foo` -... -LL | reuse Trait::<'a, 'b, String, true>::foo { &self.0 } - | --- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/inherent-impl-to-trait.rs:54:11 - | -LL | s.foo(); - | ^^^ cannot infer the value of the const parameter `B` declared on the method `foo` - | -note: required by a const generic parameter in `test_2::S::<'a, 'b, 'c, A, B>::foo` - --> $DIR/inherent-impl-to-trait.rs:38:28 - | -LL | trait Trait<'x, 'y, T, const B: bool> { - | ^^^^^^^^^^^^^ required by this const generic parameter in `S::<'a, 'b, 'c, A, B>::foo` -... -LL | reuse Trait::<'a, 'b, String, true>::foo { &self.0 } - | --- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | s.foo::(); - | ++++++++ - -error[E0282]: type annotations needed - --> $DIR/inherent-impl-to-trait.rs:142:9 - | -LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the method `foo` - | -help: consider specifying the generic arguments - | -LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); - | +++++++++++ - -error[E0282]: type annotations needed - --> $DIR/inherent-impl-to-trait.rs:165:9 - | -LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the method `foo` - | -help: consider specifying the generic arguments - | -LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); - | +++++++++++ - -error[E0282]: type annotations needed - --> $DIR/inherent-impl-to-trait.rs:188:9 - | -LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `X` declared on the method `foo` - | -help: consider specifying the generic arguments - | -LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); - | ++++++++++++++++++++ - -error[E0282]: type annotations needed - --> $DIR/inherent-impl-to-trait.rs:212:9 - | -LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `X` declared on the method `foo` - | -help: consider specifying the generic arguments - | -LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); - | ++++++++++++++++++++ - -error: aborting due to 7 previous errors - -Some errors have detailed explanations: E0282, E0283, E0284. -For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/delegation/generics/mapping/trait-to-free.rs b/tests/ui/delegation/generics/mapping/trait-to-free-pass.rs similarity index 87% rename from tests/ui/delegation/generics/mapping/trait-to-free.rs rename to tests/ui/delegation/generics/mapping/trait-to-free-pass.rs index b9cf27d72cb46..52e0a9c89394b 100644 --- a/tests/ui/delegation/generics/mapping/trait-to-free.rs +++ b/tests/ui/delegation/generics/mapping/trait-to-free-pass.rs @@ -1,3 +1,5 @@ +//@ run-pass + #![feature(fn_delegation)] #![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] @@ -15,7 +17,6 @@ mod test_1 { trait Trait<'a, A, B, C, const N: usize> { reuse foo; - //~^ ERROR: type annotations needed [E0284] reuse foo::<'static, 'static, i32, String, 1> as bar; } @@ -23,7 +24,6 @@ mod test_1 { pub fn check() { >::foo::<'static, 'static, i32, String, 1>(); >::bar(); - //~^ ERROR: type annotations needed [E0284] } } @@ -34,7 +34,6 @@ mod test_2 { trait Trait<'a, A, B, C, const N: usize> { reuse foo; - //~^ ERROR: type annotations needed [E0284] reuse foo:: as bar; } @@ -42,7 +41,6 @@ mod test_2 { pub fn check() { >::foo::(); >::bar(); - //~^ ERROR: type annotations needed [E0284] } } @@ -68,7 +66,6 @@ mod test_4 { trait Trait { reuse foo; - //~^ ERROR: type annotations needed [E0284] reuse foo::<'static, 'static, i32, String, 1> as bar; } @@ -76,7 +73,6 @@ mod test_4 { pub fn check() { >::foo::<'static, 'static, i32, String, 1>(); >::bar(); - //~^ ERROR: type annotations needed [E0284] } } @@ -87,7 +83,6 @@ mod test_5 { trait Trait { reuse foo; - //~^ ERROR: type annotations needed [E0284] reuse foo::<'static, 'static, i32, String, 1> as bar; } @@ -95,7 +90,6 @@ mod test_5 { pub fn check() { ::foo::<'static, 'static, i32, String, 1>(); ::bar(); - //~^ ERROR: type annotations needed [E0284] } } @@ -105,7 +99,6 @@ mod test_6 { trait Trait { reuse foo; - //~^ ERROR: type annotations needed [E0284] reuse foo:: as bar; } @@ -113,7 +106,6 @@ mod test_6 { pub fn check() { ::foo::(); ::bar(); - //~^ ERROR: type annotations needed [E0284] } } diff --git a/tests/ui/delegation/generics/mapping/trait-to-free.stderr b/tests/ui/delegation/generics/mapping/trait-to-free.stderr deleted file mode 100644 index fee638c6aa4b8..0000000000000 --- a/tests/ui/delegation/generics/mapping/trait-to-free.stderr +++ /dev/null @@ -1,166 +0,0 @@ -error[E0284]: type annotations needed - --> $DIR/trait-to-free.rs:17:15 - | -LL | reuse foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_1::foo` - --> $DIR/trait-to-free.rs:14:59 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone + ToString, U: Clone, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-free.rs:25:9 - | -LL | >::bar(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` - | -note: required by a const generic parameter in `test_1::Trait::bar` - --> $DIR/trait-to-free.rs:14:59 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone + ToString, U: Clone, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::bar` -... -LL | reuse foo::<'static, 'static, i32, String, 1> as bar; - | --- required by a bound in this associated function - -error[E0284]: type annotations needed - --> $DIR/trait-to-free.rs:36:15 - | -LL | reuse foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_2::foo` - --> $DIR/trait-to-free.rs:33:32 - | -LL | fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-free.rs:44:9 - | -LL | >::bar(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` - | -note: required by a const generic parameter in `test_2::Trait::bar` - --> $DIR/trait-to-free.rs:33:32 - | -LL | fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::bar` -... -LL | reuse foo:: as bar; - | --- required by a bound in this associated function - -error[E0284]: type annotations needed - --> $DIR/trait-to-free.rs:70:15 - | -LL | reuse foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_4::foo` - --> $DIR/trait-to-free.rs:67:48 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-free.rs:78:9 - | -LL | >::bar(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` - | -note: required by a const generic parameter in `test_4::Trait::bar` - --> $DIR/trait-to-free.rs:67:48 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::bar` -... -LL | reuse foo::<'static, 'static, i32, String, 1> as bar; - | --- required by a bound in this associated function - -error[E0284]: type annotations needed - --> $DIR/trait-to-free.rs:89:15 - | -LL | reuse foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_5::foo` - --> $DIR/trait-to-free.rs:86:48 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-free.rs:97:9 - | -LL | ::bar(); - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` - | -note: required by a const generic parameter in `test_5::Trait::bar` - --> $DIR/trait-to-free.rs:86:48 - | -LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::bar` -... -LL | reuse foo::<'static, 'static, i32, String, 1> as bar; - | --- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | ::bar::(); - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-free.rs:107:15 - | -LL | reuse foo; - | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` - | -note: required by a const generic parameter in `test_6::foo` - --> $DIR/trait-to-free.rs:104:32 - | -LL | fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` -help: consider specifying the generic arguments - | -LL | reuse foo::; - | +++++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-free.rs:115:9 - | -LL | ::bar(); - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` - | -note: required by a const generic parameter in `test_6::Trait::bar` - --> $DIR/trait-to-free.rs:104:32 - | -LL | fn foo() {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::bar` -... -LL | reuse foo:: as bar; - | --- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | ::bar::(); - | +++++++++++ - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/delegation/generics/mapping/trait-to-trait.rs b/tests/ui/delegation/generics/mapping/trait-to-trait-pass.rs similarity index 80% rename from tests/ui/delegation/generics/mapping/trait-to-trait.rs rename to tests/ui/delegation/generics/mapping/trait-to-trait-pass.rs index ea66efd784bfa..0e96f045065ac 100644 --- a/tests/ui/delegation/generics/mapping/trait-to-trait.rs +++ b/tests/ui/delegation/generics/mapping/trait-to-trait-pass.rs @@ -1,3 +1,5 @@ +//@ run-pass + #![feature(fn_delegation)] #![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] @@ -24,13 +26,11 @@ mod test_1 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> as bar4 { self.get_self() } @@ -47,11 +47,9 @@ mod test_1 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -60,11 +58,9 @@ mod test_1 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -73,11 +69,9 @@ mod test_1 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -90,17 +84,9 @@ mod test_1 { pub fn check<'a: 'a>() { > ::bar1::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] - //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] ::bar1::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] - //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar1::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] - //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar1::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] - //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar2(&123); ::bar2(&123); @@ -109,17 +95,9 @@ mod test_1 { > ::bar3::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] - //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] ::bar3::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] - //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar3::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] - //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar3::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] - //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar4(&123); ::bar4(&123); @@ -144,10 +122,8 @@ mod test_2 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -155,10 +131,8 @@ mod test_2 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -166,10 +140,8 @@ mod test_2 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -177,10 +149,8 @@ mod test_2 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -192,13 +162,9 @@ mod test_2 { pub fn check<'a: 'a>() { > ::bar1::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] ::bar1::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar1::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar1::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar2(&123); ::bar2(&123); @@ -207,13 +173,9 @@ mod test_2 { > ::bar3::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] ::bar3::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar3::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar3::<'static, String, true>(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar4(&123); ::bar4(&123); @@ -238,12 +200,10 @@ mod test_3 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar4 { self.get_self() } @@ -253,12 +213,10 @@ mod test_3 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar4 { self.get_self() } @@ -268,12 +226,10 @@ mod test_3 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar4 { self.get_self() } @@ -283,11 +239,9 @@ mod test_3 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -300,13 +254,9 @@ mod test_3 { pub fn check<'a: 'a>() { > ::bar1::<'static, String, true>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] ::bar1::<'static, String, true>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar1::<'static, String, true>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar1::<'static, String, true>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar2(&123); ::bar2(&123); @@ -315,13 +265,9 @@ mod test_3 { > ::bar3::<'static, String, true>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] ::bar3::<'static, String, true>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar3::<'static, String, true>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar3::<'static, String, true>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar4(&123); ::bar4(&123); @@ -346,10 +292,8 @@ mod test_4 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -357,10 +301,8 @@ mod test_4 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -368,10 +310,8 @@ mod test_4 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -379,10 +319,8 @@ mod test_4 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } reuse Trait::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } } @@ -399,13 +337,9 @@ mod test_4 { >::bar1::<'static, String, true>(&123); >::bar2(&123); - //~^ ERROR: type annotations needed [E0284] ::bar2(&123); - //~^ ERROR: type annotations needed [E0284] >::bar2(&123); - //~^ ERROR: type annotations needed [E0284] >::bar2(&123); - //~^ ERROR: type annotations needed [E0284] > ::bar3::<'static, String, true>(&123); @@ -414,13 +348,9 @@ mod test_4 { >::bar3::<'static, String, true>(&123); >::bar4(&123); - //~^ ERROR: type annotations needed [E0284] ::bar4(&123); - //~^ ERROR: type annotations needed [E0284] >::bar4(&123); - //~^ ERROR: type annotations needed [E0284] >::bar4(&123); - //~^ ERROR: type annotations needed [E0284] } } @@ -440,12 +370,10 @@ mod test_5 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar4 { self.get_self() } @@ -455,12 +383,10 @@ mod test_5 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar4 { self.get_self() } @@ -470,12 +396,10 @@ mod test_5 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar4 { self.get_self() } @@ -485,12 +409,10 @@ mod test_5 { fn get() -> &'static u8 { &0 } fn get_self(&self) -> &'static u8 { &0 } reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar2 { Self::get() } reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - //~^ ERROR: type annotations needed [E0284] reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar4 { self.get_self() } @@ -503,13 +425,9 @@ mod test_5 { pub fn check<'a: 'a>() { >::bar1::(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] ::bar1::(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar1::(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar1::(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar2(&123); ::bar2(&123); @@ -517,13 +435,9 @@ mod test_5 { >::bar2(&123); >::bar3::(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] ::bar3::(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar3::(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar3::(&123); - //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] >::bar4(&123); ::bar4(&123); @@ -579,7 +493,6 @@ mod test_6 { pub fn check<'a: 'a>() { >::bar1(&123); - //~^ ERROR: type annotations needed [E0282] ::bar1(&123); >::bar1(&123); >::bar1(&123); @@ -638,7 +551,6 @@ mod test_7 { pub fn check<'a: 'a>() { >::bar1(&123); - //~^ ERROR: type annotations needed [E0282] ::bar1(&123); >::bar1(&123); >::bar1(&123); @@ -763,7 +675,6 @@ mod test_9 { pub fn check<'a: 'a>() { > - //~^ ERROR: type annotations needed [E0282] ::bar1::<'static, 'static>(&123); ::bar1::<'static, 'static>(&123); >::bar1::<'a, 'a>(&123); @@ -851,13 +762,9 @@ mod test_10 { pub fn check<'a: 'a>() { > ::bar1::<'static, 'static>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] ::bar1::<'static, 'static>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar1::<'a, 'a>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar1::<'a, 'a>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar2(&123); ::bar2(&123); @@ -866,13 +773,9 @@ mod test_10 { > ::bar3::<'static, 'static>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] ::bar3::<'static, 'static>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar3::<'static, 'static>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar3::<'static, 'static>(&123); - //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] >::bar4(&123); ::bar4(&123); diff --git a/tests/ui/delegation/generics/mapping/trait-to-trait.stderr b/tests/ui/delegation/generics/mapping/trait-to-trait.stderr deleted file mode 100644 index 712fcc1670e5b..0000000000000 --- a/tests/ui/delegation/generics/mapping/trait-to-trait.stderr +++ /dev/null @@ -1,1544 +0,0 @@ -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:26:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_1::Trait::foo` - --> $DIR/trait-to-trait.rs:18:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:32:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_1::Trait::foo` - --> $DIR/trait-to-trait.rs:18:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:49:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_1::Trait::foo` - --> $DIR/trait-to-trait.rs:18:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:53:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_1::Trait::foo` - --> $DIR/trait-to-trait.rs:18:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:62:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_1::Trait::foo` - --> $DIR/trait-to-trait.rs:18:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:66:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_1::Trait::foo` - --> $DIR/trait-to-trait.rs:18:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:75:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_1::Trait::foo` - --> $DIR/trait-to-trait.rs:18:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:79:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_1::Trait::foo` - --> $DIR/trait-to-trait.rs:18:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:92:22 - | -LL | ::bar1::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:18:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:92:15 - | -LL | ::bar1::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:26:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | ::bar1::<'static, String, true, M>(&123); - | +++ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:95:33 - | -LL | ::bar1::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:18:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:95:26 - | -LL | ::bar1::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:49:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | ::bar1::<'static, String, true, M>(&123); - | +++ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:98:50 - | -LL | >::bar1::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:18:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:98:43 - | -LL | >::bar1::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:62:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar1::<'static, String, true, M>(&123); - | +++ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:101:51 - | -LL | >::bar1::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:18:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:101:44 - | -LL | >::bar1::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:75:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar1::<'static, String, true, M>(&123); - | +++ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:111:22 - | -LL | ::bar3::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:18:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:111:15 - | -LL | ::bar3::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:32:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | ::bar3::<'static, String, true, M>(&123); - | +++ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:114:33 - | -LL | ::bar3::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:18:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:114:26 - | -LL | ::bar3::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:53:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | ::bar3::<'static, String, true, M>(&123); - | +++ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:117:50 - | -LL | >::bar3::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:18:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:117:43 - | -LL | >::bar3::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:66:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar3::<'static, String, true, M>(&123); - | +++ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:120:51 - | -LL | >::bar3::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:18:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:120:44 - | -LL | >::bar3::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:79:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar3::<'static, String, true, M>(&123); - | +++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:146:29 - | -LL | reuse Trait::::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_2::Trait::foo` - --> $DIR/trait-to-trait.rs:138:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:149:29 - | -LL | reuse Trait::::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_2::Trait::foo` - --> $DIR/trait-to-trait.rs:138:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:157:29 - | -LL | reuse Trait::::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_2::Trait::foo` - --> $DIR/trait-to-trait.rs:138:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:160:29 - | -LL | reuse Trait::::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_2::Trait::foo` - --> $DIR/trait-to-trait.rs:138:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:168:29 - | -LL | reuse Trait::::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_2::Trait::foo` - --> $DIR/trait-to-trait.rs:138:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:171:29 - | -LL | reuse Trait::::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_2::Trait::foo` - --> $DIR/trait-to-trait.rs:138:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:179:29 - | -LL | reuse Trait::::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_2::Trait::foo` - --> $DIR/trait-to-trait.rs:138:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:182:29 - | -LL | reuse Trait::::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_2::Trait::foo` - --> $DIR/trait-to-trait.rs:138:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:194:15 - | -LL | ::bar1::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:146:36 - | -LL | trait Trait: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | ::bar1::<'static, String, true, M>(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:196:26 - | -LL | ::bar1::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:157:36 - | -LL | trait Trait: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | ::bar1::<'static, String, true, M>(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:198:43 - | -LL | >::bar1::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:168:36 - | -LL | trait Trait: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar1::<'static, String, true, M>(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:200:44 - | -LL | >::bar1::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:179:36 - | -LL | trait Trait: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar1::<'static, String, true, M>(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:209:15 - | -LL | ::bar3::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:149:36 - | -LL | trait Trait: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | ::bar3::<'static, String, true, M>(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:211:26 - | -LL | ::bar3::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:160:36 - | -LL | trait Trait: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | ::bar3::<'static, String, true, M>(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:213:43 - | -LL | >::bar3::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:171:36 - | -LL | trait Trait: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar3::<'static, String, true, M>(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:215:44 - | -LL | >::bar3::<'static, String, true>(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:182:36 - | -LL | trait Trait: Sized { - | - -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | - ------------- -... -LL | reuse Trait::::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar3::<'static, String, true, M>(&123); - | +++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:240:51 - | -LL | reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_3::Trait::foo` - --> $DIR/trait-to-trait.rs:232:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar1 { Self::get() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:245:51 - | -LL | reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_3::Trait::foo` - --> $DIR/trait-to-trait.rs:232:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar3 { self.get_self() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:255:51 - | -LL | reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_3::Trait::foo` - --> $DIR/trait-to-trait.rs:232:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar1 { Self::get() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:260:51 - | -LL | reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_3::Trait::foo` - --> $DIR/trait-to-trait.rs:232:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar3 { self.get_self() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:270:51 - | -LL | reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_3::Trait::foo` - --> $DIR/trait-to-trait.rs:232:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar1 { Self::get() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:275:51 - | -LL | reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_3::Trait::foo` - --> $DIR/trait-to-trait.rs:232:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar3 { self.get_self() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:285:51 - | -LL | reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_3::Trait::foo` - --> $DIR/trait-to-trait.rs:232:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar1 { Self::get() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:289:51 - | -LL | reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_3::Trait::foo` - --> $DIR/trait-to-trait.rs:232:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar3 { self.get_self() } - | ++++++++ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:302:22 - | -LL | ::bar1::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:232:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:304:33 - | -LL | ::bar1::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:232:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:306:50 - | -LL | >::bar1::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:232:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:308:51 - | -LL | >::bar1::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:232:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:317:22 - | -LL | ::bar3::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:232:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:319:33 - | -LL | ::bar3::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:232:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:321:50 - | -LL | >::bar3::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:232:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:323:51 - | -LL | >::bar3::<'static, String, true>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:232:42 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:348:22 - | -LL | reuse Trait::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_4::Trait::foo` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::foo:: as bar1 { Self::get() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:351:22 - | -LL | reuse Trait::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_4::Trait::foo` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::foo:: as bar3 { self.get_self() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:359:22 - | -LL | reuse Trait::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_4::Trait::foo` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::foo:: as bar1 { Self::get() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:362:22 - | -LL | reuse Trait::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_4::Trait::foo` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::foo:: as bar3 { self.get_self() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:370:22 - | -LL | reuse Trait::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_4::Trait::foo` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::foo:: as bar1 { Self::get() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:373:22 - | -LL | reuse Trait::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_4::Trait::foo` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::foo:: as bar3 { self.get_self() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:381:22 - | -LL | reuse Trait::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_4::Trait::foo` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::foo:: as bar1 { Self::get() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:384:22 - | -LL | reuse Trait::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_4::Trait::foo` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` -help: consider specifying the generic arguments - | -LL | reuse Trait::foo:: as bar3 { self.get_self() } - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:401:9 - | -LL | >::bar2(&123); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar2` - | -note: required by a const generic parameter in `test_4::Trait2::bar2` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait2::bar2` -... -LL | reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } - | ---- required by a bound in this associated function - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:403:9 - | -LL | ::bar2(&123); - | ^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar2` - | -note: required by a const generic parameter in `test_4::Trait3::bar2` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait3::bar2` -... -LL | reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } - | ---- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | ::bar2::(&123); - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:405:9 - | -LL | >::bar2(&123); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar2` - | -note: required by a const generic parameter in `test_4::Trait4::bar2` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait4::bar2` -... -LL | reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } - | ---- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | >::bar2::(&123); - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:407:9 - | -LL | >::bar2(&123); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar2` - | -note: required by a const generic parameter in `test_4::Trait5::bar2` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait5::bar2` -... -LL | reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } - | ---- required by a bound in this associated function - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:416:9 - | -LL | >::bar4(&123); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar4` - | -note: required by a const generic parameter in `test_4::Trait2::bar4` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait2::bar4` -... -LL | reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } - | ---- required by a bound in this associated function - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:418:9 - | -LL | ::bar4(&123); - | ^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar4` - | -note: required by a const generic parameter in `test_4::Trait3::bar4` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait3::bar4` -... -LL | reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } - | ---- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | ::bar4::(&123); - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:420:9 - | -LL | >::bar4(&123); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar4` - | -note: required by a const generic parameter in `test_4::Trait4::bar4` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait4::bar4` -... -LL | reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } - | ---- required by a bound in this associated function -help: consider specifying the generic arguments - | -LL | >::bar4::(&123); - | ++++++++ - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:422:9 - | -LL | >::bar4(&123); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar4` - | -note: required by a const generic parameter in `test_4::Trait5::bar4` - --> $DIR/trait-to-trait.rs:340:27 - | -LL | fn foo<'d: 'd, U, const M: bool>(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait5::bar4` -... -LL | reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } - | ---- required by a bound in this associated function - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:442:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_5::Trait::foo` - --> $DIR/trait-to-trait.rs:434:19 - | -LL | fn foo(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:447:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_5::Trait::foo` - --> $DIR/trait-to-trait.rs:434:19 - | -LL | fn foo(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:457:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_5::Trait::foo` - --> $DIR/trait-to-trait.rs:434:19 - | -LL | fn foo(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:462:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_5::Trait::foo` - --> $DIR/trait-to-trait.rs:434:19 - | -LL | fn foo(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:472:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_5::Trait::foo` - --> $DIR/trait-to-trait.rs:434:19 - | -LL | fn foo(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:477:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_5::Trait::foo` - --> $DIR/trait-to-trait.rs:434:19 - | -LL | fn foo(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:487:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_5::Trait::foo` - --> $DIR/trait-to-trait.rs:434:19 - | -LL | fn foo(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0284]: type annotations needed - --> $DIR/trait-to-trait.rs:492:56 - | -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` - | -note: required by a const generic parameter in `test_5::Trait::foo` - --> $DIR/trait-to-trait.rs:434:19 - | -LL | fn foo(&self) {} - | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:505:68 - | -LL | >::bar1::(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:442:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar1::(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:507:26 - | -LL | ::bar1::(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:457:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | ::bar1::(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:509:43 - | -LL | >::bar1::(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:472:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar1::(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:511:44 - | -LL | >::bar1::(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:487:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar1::(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:519:68 - | -LL | >::bar3::(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:447:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar3::(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:521:26 - | -LL | ::bar3::(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:462:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | ::bar3::(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:523:43 - | -LL | >::bar3::(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:477:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar3::(&123); - | +++ - -error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/trait-to-trait.rs:525:44 - | -LL | >::bar3::(&123); - | ^^^^ ------ ---- supplied 2 generic arguments - | | - | expected 3 generic arguments - | -note: method defined here, with 3 generic parameters: `T`, `U`, `M` - --> $DIR/trait-to-trait.rs:492:63 - | -LL | trait Trait<'b, 'c, 'a, T>: Sized { - | - -LL | fn foo(&self) {} - | - ------------- -... -LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } - | ^^^^ -help: add missing generic argument - | -LL | >::bar3::(&123); - | +++ - -error[E0282]: type annotations needed - --> $DIR/trait-to-trait.rs:581:9 - | -LL | >::bar1(&123); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the method `bar1` - -error[E0282]: type annotations needed - --> $DIR/trait-to-trait.rs:640:9 - | -LL | >::bar1(&123); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the method `bar1` - -error[E0282]: type annotations needed - --> $DIR/trait-to-trait.rs:765:9 - | -LL | / > -LL | | -LL | | ::bar1::<'static, 'static>(&123); - | |______________________________________^ cannot infer type of the type parameter `T` declared on the method `bar1` - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:853:22 - | -LL | ::bar1::<'static, 'static>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:797:32 - | -LL | fn foo<'a: 'a, 'b: 'b>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:855:33 - | -LL | ::bar1::<'static, 'static>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:797:32 - | -LL | fn foo<'a: 'a, 'b: 'b>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:857:50 - | -LL | >::bar1::<'a, 'a>(&123); - | ^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:797:32 - | -LL | fn foo<'a: 'a, 'b: 'b>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:859:51 - | -LL | >::bar1::<'a, 'a>(&123); - | ^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:797:32 - | -LL | fn foo<'a: 'a, 'b: 'b>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:868:22 - | -LL | ::bar3::<'static, 'static>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:797:32 - | -LL | fn foo<'a: 'a, 'b: 'b>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:870:33 - | -LL | ::bar3::<'static, 'static>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:797:32 - | -LL | fn foo<'a: 'a, 'b: 'b>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:872:50 - | -LL | >::bar3::<'static, 'static>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:797:32 - | -LL | fn foo<'a: 'a, 'b: 'b>(&self) {} - | ^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/trait-to-trait.rs:874:51 - | -LL | >::bar3::<'static, 'static>(&123); - | ^^^^^^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/trait-to-trait.rs:797:32 - | -LL | fn foo<'a: 'a, 'b: 'b>(&self) {} - | ^ - -error: aborting due to 99 previous errors - -Some errors have detailed explanations: E0107, E0282, E0284, E0794. -For more information about an error, try `rustc --explain E0107`.