diff --git a/RELEASES.md b/RELEASES.md index 29c787f4e14c6..f180d740a3d17 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,118 @@ +Version 1.94.0 (2026-03-05) +========================== + + + +Language +-------- +- [Impls and impl items inherit `dead_code` lint level of the corresponding traits and trait items](https://github.com/rust-lang/rust/pull/144113) +- [Stabilize additional 29 RISC-V target features including large portions of the RVA22U64 / RVA23U64 profiles](https://github.com/rust-lang/rust/pull/145948) +- [Add warn-by-default `unused_visibilities` lint for visibility on `const _` declarations](https://github.com/rust-lang/rust/pull/147136) +- [Update to Unicode 17](https://github.com/rust-lang/rust/pull/148321) +- [Avoid incorrect lifetime errors for closures](https://github.com/rust-lang/rust/pull/148329) + + + +Platform Support +---------------- + +- [Add `riscv64im-unknown-none-elf` as a tier 3 target](https://github.com/rust-lang/rust/pull/148790) + +Refer to Rust's [platform support page][platform-support-doc] +for more information on Rust's tiered platform support. + +[platform-support-doc]: https://doc.rust-lang.org/rustc/platform-support.html + + + +Libraries +--------- + +- [Relax `T: Ord` bound for some `BinaryHeap` methods.](https://github.com/rust-lang/rust/pull/149408) + + + +Stabilized APIs +--------------- + +- [`<[T]>::array_windows`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.array_windows) +- [`<[T]>::element_offset`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.element_offset) +- [`LazyCell::get`](https://doc.rust-lang.org/stable/std/cell/struct.LazyCell.html#method.get) +- [`LazyCell::get_mut`](https://doc.rust-lang.org/stable/std/cell/struct.LazyCell.html#method.get_mut) +- [`LazyCell::force_mut`](https://doc.rust-lang.org/stable/std/cell/struct.LazyCell.html#method.force_mut) +- [`LazyLock::get`](https://doc.rust-lang.org/stable/std/sync/struct.LazyLock.html#method.get) +- [`LazyLock::get_mut`](https://doc.rust-lang.org/stable/std/sync/struct.LazyLock.html#method.get_mut) +- [`LazyLock::force_mut`](https://doc.rust-lang.org/stable/std/sync/struct.LazyLock.html#method.force_mut) +- [`impl TryFrom for usize`](https://doc.rust-lang.org/stable/std/convert/trait.TryFrom.html#impl-TryFrom%3Cchar%3E-for-usize) +- [`std::iter::Peekable::next_if_map`](https://doc.rust-lang.org/stable/std/iter/struct.Peekable.html#method.next_if_map) +- [`std::iter::Peekable::next_if_map_mut`](https://doc.rust-lang.org/stable/std/iter/struct.Peekable.html#method.next_if_map_mut) +- [x86 `avx512fp16` intrinsics](https://github.com/rust-lang/rust/issues/127213) + (excluding those that depend directly on the unstable `f16` type) +- [AArch64 NEON fp16 intrinsics](https://github.com/rust-lang/rust/issues/136306) + (excluding those that depend directly on the unstable `f16` type) +- [`f32::consts::EULER_GAMMA`](https://doc.rust-lang.org/stable/std/f32/consts/constant.EULER_GAMMA.html) +- [`f64::consts::EULER_GAMMA`](https://doc.rust-lang.org/stable/std/f64/consts/constant.EULER_GAMMA.html) +- [`f32::consts::GOLDEN_RATIO`](https://doc.rust-lang.org/stable/std/f32/consts/constant.GOLDEN_RATIO.html) +- [`f64::consts::GOLDEN_RATIO`](https://doc.rust-lang.org/stable/std/f64/consts/constant.GOLDEN_RATIO.html) + + +These previously stable APIs are now stable in const contexts: + +- [`f32::mul_add`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.mul_add) +- [`f64::mul_add`](https://doc.rust-lang.org/stable/std/primitive.f64.html#method.mul_add) + + + + +Cargo +----- + +- Stabilize the config include key. The top-level include config key allows loading additional config files, enabling better organization, sharing, and management of Cargo configurations across projects and environments. [docs](https://doc.rust-lang.org/nightly/cargo/reference/config.html#including-extra-configuration-files) [#16284](https://github.com/rust-lang/cargo/pull/16284) +- Stabilize the pubtime field in registry index. This records when a crate version was published and enables time-based dependency resolution in the future. Note that crates.io will gradually backfill existing packages when a new version is published. Not all crates have pubtime yet. [#16369](https://github.com/rust-lang/cargo/pull/16369) [#16372](https://github.com/rust-lang/cargo/pull/16372) +- Cargo now parses [TOML v1.1](https://toml.io/en/v1.1.0) for manifests and configuration files. Note that using these features in Cargo.toml will raise your development MSRV, but the published manifest remains compatible with older parsers. [#16415](https://github.com/rust-lang/cargo/pull/16415) +- [Make `CARGO_BIN_EXE_` available at runtime ](https://github.com/rust-lang/cargo/pull/16421/) + + + +Compatibility Notes +------------------- +- [Forbid freely casting lifetime bounds of `dyn`-types](https://github.com/rust-lang/rust/pull/136776) +- [Make closure capturing have consistent and correct behaviour around patterns](https://github.com/rust-lang/rust/pull/138961) + Some finer details of how precise closure captures get affected by pattern matching have been changed. In some cases, this can cause a non-move closure that was previously capturing an entire variable by move, to now capture only part of that variable by move, and other parts by borrow. This can cause the borrow checker to complain where it previously didn't, or cause `Drop` to run at a different point in time. +- [Standard library macros are now imported via prelude, not via injected `#[macro_use]`](https://github.com/rust-lang/rust/pull/139493) + This will raise an error if macros of the same name are glob imported. + For example if a crate defines their own `matches` macro and then glob imports that, + it's now ambiguous whether the custom or standard library `matches` is meant and + an explicit import of the name is required to resolve the ambiguity. + One exception is `core::panic` and `std::panic`, if their import is ambiguous + a new warning ([`ambiguous_panic_imports`](https://github.com/rust-lang/rust/issues/147319)) is raised. + This may raise a new warning ([`ambiguous_panic_imports`](https://github.com/rust-lang/rust/issues/147319)) on `#![no_std]` code glob importing the std crate. + Both `core::panic!` and `std::panic!` are then in scope and which is used is ambiguous. +- [Don't strip shebang in expression-context `include!(…)`s](https://github.com/rust-lang/rust/pull/146377) + This can cause previously working includes to no longer compile if they included files which started with a shebang. +- [Ambiguous glob reexports are now also visible cross-crate](https://github.com/rust-lang/rust/pull/147984) + This unifies behavior between local and cross-crate errors on these exports, which may introduce new ambiguity errors. +- [Don't normalize where-clauses before checking well-formedness](https://github.com/rust-lang/rust/pull/148477) +- [Introduce a future compatibility warning on codegen attributes on body-free trait methods](https://github.com/rust-lang/rust/pull/148756) + These attributes currently have no effect in this position. +- [On Windows `std::time::SystemTime::checked_sub_duration` will return `None` for times before the Windows epoch (1/1/1601)](https://github.com/rust-lang/rust/pull/148825) +- [Lifetime identifiers such as `'a` are now NFC normalized](https://github.com/rust-lang/rust/pull/149192). +- [Overhaul filename handling for cross-compiler consistency](https://github.com/rust-lang/rust/pull/149709) + Any paths emitted by compiler now always respect the relative-ness of the paths and `--remap-path-prefix` given originally. + One side-effect of this change is that paths emitted for local crates in Cargo (path dependencies and workspace members) are no longer absolute but relative when emitted as part of a diagnostic in a downstream crate. + + + +Internal Changes +---------------- + +These changes do not affect any public interfaces of Rust, but they represent +significant improvements to the performance or internals of rustc and related +tools. + +- [Switch to `annotate-snippets` for error emission](https://github.com/rust-lang/rust/pull/150032) + This should preserve mostly the same outputs in rustc error messages. + Version 1.93.1 (2026-02-12) =========================== diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 04bad6142b6cc..333cfce47abe2 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1724,6 +1724,12 @@ pub enum StructRest { Rest(Span), /// No trailing `..` or expression. None, + /// No trailing `..` or expression, and also, a parse error occurred inside the struct braces. + /// + /// This struct should be treated similarly to as if it had an `..` in it, + /// in particular rather than reporting missing fields, because the parse error + /// makes which fields the struct was intended to have not fully known. + NoneWithError(ErrorGuaranteed), } #[derive(Clone, Encodable, Decodable, Debug, Walkable)] 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/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 5b31c421bf346..4a2992038003c 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -340,12 +340,13 @@ impl<'hir> LoweringContext<'_, 'hir> { self.arena.alloc_from_iter(fields.iter().map(|&ident| self.lower_ident(ident))), ), ExprKind::Struct(se) => { - let rest = match &se.rest { - StructRest::Base(e) => hir::StructTailExpr::Base(self.lower_expr(e)), + let rest = match se.rest { + StructRest::Base(ref e) => hir::StructTailExpr::Base(self.lower_expr(e)), StructRest::Rest(sp) => { - hir::StructTailExpr::DefaultFields(self.lower_span(*sp)) + hir::StructTailExpr::DefaultFields(self.lower_span(sp)) } StructRest::None => hir::StructTailExpr::None, + StructRest::NoneWithError(guar) => hir::StructTailExpr::NoneWithError(guar), }; hir::ExprKind::Struct( self.arena.alloc(self.lower_qpath( @@ -1435,7 +1436,7 @@ impl<'hir> LoweringContext<'_, 'hir> { Some(self.lower_span(e.span)) } StructRest::Rest(span) => Some(self.lower_span(*span)), - StructRest::None => None, + StructRest::None | StructRest::NoneWithError(_) => None, }; let struct_pat = hir::PatKind::Struct(qpath, field_pats, fields_omitted); return self.pat_without_dbm(lhs.span, struct_pat); 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 d2aae3c07ca7e..5c293b82a4209 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_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index 7dce7f6d41954..9b4ff2b63bd45 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -162,7 +162,7 @@ impl<'a> State<'a> { self.word("{"); let has_rest = match rest { ast::StructRest::Base(_) | ast::StructRest::Rest(_) => true, - ast::StructRest::None => false, + ast::StructRest::None | ast::StructRest::NoneWithError(_) => false, }; if fields.is_empty() && !has_rest { self.word("}"); diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index 460f4afea963f..9e6b366464341 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -8,7 +8,7 @@ use rustc_codegen_ssa::traits::{ use rustc_middle::bug; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout}; -use rustc_target::spec::{Abi, Arch, Env}; +use rustc_target::spec::{Arch, Env, RustcAbi}; use crate::builder::Builder; use crate::llvm::{Type, Value}; @@ -272,7 +272,7 @@ fn emit_powerpc_va_arg<'ll, 'tcx>( // Rust does not currently support any powerpc softfloat targets. let target = &bx.cx.tcx.sess.target; - let is_soft_float_abi = target.abi == Abi::SoftFloat; + let is_soft_float_abi = target.rustc_abi == Some(RustcAbi::Softfloat); assert!(!is_soft_float_abi); // All instances of VaArgSafe are passed directly. @@ -1077,7 +1077,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( AllowHigherAlign::Yes, ForceRightAdjust::Yes, ), - Arch::RiscV32 if target.abi == Abi::Ilp32e => { + Arch::RiscV32 if target.llvm_abiname == "ilp32e" => { // FIXME: clang manually adjusts the alignment for this ABI. It notes: // // > To be compatible with GCC's behaviors, we force arguments with diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index de00cbc8e7098..949aff7d6600a 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. @@ -2658,7 +2662,9 @@ impl Expr<'_> { ExprKind::Struct(_, fields, init) => { let init_side_effects = match init { StructTailExpr::Base(init) => init.can_have_side_effects(), - StructTailExpr::DefaultFields(_) | StructTailExpr::None => false, + StructTailExpr::DefaultFields(_) + | StructTailExpr::None + | StructTailExpr::NoneWithError(_) => false, }; fields.iter().map(|field| field.expr).any(|e| e.can_have_side_effects()) || init_side_effects @@ -2950,6 +2956,12 @@ pub enum StructTailExpr<'hir> { /// fields' default values will be used to populate any fields not explicitly mentioned: /// `Foo { .. }`. DefaultFields(Span), + /// No trailing `..` was written, and also, a parse error occurred inside the struct braces. + /// + /// This struct should be treated similarly to as if it had an `..` in it, + /// in particular rather than reporting missing fields, because the parse error + /// makes which fields the struct was intended to have not fully known. + NoneWithError(ErrorGuaranteed), } /// Represents an optionally `Self`-qualified value/type path or associated extension. @@ -3759,10 +3771,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 enum InferDelegationKind { +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<'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. @@ -3774,7 +3794,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]`). @@ -3931,6 +3951,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/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index 6a69326d8c847..25ef56f8b0f2c 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -830,7 +830,9 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) walk_list!(visitor, visit_expr_field, fields); match optional_base { StructTailExpr::Base(base) => try_visit!(visitor.visit_expr(base)), - StructTailExpr::None | StructTailExpr::DefaultFields(_) => {} + StructTailExpr::None + | StructTailExpr::NoneWithError(_) + | StructTailExpr::DefaultFields(_) => {} } } ExprKind::Tup(subexpressions) => { 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 8021b02fa2964..8b1dad9a65471 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -321,7 +321,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 @@ -556,7 +556,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))); } @@ -598,13 +605,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, @@ -627,14 +635,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 @@ -797,6 +799,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { infer_args: segment.infer_args, incorrect_args: &arg_count.correct, }; + let args = lower_generic_args( self, def_id, @@ -818,8 +821,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))); } @@ -931,6 +940,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { &[], segment, Some(self_ty), + GenericArgPosition::Type, ); let constraints = segment.args().constraints; @@ -1106,8 +1116,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))); } @@ -2892,11 +2908,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/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index ec0688b64f3dd..369c7c077474a 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1314,6 +1314,7 @@ impl<'a> State<'a> { self.end(ib); } hir::StructTailExpr::None => {} + hir::StructTailExpr::NoneWithError(_) => {} } self.space(); self.word("}"); diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index fd83f6f9ae1eb..9f2134e050bc0 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -2000,229 +2000,256 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return; } - if let hir::StructTailExpr::DefaultFields(span) = *base_expr { - let mut missing_mandatory_fields = Vec::new(); - let mut missing_optional_fields = Vec::new(); - for f in &variant.fields { - let ident = self.tcx.adjust_ident(f.ident(self.tcx), variant.def_id); - if let Some(_) = remaining_fields.remove(&ident) { - if f.value.is_none() { - missing_mandatory_fields.push(ident); - } else { - missing_optional_fields.push(ident); + match *base_expr { + hir::StructTailExpr::DefaultFields(span) => { + let mut missing_mandatory_fields = Vec::new(); + let mut missing_optional_fields = Vec::new(); + for f in &variant.fields { + let ident = self.tcx.adjust_ident(f.ident(self.tcx), variant.def_id); + if let Some(_) = remaining_fields.remove(&ident) { + if f.value.is_none() { + missing_mandatory_fields.push(ident); + } else { + missing_optional_fields.push(ident); + } } } - } - if !self.tcx.features().default_field_values() { - let sugg = self.tcx.crate_level_attribute_injection_span(); - self.dcx().emit_err(BaseExpressionDoubleDot { - span: span.shrink_to_hi(), - // We only mention enabling the feature if this is a nightly rustc *and* the - // expression would make sense with the feature enabled. - default_field_values_suggestion: if self.tcx.sess.is_nightly_build() - && missing_mandatory_fields.is_empty() - && !missing_optional_fields.is_empty() - { - Some(sugg) - } else { - None - }, - add_expr: if !missing_mandatory_fields.is_empty() - || !missing_optional_fields.is_empty() - { - Some(BaseExpressionDoubleDotAddExpr { span: span.shrink_to_hi() }) - } else { - None - }, - remove_dots: if missing_mandatory_fields.is_empty() - && missing_optional_fields.is_empty() - { - Some(BaseExpressionDoubleDotRemove { span }) - } else { - None - }, - }); - return; - } - if variant.fields.is_empty() { - let mut err = self.dcx().struct_span_err( - span, - format!( - "`{adt_ty}` has no fields, `..` needs at least one default field in the \ - struct definition", - ), - ); - err.span_label(path_span, "this type has no fields"); - err.emit(); - } - if !missing_mandatory_fields.is_empty() { - let s = pluralize!(missing_mandatory_fields.len()); - let fields = listify(&missing_mandatory_fields, |f| format!("`{f}`")).unwrap(); - self.dcx() - .struct_span_err( - span.shrink_to_lo(), - format!("missing field{s} {fields} in initializer"), - ) - .with_span_label( - span.shrink_to_lo(), - "fields that do not have a defaulted value must be provided explicitly", - ) - .emit(); - return; - } - let fru_tys = match adt_ty.kind() { - ty::Adt(adt, args) if adt.is_struct() => variant - .fields - .iter() - .map(|f| self.normalize(span, f.ty(self.tcx, args))) - .collect(), - ty::Adt(adt, args) if adt.is_enum() => variant - .fields - .iter() - .map(|f| self.normalize(span, f.ty(self.tcx, args))) - .collect(), - _ => { - self.dcx().emit_err(FunctionalRecordUpdateOnNonStruct { span }); + if !self.tcx.features().default_field_values() { + let sugg = self.tcx.crate_level_attribute_injection_span(); + self.dcx().emit_err(BaseExpressionDoubleDot { + span: span.shrink_to_hi(), + // We only mention enabling the feature if this is a nightly rustc *and* the + // expression would make sense with the feature enabled. + default_field_values_suggestion: if self.tcx.sess.is_nightly_build() + && missing_mandatory_fields.is_empty() + && !missing_optional_fields.is_empty() + { + Some(sugg) + } else { + None + }, + add_expr: if !missing_mandatory_fields.is_empty() + || !missing_optional_fields.is_empty() + { + Some(BaseExpressionDoubleDotAddExpr { span: span.shrink_to_hi() }) + } else { + None + }, + remove_dots: if missing_mandatory_fields.is_empty() + && missing_optional_fields.is_empty() + { + Some(BaseExpressionDoubleDotRemove { span }) + } else { + None + }, + }); return; } - }; - self.typeck_results.borrow_mut().fru_field_types_mut().insert(expr.hir_id, fru_tys); - } else if let hir::StructTailExpr::Base(base_expr) = base_expr { - // FIXME: We are currently creating two branches here in order to maintain - // consistency. But they should be merged as much as possible. - let fru_tys = if self.tcx.features().type_changing_struct_update() { - if adt.is_struct() { - // Make some fresh generic parameters for our ADT type. - let fresh_args = self.fresh_args_for_item(base_expr.span, adt.did()); - // We do subtyping on the FRU fields first, so we can - // learn exactly what types we expect the base expr - // needs constrained to be compatible with the struct - // type we expect from the expectation value. - let fru_tys = variant - .fields - .iter() - .map(|f| { - let fru_ty = self - .normalize(expr.span, self.field_ty(base_expr.span, f, fresh_args)); - let ident = self.tcx.adjust_ident(f.ident(self.tcx), variant.def_id); - if let Some(_) = remaining_fields.remove(&ident) { - let target_ty = self.field_ty(base_expr.span, f, args); - let cause = self.misc(base_expr.span); - match self.at(&cause, self.param_env).sup( - // We're already using inference variables for any params, and don't allow converting - // between different structs, so there is no way this ever actually defines an opaque type. - // Thus choosing `Yes` is fine. - DefineOpaqueTypes::Yes, - target_ty, - fru_ty, - ) { - Ok(InferOk { obligations, value: () }) => { - self.register_predicates(obligations) - } - Err(_) => { - span_bug!( - cause.span, - "subtyping remaining fields of type changing FRU failed: {target_ty} != {fru_ty}: {}::{}", - variant.name, - ident.name, - ); - } - } - } - self.resolve_vars_if_possible(fru_ty) - }) - .collect(); - // The use of fresh args that we have subtyped against - // our base ADT type's fields allows us to guide inference - // along so that, e.g. - // ``` - // MyStruct<'a, F1, F2, const C: usize> { - // f: F1, - // // Other fields that reference `'a`, `F2`, and `C` - // } - // - // let x = MyStruct { - // f: 1usize, - // ..other_struct - // }; - // ``` - // will have the `other_struct` expression constrained to - // `MyStruct<'a, _, F2, C>`, as opposed to just `_`... - // This is important to allow coercions to happen in - // `other_struct` itself. See `coerce-in-base-expr.rs`. - let fresh_base_ty = Ty::new_adt(self.tcx, *adt, fresh_args); - self.check_expr_has_type_or_error( - base_expr, - self.resolve_vars_if_possible(fresh_base_ty), - |_| {}, + if variant.fields.is_empty() { + let mut err = self.dcx().struct_span_err( + span, + format!( + "`{adt_ty}` has no fields, `..` needs at least one default field in \ + the struct definition", + ), ); - fru_tys - } else { - // Check the base_expr, regardless of a bad expected adt_ty, so we can get - // type errors on that expression, too. - self.check_expr(base_expr); - self.dcx().emit_err(FunctionalRecordUpdateOnNonStruct { span: base_expr.span }); - return; + err.span_label(path_span, "this type has no fields"); + err.emit(); } - } else { - self.check_expr_has_type_or_error(base_expr, adt_ty, |_| { - let base_ty = self.typeck_results.borrow().expr_ty(*base_expr); - let same_adt = matches!((adt_ty.kind(), base_ty.kind()), - (ty::Adt(adt, _), ty::Adt(base_adt, _)) if adt == base_adt); - if self.tcx.sess.is_nightly_build() && same_adt { - feature_err( - &self.tcx.sess, - sym::type_changing_struct_update, - base_expr.span, - "type changing struct updating is experimental", + if !missing_mandatory_fields.is_empty() { + let s = pluralize!(missing_mandatory_fields.len()); + let fields = listify(&missing_mandatory_fields, |f| format!("`{f}`")).unwrap(); + self.dcx() + .struct_span_err( + span.shrink_to_lo(), + format!("missing field{s} {fields} in initializer"), + ) + .with_span_label( + span.shrink_to_lo(), + "fields that do not have a defaulted value must be provided explicitly", ) .emit(); - } - }); - match adt_ty.kind() { + return; + } + let fru_tys = match adt_ty.kind() { ty::Adt(adt, args) if adt.is_struct() => variant .fields .iter() - .map(|f| self.normalize(expr.span, f.ty(self.tcx, args))) + .map(|f| self.normalize(span, f.ty(self.tcx, args))) + .collect(), + ty::Adt(adt, args) if adt.is_enum() => variant + .fields + .iter() + .map(|f| self.normalize(span, f.ty(self.tcx, args))) .collect(), _ => { + self.dcx().emit_err(FunctionalRecordUpdateOnNonStruct { span }); + return; + } + }; + self.typeck_results.borrow_mut().fru_field_types_mut().insert(expr.hir_id, fru_tys); + } + hir::StructTailExpr::Base(base_expr) => { + // FIXME: We are currently creating two branches here in order to maintain + // consistency. But they should be merged as much as possible. + let fru_tys = if self.tcx.features().type_changing_struct_update() { + if adt.is_struct() { + // Make some fresh generic parameters for our ADT type. + let fresh_args = self.fresh_args_for_item(base_expr.span, adt.did()); + // We do subtyping on the FRU fields first, so we can + // learn exactly what types we expect the base expr + // needs constrained to be compatible with the struct + // type we expect from the expectation value. + let fru_tys = variant + .fields + .iter() + .map(|f| { + let fru_ty = self.normalize( + expr.span, + self.field_ty(base_expr.span, f, fresh_args), + ); + let ident = + self.tcx.adjust_ident(f.ident(self.tcx), variant.def_id); + if let Some(_) = remaining_fields.remove(&ident) { + let target_ty = self.field_ty(base_expr.span, f, args); + let cause = self.misc(base_expr.span); + match self.at(&cause, self.param_env).sup( + // We're already using inference variables for any params, + // and don't allow converting between different structs, + // so there is no way this ever actually defines an opaque + // type. Thus choosing `Yes` is fine. + DefineOpaqueTypes::Yes, + target_ty, + fru_ty, + ) { + Ok(InferOk { obligations, value: () }) => { + self.register_predicates(obligations) + } + Err(_) => { + span_bug!( + cause.span, + "subtyping remaining fields of type changing FRU \ + failed: {target_ty} != {fru_ty}: {}::{}", + variant.name, + ident.name, + ); + } + } + } + self.resolve_vars_if_possible(fru_ty) + }) + .collect(); + // The use of fresh args that we have subtyped against + // our base ADT type's fields allows us to guide inference + // along so that, e.g. + // ``` + // MyStruct<'a, F1, F2, const C: usize> { + // f: F1, + // // Other fields that reference `'a`, `F2`, and `C` + // } + // + // let x = MyStruct { + // f: 1usize, + // ..other_struct + // }; + // ``` + // will have the `other_struct` expression constrained to + // `MyStruct<'a, _, F2, C>`, as opposed to just `_`... + // This is important to allow coercions to happen in + // `other_struct` itself. See `coerce-in-base-expr.rs`. + let fresh_base_ty = Ty::new_adt(self.tcx, *adt, fresh_args); + self.check_expr_has_type_or_error( + base_expr, + self.resolve_vars_if_possible(fresh_base_ty), + |_| {}, + ); + fru_tys + } else { + // Check the base_expr, regardless of a bad expected adt_ty, so we can get + // type errors on that expression, too. + self.check_expr(base_expr); self.dcx() .emit_err(FunctionalRecordUpdateOnNonStruct { span: base_expr.span }); return; } + } else { + self.check_expr_has_type_or_error(base_expr, adt_ty, |_| { + let base_ty = self.typeck_results.borrow().expr_ty(base_expr); + let same_adt = matches!((adt_ty.kind(), base_ty.kind()), + (ty::Adt(adt, _), ty::Adt(base_adt, _)) if adt == base_adt); + if self.tcx.sess.is_nightly_build() && same_adt { + feature_err( + &self.tcx.sess, + sym::type_changing_struct_update, + base_expr.span, + "type changing struct updating is experimental", + ) + .emit(); + } + }); + match adt_ty.kind() { + ty::Adt(adt, args) if adt.is_struct() => variant + .fields + .iter() + .map(|f| self.normalize(expr.span, f.ty(self.tcx, args))) + .collect(), + _ => { + self.dcx().emit_err(FunctionalRecordUpdateOnNonStruct { + span: base_expr.span, + }); + return; + } + } + }; + self.typeck_results.borrow_mut().fru_field_types_mut().insert(expr.hir_id, fru_tys); + } + rustc_hir::StructTailExpr::NoneWithError(ErrorGuaranteed { .. }) => { + // If parsing the struct recovered from a syntax error, do not report missing + // fields. This prevents spurious errors when a field is intended to be present + // but a preceding syntax error caused it not to be parsed. For example, if a + // struct type `StructName` has fields `foo` and `bar`, then + // StructName { foo(), bar: 2 } + // will not successfully parse a field `foo`, but we will not mention that, + // since the syntax error has already been reported. + } + rustc_hir::StructTailExpr::None => { + if adt_kind != AdtKind::Union + && !remaining_fields.is_empty() + //~ non_exhaustive already reported, which will only happen for extern modules + && !variant.field_list_has_applicable_non_exhaustive() + { + debug!(?remaining_fields); + + // Report missing fields. + + let private_fields: Vec<&ty::FieldDef> = variant + .fields + .iter() + .filter(|field| { + !field.vis.is_accessible_from(tcx.parent_module(expr.hir_id), tcx) + }) + .collect(); + + if !private_fields.is_empty() { + self.report_private_fields( + adt_ty, + path_span, + expr.span, + private_fields, + hir_fields, + ); + } else { + self.report_missing_fields( + adt_ty, + path_span, + expr.span, + remaining_fields, + variant, + hir_fields, + args, + ); + } } - }; - self.typeck_results.borrow_mut().fru_field_types_mut().insert(expr.hir_id, fru_tys); - } else if adt_kind != AdtKind::Union - && !remaining_fields.is_empty() - //~ non_exhaustive already reported, which will only happen for extern modules - && !variant.field_list_has_applicable_non_exhaustive() - { - debug!(?remaining_fields); - let private_fields: Vec<&ty::FieldDef> = variant - .fields - .iter() - .filter(|field| !field.vis.is_accessible_from(tcx.parent_module(expr.hir_id), tcx)) - .collect(); - - if !private_fields.is_empty() { - self.report_private_fields( - adt_ty, - path_span, - expr.span, - private_fields, - hir_fields, - ); - } else { - self.report_missing_fields( - adt_ty, - path_span, - expr.span, - remaining_fields, - variant, - hir_fields, - args, - ); } } } diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index 94f682a8859e9..0a492c795b29c 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -673,7 +673,9 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx let with_expr = match *opt_with { hir::StructTailExpr::Base(w) => &*w, - hir::StructTailExpr::DefaultFields(_) | hir::StructTailExpr::None => { + hir::StructTailExpr::DefaultFields(_) + | hir::StructTailExpr::None + | hir::StructTailExpr::NoneWithError(_) => { return Ok(()); } }; diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index b63feb022ff0c..8e6e9af5a4867 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -632,7 +632,8 @@ impl<'tcx> ThirBuildCx<'tcx> { .collect(), ) } - hir::StructTailExpr::None => AdtExprBase::None, + hir::StructTailExpr::None + | hir::StructTailExpr::NoneWithError(_) => AdtExprBase::None, }, })) } @@ -669,7 +670,10 @@ impl<'tcx> ThirBuildCx<'tcx> { hir::StructTailExpr::Base(base) => { span_bug!(base.span, "unexpected res: {:?}", res); } - hir::StructTailExpr::None => AdtExprBase::None, + hir::StructTailExpr::None + | hir::StructTailExpr::NoneWithError(_) => { + AdtExprBase::None + } }, })) } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 1a4c5238f72bc..e6f73e41f0821 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -3842,6 +3842,15 @@ impl<'a> Parser<'a> { recovered_async = Some(guar); } + // If we encountered an error which we are recovering from, treat the struct + // as if it has a `..` in it, because we don’t know what fields the user + // might have *intended* it to have. + // + // This assignment will be overwritten if we actually parse a `..` later. + // + // (Note that this code is duplicated between here and below in comma parsing. + base = ast::StructRest::NoneWithError(guar); + // If the next token is a comma, then try to parse // what comes next as additional fields, rather than // bailing out until next `}`. @@ -3892,6 +3901,10 @@ impl<'a> Parser<'a> { } else if let Some(f) = field_ident(self, guar) { fields.push(f); } + + // See comment above on this same assignment inside of field parsing. + base = ast::StructRest::NoneWithError(guar); + self.recover_stmt_(SemiColonMode::Comma, BlockMode::Ignore); let _ = self.eat(exp!(Comma)); } diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 287e8579e080a..63860dfdd1a65 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -1100,7 +1100,7 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> { qpath.span(), ); } - hir::StructTailExpr::None => { + hir::StructTailExpr::None | hir::StructTailExpr::NoneWithError(_) => { let mut failed_fields = vec![]; for field in fields { let (hir_id, use_ctxt) = (field.hir_id, field.ident.span); diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 3e9476b124f67..6e9d4a38d987c 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -5066,7 +5066,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { match &se.rest { StructRest::Base(expr) => self.visit_expr(expr), StructRest::Rest(_span) => {} - StructRest::None => {} + StructRest::None | StructRest::NoneWithError(_) => {} } } diff --git a/compiler/rustc_target/src/callconv/aarch64.rs b/compiler/rustc_target/src/callconv/aarch64.rs index 13be3888611f1..e9a19aa7024bb 100644 --- a/compiler/rustc_target/src/callconv/aarch64.rs +++ b/compiler/rustc_target/src/callconv/aarch64.rs @@ -3,7 +3,7 @@ use std::iter; use rustc_abi::{BackendRepr, HasDataLayout, Primitive, TyAbiInterface}; use crate::callconv::{ArgAbi, FnAbi, Reg, RegKind, Uniform}; -use crate::spec::{Abi, HasTargetSpec, Target}; +use crate::spec::{HasTargetSpec, RustcAbi, Target}; /// Indicates the variant of the AArch64 ABI we are compiling for. /// Used to accommodate Apple and Microsoft's deviations from the usual AAPCS ABI. @@ -34,7 +34,7 @@ where RegKind::Integer => false, // The softfloat ABI treats floats like integers, so they // do not get homogeneous aggregate treatment. - RegKind::Float => cx.target_spec().abi != Abi::SoftFloat, + RegKind::Float => cx.target_spec().rustc_abi != Some(RustcAbi::Softfloat), RegKind::Vector => size.bits() == 64 || size.bits() == 128, }; @@ -43,7 +43,7 @@ where } fn softfloat_float_abi(target: &Target, arg: &mut ArgAbi<'_, Ty>) { - if target.abi != Abi::SoftFloat { + if target.rustc_abi != Some(RustcAbi::Softfloat) { return; } // Do *not* use the float registers for passing arguments, as that would make LLVM pick the ABI diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index d9c872c9b4352..a4460a3725174 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2210,8 +2210,10 @@ pub struct TargetOptions { pub env: Env, /// ABI name to distinguish multiple ABIs on the same OS and architecture. For instance, `"eabi"` /// or `"eabihf"`. Defaults to [`Abi::Unspecified`]. - /// This field is *not* forwarded directly to LLVM; its primary purpose is `cfg(target_abi)`. - /// However, parts of the backend do check this field for specific values to enable special behavior. + /// This field is *not* forwarded directly to LLVM and therefore does not control which ABI (in + /// the sense of function calling convention) is actually used; its primary purpose is + /// `cfg(target_abi)`. The actual calling convention is controlled by `llvm_abiname`, + /// `llvm_floatabi`, and `rustc_abi`. pub abi: Abi, /// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown". #[rustc_lint_opt_deny_field_access( @@ -3228,8 +3230,8 @@ impl Target { ), RustcAbi::Softfloat => check_matches!( self.arch, - Arch::X86 | Arch::X86_64 | Arch::S390x, - "`softfloat` ABI is only valid for x86 and s390x targets" + Arch::X86 | Arch::X86_64 | Arch::S390x | Arch::AArch64, + "`softfloat` ABI is only valid for x86, s390x, and aarch64 targets" ), } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs index 07512c01dc4a8..e204c6466e297 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs @@ -8,13 +8,14 @@ use rustc_abi::Endian; use crate::spec::{ - Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, - Target, TargetMetadata, TargetOptions, + Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, RustcAbi, SanitizerSet, + StackProbeType, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { let opts = TargetOptions { abi: Abi::SoftFloat, + rustc_abi: Some(RustcAbi::Softfloat), linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), linker: Some("rust-lld".into()), features: "+v8a,+strict-align,-neon".into(), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs index ad444c139bff6..ed2e2fb6ab70b 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs @@ -7,13 +7,14 @@ // For example, `-C target-cpu=cortex-a53`. use crate::spec::{ - Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, - Target, TargetMetadata, TargetOptions, + Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, RustcAbi, SanitizerSet, + StackProbeType, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { let opts = TargetOptions { abi: Abi::SoftFloat, + rustc_abi: Some(RustcAbi::Softfloat), linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), linker: Some("rust-lld".into()), features: "+v8a,+strict-align,-neon".into(), diff --git a/compiler/rustc_target/src/spec/targets/aarch64v8r_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/aarch64v8r_unknown_none_softfloat.rs index 63f518873c609..6f11f97e3d1df 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64v8r_unknown_none_softfloat.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64v8r_unknown_none_softfloat.rs @@ -1,11 +1,12 @@ use crate::spec::{ - Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, - Target, TargetMetadata, TargetOptions, + Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, RustcAbi, SanitizerSet, + StackProbeType, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { let opts = TargetOptions { abi: Abi::SoftFloat, + rustc_abi: Some(RustcAbi::Softfloat), linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), linker: Some("rust-lld".into()), relocation_model: RelocModel::Static, diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index c3de7e257662f..80674ab4cf8a2 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -5,7 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_macros::HashStable_Generic; use rustc_span::{Symbol, sym}; -use crate::spec::{Abi, Arch, FloatAbi, RustcAbi, Target}; +use crate::spec::{Arch, FloatAbi, RustcAbi, Target}; /// Features that control behaviour of rustc, rather than the codegen. /// These exist globally and are not in the target-specific lists below. @@ -1154,17 +1154,21 @@ impl Target { Arch::AArch64 | Arch::Arm64EC => { // Aarch64 has no sane ABI specifier, and LLVM doesn't even have a way to force // the use of soft-float, so all we can do here is some crude hacks. - if self.abi == Abi::SoftFloat { - // LLVM will use float registers when `fp-armv8` is available, e.g. for - // calls to built-ins. The only way to ensure a consistent softfloat ABI - // on aarch64 is to never enable `fp-armv8`, so we enforce that. - // In Rust we tie `neon` and `fp-armv8` together, therefore `neon` is the - // feature we have to mark as incompatible. - FeatureConstraints { required: &[], incompatible: &["neon"] } - } else { - // Everything else is assumed to use a hardfloat ABI. neon and fp-armv8 must be enabled. - // `FeatureConstraints` uses Rust feature names, hence only "neon" shows up. - FeatureConstraints { required: &["neon"], incompatible: &[] } + match self.rustc_abi { + Some(RustcAbi::Softfloat) => { + // LLVM will use float registers when `fp-armv8` is available, e.g. for + // calls to built-ins. The only way to ensure a consistent softfloat ABI + // on aarch64 is to never enable `fp-armv8`, so we enforce that. + // In Rust we tie `neon` and `fp-armv8` together, therefore `neon` is the + // feature we have to mark as incompatible. + FeatureConstraints { required: &[], incompatible: &["neon"] } + } + None => { + // Everything else is assumed to use a hardfloat ABI. neon and fp-armv8 must be enabled. + // `FeatureConstraints` uses Rust feature names, hence only "neon" shows up. + FeatureConstraints { required: &["neon"], incompatible: &[] } + } + Some(r) => panic!("invalid Rust ABI for aarch64: {r:?}"), } } Arch::RiscV32 | Arch::RiscV64 => { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 386c75dad9dd3..814333859488f 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -3883,7 +3883,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { err.span_note(assoc_span, msg); } ObligationCauseCode::TrivialBound => { - err.help("see issue #48214"); tcx.disabled_nightly_features(err, [(String::new(), sym::trivial_bounds)]); } ObligationCauseCode::OpaqueReturnType(expr_info) => { diff --git a/library/std/src/os/hermit/ffi.rs b/library/std/src/os/hermit/ffi.rs index 19761fd99b400..01a54e1ac8df8 100644 --- a/library/std/src/os/hermit/ffi.rs +++ b/library/std/src/os/hermit/ffi.rs @@ -1,4 +1,4 @@ -//! HermitCore-specific extension to the primitives in the `std::ffi` module +//! Hermit-specific extension to the primitives in the `std::ffi` module //! //! # Examples //! diff --git a/library/std/src/sys/pal/hermit/mod.rs b/library/std/src/sys/pal/hermit/mod.rs index db64f8d882e24..f10a090a6e919 100644 --- a/library/std/src/sys/pal/hermit/mod.rs +++ b/library/std/src/sys/pal/hermit/mod.rs @@ -1,7 +1,7 @@ -//! System bindings for HermitCore +//! System bindings for Hermit //! //! This module contains the facade (aka platform-specific) implementations of -//! OS level functionality for HermitCore. +//! OS level functionality for Hermit. //! //! This is all super highly experimental and not actually intended for //! wide/production use yet, it's still all in the experimental category. This @@ -30,7 +30,7 @@ pub fn unsupported() -> io::Result { } pub fn unsupported_err() -> io::Error { - io::const_error!(io::ErrorKind::Unsupported, "operation not supported on HermitCore yet") + io::const_error!(io::ErrorKind::Unsupported, "operation not supported on Hermit yet") } pub fn abort_internal() -> ! { diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index 485af5ab1d016..3ec2bc3af8d42 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -429,7 +429,7 @@ impl fmt::Display for Display<'_> { "freebsd" => "FreeBSD", "fuchsia" => "Fuchsia", "haiku" => "Haiku", - "hermit" => "HermitCore", + "hermit" => "Hermit", "illumos" => "illumos", "ios" => "iOS", "l4re" => "L4Re", diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 375f8338319b6..79dd50c4682de 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -285,7 +285,11 @@ pub(crate) fn create_config( crate_check_cfg: check_cfgs, input, output_file: None, - output_dir: None, + output_dir: if render_options.output_to_stdout { + None + } else { + Some(render_options.output.clone()) + }, file_loader: None, lint_caps, psess_created: None, diff --git a/src/tools/clippy/clippy_lints/src/no_effect.rs b/src/tools/clippy/clippy_lints/src/no_effect.rs index fdb8e1b475c1d..3620e5425a947 100644 --- a/src/tools/clippy/clippy_lints/src/no_effect.rs +++ b/src/tools/clippy/clippy_lints/src/no_effect.rs @@ -242,7 +242,7 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { !expr_ty_has_significant_drop(cx, expr) && fields.iter().all(|field| has_no_effect(cx, field.expr)) && match &base { - StructTailExpr::None | StructTailExpr::DefaultFields(_) => true, + StructTailExpr::None | StructTailExpr::NoneWithError(_) | StructTailExpr::DefaultFields(_) => true, StructTailExpr::Base(base) => has_no_effect(cx, base), } }, @@ -353,7 +353,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option Some(base), - StructTailExpr::None | StructTailExpr::DefaultFields(_) => None, + StructTailExpr::None | StructTailExpr::NoneWithError(_) | StructTailExpr::DefaultFields(_) => None, }; Some(fields.iter().map(|f| &f.expr).chain(base).map(Deref::deref).collect()) } diff --git a/src/tools/clippy/clippy_lints/src/utils/author.rs b/src/tools/clippy/clippy_lints/src/utils/author.rs index d5191794b6b06..7ba28f95a719f 100644 --- a/src/tools/clippy/clippy_lints/src/utils/author.rs +++ b/src/tools/clippy/clippy_lints/src/utils/author.rs @@ -673,7 +673,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> { bind!(self, qpath, fields); let base = OptionPat::new(match base { StructTailExpr::Base(base) => Some(self.bind("base", base)), - StructTailExpr::None | StructTailExpr::DefaultFields(_) => None, + StructTailExpr::None | StructTailExpr::NoneWithError(_) | StructTailExpr::DefaultFields(_) => None, }); kind!("Struct({qpath}, {fields}, {base})"); self.qpath(qpath, &expr.name, expr.value.hir_id); diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index b79137c44427e..51b73351fe6a5 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -1809,7 +1809,7 @@ fn rewrite_struct_lit<'a>( match struct_rest { ast::StructRest::Base(expr) => Some(StructLitField::Base(&**expr)), ast::StructRest::Rest(span) => Some(StructLitField::Rest(*span)), - ast::StructRest::None => None, + ast::StructRest::None | ast::StructRest::NoneWithError(_) => None, } .into_iter(), ); diff --git a/tests/pretty/delegation-inherit-attributes.pp b/tests/pretty/delegation-inherit-attributes.pp index 72493f557dfc2..2525d308553ba 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 efa643313e6b4..28bb49458ce1d 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/run-make/rustdoc-dep-info/rmake.rs b/tests/run-make/rustdoc-dep-info/rmake.rs index 5d6176b18e886..11901c97fd6a0 100644 --- a/tests/run-make/rustdoc-dep-info/rmake.rs +++ b/tests/run-make/rustdoc-dep-info/rmake.rs @@ -7,6 +7,8 @@ use run_make_support::assertion_helpers::assert_contains; use run_make_support::{path, rfs, rustdoc}; fn main() { + rfs::create_dir("doc"); + // We're only emitting dep info, so we shouldn't be running static analysis to // figure out that this program is erroneous. // Ensure that all kinds of input reading flags end up in dep-info. @@ -20,7 +22,7 @@ fn main() { .emit("dep-info") .run(); - let content = rfs::read_to_string("foo.d"); + let content = rfs::read_to_string("doc/foo.d"); assert_contains(&content, "lib.rs:"); assert_contains(&content, "foo.rs:"); assert_contains(&content, "bar.rs:"); diff --git a/tests/run-make/rustdoc-scrape-examples-dep-info/rmake.rs b/tests/run-make/rustdoc-scrape-examples-dep-info/rmake.rs index 00a87477ab5e4..5a612fd130052 100644 --- a/tests/run-make/rustdoc-scrape-examples-dep-info/rmake.rs +++ b/tests/run-make/rustdoc-scrape-examples-dep-info/rmake.rs @@ -5,15 +5,17 @@ use run_make_support::{assert_contains, rfs}; mod scrape; fn main() { + rfs::create_dir("rustdoc"); + scrape::scrape( &["--scrape-tests", "--emit=dep-info"], &["--emit=dep-info,invocation-specific"], ); - let content = rfs::read_to_string("foobar.d").replace(r"\", "/"); + let content = rfs::read_to_string("rustdoc/foobar.d").replace(r"\", "/"); assert_contains(&content, "lib.rs:"); assert_contains(&content, "rustdoc/ex.calls:"); - let content = rfs::read_to_string("ex.d").replace(r"\", "/"); + let content = rfs::read_to_string("rustdoc/ex.d").replace(r"\", "/"); assert_contains(&content, "examples/ex.rs:"); } diff --git a/tests/ui/const-generics/issues/issue-67185-2.stderr b/tests/ui/const-generics/issues/issue-67185-2.stderr index 85f916974e383..8a170201832c9 100644 --- a/tests/ui/const-generics/issues/issue-67185-2.stderr +++ b/tests/ui/const-generics/issues/issue-67185-2.stderr @@ -11,7 +11,6 @@ LL | impl Bar for [u16; 4] {} | ^^^^^^^^^^^^^^^^^^^^^ `[u16; 4]` LL | impl Bar for [[u16; 3]; 3] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `[[u16; 3]; 3]` - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -30,7 +29,6 @@ LL | impl Bar for [u16; 4] {} | ^^^^^^^^^^^^^^^^^^^^^ `[u16; 4]` LL | impl Bar for [[u16; 3]; 3] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `[[u16; 3]; 3]` - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] diff --git a/tests/ui/cross/cross-fn-cache-hole.stderr b/tests/ui/cross/cross-fn-cache-hole.stderr index b7bcbc8933ff4..ca43119dde7f6 100644 --- a/tests/ui/cross/cross-fn-cache-hole.stderr +++ b/tests/ui/cross/cross-fn-cache-hole.stderr @@ -9,7 +9,6 @@ help: this trait has no implementations, consider adding one | LL | trait Bar { } | ^^^^^^^^^^^^ - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] 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-to-trait-method.stderr b/tests/ui/delegation/generics/impl-to-trait-method.stderr index 2c0b466dba3c9..74ccf61bea703 100644 --- a/tests/ui/delegation/generics/impl-to-trait-method.stderr +++ b/tests/ui/delegation/generics/impl-to-trait-method.stderr @@ -14,7 +14,6 @@ help: this trait has no implementations, consider adding one | LL | trait Trait0 {} | ^^^^^^^^^^^^ - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] 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`. diff --git a/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr b/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr index 10a7498d5a1c3..e9bee1597c5cd 100644 --- a/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -9,7 +9,6 @@ help: the trait `Foo` is implemented for `()` | LL | impl Foo for () where i32: Foo { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -26,7 +25,6 @@ help: the trait `Foo` is implemented for `()` | LL | impl Foo for () where i32: Foo { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -43,7 +41,6 @@ help: the trait `Foo` is implemented for `()` | LL | impl Foo for () where i32: Foo { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -60,7 +57,6 @@ help: the trait `Foo` is implemented for `()` | LL | impl Foo for () where i32: Foo { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -77,7 +73,6 @@ help: the trait `Foo` is implemented for `()` | LL | impl Foo for () where i32: Foo { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -94,7 +89,6 @@ help: the trait `Foo` is implemented for `()` | LL | impl Foo for () where i32: Foo { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -106,7 +100,6 @@ error[E0277]: the trait bound `String: Neg` is not satisfied LL | fn use_op(s: String) -> String where String: ::std::ops::Neg { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Neg` is not implemented for `String` | - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -119,7 +112,6 @@ LL | fn use_for() where i32: Iterator { | ^^^^^^^^^^^^^ `i32` is not an iterator | = help: the trait `Iterator` is not implemented for `i32` - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -132,7 +124,6 @@ LL | struct TwoStrs(str, str) where str: Sized; | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -150,7 +141,6 @@ note: required because it appears within the type `Dst<(dyn A + 'static)>` | LL | struct Dst { | ^^^ - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -163,7 +153,6 @@ LL | fn return_str() -> str where str: Sized { | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] diff --git a/tests/ui/impl-trait/in-trait/synthetic-hir-has-parent.stderr b/tests/ui/impl-trait/in-trait/synthetic-hir-has-parent.stderr index 8ff8f12cdf462..5d19e20757f4c 100644 --- a/tests/ui/impl-trait/in-trait/synthetic-hir-has-parent.stderr +++ b/tests/ui/impl-trait/in-trait/synthetic-hir-has-parent.stderr @@ -4,7 +4,6 @@ error[E0277]: the trait bound `String: Copy` is not satisfied LL | String: Copy; | ^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] @@ -16,7 +15,6 @@ error[E0277]: the trait bound `String: Copy` is not satisfied LL | fn demo() -> impl Foo | ^^^^^^^^ the trait `Copy` is not implemented for `String` | - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] diff --git a/tests/ui/issues/auxiliary/issue-14422.rs b/tests/ui/imports/auxiliary/extern-crate-alias-impl-method-aux.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-14422.rs rename to tests/ui/imports/auxiliary/extern-crate-alias-impl-method-aux.rs diff --git a/tests/ui/issues/auxiliary/issue-13620-1.rs b/tests/ui/imports/auxiliary/extern-crate-indirect-fn-ptr-aux-1.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-13620-1.rs rename to tests/ui/imports/auxiliary/extern-crate-indirect-fn-ptr-aux-1.rs diff --git a/tests/ui/imports/auxiliary/extern-crate-indirect-fn-ptr-aux-2.rs b/tests/ui/imports/auxiliary/extern-crate-indirect-fn-ptr-aux-2.rs new file mode 100644 index 0000000000000..f415671fc5a92 --- /dev/null +++ b/tests/ui/imports/auxiliary/extern-crate-indirect-fn-ptr-aux-2.rs @@ -0,0 +1,3 @@ +extern crate extern_crate_indirect_fn_ptr_aux_1 as crate1; + +pub static FOO2: crate1::Foo = crate1::FOO; diff --git a/tests/ui/issues/auxiliary/issue-14344-1.rs b/tests/ui/imports/auxiliary/extern-crate-no-prefer-dynamic-aux-1.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-14344-1.rs rename to tests/ui/imports/auxiliary/extern-crate-no-prefer-dynamic-aux-1.rs diff --git a/tests/ui/imports/auxiliary/extern-crate-no-prefer-dynamic-aux-2.rs b/tests/ui/imports/auxiliary/extern-crate-no-prefer-dynamic-aux-2.rs new file mode 100644 index 0000000000000..001585c34afb8 --- /dev/null +++ b/tests/ui/imports/auxiliary/extern-crate-no-prefer-dynamic-aux-2.rs @@ -0,0 +1,3 @@ +extern crate extern_crate_no_prefer_dynamic_aux_1; + +pub fn bar() {} diff --git a/tests/ui/issues/auxiliary/issue-15562.rs b/tests/ui/imports/auxiliary/extern-transmute-aux.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-15562.rs rename to tests/ui/imports/auxiliary/extern-transmute-aux.rs diff --git a/tests/ui/issues/auxiliary/issue-13507.rs b/tests/ui/imports/auxiliary/typeid-cross-crate-aux.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-13507.rs rename to tests/ui/imports/auxiliary/typeid-cross-crate-aux.rs diff --git a/tests/ui/issues/auxiliary/issue-12612-1.rs b/tests/ui/imports/auxiliary/unused-cross-crate-import-aux-1.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-12612-1.rs rename to tests/ui/imports/auxiliary/unused-cross-crate-import-aux-1.rs diff --git a/tests/ui/issues/auxiliary/issue-12612-2.rs b/tests/ui/imports/auxiliary/unused-cross-crate-import-aux-2.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-12612-2.rs rename to tests/ui/imports/auxiliary/unused-cross-crate-import-aux-2.rs diff --git a/tests/ui/issues/auxiliary/issue-11224.rs b/tests/ui/imports/auxiliary/unused-extern-crate-aux.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-11224.rs rename to tests/ui/imports/auxiliary/unused-extern-crate-aux.rs diff --git a/tests/ui/imports/extern-crate-alias-impl-method.rs b/tests/ui/imports/extern-crate-alias-impl-method.rs new file mode 100644 index 0000000000000..25baa3834cd05 --- /dev/null +++ b/tests/ui/imports/extern-crate-alias-impl-method.rs @@ -0,0 +1,16 @@ +// issue: +// Test that we can call an inherently implemented method via aliasing from an extern crate. +//@ run-pass +#![allow(non_snake_case)] + +//@ aux-build:extern-crate-alias-impl-method-aux.rs + +extern crate extern_crate_alias_impl_method_aux as bug_lib; + +use bug_lib::B; +use bug_lib::make; + +pub fn main() { + let mut an_A: B = make(); + an_A.foo(); +} diff --git a/tests/ui/imports/extern-crate-indirect-fn-ptr.rs b/tests/ui/imports/extern-crate-indirect-fn-ptr.rs new file mode 100644 index 0000000000000..5b88694463496 --- /dev/null +++ b/tests/ui/imports/extern-crate-indirect-fn-ptr.rs @@ -0,0 +1,11 @@ +// issue: +// Test cross crate resolution of an indirect function pointer +//@ run-pass +//@ aux-build:extern-crate-indirect-fn-ptr-aux-1.rs +//@ aux-build:extern-crate-indirect-fn-ptr-aux-2.rs + +extern crate extern_crate_indirect_fn_ptr_aux_2 as crate2; + +fn main() { + (crate2::FOO2.foo)(); +} diff --git a/tests/ui/imports/extern-crate-no-prefer-dynamic.rs b/tests/ui/imports/extern-crate-no-prefer-dynamic.rs new file mode 100644 index 0000000000000..681e7cb599d5c --- /dev/null +++ b/tests/ui/imports/extern-crate-no-prefer-dynamic.rs @@ -0,0 +1,13 @@ +// issue: +// Test that we can depend on an `no-prefer-dynamic` crate. +//@ run-pass +//@ aux-build:extern-crate-no-prefer-dynamic-aux-1.rs +//@ aux-build:extern-crate-no-prefer-dynamic-aux-2.rs + +extern crate extern_crate_no_prefer_dynamic_aux_1; +extern crate extern_crate_no_prefer_dynamic_aux_2; + +fn main() { + extern_crate_no_prefer_dynamic_aux_1::foo(); + extern_crate_no_prefer_dynamic_aux_2::bar(); +} diff --git a/tests/ui/issues/issue-15562.rs b/tests/ui/imports/extern-transmute.rs similarity index 61% rename from tests/ui/issues/issue-15562.rs rename to tests/ui/imports/extern-transmute.rs index d3a8f24c51b7e..18c2530236d54 100644 --- a/tests/ui/issues/issue-15562.rs +++ b/tests/ui/imports/extern-transmute.rs @@ -1,8 +1,9 @@ +// issue: +// Test resolution of `transmute` in an extern block to rust intrinsics. //@ run-pass -//@ aux-build:issue-15562.rs +//@ aux-build:extern-transmute-aux.rs - -extern crate issue_15562 as i; +extern crate extern_transmute_aux as i; pub fn main() { unsafe { diff --git a/tests/ui/issues/issue-13507-2.rs b/tests/ui/imports/typeid-cross-crate.rs similarity index 66% rename from tests/ui/issues/issue-13507-2.rs rename to tests/ui/imports/typeid-cross-crate.rs index afd88a1488153..0b217bde9aee4 100644 --- a/tests/ui/issues/issue-13507-2.rs +++ b/tests/ui/imports/typeid-cross-crate.rs @@ -1,14 +1,16 @@ +// issue: +// Test cross-crate TypeId stability //@ run-pass #![allow(unused_imports)] -//@ aux-build:issue-13507.rs +//@ aux-build:typeid-cross-crate-aux.rs -extern crate issue_13507; -use issue_13507::testtypes; +extern crate typeid_cross_crate_aux; +use typeid_cross_crate_aux::testtypes; use std::any::TypeId; pub fn type_ids() -> Vec { - use issue_13507::testtypes::*; + use typeid_cross_crate_aux::testtypes::*; vec![ TypeId::of::(), TypeId::of::(), @@ -25,12 +27,12 @@ pub fn type_ids() -> Vec { TypeId::of::(), TypeId::of::(), TypeId::of::(), - TypeId::of::() + TypeId::of::(), ] } pub fn main() { - let othercrate = issue_13507::testtypes::type_ids(); + let othercrate = typeid_cross_crate_aux::testtypes::type_ids(); let thiscrate = type_ids(); assert_eq!(thiscrate, othercrate); } diff --git a/tests/ui/imports/unused-cross-crate-import.rs b/tests/ui/imports/unused-cross-crate-import.rs new file mode 100644 index 0000000000000..4e115c3e4445d --- /dev/null +++ b/tests/ui/imports/unused-cross-crate-import.rs @@ -0,0 +1,15 @@ +// issue: +// Test that unused `use` declarations involving multiple external crates are handled properly. +//@ run-pass +#![allow(unused_imports)] +//@ aux-build:unused-cross-crate-import-aux-1.rs +//@ aux-build:unused-cross-crate-import-aux-2.rs + +extern crate unused_cross_crate_import_aux_1 as foo; +extern crate unused_cross_crate_import_aux_2 as bar; + +mod test { + use bar::baz; +} + +fn main() {} diff --git a/tests/ui/imports/unused-extern-crate.rs b/tests/ui/imports/unused-extern-crate.rs new file mode 100644 index 0000000000000..0abfa606d93ad --- /dev/null +++ b/tests/ui/imports/unused-extern-crate.rs @@ -0,0 +1,8 @@ +// issue: +// Test that an unused `extern crate` declaration does not crash the compiler. +//@ run-pass +//@ aux-build:unused-extern-crate-aux.rs + +extern crate unused_extern_crate_aux as unused; + +pub fn main() {} diff --git a/tests/ui/issues/auxiliary/issue-13620-2.rs b/tests/ui/issues/auxiliary/issue-13620-2.rs deleted file mode 100644 index 7efd24407ba9c..0000000000000 --- a/tests/ui/issues/auxiliary/issue-13620-2.rs +++ /dev/null @@ -1,3 +0,0 @@ -extern crate issue_13620_1 as crate1; - -pub static FOO2: crate1::Foo = crate1::FOO; diff --git a/tests/ui/issues/auxiliary/issue-14344-2.rs b/tests/ui/issues/auxiliary/issue-14344-2.rs deleted file mode 100644 index c47b8c0ea6c79..0000000000000 --- a/tests/ui/issues/auxiliary/issue-14344-2.rs +++ /dev/null @@ -1,3 +0,0 @@ -extern crate issue_14344_1; - -pub fn bar() {} diff --git a/tests/ui/issues/issue-11224.rs b/tests/ui/issues/issue-11224.rs deleted file mode 100644 index a7255e6299f98..0000000000000 --- a/tests/ui/issues/issue-11224.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -//@ aux-build:issue-11224.rs - - -extern crate issue_11224 as unused; - -pub fn main() {} diff --git a/tests/ui/issues/issue-11508.rs b/tests/ui/issues/issue-11508.rs deleted file mode 100644 index e7ed7a9f15f1d..0000000000000 --- a/tests/ui/issues/issue-11508.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -//@ aux-build:issue-11508.rs - -extern crate issue_11508 as rand; - -use rand::{Closed01, random}; - -fn main() { - let Closed01(val) = random::>(); - println!("{}", val); -} diff --git a/tests/ui/issues/issue-11552.rs b/tests/ui/issues/issue-11552.rs deleted file mode 100644 index d4784e53e6b41..0000000000000 --- a/tests/ui/issues/issue-11552.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ run-pass -#![feature(box_patterns)] - -#[derive(Clone)] -enum Noun -{ - Atom(isize), - Cell(Box, Box) -} - -fn fas(n: &Noun) -> Noun -{ - match n { - &Noun::Cell(box Noun::Atom(2), box Noun::Cell(ref a, _)) => (**a).clone(), - _ => panic!("Invalid fas pattern") - } -} - -pub fn main() { - fas( - &Noun::Cell(Box::new(Noun::Atom(2)), - Box::new(Noun::Cell(Box::new(Noun::Atom(2)), Box::new(Noun::Atom(3))))) - ); -} diff --git a/tests/ui/issues/issue-11592.rs b/tests/ui/issues/issue-11592.rs deleted file mode 100644 index cb1a92e809a9d..0000000000000 --- a/tests/ui/issues/issue-11592.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ check-pass -//! Ensure the private trait Bar isn't complained about. - -#![deny(missing_docs)] - -mod foo { - trait Bar { fn bar(&self) { } } - impl Bar for i8 { fn bar(&self) { } } -} - -fn main() { } diff --git a/tests/ui/issues/issue-11677.rs b/tests/ui/issues/issue-11677.rs deleted file mode 100644 index 32e129b2c01d6..0000000000000 --- a/tests/ui/issues/issue-11677.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ run-pass -#![allow(unused_imports)] - -#![allow(dead_code)] - -// this code used to cause an ICE - -use std::marker; - -trait X { - fn dummy(&self) -> T { panic!() } -} - -struct S {f: Box+'static>, - g: Box+'static>} - -struct F; -impl X for F { -} - -fn main() { - S {f: Box::new(F), g: Box::new(F) }; -} diff --git a/tests/ui/issues/issue-12612.rs b/tests/ui/issues/issue-12612.rs deleted file mode 100644 index ec0f3926aa5d3..0000000000000 --- a/tests/ui/issues/issue-12612.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass -#![allow(unused_imports)] -//@ aux-build:issue-12612-1.rs -//@ aux-build:issue-12612-2.rs - - -extern crate issue_12612_1 as foo; -extern crate issue_12612_2 as bar; - -mod test { - use bar::baz; -} - -fn main() {} diff --git a/tests/ui/issues/issue-13620.rs b/tests/ui/issues/issue-13620.rs deleted file mode 100644 index 4d9db3aa7ceda..0000000000000 --- a/tests/ui/issues/issue-13620.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -//@ aux-build:issue-13620-1.rs -//@ aux-build:issue-13620-2.rs - - -extern crate issue_13620_2 as crate2; - -fn main() { - (crate2::FOO2.foo)(); -} diff --git a/tests/ui/issues/issue-14344.rs b/tests/ui/issues/issue-14344.rs deleted file mode 100644 index 17863c7809ea6..0000000000000 --- a/tests/ui/issues/issue-14344.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -//@ aux-build:issue-14344-1.rs -//@ aux-build:issue-14344-2.rs - -extern crate issue_14344_1; -extern crate issue_14344_2; - -fn main() { - issue_14344_1::foo(); - issue_14344_2::bar(); -} diff --git a/tests/ui/issues/issue-14422.rs b/tests/ui/issues/issue-14422.rs deleted file mode 100644 index b7bb2caa7f088..0000000000000 --- a/tests/ui/issues/issue-14422.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-pass -#![allow(non_snake_case)] - -//@ aux-build:issue-14422.rs - - -extern crate issue_14422 as bug_lib; - -use bug_lib::B; -use bug_lib::make; - -pub fn main() { - let mut an_A: B = make(); - an_A.foo(); -} diff --git a/tests/ui/lint/missing-docs-private-trait.rs b/tests/ui/lint/missing-docs-private-trait.rs new file mode 100644 index 0000000000000..dde4dc2a02680 --- /dev/null +++ b/tests/ui/lint/missing-docs-private-trait.rs @@ -0,0 +1,17 @@ +// issue: +// Test that the `missing_docs` lint does not trigger for a private trait. +//@ check-pass +//! Ensure the private trait Bar isn't complained about. + +#![deny(missing_docs)] + +mod foo { + trait Bar { + fn bar(&self) {} + } + impl Bar for i8 { + fn bar(&self) {} + } +} + +fn main() {} diff --git a/tests/ui/parser/impl-item-type-no-body-semantic-fail.stderr b/tests/ui/parser/impl-item-type-no-body-semantic-fail.stderr index 9800420072be4..5c50a580fd148 100644 --- a/tests/ui/parser/impl-item-type-no-body-semantic-fail.stderr +++ b/tests/ui/parser/impl-item-type-no-body-semantic-fail.stderr @@ -88,7 +88,6 @@ error[E0277]: the trait bound `X: Eq` is not satisfied LL | type W: Ord where Self: Eq; | ^^^^^^^^ the trait `Eq` is not implemented for `X` | - = help: see issue #48214 help: consider annotating `X` with `#[derive(Eq)]` | LL + #[derive(Eq)] @@ -105,7 +104,6 @@ error[E0277]: the trait bound `X: Eq` is not satisfied LL | type W where Self: Eq; | ^^^^^^^^ the trait `Eq` is not implemented for `X` | - = help: see issue #48214 help: consider annotating `X` with `#[derive(Eq)]` | LL + #[derive(Eq)] diff --git a/tests/ui/parser/issues/issue-102806.rs b/tests/ui/parser/issues/issue-102806.rs index 5ee8c5c1e3de0..804e727272d4c 100644 --- a/tests/ui/parser/issues/issue-102806.rs +++ b/tests/ui/parser/issues/issue-102806.rs @@ -16,7 +16,6 @@ fn pz(v: V3) { let _ = V3 { z: 0.0, ... }; //~^ ERROR expected identifier - //~| ERROR missing fields `x` and `y` in initializer of `V3` let V3 { z: val, ... } = v; //~^ ERROR expected field pattern diff --git a/tests/ui/parser/issues/issue-102806.stderr b/tests/ui/parser/issues/issue-102806.stderr index cd447c6dec0d2..d4c899ed58114 100644 --- a/tests/ui/parser/issues/issue-102806.stderr +++ b/tests/ui/parser/issues/issue-102806.stderr @@ -31,7 +31,7 @@ LL | let _ = V3 { z: 0.0, ... }; | while parsing this struct error: expected field pattern, found `...` - --> $DIR/issue-102806.rs:21:22 + --> $DIR/issue-102806.rs:20:22 | LL | let V3 { z: val, ... } = v; | ^^^ @@ -42,12 +42,5 @@ LL - let V3 { z: val, ... } = v; LL + let V3 { z: val, .. } = v; | -error[E0063]: missing fields `x` and `y` in initializer of `V3` - --> $DIR/issue-102806.rs:17:13 - | -LL | let _ = V3 { z: 0.0, ... }; - | ^^ missing `x` and `y` - -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0063`. diff --git a/tests/ui/parser/issues/issue-52496.rs b/tests/ui/parser/issues/issue-52496.rs index 05461f8b8c413..3e88a92aae9bf 100644 --- a/tests/ui/parser/issues/issue-52496.rs +++ b/tests/ui/parser/issues/issue-52496.rs @@ -7,6 +7,5 @@ fn main() { let bar = 1.5f32; let _ = Foo { bar.into(), bat: -1, . }; //~^ ERROR expected one of - //~| ERROR missing fields `bar` and `baz` in initializer of `Foo` //~| ERROR expected identifier, found `.` } diff --git a/tests/ui/parser/issues/issue-52496.stderr b/tests/ui/parser/issues/issue-52496.stderr index a97effb4e0cd8..da22f5ce13562 100644 --- a/tests/ui/parser/issues/issue-52496.stderr +++ b/tests/ui/parser/issues/issue-52496.stderr @@ -37,12 +37,6 @@ error[E0063]: missing field `bat` in initializer of `Foo` LL | let _ = Foo { bar: .5, baz: 42 }; | ^^^ missing `bat` -error[E0063]: missing fields `bar` and `baz` in initializer of `Foo` - --> $DIR/issue-52496.rs:8:13 - | -LL | let _ = Foo { bar.into(), bat: -1, . }; - | ^^^ missing `bar` and `baz` - -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0063`. diff --git a/tests/ui/parser/removed-syntax/removed-syntax-with-2.rs b/tests/ui/parser/removed-syntax/removed-syntax-with-2.rs index 451057c66a127..119afdcc75e36 100644 --- a/tests/ui/parser/removed-syntax/removed-syntax-with-2.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-with-2.rs @@ -7,5 +7,4 @@ fn main() { let a = S { foo: (), bar: () }; let b = S { foo: (), with a }; //~^ ERROR expected one of `,`, `:`, or `}`, found `a` - //~| ERROR missing field `bar` in initializer of `S` } diff --git a/tests/ui/parser/removed-syntax/removed-syntax-with-2.stderr b/tests/ui/parser/removed-syntax/removed-syntax-with-2.stderr index e75c5bcd64319..7768aeccfad99 100644 --- a/tests/ui/parser/removed-syntax/removed-syntax-with-2.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-with-2.stderr @@ -7,12 +7,5 @@ LL | let b = S { foo: (), with a }; | | while parsing this struct field | while parsing this struct -error[E0063]: missing field `bar` in initializer of `S` - --> $DIR/removed-syntax-with-2.rs:8:13 - | -LL | let b = S { foo: (), with a }; - | ^ missing `bar` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0063`. diff --git a/tests/ui/parser/struct-field-numeric-shorthand.rs b/tests/ui/parser/struct-field-numeric-shorthand.rs index 645abd9c7192d..aa342eb02a916 100644 --- a/tests/ui/parser/struct-field-numeric-shorthand.rs +++ b/tests/ui/parser/struct-field-numeric-shorthand.rs @@ -5,5 +5,4 @@ fn main() { //~^ ERROR expected identifier, found `0` //~| ERROR expected identifier, found `1` //~| ERROR expected identifier, found `2` - //~| ERROR missing fields `0`, `1` and `2` in initializer of `Rgb` } diff --git a/tests/ui/parser/struct-field-numeric-shorthand.stderr b/tests/ui/parser/struct-field-numeric-shorthand.stderr index bfb8a931b6406..9878cfbbdceb8 100644 --- a/tests/ui/parser/struct-field-numeric-shorthand.stderr +++ b/tests/ui/parser/struct-field-numeric-shorthand.stderr @@ -22,12 +22,5 @@ LL | let _ = Rgb { 0, 1, 2 }; | | | while parsing this struct -error[E0063]: missing fields `0`, `1` and `2` in initializer of `Rgb` - --> $DIR/struct-field-numeric-shorthand.rs:4:13 - | -LL | let _ = Rgb { 0, 1, 2 }; - | ^^^ missing `0`, `1` and `2` - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0063`. diff --git a/tests/ui/issues/auxiliary/issue-11508.rs b/tests/ui/pattern/auxiliary/tuple-struct-cross-crate-aux.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-11508.rs rename to tests/ui/pattern/auxiliary/tuple-struct-cross-crate-aux.rs diff --git a/tests/ui/pattern/box-pattern-nested.rs b/tests/ui/pattern/box-pattern-nested.rs new file mode 100644 index 0000000000000..f686fee8742ce --- /dev/null +++ b/tests/ui/pattern/box-pattern-nested.rs @@ -0,0 +1,24 @@ +// issue: +// Test nested box pattern matching inside a larger `match` statement. +//@ run-pass +#![feature(box_patterns)] + +#[derive(Clone)] +enum Noun { + Atom(isize), + Cell(Box, Box), +} + +fn fas(n: &Noun) -> Noun { + match n { + &Noun::Cell(box Noun::Atom(2), box Noun::Cell(ref a, _)) => (**a).clone(), + _ => panic!("Invalid fas pattern"), + } +} + +pub fn main() { + fas(&Noun::Cell( + Box::new(Noun::Atom(2)), + Box::new(Noun::Cell(Box::new(Noun::Atom(2)), Box::new(Noun::Atom(3)))), + )); +} diff --git a/tests/ui/pattern/tuple-struct-cross-crate.rs b/tests/ui/pattern/tuple-struct-cross-crate.rs new file mode 100644 index 0000000000000..fd1158d44bdb0 --- /dev/null +++ b/tests/ui/pattern/tuple-struct-cross-crate.rs @@ -0,0 +1,13 @@ +// issue: +// Test pattern matching on a tuple struct defined in an external crate. +//@ run-pass +//@ aux-build:tuple-struct-cross-crate-aux.rs + +extern crate tuple_struct_cross_crate_aux as rand; + +use rand::{Closed01, random}; + +fn main() { + let Closed01(val) = random::>(); + println!("{}", val); +} diff --git a/tests/ui/structs/syntax-error-not-missing-field.rs b/tests/ui/structs/syntax-error-not-missing-field.rs new file mode 100644 index 0000000000000..f1080d3908cf4 --- /dev/null +++ b/tests/ui/structs/syntax-error-not-missing-field.rs @@ -0,0 +1,38 @@ +// Check that a syntax error inside a struct literal does not also report missing fields, +// because the field might be present but hidden by the syntax error. +// +// The stderr for this test should contain ONLY one syntax error per struct literal, +// and not any errors about missing fields. + +struct Foo { a: isize, b: isize } + +fn make_a() -> isize { 1234 } + +fn expr_wrong_separator() { + let f = Foo { a: make_a(); b: 2 }; //~ ERROR found `;` +} + +fn expr_missing_separator() { + let f = Foo { a: make_a() b: 2 }; //~ ERROR found `b` +} + +fn expr_rest_trailing_comma() { + let f = Foo { a: make_a(), ..todo!(), }; //~ ERROR cannot use a comma +} + +fn expr_missing_field_name() { + let f = Foo { make_a(), b: 2, }; //~ ERROR found `(` +} + +fn pat_wrong_separator(Foo { a; b }: Foo) { //~ ERROR expected `,` + let _ = (a, b); +} + +fn pat_missing_separator(Foo { a b }: Foo) { //~ ERROR expected `,` + let _ = (a, b); +} + +fn pat_rest_trailing_comma(Foo { a, .., }: Foo) { //~ ERROR expected `}`, found `,` +} + +fn main() {} diff --git a/tests/ui/structs/syntax-error-not-missing-field.stderr b/tests/ui/structs/syntax-error-not-missing-field.stderr new file mode 100644 index 0000000000000..d781a41300f36 --- /dev/null +++ b/tests/ui/structs/syntax-error-not-missing-field.stderr @@ -0,0 +1,74 @@ +error: expected one of `,`, `.`, `?`, `}`, or an operator, found `;` + --> $DIR/syntax-error-not-missing-field.rs:12:30 + | +LL | let f = Foo { a: make_a(); b: 2 }; + | --- ^ + | | | + | | expected one of `,`, `.`, `?`, `}`, or an operator + | | help: try adding a comma: `,` + | while parsing this struct + +error: expected one of `,`, `.`, `?`, `}`, or an operator, found `b` + --> $DIR/syntax-error-not-missing-field.rs:16:31 + | +LL | let f = Foo { a: make_a() b: 2 }; + | --- -^ expected one of `,`, `.`, `?`, `}`, or an operator + | | | + | | help: try adding a comma: `,` + | while parsing this struct + +error: cannot use a comma after the base struct + --> $DIR/syntax-error-not-missing-field.rs:20:32 + | +LL | let f = Foo { a: make_a(), ..todo!(), }; + | ^^^^^^^^^ + | + = note: the base struct must always be the last field +help: remove this comma + | +LL - let f = Foo { a: make_a(), ..todo!(), }; +LL + let f = Foo { a: make_a(), ..todo!() }; + | + +error: expected one of `,`, `:`, or `}`, found `(` + --> $DIR/syntax-error-not-missing-field.rs:24:25 + | +LL | let f = Foo { make_a(), b: 2, }; + | --- ------^ expected one of `,`, `:`, or `}` + | | | + | | while parsing this struct field + | while parsing this struct + | +help: try naming a field + | +LL | let f = Foo { make_a: make_a(), b: 2, }; + | +++++++ + +error: expected `,` + --> $DIR/syntax-error-not-missing-field.rs:27:31 + | +LL | fn pat_wrong_separator(Foo { a; b }: Foo) { + | --- ^ + | | + | while parsing the fields for this pattern + +error: expected `,` + --> $DIR/syntax-error-not-missing-field.rs:31:34 + | +LL | fn pat_missing_separator(Foo { a b }: Foo) { + | --- ^ + | | + | while parsing the fields for this pattern + +error: expected `}`, found `,` + --> $DIR/syntax-error-not-missing-field.rs:35:39 + | +LL | fn pat_rest_trailing_comma(Foo { a, .., }: Foo) { + | --^ + | | | + | | expected `}` + | | help: remove this comma + | `..` must be at the end and cannot have a trailing comma + +error: aborting due to 7 previous errors + diff --git a/tests/ui/suggestions/struct-initializer-comma.fixed b/tests/ui/suggestions/struct-initializer-comma.fixed index 556bfbca58df4..9bd9434a3b59d 100644 --- a/tests/ui/suggestions/struct-initializer-comma.fixed +++ b/tests/ui/suggestions/struct-initializer-comma.fixed @@ -7,7 +7,6 @@ pub struct Foo { fn main() { let _ = Foo { - //~^ ERROR missing field first: true, second: 25 //~^ ERROR expected one of diff --git a/tests/ui/suggestions/struct-initializer-comma.rs b/tests/ui/suggestions/struct-initializer-comma.rs index 7b93bf187b870..4b225df08df0a 100644 --- a/tests/ui/suggestions/struct-initializer-comma.rs +++ b/tests/ui/suggestions/struct-initializer-comma.rs @@ -7,7 +7,6 @@ pub struct Foo { fn main() { let _ = Foo { - //~^ ERROR missing field first: true second: 25 //~^ ERROR expected one of diff --git a/tests/ui/suggestions/struct-initializer-comma.stderr b/tests/ui/suggestions/struct-initializer-comma.stderr index 5eff43f32cda1..5fdc95a30cc44 100644 --- a/tests/ui/suggestions/struct-initializer-comma.stderr +++ b/tests/ui/suggestions/struct-initializer-comma.stderr @@ -1,9 +1,8 @@ error: expected one of `,`, `.`, `?`, `}`, or an operator, found `second` - --> $DIR/struct-initializer-comma.rs:12:9 + --> $DIR/struct-initializer-comma.rs:11:9 | LL | let _ = Foo { | --- while parsing this struct -LL | LL | first: true | - | | @@ -12,12 +11,5 @@ LL | first: true LL | second: 25 | ^^^^^^ unexpected token -error[E0063]: missing field `second` in initializer of `Foo` - --> $DIR/struct-initializer-comma.rs:9:13 - | -LL | let _ = Foo { - | ^^^ missing `second` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0063`. diff --git a/tests/ui/trait-bounds/super-assoc-mismatch.stderr b/tests/ui/trait-bounds/super-assoc-mismatch.stderr index 780535283a3a9..11d764d111eed 100644 --- a/tests/ui/trait-bounds/super-assoc-mismatch.stderr +++ b/tests/ui/trait-bounds/super-assoc-mismatch.stderr @@ -77,7 +77,6 @@ help: this trait has no implementations, consider adding one | LL | trait Sub: Super {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] diff --git a/tests/ui/typeck/infer-struct-with-trait-object.rs b/tests/ui/typeck/infer-struct-with-trait-object.rs new file mode 100644 index 0000000000000..c6de73a69dc0c --- /dev/null +++ b/tests/ui/typeck/infer-struct-with-trait-object.rs @@ -0,0 +1,27 @@ +// issue: +// Test that type inference works correctly for struct fields containing trait objects. +//@ run-pass +#![allow(unused_imports)] +#![allow(dead_code)] + +// this code used to cause an ICE + +use std::marker; + +trait X { + fn dummy(&self) -> T { + panic!() + } +} + +struct S { + f: Box + 'static>, + g: Box + 'static>, +} + +struct F; +impl X for F {} + +fn main() { + S { f: Box::new(F), g: Box::new(F) }; +}