Auto merge of #155687 - GuillaumeGomez:rollup-aZ7YrAD, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#155469 (Account for titlecase in casing lints)
 - rust-lang/rust#155644 (delegation: support self ty propagation for functions in free to trait reuse)
 - rust-lang/rust#154957 (Fix ICE when const closure appears inside a non-const trait method)
 - rust-lang/rust#155442 (Change keyword order for `impl` restrictions)
 - rust-lang/rust#155561 (Use singular wording for single _ placeholders in type suggestions)
 - rust-lang/rust#155637 (Fix E0191 suggestion for empty dyn trait args)
 - rust-lang/rust#155661 (Remove `AttributeLintKind` variants - part 6)
This commit is contained in:
bors
2026-04-23 15:55:48 +00:00
234 changed files with 1686 additions and 1353 deletions

View File

@@ -3786,10 +3786,10 @@ pub struct TraitAlias {
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
pub struct Trait {
pub impl_restriction: ImplRestriction,
pub constness: Const,
pub safety: Safety,
pub is_auto: IsAuto,
pub impl_restriction: ImplRestriction,
pub ident: Ident,
pub generics: Generics,
#[visitable(extra = BoundKind::SuperTraits)]

View File

@@ -143,7 +143,8 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
let (param_count, c_variadic) = self.param_count(sig_id);
let mut generics = self.uplift_delegation_generics(delegation, sig_id, item_id);
let mut generics =
self.uplift_delegation_generics(delegation, sig_id, item_id, is_method);
let body_id = self.lower_delegation_body(
delegation,
@@ -301,6 +302,8 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
hir::InferDelegationSig::Output(self.arena.alloc(hir::DelegationGenerics {
child_args_segment_id: generics.child.args_segment_id,
parent_args_segment_id: generics.parent.args_segment_id,
self_ty_id: generics.self_ty_id,
propagate_self_ty: generics.propagate_self_ty,
})),
)),
span,
@@ -554,6 +557,12 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
}
};
generics.self_ty_id = match new_path {
hir::QPath::Resolved(ty, _) => ty,
hir::QPath::TypeRelative(ty, _) => Some(ty),
}
.map(|ty| ty.hir_id);
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))
};

View File

@@ -67,6 +67,8 @@ pub(super) struct GenericsGenerationResult<'hir> {
pub(super) struct GenericsGenerationResults<'hir> {
pub(super) parent: GenericsGenerationResult<'hir>,
pub(super) child: GenericsGenerationResult<'hir>,
pub(super) self_ty_id: Option<HirId>,
pub(super) propagate_self_ty: bool,
}
pub(super) struct GenericArgsPropagationDetails {
@@ -209,6 +211,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
delegation: &Delegation,
sig_id: DefId,
item_id: NodeId,
is_method: bool,
) -> GenericsGenerationResults<'hir> {
let delegation_parent_kind =
self.tcx.def_kind(self.tcx.local_parent(self.local_def_id(item_id)));
@@ -230,7 +233,12 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
let child = DelegationGenerics::trait_impl(sig_params, child_user_specified);
let child = GenericsGenerationResult::new(child);
return GenericsGenerationResults { parent, child };
return GenericsGenerationResults {
parent,
child,
self_ty_id: None,
propagate_self_ty: false,
};
}
let delegation_in_free_ctx =
@@ -238,13 +246,14 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
let sig_parent = self.tcx.parent(sig_id);
let sig_in_trait = matches!(self.tcx.def_kind(sig_parent), DefKind::Trait);
let free_to_trait_delegation = delegation_in_free_ctx && sig_in_trait;
let generate_self = free_to_trait_delegation && is_method && delegation.qself.is_none();
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 generate_self = delegation_in_free_ctx && sig_in_trait;
let parent_generics = if can_add_generics_to_parent {
let sig_parent_params = &self.tcx.generics_of(sig_parent).own_params[..];
@@ -278,6 +287,8 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
GenericsGenerationResults {
parent: GenericsGenerationResult::new(parent_generics),
child: GenericsGenerationResult::new(child_generics),
self_ty_id: None,
propagate_self_ty: free_to_trait_delegation && !generate_self,
}
}

View File

@@ -556,10 +556,10 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
})
}
ItemKind::Trait(box Trait {
impl_restriction,
constness,
is_auto,
safety,
impl_restriction,
ident,
generics,
bounds,
@@ -586,10 +586,10 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
},
);
hir::ItemKind::Trait(
impl_restriction,
constness,
*is_auto,
safety,
impl_restriction,
ident,
generics,
bounds,

View File

@@ -371,10 +371,10 @@ impl<'a> State<'a> {
self.bclose(item.span, empty, cb);
}
ast::ItemKind::Trait(box ast::Trait {
impl_restriction,
constness,
safety,
is_auto,
impl_restriction,
ident,
generics,
bounds,
@@ -382,10 +382,10 @@ impl<'a> State<'a> {
}) => {
let (cb, ib) = self.head("");
self.print_visibility(&item.vis);
self.print_impl_restriction(impl_restriction);
self.print_constness(*constness);
self.print_safety(*safety);
self.print_is_auto(*is_auto);
self.print_impl_restriction(impl_restriction);
self.word_nbsp("trait");
self.print_ident(*ident);
self.print_generic_params(&generics.params);

View File

@@ -1,6 +1,6 @@
use std::ops::Range;
use rustc_errors::E0232;
use rustc_errors::{Diagnostic, E0232};
use rustc_hir::AttrPath;
use rustc_hir::attrs::diagnostic::{
Directive, FilterFormatString, Flag, FormatArg, FormatString, LitOrArg, Name, NameValue,
@@ -18,6 +18,10 @@ use rustc_span::{Ident, InnerSpan, Span, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::context::{AcceptContext, Stage};
use crate::errors::{
DisallowedPlaceholder, DisallowedPositionalArgument, IgnoredDiagnosticOption,
InvalidFormatSpecifier, MalFormedDiagnosticAttributeLint, WrappedParserError,
};
use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser};
pub(crate) mod do_not_recommend;
@@ -112,12 +116,12 @@ fn merge<T, S: Stage>(
match (first, later) {
(Some(_) | None, None) => {}
(Some((first_span, _)), Some((later_span, _))) => {
cx.emit_lint(
let first_span = *first_span;
cx.emit_dyn_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
AttributeLintKind::IgnoredDiagnosticOption {
first_span: *first_span,
later_span,
option_name,
move |dcx, level| {
IgnoredDiagnosticOption { first_span, later_span, option_name }
.into_diag(dcx, level)
},
later_span,
);
@@ -157,12 +161,15 @@ fn parse_list<'p, S: Stage>(
);
}
ArgParser::NameValue(_) => {
cx.emit_lint(
cx.emit_dyn_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
AttributeLintKind::MalFormedDiagnosticAttribute {
attribute: mode.as_str(),
options: mode.allowed_options(),
span,
move |dcx, level| {
MalFormedDiagnosticAttributeLint {
attribute: mode.as_str(),
options: mode.allowed_options(),
span,
}
.into_diag(dcx, level)
},
span,
);
@@ -188,12 +195,15 @@ fn parse_directive_items<'p, S: Stage>(
let span = item.span();
macro malformed() {{
cx.emit_lint(
cx.emit_dyn_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
AttributeLintKind::MalFormedDiagnosticAttribute {
attribute: mode.as_str(),
options: mode.allowed_options(),
span,
move |dcx, level| {
MalFormedDiagnosticAttributeLint {
attribute: mode.as_str(),
options: mode.allowed_options(),
span,
}
.into_diag(dcx, level)
},
span,
);
@@ -210,13 +220,14 @@ fn parse_directive_items<'p, S: Stage>(
}}
macro duplicate($name: ident, $($first_span:tt)*) {{
cx.emit_lint(
let first_span = $($first_span)*;
cx.emit_dyn_lint(
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
AttributeLintKind::IgnoredDiagnosticOption {
first_span: $($first_span)*,
move |dcx, level| IgnoredDiagnosticOption {
first_span,
later_span: span,
option_name: $name,
},
}.into_diag(dcx, level),
span,
);
}}
@@ -245,9 +256,19 @@ fn parse_directive_items<'p, S: Stage>(
let (FormatWarning::InvalidSpecifier { span, .. }
| FormatWarning::PositionalArgument { span, .. }
| FormatWarning::DisallowedPlaceholder { span }) = warning;
cx.emit_lint(
cx.emit_dyn_lint(
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
AttributeLintKind::MalformedDiagnosticFormat { warning },
move |dcx, level| match warning {
FormatWarning::PositionalArgument { .. } => {
DisallowedPositionalArgument.into_diag(dcx, level)
}
FormatWarning::InvalidSpecifier { .. } => {
InvalidFormatSpecifier.into_diag(dcx, level)
}
FormatWarning::DisallowedPlaceholder { .. } => {
DisallowedPlaceholder.into_diag(dcx, level)
}
},
span,
);
}
@@ -255,12 +276,15 @@ fn parse_directive_items<'p, S: Stage>(
f
}
Err(e) => {
cx.emit_lint(
cx.emit_dyn_lint(
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
AttributeLintKind::DiagnosticWrappedParserError {
description: e.description,
label: e.label,
span: slice_span(input.span, e.span, is_snippet),
move |dcx, level| {
WrappedParserError {
description: &e.description,
label: &e.label,
span: slice_span(input.span, e.span.clone(), is_snippet),
}
.into_diag(dcx, level)
},
input.span,
);

View File

@@ -5,7 +5,6 @@ use rustc_hir::Target;
use rustc_hir::attrs::{
AttributeKind, CfgEntry, CfgHideShow, CfgInfo, DocAttribute, DocInline, HideOrShow,
};
use rustc_hir::lints::AttributeLintKind;
use rustc_session::parse::feature_err;
use rustc_span::{Span, Symbol, edition, sym};
use thin_vec::ThinVec;
@@ -17,7 +16,8 @@ use crate::errors::{
AttrCrateLevelOnly, DocAliasDuplicated, DocAutoCfgExpectsHideOrShow,
DocAutoCfgHideShowExpectsList, DocAutoCfgHideShowUnexpectedItem, DocAutoCfgWrongLiteral,
DocTestLiteral, DocTestTakesList, DocTestUnknown, DocUnknownAny, DocUnknownInclude,
DocUnknownPasses, DocUnknownPlugins, DocUnknownSpotlight, IllFormedAttributeInput,
DocUnknownPasses, DocUnknownPlugins, DocUnknownSpotlight, ExpectedNameValue, ExpectedNoArgs,
IllFormedAttributeInput, MalformedDoc,
};
use crate::parser::{ArgParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser};
use crate::session_diagnostics::{
@@ -84,18 +84,18 @@ fn expected_name_value<S: Stage>(
span: Span,
_name: Option<Symbol>,
) {
cx.emit_lint(
cx.emit_dyn_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::ExpectedNameValue,
|dcx, level| ExpectedNameValue.into_diag(dcx, level),
span,
);
}
// FIXME: remove this method once merged and use `cx.expected_no_args(span)` instead.
fn expected_no_args<S: Stage>(cx: &mut AcceptContext<'_, '_, S>, span: Span) {
cx.emit_lint(
cx.emit_dyn_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::ExpectedNoArgs,
|dcx, level| ExpectedNoArgs.into_diag(dcx, level),
span,
);
}
@@ -107,9 +107,9 @@ fn expected_string_literal<S: Stage>(
span: Span,
_actual_literal: Option<&MetaItemLit>,
) {
cx.emit_lint(
cx.emit_dyn_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::MalformedDoc,
|dcx, level| MalformedDoc.into_diag(dcx, level),
span,
);
}
@@ -203,9 +203,9 @@ impl DocParser {
// FIXME: remove this method once merged and uncomment the line below instead.
// cx.expected_list(cx.attr_span, args);
let span = cx.attr_span;
cx.emit_lint(
cx.emit_dyn_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::MalformedDoc,
|dcx, level| MalformedDoc.into_diag(dcx, level),
span,
);
return;
@@ -399,9 +399,9 @@ impl DocParser {
// FIXME: remove this method once merged and uncomment the line
// below instead.
// cx.expected_identifier(sub_item.path().span());
cx.emit_lint(
cx.emit_dyn_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::MalformedDoc,
|dcx, level| MalformedDoc.into_diag(dcx, level),
sub_item.path().span(),
);
continue;
@@ -605,9 +605,9 @@ impl DocParser {
// FIXME: remove this method once merged and uncomment the line
// below instead.
// cx.unexpected_literal(lit.span);
cx.emit_lint(
cx.emit_dyn_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
AttributeLintKind::MalformedDoc,
|dcx, level| MalformedDoc.into_diag(dcx, level),
lit.span,
);
}

View File

@@ -325,3 +325,70 @@ pub(crate) struct IncorrectDoNotRecommendLocation {
#[label("not a trait implementation")]
pub target_span: Span,
}
#[derive(Diagnostic)]
#[diag("malformed `doc` attribute input")]
#[warning(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
pub(crate) struct MalformedDoc;
#[derive(Diagnostic)]
#[diag("didn't expect any arguments here")]
#[warning(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
pub(crate) struct ExpectedNoArgs;
#[derive(Diagnostic)]
#[diag("expected this to be of the form `... = \"...\"`")]
#[warning(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
pub(crate) struct ExpectedNameValue;
#[derive(Diagnostic)]
#[diag("malformed `{$attribute}` attribute")]
#[help("{$options}")]
pub(crate) struct MalFormedDiagnosticAttributeLint {
pub attribute: &'static str,
pub options: &'static str,
#[label("invalid option found here")]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag("positional format arguments are not allowed here")]
#[help(
"only named format arguments with the name of one of the generic types are allowed in this context"
)]
pub(crate) struct DisallowedPositionalArgument;
#[derive(Diagnostic)]
#[diag("format arguments are not allowed here")]
#[help("consider removing this format argument")]
pub(crate) struct DisallowedPlaceholder;
#[derive(Diagnostic)]
#[diag("invalid format specifier")]
#[help("no format specifier are supported in this position")]
pub(crate) struct InvalidFormatSpecifier;
#[derive(Diagnostic)]
#[diag("{$description}")]
pub(crate) struct WrappedParserError<'a> {
pub description: &'a str,
#[label("{$label}")]
pub span: Span,
pub label: &'a str,
}
#[derive(Diagnostic)]
#[diag("`{$option_name}` is ignored due to previous definition of `{$option_name}`")]
pub(crate) struct IgnoredDiagnosticOption {
pub option_name: Symbol,
#[label("`{$option_name}` is first declared here")]
pub first_span: Span,
#[label("`{$option_name}` is later redundantly declared here")]
pub later_span: Span,
}

View File

@@ -3761,6 +3761,8 @@ pub enum OpaqueTyOrigin<D> {
pub struct DelegationGenerics {
pub parent_args_segment_id: Option<HirId>,
pub child_args_segment_id: Option<HirId>,
pub self_ty_id: Option<HirId>,
pub propagate_self_ty: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable_Generic)]
@@ -4455,17 +4457,17 @@ impl<'hir> Item<'hir> {
expect_trait,
(
&'hir ImplRestriction<'hir>,
Constness,
IsAuto,
Safety,
&'hir ImplRestriction<'hir>,
Ident,
&'hir Generics<'hir>,
GenericBounds<'hir>,
&'hir [TraitItemId]
),
ItemKind::Trait(constness, is_auto, safety, impl_restriction, ident, generics, bounds, items),
(*constness, *is_auto, *safety, impl_restriction, *ident, generics, bounds, items);
ItemKind::Trait(impl_restriction, constness, is_auto, safety, ident, generics, bounds, items),
(impl_restriction, *constness, *is_auto, *safety, *ident, generics, bounds, items);
expect_trait_alias, (Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
ItemKind::TraitAlias(constness, ident, generics, bounds), (*constness, *ident, generics, bounds);
@@ -4657,10 +4659,10 @@ pub enum ItemKind<'hir> {
Union(Ident, &'hir Generics<'hir>, VariantData<'hir>),
/// A trait definition.
Trait(
&'hir ImplRestriction<'hir>,
Constness,
IsAuto,
Safety,
&'hir ImplRestriction<'hir>,
Ident,
&'hir Generics<'hir>,
GenericBounds<'hir>,

View File

@@ -619,10 +619,10 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
try_visit!(visitor.visit_variant_data(struct_definition));
}
ItemKind::Trait(
ref impl_restriction,
_constness,
_is_auto,
_safety,
ref impl_restriction,
ident,
ref generics,
bounds,

View File

@@ -895,7 +895,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
let item = tcx.hir_expect_item(def_id);
let (constness, is_alias, is_auto, safety, impl_restriction) = match item.kind {
hir::ItemKind::Trait(constness, is_auto, safety, impl_restriction, ..) => (
hir::ItemKind::Trait(impl_restriction, constness, is_auto, safety, ..) => (
constness,
false,
is_auto == hir::IsAuto::Yes,
@@ -959,9 +959,9 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
ty::TraitDef {
def_id: def_id.to_def_id(),
impl_restriction,
safety,
constness,
impl_restriction,
paren_sugar,
has_auto_impl: is_auto,
is_marker,

View File

@@ -7,7 +7,7 @@ use std::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_hir::{DelegationGenerics, HirId, PathSegment};
use rustc_middle::ty::{
self, EarlyBinder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
};
@@ -65,19 +65,35 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ParamIndexRemapper<'tcx> {
}
enum SelfPositionKind {
AfterLifetimes,
AfterLifetimes(bool /* Should propagate self ty */),
Zero,
None,
}
fn create_self_position_kind(caller_kind: FnKind, callee_kind: FnKind) -> SelfPositionKind {
match (caller_kind, callee_kind) {
fn get_delegation_generics(tcx: TyCtxt<'_>, delegation_id: LocalDefId) -> &DelegationGenerics {
tcx.hir_node(tcx.local_def_id_to_hir_id(delegation_id))
.fn_sig()
.expect("processing delegation")
.decl
.opt_delegation_generics()
.expect("processing delegation")
}
fn create_self_position_kind(
tcx: TyCtxt<'_>,
delegation_id: LocalDefId,
sig_id: DefId,
) -> SelfPositionKind {
match (fn_kind(tcx, delegation_id), fn_kind(tcx, sig_id)) {
(FnKind::AssocInherentImpl, FnKind::AssocTrait)
| (FnKind::AssocTraitImpl, FnKind::AssocTrait)
| (FnKind::AssocTrait, FnKind::AssocTrait)
| (FnKind::AssocTrait, FnKind::Free) => SelfPositionKind::Zero,
(FnKind::Free, FnKind::AssocTrait) => SelfPositionKind::AfterLifetimes,
(FnKind::Free, FnKind::AssocTrait) => {
let propagate_self_ty = get_delegation_generics(tcx, delegation_id).propagate_self_ty;
SelfPositionKind::AfterLifetimes(propagate_self_ty)
}
_ => SelfPositionKind::None,
}
@@ -141,8 +157,7 @@ fn create_mapping<'tcx>(
) -> FxHashMap<u32, u32> {
let mut mapping: FxHashMap<u32, u32> = 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 self_pos_kind = create_self_position_kind(tcx, def_id, sig_id);
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.
@@ -156,7 +171,7 @@ fn create_mapping<'tcx>(
args_index += get_delegation_parent_args_count_without_self(tcx, def_id, sig_id);
let sig_generics = tcx.generics_of(sig_id);
let process_sig_parent_generics = matches!(callee_kind, FnKind::AssocTrait);
let process_sig_parent_generics = matches!(fn_kind(tcx, sig_id), FnKind::AssocTrait);
if process_sig_parent_generics {
for i in (sig_generics.has_self as usize)..sig_generics.parent_count {
@@ -176,7 +191,9 @@ fn create_mapping<'tcx>(
}
// If self after lifetimes insert mapping, relying that self is at 0 in sig parent.
if matches!(self_pos_kind, SelfPositionKind::AfterLifetimes) {
// If self ty is propagated (meaning there is no generic param `Self`), the specified
// self ty will be inserted in args in `create_generic_args`.
if matches!(self_pos_kind, SelfPositionKind::AfterLifetimes { .. }) {
mapping.insert(0, args_index as u32);
args_index += 1;
}
@@ -259,6 +276,22 @@ fn get_parent_and_inheritance_kind<'tcx>(
}
}
fn get_delegation_self_ty_or_err(tcx: TyCtxt<'_>, delegation_id: LocalDefId) -> Ty<'_> {
get_delegation_generics(tcx, delegation_id)
.self_ty_id
.map(|id| {
let ctx = ItemCtxt::new(tcx, delegation_id);
ctx.lower_ty(tcx.hir_node(id).expect_ty())
})
.unwrap_or_else(|| {
Ty::new_error_with_message(
tcx,
tcx.def_span(delegation_id),
"the self type must be specified",
)
})
}
fn get_delegation_self_ty<'tcx>(tcx: TyCtxt<'tcx>, delegation_id: LocalDefId) -> Option<Ty<'tcx>> {
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));
@@ -269,15 +302,19 @@ fn get_delegation_self_ty<'tcx>(tcx: TyCtxt<'tcx>, delegation_id: LocalDefId) ->
| (FnKind::Free, FnKind::Free)
| (FnKind::AssocTrait, FnKind::Free)
| (FnKind::AssocTrait, FnKind::AssocTrait) => {
match create_self_position_kind(caller_kind, callee_kind) {
match create_self_position_kind(tcx, delegation_id, sig_id) {
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::AfterLifetimes(propagate_self_ty) => {
if propagate_self_ty {
Some(get_delegation_self_ty_or_err(tcx, delegation_id))
} else {
// Both sig parent and child lifetimes are in included in this count.
let index = tcx.generics_of(delegation_id).own_counts().lifetimes;
Some(Ty::new_param(tcx, index as u32, kw::SelfUpper))
}
}
SelfPositionKind::Zero => Some(0),
SelfPositionKind::Zero => Some(Ty::new_param(tcx, 0, kw::SelfUpper)),
}
.map(|self_index| Ty::new_param(tcx, self_index as u32, kw::SelfUpper))
}
(FnKind::AssocTraitImpl, FnKind::AssocTrait)
@@ -366,7 +403,7 @@ fn create_generic_args<'tcx>(
let mut new_args = vec![];
let self_pos_kind = create_self_position_kind(caller_kind, callee_kind);
let self_pos_kind = create_self_position_kind(tcx, delegation_id, sig_id);
let mut lifetimes_end_pos;
if !parent_args.is_empty() {
@@ -374,7 +411,7 @@ fn create_generic_args<'tcx>(
parent_args.iter().filter(|a| a.as_region().is_some()).count();
match self_pos_kind {
SelfPositionKind::AfterLifetimes => {
SelfPositionKind::AfterLifetimes { .. } => {
new_args.extend(&parent_args[1..1 + parent_args_lifetimes_count]);
lifetimes_end_pos = parent_args_lifetimes_count;
@@ -407,6 +444,15 @@ fn create_generic_args<'tcx>(
.count();
new_args.extend_from_slice(args);
// Parent args are empty, then if we should propagate self ty (meaning Self generic
// param was not generated) then we should insert it, as it won't be in `args`.
if matches!(self_pos_kind, SelfPositionKind::AfterLifetimes(true)) {
new_args.insert(
lifetimes_end_pos,
ty::GenericArg::from(get_delegation_self_ty_or_err(tcx, delegation_id)),
);
}
}
if !child_args.is_empty() {
@@ -427,7 +473,8 @@ fn create_generic_args<'tcx>(
new_args.insert(lifetimes_end_pos + i, child_args[i]);
}
let skip_self = matches!(self_pos_kind, SelfPositionKind::AfterLifetimes);
// If self_ty is propagated it means that Self generic param was not generated.
let skip_self = matches!(self_pos_kind, SelfPositionKind::AfterLifetimes(false));
new_args.extend(&child_args[child_lifetimes_count + skip_self as usize..]);
}
@@ -446,6 +493,7 @@ pub(crate) fn inherit_predicates_for_delegation_item<'tcx>(
preds: Vec<(ty::Clause<'tcx>, Span)>,
args: Vec<ty::GenericArg<'tcx>>,
folder: ParamIndexRemapper<'tcx>,
filter_self_preds: bool,
}
impl<'tcx> PredicatesCollector<'tcx> {
@@ -458,6 +506,16 @@ pub(crate) fn inherit_predicates_for_delegation_item<'tcx>(
let args = self.args.as_slice();
for pred in preds.predicates {
// If self ty is specified then there will be no generic param `Self`,
// so we do not need its predicates.
if self.filter_self_preds
&& let Some(trait_pred) = pred.0.as_trait_clause()
// Rely that `Self` has zero index.
&& trait_pred.self_ty().skip_binder().is_param(0)
{
continue;
}
let new_pred = pred.0.fold_with(&mut self.folder);
self.preds.push((
EarlyBinder::bind(new_pred).instantiate(self.tcx, args).skip_norm_wip(),
@@ -484,8 +542,10 @@ pub(crate) fn inherit_predicates_for_delegation_item<'tcx>(
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 self_pos_kind = create_self_position_kind(tcx, def_id, sig_id);
let filter_self_preds = matches!(self_pos_kind, SelfPositionKind::AfterLifetimes(true));
let collector = PredicatesCollector { tcx, preds: vec![], args, folder, filter_self_preds };
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.
@@ -573,13 +633,7 @@ 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 info = get_delegation_generics(tcx, delegation_id);
let get_segment = |hir_id: HirId| -> Option<(&'tcx PathSegment<'tcx>, DefId)> {
let segment = tcx.hir_node(hir_id).expect_path_segment();

View File

@@ -1115,12 +1115,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
)
})
.collect();
// FIXME(fmease): Does not account for `dyn Trait<>` (suggs `dyn Trait<, X = Y>`).
let code = if let Some(snippet) = snippet.strip_suffix('>') {
// The user wrote `Trait<'a>` or similar and we don't have a term we can suggest,
// but at least we can clue them to the correct syntax `Trait<'a, Item = /* ... */>`
// while accounting for the `<'a>` in the suggestion.
format!("{}, {}>", snippet, bindings.join(", "))
let code = if let Some(snippet) = snippet.strip_suffix("<>") {
// Empty generics
format!("{snippet}<{}>", bindings.join(", "))
} else if let Some(snippet) = snippet.strip_suffix('>') {
// Non-empty generics
format!("{snippet}, {}>", bindings.join(", "))
} else if in_expr_or_pat {
// The user wrote `Trait`, so we don't have a term we can suggest, but at least we
// can clue them to the correct syntax `Trait::<Item = /* ... */>`.

View File

@@ -758,20 +758,20 @@ impl<'a> State<'a> {
self.bclose(item.span, cb);
}
hir::ItemKind::Trait(
impl_restriction,
constness,
is_auto,
safety,
impl_restriction,
ident,
generics,
bounds,
trait_items,
) => {
let (cb, ib) = self.head("");
self.print_impl_restriction(impl_restriction);
self.print_constness(constness);
self.print_is_auto(is_auto);
self.print_safety(safety);
self.print_impl_restriction(impl_restriction);
self.word_nbsp("trait");
self.print_ident(ident);
self.print_generic_params(generics.params);

View File

@@ -1900,7 +1900,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
entry.1.insert((self_ty.span, String::new()));
}
Some(Node::Item(hir::Item {
kind: hir::ItemKind::Trait(_, rustc_ast::ast::IsAuto::Yes, ..),
kind: hir::ItemKind::Trait(_, _, rustc_ast::ast::IsAuto::Yes, ..),
span: item_span,
..
})) => {

View File

@@ -2,7 +2,7 @@ use std::any::Any;
use rustc_data_structures::sync::DynSend;
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level};
use rustc_hir::lints::{AttributeLintKind, FormatWarning};
use rustc_hir::lints::AttributeLintKind;
use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
@@ -43,33 +43,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateAttrLint<'_, '_, '_> {
.into_diag(dcx, level)
}
&AttributeLintKind::MalformedDoc => lints::MalformedDoc.into_diag(dcx, level),
&AttributeLintKind::ExpectedNoArgs => lints::ExpectedNoArgs.into_diag(dcx, level),
&AttributeLintKind::ExpectedNameValue => lints::ExpectedNameValue.into_diag(dcx, level),
&AttributeLintKind::MalFormedDiagnosticAttribute { attribute, options, span } => {
lints::MalFormedDiagnosticAttributeLint { attribute, options, span }
.into_diag(dcx, level)
}
AttributeLintKind::MalformedDiagnosticFormat { warning } => match warning {
FormatWarning::PositionalArgument { .. } => {
lints::DisallowedPositionalArgument.into_diag(dcx, level)
}
FormatWarning::InvalidSpecifier { .. } => {
lints::InvalidFormatSpecifier.into_diag(dcx, level)
}
FormatWarning::DisallowedPlaceholder { .. } => {
lints::DisallowedPlaceholder.into_diag(dcx, level)
}
},
AttributeLintKind::DiagnosticWrappedParserError { description, label, span } => {
lints::WrappedParserError { description, label, span: *span }.into_diag(dcx, level)
}
&AttributeLintKind::IgnoredDiagnosticOption { option_name, first_span, later_span } => {
lints::IgnoredDiagnosticOption { option_name, first_span, later_span }
.into_diag(dcx, level)
}
&AttributeLintKind::MissingOptionsForDiagnosticAttribute { attribute, options } => {
lints::MissingOptionsForDiagnosticAttribute { attribute, options }
.into_diag(dcx, level)

View File

@@ -24,6 +24,7 @@
#![feature(box_patterns)]
#![feature(iter_order_by)]
#![feature(rustc_attrs)]
#![feature(titlecase)]
#![feature(try_blocks)]
// tidy-alphabetical-end

View File

@@ -3282,63 +3282,6 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion {
}
}
#[derive(Diagnostic)]
#[diag("malformed `doc` attribute input")]
#[warning(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
pub(crate) struct MalformedDoc;
#[derive(Diagnostic)]
#[diag("didn't expect any arguments here")]
#[warning(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
pub(crate) struct ExpectedNoArgs;
#[derive(Diagnostic)]
#[diag("expected this to be of the form `... = \"...\"`")]
#[warning(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
pub(crate) struct ExpectedNameValue;
#[derive(Diagnostic)]
#[diag("positional format arguments are not allowed here")]
#[help(
"only named format arguments with the name of one of the generic types are allowed in this context"
)]
pub(crate) struct DisallowedPositionalArgument;
#[derive(Diagnostic)]
#[diag("format arguments are not allowed here")]
#[help("consider removing this format argument")]
pub(crate) struct DisallowedPlaceholder;
#[derive(Diagnostic)]
#[diag("invalid format specifier")]
#[help("no format specifier are supported in this position")]
pub(crate) struct InvalidFormatSpecifier;
#[derive(Diagnostic)]
#[diag("{$description}")]
pub(crate) struct WrappedParserError<'a> {
pub description: &'a str,
#[label("{$label}")]
pub span: Span,
pub label: &'a str,
}
#[derive(Diagnostic)]
#[diag("`{$option_name}` is ignored due to previous definition of `{$option_name}`")]
pub(crate) struct IgnoredDiagnosticOption {
pub option_name: Symbol,
#[label("`{$option_name}` is first declared here")]
pub first_span: Span,
#[label("`{$option_name}` is later redundantly declared here")]
pub later_span: Span,
}
#[derive(Diagnostic)]
#[diag("missing options for `{$attribute}` attribute")]
#[help("{$options}")]
@@ -3358,13 +3301,3 @@ pub(crate) struct EqInternalMethodImplemented;
"only literals are allowed as values for the `message`, `note` and `label` options. These options must be separated by a comma"
)]
pub(crate) struct NonMetaItemDiagnosticAttribute;
#[derive(Diagnostic)]
#[diag("malformed `{$attribute}` attribute")]
#[help("{$options}")]
pub(crate) struct MalFormedDiagnosticAttributeLint {
pub attribute: &'static str,
pub options: &'static str,
#[label("invalid option found here")]
pub span: Span,
}

View File

@@ -47,34 +47,46 @@ declare_lint! {
declare_lint_pass!(NonCamelCaseTypes => [NON_CAMEL_CASE_TYPES]);
/// Some unicode characters *have* case, are considered upper case or lower case, but they *can't*
/// be upper cased or lower cased. For the purposes of the lint suggestion, we care about being able
/// Some unicode characters *have* case, are considered upper, title, or lower case, but they *can't*
/// be title cased or lower cased. For the purposes of the lint suggestion, we care about being able
/// to change the char's case.
fn char_has_case(c: char) -> bool {
!c.to_lowercase().eq(c.to_uppercase())
!c.to_lowercase().eq(c.to_titlecase())
}
// contains a capitalisable character followed by, or preceded by, an underscore
fn has_underscore_case(s: &str) -> bool {
/// FIXME: we should add a more efficient version
/// in the stdlib for this
fn changes_when_titlecased(c: char) -> bool {
!c.to_titlecase().eq([c])
}
// contains a capitalisable character followed by, or preceded by, an underscore,
// or contains an uppercase character that changes when titlecased,
// or contains `__`
fn not_camel_case(s: &str) -> bool {
let mut last = '\0';
s.chars().any(|c| match (std::mem::replace(&mut last, c), c) {
('_', cs) | (cs, '_') => char_has_case(cs),
_ => false,
s.chars().any(|snd| {
let fst = std::mem::replace(&mut last, snd);
match (fst, snd) {
('_', '_') => return true,
('_', _) if char_has_case(snd) => return true,
(_, '_') if char_has_case(fst) => return true,
_ => snd.is_uppercase() && changes_when_titlecased(snd),
}
})
}
fn is_camel_case(name: &str) -> bool {
fn is_upper_camel_case(name: &str) -> bool {
let name = name.trim_matches('_');
let Some(first) = name.chars().next() else {
return true;
};
// start with a non-lowercase letter rather than uppercase
// ones (some scripts don't have a concept of upper/lowercase)
!(first.is_lowercase() || name.contains("__") || has_underscore_case(name))
// some scripts don't have a concept of upper/lowercase
!(changes_when_titlecased(first) || not_camel_case(name))
}
fn to_camel_case(s: &str) -> String {
fn to_upper_camel_case(s: &str) -> String {
s.trim_matches('_')
.split('_')
.filter(|component| !component.is_empty())
@@ -83,24 +95,31 @@ fn to_camel_case(s: &str) -> String {
let mut new_word = true;
let mut prev_is_lower_case = true;
let mut prev_is_lowercased_sigma = false;
for c in component.chars() {
// Preserve the case if an uppercase letter follows a lowercase letter, so that
// `camelCase` is converted to `CamelCase`.
if prev_is_lower_case && c.is_uppercase() {
if prev_is_lower_case && (c.is_uppercase() | c.is_titlecase()) {
new_word = true;
}
if new_word {
camel_cased_component.extend(c.to_uppercase());
camel_cased_component.extend(c.to_titlecase());
} else {
camel_cased_component.extend(c.to_lowercase());
}
prev_is_lower_case = c.is_lowercase();
prev_is_lower_case = c.is_lowercase() || c.is_titlecase();
prev_is_lowercased_sigma = !new_word && c == 'Σ';
new_word = false;
}
if prev_is_lowercased_sigma {
camel_cased_component.pop();
camel_cased_component.push('ς');
}
camel_cased_component
})
.fold((String::new(), None), |(acc, prev): (String, Option<String>), next| {
@@ -122,8 +141,8 @@ impl NonCamelCaseTypes {
fn check_case(&self, cx: &EarlyContext<'_>, sort: &str, ident: &Ident) {
let name = ident.name.as_str();
if !is_camel_case(name) {
let cc = to_camel_case(name);
if !is_upper_camel_case(name) {
let cc = to_upper_camel_case(name);
let sub = if *name != cc {
NonCamelCaseTypeSub::Suggestion { span: ident.span, replace: cc }
} else {
@@ -235,14 +254,20 @@ impl NonSnakeCase {
continue;
}
for ch in s.chars() {
if !buf.is_empty() && buf != "'" && ch.is_uppercase() && !last_upper {
words.push(buf);
if !buf.is_empty()
&& buf != "'"
&& (ch.is_uppercase() || ch.is_titlecase())
&& !last_upper
{
// We lowercase only at the end, to handle final sigma correctly
words.push(buf.to_lowercase());
buf = String::new();
}
last_upper = ch.is_uppercase();
buf.extend(ch.to_lowercase());
last_upper = ch.is_uppercase() || ch.is_titlecase();
buf.push(ch);
}
words.push(buf);
// We lowercase only at the end, to handle final sigma correctly
words.push(buf.to_lowercase());
}
words.join("_")
}
@@ -262,7 +287,8 @@ impl NonSnakeCase {
// This correctly handles letters in languages with and without
// cases, as well as numbers and underscores.
!ident.chars().any(char::is_uppercase)
// FIXME: we should add a standard library impl of `c.to_lowercase().eq([c])`
ident.chars().all(|c| c.to_lowercase().eq([c]))
}
let name = ident.name.as_str();
@@ -474,10 +500,12 @@ impl<'a, 'b, F: FnOnce() -> NonUpperCaseGlobal<'b>> Diagnostic<'a, ()>
impl NonUpperCaseGlobals {
fn check_upper_case(cx: &LateContext<'_>, sort: &str, did: Option<LocalDefId>, ident: &Ident) {
let name = ident.name.as_str();
if name.chars().any(|c| c.is_lowercase()) {
// FIXME: we should add a more efficient version
// in the stdlib for `c.to_uppercase().eq([c])`
if !name.chars().all(|c| c.to_uppercase().eq([c])) {
let uc = NonSnakeCase::to_snake_case(name).to_uppercase();
// If the item is exported, suggesting changing it's name would be breaking-change
// If the item is exported, suggesting changing its name would be a breaking change
// and could break users without a "nice" applicable fix, so let's avoid it.
let can_change_usages = if let Some(did) = did {
!cx.tcx.effective_visibilities(()).is_exported(did)

View File

@@ -1,21 +1,37 @@
use super::{is_camel_case, to_camel_case};
use super::{is_upper_camel_case, to_upper_camel_case};
#[test]
fn camel_case() {
assert!(!is_camel_case("userData"));
assert_eq!(to_camel_case("userData"), "UserData");
assert!(!is_upper_camel_case("userData"));
assert_eq!(to_upper_camel_case("userData"), "UserData");
assert!(is_camel_case("X86_64"));
assert!(is_upper_camel_case("X86_64"));
assert!(!is_camel_case("X86__64"));
assert_eq!(to_camel_case("X86__64"), "X86_64");
assert!(!is_upper_camel_case("X86__64"));
assert_eq!(to_upper_camel_case("X86__64"), "X86_64");
assert!(!is_camel_case("Abc_123"));
assert_eq!(to_camel_case("Abc_123"), "Abc123");
assert!(!is_upper_camel_case("Abc_123"));
assert_eq!(to_upper_camel_case("Abc_123"), "Abc123");
assert!(!is_camel_case("A1_b2_c3"));
assert_eq!(to_camel_case("A1_b2_c3"), "A1B2C3");
assert!(!is_upper_camel_case("A1_b2_c3"));
assert_eq!(to_upper_camel_case("A1_b2_c3"), "A1B2C3");
assert!(!is_camel_case("ONE_TWO_THREE"));
assert_eq!(to_camel_case("ONE_TWO_THREE"), "OneTwoThree");
assert!(!is_upper_camel_case("ONE_TWO_THREE"));
assert_eq!(to_upper_camel_case("ONE_TWO_THREE"), "OneTwoThree");
// FIXME(@Jules-Bertholet): This test doesn't work due to what I believe
// is a Unicode spec bug - uppercase Georgian letters have
// incorrect titlecase mappings.
// I've reported it to Unicode.
// Georgian mtavruli is only used in all-caps
//assert!(!is_upper_camel_case("ᲫალაᲔრთობაშია"));
//assert_eq!(to_upper_camel_case("ᲫალაᲔრთობაშია"), "ძალა_ერთობაშია");
assert!(!is_upper_camel_case("LJNJaaaDŽooo"));
assert_eq!(to_upper_camel_case("LJNJaaLjNJaDŽooo"), "LjnjaaLjNjaDžooo");
// Final sigma
assert!(!is_upper_camel_case("ΦΙΛΟΣ_ΦΙΛΟΣ"));
assert_eq!(to_upper_camel_case("ΦΙΛΟΣ_ΦΙΛΟΣ"), "ΦιλοςΦιλος");
assert!(is_upper_camel_case("ΦιλοσΦιλοσ"));
}

View File

@@ -656,13 +656,6 @@ pub enum DeprecatedSinceKind {
pub enum AttributeLintKind {
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
MalformedDoc,
ExpectedNoArgs,
ExpectedNameValue,
MalFormedDiagnosticAttribute { attribute: &'static str, options: &'static str, span: Span },
MalformedDiagnosticFormat { warning: FormatWarning },
DiagnosticWrappedParserError { description: String, label: String, span: Span },
IgnoredDiagnosticOption { option_name: Symbol, first_span: Span, later_span: Span },
MissingOptionsForDiagnosticAttribute { attribute: &'static str, options: &'static str },
NonMetaItemDiagnosticAttribute,
}

View File

@@ -319,7 +319,17 @@ impl<'tcx> TyCtxt<'tcx> {
BodyOwnerKind::Fn if self.is_constructor(def_id) => return None,
// Const closures use their parent's const context
BodyOwnerKind::Closure if self.is_const_fn(def_id) => {
return self.hir_body_const_context(self.local_parent(local_def_id));
return Some(
self.hir_body_const_context(self.local_parent(local_def_id)).unwrap_or_else(
|| {
assert!(
self.dcx().has_errors().is_some(),
"`const` closure with no enclosing const context",
);
ConstContext::ConstFn
},
),
);
}
BodyOwnerKind::Fn if self.is_const_fn(def_id) => ConstContext::ConstFn,
BodyOwnerKind::Fn | BodyOwnerKind::Closure | BodyOwnerKind::GlobalAsm => return None,

View File

@@ -20,14 +20,14 @@ use crate::ty::{Ident, Ty, TyCtxt};
pub struct TraitDef {
pub def_id: DefId,
/// Restrictions on trait implementations.
pub impl_restriction: ImplRestrictionKind,
pub safety: hir::Safety,
/// Whether this trait is `const`.
pub constness: hir::Constness,
/// Restrictions on trait implementations.
pub impl_restriction: ImplRestrictionKind,
/// If `true`, then this trait had the `#[rustc_paren_sugar]`
/// attribute, indicating that it should be used with `Foo()`
/// sugar. This is a temporary thing -- eventually any trait will

View File

@@ -1052,80 +1052,69 @@ impl<'a> Parser<'a> {
}
}
/// Is there an `[ impl(in? path) ]? trait` item `dist` tokens ahead?
fn is_trait_with_maybe_impl_restriction_in_front(&self, dist: usize) -> bool {
// `trait`
if self.is_keyword_ahead(dist, &[kw::Trait]) {
return true;
}
// `impl(`
if !self.is_keyword_ahead(dist, &[kw::Impl])
|| !self.look_ahead(dist + 1, |t| t == &token::OpenParen)
{
return false;
}
// `crate | super | self) trait`
if self.is_keyword_ahead(dist + 2, &[kw::Crate, kw::Super, kw::SelfLower])
&& self.look_ahead(dist + 3, |t| t == &token::CloseParen)
&& self.is_keyword_ahead(dist + 4, &[kw::Trait])
{
return true;
}
// `impl(in? something) trait`
// We catch cases where the `in` keyword is missing to provide a
// better error message. This is handled later in
// `self.recover_incorrect_impl_restriction`.
self.tree_look_ahead(dist + 2, |t| {
if let TokenTree::Token(token, _) = t { token.is_keyword(kw::Trait) } else { false }
})
.unwrap_or(false)
}
/// Is this an `(const unsafe? auto? [ impl(in? path) ]? | unsafe auto? [ impl(in? path) ]? | auto [ impl(in? path) ]? | [ impl(in? path) ]?) trait` item?
/// Is this an `[impl(in? path)]? const? unsafe? auto? trait` item?
fn check_trait_front_matter(&mut self) -> bool {
// `[ impl(in? path) ]? trait`
if self.is_trait_with_maybe_impl_restriction_in_front(0) {
return true;
const SUFFIXES: &[&[Symbol]] = &[
&[kw::Trait],
&[kw::Auto, kw::Trait],
&[kw::Unsafe, kw::Trait],
&[kw::Unsafe, kw::Auto, kw::Trait],
&[kw::Const, kw::Trait],
&[kw::Const, kw::Auto, kw::Trait],
&[kw::Const, kw::Unsafe, kw::Trait],
&[kw::Const, kw::Unsafe, kw::Auto, kw::Trait],
];
// `impl(`
if self.check_keyword(exp!(Impl)) && self.look_ahead(1, |t| t == &token::OpenParen) {
// `impl(in` unambiguously introduces an `impl` restriction
if self.is_keyword_ahead(2, &[kw::In]) {
return true;
}
// `impl(crate | self | super)` + SUFFIX
if self.is_keyword_ahead(2, &[kw::Crate, kw::SelfLower, kw::Super])
&& self.look_ahead(3, |t| t == &token::CloseParen)
&& SUFFIXES.iter().any(|suffix| {
suffix.iter().enumerate().all(|(i, kw)| self.is_keyword_ahead(i + 4, &[*kw]))
})
{
return true;
}
// Recover cases like `impl(path::to::module)` + SUFFIX to suggest inserting `in`.
SUFFIXES.iter().any(|suffix| {
suffix.iter().enumerate().all(|(i, kw)| {
self.tree_look_ahead(i + 2, |t| {
if let TokenTree::Token(token, _) = t {
token.is_keyword(*kw)
} else {
false
}
})
.unwrap_or(false)
})
})
} else {
SUFFIXES.iter().any(|suffix| {
suffix.iter().enumerate().all(|(i, kw)| {
// We use `check_keyword` for the first token to include it in the expected tokens.
if i == 0 {
match *kw {
kw::Const => self.check_keyword(exp!(Const)),
kw::Unsafe => self.check_keyword(exp!(Unsafe)),
kw::Auto => self.check_keyword(exp!(Auto)),
kw::Trait => self.check_keyword(exp!(Trait)),
_ => unreachable!(),
}
} else {
self.is_keyword_ahead(i, &[*kw])
}
})
})
}
// `auto [ impl(in? path) ]? trait`
if self.check_keyword(exp!(Auto)) && self.is_trait_with_maybe_impl_restriction_in_front(1) {
return true;
}
// `unsafe auto? [ impl(in? path) ]? trait`
if self.check_keyword(exp!(Unsafe))
&& (self.is_trait_with_maybe_impl_restriction_in_front(1)
|| self.is_keyword_ahead(1, &[kw::Auto])
&& self.is_trait_with_maybe_impl_restriction_in_front(2))
{
return true;
}
// `const` ...
if !self.check_keyword(exp!(Const)) {
return false;
}
// `const [ impl(in? path) ]? trait`
if self.is_trait_with_maybe_impl_restriction_in_front(1) {
return true;
}
// `const (unsafe | auto) [ impl(in? path) ]? trait`
if self.is_keyword_ahead(1, &[kw::Unsafe, kw::Auto])
&& self.is_trait_with_maybe_impl_restriction_in_front(2)
{
return true;
}
// `const unsafe auto [ impl(in? path) ]? trait`
self.is_keyword_ahead(1, &[kw::Unsafe])
&& self.is_keyword_ahead(2, &[kw::Auto])
&& self.is_trait_with_maybe_impl_restriction_in_front(3)
}
/// Parses `const? unsafe? auto? [impl(in? path)]? trait Foo { ... }` or `trait Foo = Bar;`.
///
/// FIXME(restrictions): The current keyword order follows the grammar specified in RFC 3323.
/// However, whether the restriction should be grouped closer to the visibility modifier
/// (e.g., `pub impl(crate) const unsafe auto trait`) remains an unresolved design question.
/// This ordering must be kept in sync with the logic in `check_trait_front_matter`.
/// Parses `[impl(in? path)]? const? unsafe? auto? trait Foo { ... }` or `trait Foo = Bar;`.
fn parse_item_trait(&mut self, attrs: &mut AttrVec, lo: Span) -> PResult<'a, ItemKind> {
let impl_restriction = self.parse_impl_restriction()?;
let constness = self.parse_constness(Case::Sensitive);
if let Const::Yes(span) = constness {
self.psess.gated_spans.gate(sym::const_trait_impl, span);
@@ -1139,8 +1128,6 @@ impl<'a> Parser<'a> {
IsAuto::No
};
let impl_restriction = self.parse_impl_restriction()?;
self.expect_keyword(exp!(Trait))?;
let ident = self.parse_ident()?;
let mut generics = self.parse_generics()?;
@@ -1181,10 +1168,10 @@ impl<'a> Parser<'a> {
generics.where_clause = self.parse_where_clause()?;
let items = self.parse_item_list(attrs, |p| p.parse_trait_item(ForceCollect::No))?;
Ok(ItemKind::Trait(Box::new(Trait {
impl_restriction,
constness,
is_auto,
safety,
impl_restriction,
ident,
generics,
bounds,
@@ -2966,7 +2953,7 @@ impl<'a> Parser<'a> {
&& !self.is_unsafe_foreign_mod()
// Rule out `async gen {` and `async gen move {`
&& !self.is_async_gen_block()
// Rule out `const unsafe auto` and `const unsafe trait` and `const unsafe impl`.
// Rule out `const unsafe auto` and `const unsafe trait` and `const unsafe impl`
&& !self.is_keyword_ahead(2, &[kw::Auto, kw::Trait, kw::Impl])
)
})

View File

@@ -28,7 +28,7 @@ use crate::errors::{
AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError,
SourceKindMultiSuggestion, SourceKindSubdiag,
};
use crate::infer::InferCtxt;
use crate::infer::{InferCtxt, TyOrConstInferVar};
pub enum TypeAnnotationNeeded {
/// ```compile_fail,E0282
@@ -82,13 +82,27 @@ impl InferenceDiagnosticsData {
!(self.name == "_" && matches!(self.kind, UnderspecifiedArgKind::Type { .. }))
}
fn where_x_is_kind(&self, in_type: Ty<'_>) -> &'static str {
fn where_x_is_kind<'tcx>(&self, infcx: &InferCtxt<'tcx>, in_type: Ty<'tcx>) -> &'static str {
if in_type.is_ty_or_numeric_infer() {
""
} else if self.name == "_" {
// FIXME: Consider specializing this message if there is a single `_`
// in the type.
"underscore"
let displayed_ty = infcx
.resolve_vars_if_possible(in_type)
.fold_with(&mut ClosureEraser { infcx, depth: 0 });
if displayed_ty.is_ty_or_numeric_infer() {
""
} else {
match displayed_ty
.walk()
.filter_map(TyOrConstInferVar::maybe_from_generic_arg)
.take(2)
.count()
{
0 => "",
1 => "underscore_single",
_ => "underscore_multiple",
}
}
} else {
"has_name"
}
@@ -555,7 +569,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
infer_subdiags.push(SourceKindSubdiag::LetLike {
span: insert_span,
name: pattern_name.map(|name| name.to_string()).unwrap_or_else(String::new),
x_kind: arg_data.where_x_is_kind(ty),
x_kind: arg_data.where_x_is_kind(self.infcx, ty),
prefix_kind: arg_data.kind.clone(),
prefix: arg_data.kind.try_get_prefix().unwrap_or_default(),
arg_name: arg_data.name,
@@ -567,7 +581,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
infer_subdiags.push(SourceKindSubdiag::LetLike {
span: insert_span,
name: String::new(),
x_kind: arg_data.where_x_is_kind(ty),
x_kind: arg_data.where_x_is_kind(self.infcx, ty),
prefix_kind: arg_data.kind.clone(),
prefix: arg_data.kind.try_get_prefix().unwrap_or_default(),
arg_name: arg_data.name,

View File

@@ -4142,7 +4142,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let mut is_auto_trait = false;
match tcx.hir_get_if_local(data.impl_or_alias_def_id) {
Some(Node::Item(hir::Item {
kind: hir::ItemKind::Trait(_, is_auto, _, _, ident, _, _, _),
kind: hir::ItemKind::Trait(_, _, is_auto, _, ident, _, _, _),
..
})) => {
// FIXME: we should do something else so that it works even on crate foreign

View File

@@ -277,7 +277,8 @@ pub(crate) enum SourceKindSubdiag<'a> {
[const_with_param] value of const parameter
[const] value of the constant
} `{$arg_name}` is specified
[underscore] , where the placeholders `_` are specified
[underscore_single] , where the placeholder `_` is specified
[underscore_multiple] , where the placeholders `_` are specified
*[empty] {\"\"}
}",
style = "verbose",

View File

@@ -2942,7 +2942,7 @@ fn clean_maybe_renamed_item<'tcx>(
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
}
// FIXME: rustdoc will need to handle `impl` restrictions at some point
ItemKind::Trait(_, _, _, _impl_restriction, _, generics, bounds, item_ids) => {
ItemKind::Trait(_impl_restriction, _, _, _, _, generics, bounds, item_ids) => {
let items = item_ids
.iter()
.map(|&ti| clean_trait_item(cx.tcx.hir_trait_item(ti), cx))

View File

@@ -307,10 +307,10 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
}
},
ItemKind::Trait(
_impl_restriction,
_constness,
is_auto,
_safety,
_impl_restriction,
_ident,
_generics,
_generic_bounds,

View File

@@ -769,7 +769,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
{
missing_headers::check(cx, item.owner_id, sig, headers, Some(body), self.check_private_items);
},
ItemKind::Trait(_, _, unsafety, ..) => match (headers.safety, unsafety) {
ItemKind::Trait(_, _, _, unsafety, ..) => match (headers.safety, unsafety) {
(false, Safety::Unsafe) => span_lint(
cx,
MISSING_SAFETY_DOC,

View File

@@ -448,30 +448,30 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
},
(
Trait(box ast::Trait {
impl_restriction: liprt,
constness: lc,
is_auto: la,
safety: lu,
impl_restriction: liprt,
ident: li,
generics: lg,
bounds: lb,
items: lis,
}),
Trait(box ast::Trait {
impl_restriction: riprt,
constness: rc,
is_auto: ra,
safety: ru,
impl_restriction: riprt,
ident: ri,
generics: rg,
bounds: rb,
items: ris,
}),
) => {
matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
eq_impl_restriction(liprt, riprt)
&& matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
&& la == ra
&& matches!(lu, Safety::Default) == matches!(ru, Safety::Default)
&& eq_impl_restriction(liprt, riprt)
&& eq_id(*li, *ri)
&& eq_generics(lg, rg)
&& over(lb, rb, eq_generic_bound)

View File

@@ -265,14 +265,14 @@ fn item_search_pat(item: &Item<'_>) -> (Pat, Pat) {
ItemKind::Struct(_, _, VariantData::Struct { .. }) => (Pat::Str("struct"), Pat::Str("}")),
ItemKind::Struct(..) => (Pat::Str("struct"), Pat::Str(";")),
ItemKind::Union(..) => (Pat::Str("union"), Pat::Str("}")),
ItemKind::Trait(_, _, Safety::Unsafe, ..)
ItemKind::Trait(_, _, _, Safety::Unsafe, ..)
| ItemKind::Impl(Impl {
of_trait: Some(TraitImplHeader {
safety: Safety::Unsafe, ..
}),
..
}) => (Pat::Str("unsafe"), Pat::Str("}")),
ItemKind::Trait(_, IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")),
ItemKind::Trait(_, _, IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")),
ItemKind::Trait(..) => (Pat::Str("trait"), Pat::Str("}")),
ItemKind::Impl(_) => (Pat::Str("impl"), Pat::Str("}")),
ItemKind::Mod(..) => (Pat::Str("mod"), Pat::Str("")),

View File

@@ -1155,10 +1155,10 @@ pub(crate) fn format_trait(
offset: Indent,
) -> RewriteResult {
let ast::Trait {
ref impl_restriction,
constness,
is_auto,
safety,
ref impl_restriction,
ident,
ref generics,
ref bounds,
@@ -1169,10 +1169,10 @@ pub(crate) fn format_trait(
let header = format!(
"{}{}{}{}{}trait ",
format_visibility(context, &item.vis),
format_impl_restriction(context, impl_restriction),
format_constness(constness),
format_safety(safety),
format_auto(is_auto),
format_impl_restriction(context, impl_restriction),
);
result.push_str(&header);

View File

@@ -18,24 +18,25 @@ bar )
trait Baz {}
pub
const
impl
(self)
const
trait QuxConst {}
pub
auto impl(
pub
impl(
super
)
) auto
trait QuxAuto {}
pub
unsafe impl
(in crate)
pub
impl
(in crate) unsafe
trait QuxUnsafe {}
pub const
unsafe impl
pub
impl
(in super
::foo)
const unsafe
trait QuxConstUnsafe {}

View File

@@ -6,10 +6,10 @@ pub impl(in crate) trait Bar {}
pub impl(in foo::bar) trait Baz {}
pub const impl(self) trait QuxConst {}
pub impl(self) const trait QuxConst {}
pub auto impl(super) trait QuxAuto {}
pub impl(super) auto trait QuxAuto {}
pub unsafe impl(in crate) trait QuxUnsafe {}
pub impl(in crate) unsafe trait QuxUnsafe {}
pub const unsafe impl(in super::foo) trait QuxConstUnsafe {}
pub impl(in super::foo) const unsafe trait QuxConstUnsafe {}

View File

@@ -114,10 +114,10 @@ mod recursive {
#[attr = MustUse {reason: "some reason"}]
#[attr = Inline(Hint)]
fn foo<Self>(self: _, arg1: _) -> _ { <X as T>::foo(self + 1, arg1) }
fn foo(self: _, arg1: _) -> _ { <X as T>::foo(self + 1, arg1) }
#[attr = MustUse {reason: "some reason"}]
#[attr = Inline(Hint)]
fn bar<Self>(arg0: _, arg1: _) -> _ { foo(self + 1, arg1) }
fn bar(arg0: _, arg1: _) -> _ { foo(self + 1, arg1) }
}
}

View File

@@ -7,7 +7,7 @@ LL | let var_fn = Value::wrap();
LL | let _ = var_fn.clone();
| ------ type must be known at this point
|
help: consider giving `var_fn` an explicit type, where the placeholders `_` are specified
help: consider giving `var_fn` an explicit type, where the placeholder `_` is specified
|
LL | let var_fn: Value<Rc<_>> = Value::wrap();
| ++++++++++++++

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
fn foo() {}

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {
const C: u32 = 0;

View File

@@ -1,5 +1,5 @@
error[E0324]: item `C` is an associated method, which doesn't match its trait `Trait`
--> $DIR/bad-resolve.rs:24:5
--> $DIR/bad-resolve.rs:23:5
|
LL | const C: u32 = 0;
| ----------------- item in trait
@@ -8,7 +8,7 @@ LL | reuse <F as Trait>::C;
| ^^^^^^^^^^^^^^^^^^^^^^ does not match trait
error[E0324]: item `Type` is an associated method, which doesn't match its trait `Trait`
--> $DIR/bad-resolve.rs:27:5
--> $DIR/bad-resolve.rs:26:5
|
LL | type Type;
| ---------- item in trait
@@ -17,7 +17,7 @@ LL | reuse <F as Trait>::Type;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ does not match trait
error[E0407]: method `baz` is not a member of trait `Trait`
--> $DIR/bad-resolve.rs:30:5
--> $DIR/bad-resolve.rs:29:5
|
LL | reuse <F as Trait>::baz;
| ^^^^^^^^^^^^^^^^^^^^---^
@@ -26,7 +26,7 @@ LL | reuse <F as Trait>::baz;
| not a member of trait `Trait`
error[E0407]: method `foo2` is not a member of trait `Trait`
--> $DIR/bad-resolve.rs:37:5
--> $DIR/bad-resolve.rs:36:5
|
LL | reuse Trait::foo2 { self.0 }
| ^^^^^^^^^^^^^----^^^^^^^^^^^
@@ -35,19 +35,19 @@ LL | reuse Trait::foo2 { self.0 }
| not a member of trait `Trait`
error[E0423]: expected function, found associated constant `Trait::C`
--> $DIR/bad-resolve.rs:24:11
--> $DIR/bad-resolve.rs:23:11
|
LL | reuse <F as Trait>::C;
| ^^^^^^^^^^^^^^^ not a function
error[E0575]: expected method or associated constant, found associated type `Trait::Type`
--> $DIR/bad-resolve.rs:27:11
--> $DIR/bad-resolve.rs:26:11
|
LL | reuse <F as Trait>::Type;
| ^^^^^^^^^^^^^^^^^^ not a method or associated constant
error[E0576]: cannot find method or associated constant `baz` in trait `Trait`
--> $DIR/bad-resolve.rs:30:25
--> $DIR/bad-resolve.rs:29:25
|
LL | fn bar() {}
| -------- similarly named associated function `bar` defined here
@@ -62,13 +62,13 @@ LL + reuse <F as Trait>::bar;
|
error[E0425]: cannot find function `foo` in this scope
--> $DIR/bad-resolve.rs:35:11
--> $DIR/bad-resolve.rs:34:11
|
LL | reuse foo { &self.0 }
| ^^^ not found in this scope
error[E0425]: cannot find function `foo2` in trait `Trait`
--> $DIR/bad-resolve.rs:37:18
--> $DIR/bad-resolve.rs:36:18
|
LL | fn foo(&self, x: i32) -> i32 { x }
| ---------------------------- similarly named associated function `foo` defined here
@@ -83,7 +83,7 @@ LL + reuse Trait::foo { self.0 }
|
error[E0046]: not all trait items implemented, missing: `Type`
--> $DIR/bad-resolve.rs:22:1
--> $DIR/bad-resolve.rs:21:1
|
LL | type Type;
| --------- `Type` from trait
@@ -92,7 +92,7 @@ LL | impl Trait for S {
| ^^^^^^^^^^^^^^^^ missing `Type` in implementation
error[E0433]: cannot find module or crate `unresolved_prefix` in this scope
--> $DIR/bad-resolve.rs:43:7
--> $DIR/bad-resolve.rs:42:7
|
LL | reuse unresolved_prefix::{a, b, c};
| ^^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved_prefix`
@@ -100,7 +100,7 @@ LL | reuse unresolved_prefix::{a, b, c};
= help: you might be missing a crate named `unresolved_prefix`
error[E0433]: `crate` in paths can only be used in start position
--> $DIR/bad-resolve.rs:44:29
--> $DIR/bad-resolve.rs:43:29
|
LL | reuse prefix::{self, super, crate};
| ^^^^^ can only be used in path start position

View File

@@ -1,7 +1,6 @@
//@ check-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {
fn foo(&self) {}

View File

@@ -1,7 +1,6 @@
//@ check-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {
fn foo(&self) {}

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
use std::marker::PhantomData;

View File

@@ -1,5 +1,5 @@
error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:68
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:68
|
LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
| ^^ undeclared lifetime
@@ -14,7 +14,7 @@ LL | impl<'a> Trait for Z {
| ++++
error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:68
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:68
|
LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
| ^^ undeclared lifetime
@@ -29,7 +29,7 @@ LL | impl<'a> Trait for Z {
| ++++
error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:68
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:68
|
LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
| ^^ undeclared lifetime
@@ -44,7 +44,7 @@ LL | impl<'a> Trait for Z {
| ++++
error[E0599]: no associated function or constant named `new` found for struct `InvariantRef<'a, T>` in the current scope
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:9:41
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:8:41
|
LL | pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
| -------------------------------------- associated function or constant `new` not found for this struct
@@ -53,19 +53,19 @@ LL | pub const NEW: Self = InvariantRef::new(&());
| ^^^ associated function or constant not found in `InvariantRef<'_, _>`
error[E0277]: the trait bound `u8: Trait` is not satisfied
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:12
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:12
|
LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
| ^^ the trait `Trait` is not implemented for `u8`
|
help: the trait `Trait` is implemented for `Z`
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:1
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:20:1
|
LL | impl Trait for Z {
| ^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:53
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:53
|
LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `InvariantRef<'_, ()>`
@@ -74,20 +74,20 @@ LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW
found struct `InvariantRef<'_, ()>`
error[E0277]: the trait bound `u8: Trait` is not satisfied
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:12
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:12
|
LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
| ^^ the trait `Trait` is not implemented for `u8`
|
help: the trait `Trait` is implemented for `Z`
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:1
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:20:1
|
LL | impl Trait for Z {
| ^^^^^^^^^^^^^^^^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0308]: mismatched types
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:53
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:53
|
LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `InvariantRef<'_, ()>`
@@ -97,20 +97,20 @@ LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `u8: Trait` is not satisfied
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:12
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:12
|
LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
| ^^ the trait `Trait` is not implemented for `u8`
|
help: the trait `Trait` is implemented for `Z`
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:1
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:20:1
|
LL | impl Trait for Z {
| ^^^^^^^^^^^^^^^^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0308]: mismatched types
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:53
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:53
|
LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `InvariantRef<'_, ()>`

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {
fn foo(&self) -> u32 { 0 }

View File

@@ -1,5 +1,5 @@
error[E0201]: duplicate definitions with name `foo`:
--> $DIR/duplicate-definition-inside-trait-impl.rs:19:5
--> $DIR/duplicate-definition-inside-trait-impl.rs:18:5
|
LL | fn foo(&self) -> u32 { 0 }
| -------------------------- item in trait
@@ -10,13 +10,13 @@ LL | reuse Trait::foo;
| ^^^^^^^^^^^^^^^^^ duplicate definition
error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/duplicate-definition-inside-trait-impl.rs:19:18
--> $DIR/duplicate-definition-inside-trait-impl.rs:18:18
|
LL | reuse Trait::foo;
| ^^^ argument #1 of type `&_` is missing
|
note: method defined here
--> $DIR/duplicate-definition-inside-trait-impl.rs:5:8
--> $DIR/duplicate-definition-inside-trait-impl.rs:4:8
|
LL | fn foo(&self) -> u32 { 0 }
| ^^^ -----
@@ -26,7 +26,7 @@ LL | reuse Trait::foo(/* value */);
| +++++++++++++
error[E0308]: mismatched types
--> $DIR/duplicate-definition-inside-trait-impl.rs:19:18
--> $DIR/duplicate-definition-inside-trait-impl.rs:18:18
|
LL | reuse Trait::foo;
| ^^^- help: consider using a semicolon here: `;`

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {}

View File

@@ -1,5 +1,5 @@
error: empty glob delegation is not supported
--> $DIR/empty-glob.rs:8:5
--> $DIR/empty-glob.rs:7:5
|
LL | reuse Trait::*;
| ^^^^^^^^^^^^^^^

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
mod m {}

View File

@@ -1,5 +1,5 @@
error: empty list delegation is not supported
--> $DIR/empty-list.rs:6:1
--> $DIR/empty-list.rs:5:1
|
LL | reuse m::{};
| ^^^^^^^^^^^^

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait ToReuse {
fn foo(&self, x: i32) -> i32 { x }

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {
fn bar(&self, x: i32) -> i32 { x }

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
mod to_reuse {
use crate::S;

View File

@@ -1,6 +1,5 @@
//@ edition:2015
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {
fn foo1(&self, x: i32) -> i32 { x }

View File

@@ -1,5 +1,5 @@
error[E0407]: method `foo3` is not a member of trait `Trait`
--> $DIR/explicit-paths.rs:50:9
--> $DIR/explicit-paths.rs:49:9
|
LL | reuse to_reuse::foo3;
| ^^^^^^^^^^^^^^^^----^
@@ -8,7 +8,7 @@ LL | reuse to_reuse::foo3;
| not a member of trait `Trait`
error[E0407]: method `foo4` is not a member of trait `Trait`
--> $DIR/explicit-paths.rs:52:9
--> $DIR/explicit-paths.rs:51:9
|
LL | reuse F::foo4 { &self.0 }
| ^^^^^^^^^----^^^^^^^^^^^^
@@ -17,49 +17,49 @@ LL | reuse F::foo4 { &self.0 }
| not a member of trait `Trait`
error[E0425]: cannot find function `foo4` in `S`
--> $DIR/explicit-paths.rs:28:14
--> $DIR/explicit-paths.rs:27:14
|
LL | reuse S::foo4;
| ^^^^ not found in `S`
error[E0425]: cannot find function `foo4` in `F`
--> $DIR/explicit-paths.rs:39:18
--> $DIR/explicit-paths.rs:38:18
|
LL | reuse F::foo4 { &self.0 }
| ^^^^ not found in `F`
|
note: function `fn_to_other::foo4` exists but is inaccessible
--> $DIR/explicit-paths.rs:28:5
--> $DIR/explicit-paths.rs:27:5
|
LL | reuse S::foo4;
| ^^^^^^^^^^^^^^ not accessible
error[E0425]: cannot find function `foo4` in `F`
--> $DIR/explicit-paths.rs:52:18
--> $DIR/explicit-paths.rs:51:18
|
LL | reuse F::foo4 { &self.0 }
| ^^^^ not found in `F`
|
note: function `fn_to_other::foo4` exists but is inaccessible
--> $DIR/explicit-paths.rs:28:5
--> $DIR/explicit-paths.rs:27:5
|
LL | reuse S::foo4;
| ^^^^^^^^^^^^^^ not accessible
error[E0425]: cannot find function `foo4` in `F`
--> $DIR/explicit-paths.rs:66:18
--> $DIR/explicit-paths.rs:65:18
|
LL | reuse F::foo4 { &F }
| ^^^^ not found in `F`
|
note: function `fn_to_other::foo4` exists but is inaccessible
--> $DIR/explicit-paths.rs:28:5
--> $DIR/explicit-paths.rs:27:5
|
LL | reuse S::foo4;
| ^^^^^^^^^^^^^^ not accessible
error[E0119]: conflicting implementations of trait `Trait` for type `S`
--> $DIR/explicit-paths.rs:75:5
--> $DIR/explicit-paths.rs:74:5
|
LL | impl Trait for S {
| ---------------- first implementation here
@@ -68,7 +68,7 @@ LL | impl Trait for S {
| ^^^^^^^^^^^^^^^^ conflicting implementation for `S`
error[E0308]: mismatched types
--> $DIR/explicit-paths.rs:62:36
--> $DIR/explicit-paths.rs:61:36
|
LL | trait Trait2 : Trait {
| -------------------- found this type parameter
@@ -80,24 +80,24 @@ LL | reuse <F as Trait>::foo1 { self }
= note: expected reference `&F`
found reference `&Self`
note: method defined here
--> $DIR/explicit-paths.rs:6:8
--> $DIR/explicit-paths.rs:5:8
|
LL | fn foo1(&self, x: i32) -> i32 { x }
| ^^^^ -----
error[E0277]: the trait bound `S2: Trait` is not satisfied
--> $DIR/explicit-paths.rs:77:16
--> $DIR/explicit-paths.rs:76:16
|
LL | reuse <S2 as Trait>::foo1;
| ^^ unsatisfied trait bound
|
help: the trait `Trait` is not implemented for `S2`
--> $DIR/explicit-paths.rs:74:5
--> $DIR/explicit-paths.rs:73:5
|
LL | struct S2;
| ^^^^^^^^^
help: the following other types implement trait `Trait`
--> $DIR/explicit-paths.rs:11:1
--> $DIR/explicit-paths.rs:10:1
|
LL | impl Trait for F {}
| ^^^^^^^^^^^^^^^^ `F`
@@ -109,7 +109,7 @@ LL | impl Trait for S {
| ^^^^^^^^^^^^^^^^ `S`
error[E0308]: mismatched types
--> $DIR/explicit-paths.rs:77:30
--> $DIR/explicit-paths.rs:76:30
|
LL | reuse <S2 as Trait>::foo1;
| ^^^^
@@ -120,7 +120,7 @@ LL | reuse <S2 as Trait>::foo1;
= note: expected reference `&S2`
found reference `&S`
note: method defined here
--> $DIR/explicit-paths.rs:6:8
--> $DIR/explicit-paths.rs:5:8
|
LL | fn foo1(&self, x: i32) -> i32 { x }
| ^^^^ -----

View File

@@ -3,7 +3,6 @@
#![feature(c_variadic)]
#![feature(fn_delegation)]
#![allow(incomplete_features)]
mod to_reuse {
pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) {}

View File

@@ -1,5 +1,5 @@
error: delegation to C-variadic functions is not allowed
--> $DIR/fn-header-variadic.rs:12:17
--> $DIR/fn-header-variadic.rs:11:17
|
LL | pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) {}
| ------------------------------------------------------------- callee defined here
@@ -8,7 +8,7 @@ LL | reuse to_reuse::variadic_fn;
| ^^^^^^^^^^^
error: delegation to C-variadic functions is not allowed
--> $DIR/fn-header-variadic.rs:14:22
--> $DIR/fn-header-variadic.rs:13:22
|
LL | reuse fn_header_aux::variadic_fn_extern;
| ^^^^^^^^^^^^^^^^^^

View File

@@ -5,7 +5,6 @@
#![feature(c_variadic)]
#![feature(fn_delegation)]
#![allow(incomplete_features)]
#![deny(unused_unsafe)]
mod to_reuse {

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(unused_unsafe)]

View File

@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/foreign-fn.rs:17:30
--> $DIR/foreign-fn.rs:16:30
|
LL | let _: extern "C" fn() = default_unsafe_foo;
| --------------- ^^^^^^^^^^^^^^^^^^ expected safe fn, found unsafe fn
@@ -11,7 +11,7 @@ LL | let _: extern "C" fn() = default_unsafe_foo;
= note: unsafe functions cannot be coerced into safe function pointers
error[E0308]: mismatched types
--> $DIR/foreign-fn.rs:19:30
--> $DIR/foreign-fn.rs:18:30
|
LL | let _: extern "C" fn() = unsafe_foo;
| --------------- ^^^^^^^^^^ expected safe fn, found unsafe fn

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
fn main() {
fn foo<const N: dyn for<'a> Foo>() {}

View File

@@ -1,5 +1,5 @@
error[E0405]: cannot find trait `Foo` in this scope
--> $DIR/const-type-ice-153433.rs:5:33
--> $DIR/const-type-ice-153433.rs:4:33
|
LL | fn foo<const N: dyn for<'a> Foo>() {}
| ^^^ not found in this scope

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait<'a, T, const F: fn(&CStr) -> usize> {
//~^ ERROR: cannot find type `CStr` in this scope

View File

@@ -1,5 +1,5 @@
error[E0425]: cannot find type `CStr` in this scope
--> $DIR/const-type-ice-153499.rs:4:33
--> $DIR/const-type-ice-153499.rs:3:33
|
LL | trait Trait<'a, T, const F: fn(&CStr) -> usize> {
| ^^^^ not found in this scope
@@ -10,7 +10,7 @@ LL + use std::ffi::CStr;
|
error: using function pointers as const generic parameters is forbidden
--> $DIR/const-type-ice-153499.rs:4:29
--> $DIR/const-type-ice-153499.rs:3:29
|
LL | trait Trait<'a, T, const F: fn(&CStr) -> usize> {
| ^^^^^^^^^^^^^^^^^^
@@ -18,7 +18,7 @@ LL | trait Trait<'a, T, const F: fn(&CStr) -> usize> {
= note: the only supported types are integers, `bool`, and `char`
error: using function pointers as const generic parameters is forbidden
--> $DIR/const-type-ice-153499.rs:10:14
--> $DIR/const-type-ice-153499.rs:9:14
|
LL | reuse Trait::foo;
| ^^^

View File

@@ -5,6 +5,7 @@
#![feature(fn_delegation)]
#![feature(adt_const_params)]
#![feature(unsized_const_params)]
trait Trait<'a, T, const N: str> {
fn foo<'v, A, B>(&self) {}
}

View File

@@ -1,8 +1,7 @@
//@ compile-flags: -Z deduplicate-diagnostics=yes
//@ edition:2024
#![feature(fn_delegation)]
#![feature(iter_advance_by)]
#![feature(fn_delegation)]#![feature(iter_advance_by)]
#![feature(iter_array_chunks)]
#![feature(iterator_try_collect)]
#![feature(iterator_try_reduce)]
@@ -15,7 +14,7 @@
#![feature(iter_partition_in_place)]
#![feature(trusted_random_access)]
#![feature(try_find)]
#![allow(incomplete_features)]
impl Iterator {
//~^ ERROR: expected a type, found a trait [E0782]

View File

@@ -1,11 +1,11 @@
error[E0575]: expected method or associated constant, found associated type `Iterator::Item`
--> $DIR/def-path-hash-collision-ice-153410.rs:22:10
--> $DIR/def-path-hash-collision-ice-153410.rs:21:10
|
LL | reuse< < <for<'a> fn()>::Output>::Item as Iterator>::*;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a method or associated constant
error[E0782]: expected a type, found a trait
--> $DIR/def-path-hash-collision-ice-153410.rs:20:6
--> $DIR/def-path-hash-collision-ice-153410.rs:19:6
|
LL | impl Iterator {
| ^^^^^^^^
@@ -20,7 +20,7 @@ LL | impl Iterator for /* Type */ {
| ++++++++++++++
error[E0223]: ambiguous associated type
--> $DIR/def-path-hash-collision-ice-153410.rs:22:14
--> $DIR/def-path-hash-collision-ice-153410.rs:21:14
|
LL | reuse< < <for<'a> fn()>::Output>::Item as Iterator>::*;
| ^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -1,6 +1,5 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
mod to_reuse {
pub fn types<T, U>(x: U, y: T) -> (T, U) {

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
mod to_reuse {
pub fn consts<const N: i32>() -> i32 {

View File

@@ -1,5 +1,5 @@
error[E0107]: function takes 0 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/free-fn-to-free-fn.rs:19:5
--> $DIR/free-fn-to-free-fn.rs:18:5
|
LL | late::<'static>(&0u8);
| ^^^^----------- help: remove the unnecessary generics
@@ -7,13 +7,13 @@ LL | late::<'static>(&0u8);
| expected 0 lifetime arguments
|
note: function defined here, with 0 lifetime parameters
--> $DIR/free-fn-to-free-fn.rs:15:17
--> $DIR/free-fn-to-free-fn.rs:14:17
|
LL | reuse to_reuse::late;
| ^^^^
error[E0277]: the trait bound `S: Clone` is not satisfied
--> $DIR/free-fn-to-free-fn.rs:23:12
--> $DIR/free-fn-to-free-fn.rs:22:12
|
LL | bounds(S);
| ------ ^ the trait `Clone` is not implemented for `S`
@@ -21,7 +21,7 @@ LL | bounds(S);
| required by a bound introduced by this call
|
note: required by a bound in `bounds`
--> $DIR/free-fn-to-free-fn.rs:11:22
--> $DIR/free-fn-to-free-fn.rs:10:22
|
LL | pub fn bounds<T: Clone>(_: T) {}
| ^^^^^ required by this bound in `bounds`

View File

@@ -1,7 +1,6 @@
//@ compile-flags: -Z deduplicate-diagnostics=yes
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait<T> {
fn foo<U>(&self, _: U, _: T) {}
@@ -13,8 +12,8 @@ reuse Trait::<_>::foo::<i32> as generic_arguments1;
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
reuse <u8 as Trait<_>>::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
//~| ERROR the placeholder `_` is not allowed within types on item signatures for functions
fn main() {}

View File

@@ -1,39 +1,27 @@
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
--> $DIR/free-fn-to-trait-infer.rs:12:15
--> $DIR/free-fn-to-trait-infer.rs:11:15
|
LL | reuse Trait::<_>::foo::<i32> 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
--> $DIR/free-fn-to-trait-infer.rs:13:20
|
LL | reuse <u8 as Trait<_>>::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
--> $DIR/free-fn-to-trait-infer.rs:15:8
|
LL | reuse <_ as Trait<_>>::foo as generic_arguments3;
| ^ 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:15: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 <u8 as Trait<_>>::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-infer.rs:7:8
|
LL | fn foo<U>(&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`.
For more information about this error, try `rustc --explain E0121`.

View File

@@ -1,6 +1,5 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
mod types {
pub trait Trait<T> {

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
mod default_param {
pub trait Trait<T = u32> {

View File

@@ -1,5 +1,5 @@
error[E0277]: the trait bound `S: Copy` is not satisfied
--> $DIR/free-fn-to-trait-method.rs:39:18
--> $DIR/free-fn-to-trait-method.rs:38:18
|
LL | bounds(&0u8, S, U);
| ------ ^ the trait `Copy` is not implemented for `S`
@@ -7,7 +7,7 @@ LL | bounds(&0u8, S, U);
| required by a bound introduced by this call
|
note: required by a bound in `bounds`
--> $DIR/free-fn-to-trait-method.rs:23:54
--> $DIR/free-fn-to-trait-method.rs:22:54
|
LL | fn foo<U: Clone>(&self, t: T, u: U) where T: Copy {}
| ^^^^ required by this bound in `bounds`
@@ -21,7 +21,7 @@ LL | struct S;
|
error[E0277]: the trait bound `U: Clone` is not satisfied
--> $DIR/free-fn-to-trait-method.rs:39:21
--> $DIR/free-fn-to-trait-method.rs:38:21
|
LL | bounds(&0u8, S, U);
| ------ ^ the trait `Clone` is not implemented for `U`
@@ -29,7 +29,7 @@ LL | bounds(&0u8, S, U);
| required by a bound introduced by this call
|
note: required by a bound in `bounds`
--> $DIR/free-fn-to-trait-method.rs:23:19
--> $DIR/free-fn-to-trait-method.rs:22:19
|
LL | fn foo<U: Clone>(&self, t: T, u: U) where T: Copy {}
| ^^^^^ required by this bound in `bounds`

View File

@@ -0,0 +1,55 @@
#![feature(fn_delegation)]
trait Bound<T> {}
trait Trait<'a, T, const X: usize>
where
Self: Bound<T> + Sized,
{
fn method<U, const B: bool>(&self, x: U) {}
fn method2<U, const B: bool>(self, x: U) {}
fn method3<U, const B: bool>(&mut self, x: U) {}
}
impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
impl<T> Bound<T> for usize {}
reuse <usize as Trait<'static, i32, 123>>::method as foo;
reuse <usize as Trait<'static, i32, 123>>::method::<String, false> as foo2;
reuse <usize as Trait>::method as bar;
reuse <usize as Trait>::method::<Vec<i32>, false> as bar2;
reuse Trait::<'static, i32, 123>::method as foo3;
reuse Trait::<'static, i32, 123>::method2::<String, false> as foo4;
reuse Trait::method3 as bar3;
reuse Trait::method3::<Vec<i32>, false> as bar4;
reuse <String as Trait>::method as error5;
//~^ ERROR: the trait bound `String: Trait<'a, T, X>` is not satisfied
struct Struct;
impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
//~^ ERROR: the trait bound `Struct: Bound<T>` is not satisfied
reuse <Struct as Trait>::method as error6;
//~^ ERROR: the trait bound `Struct: Bound<T>` is not satisfied
fn main() {
foo::<&'static str, true>(&123, "");
foo2(&123, "".to_string());
bar::<'static, i32, 123, String, false>(&123, "".to_string());
bar2::<'static, usize, 321>(&123, vec![213, 123]);
foo3::<String, true>(&123, "".to_string());
//~^ ERROR: function takes 3 generic arguments but 2 generic arguments were supplied
foo4(123, "".to_string());
bar3::<'static, i32, 123, bool, false>(&mut 123, true);
//~^ ERROR: function takes 5 generic arguments but 4 generic arguments were supplied
bar4::<'static, usize, 321>(&mut 123, vec![123]);
//~^ ERROR: function takes 3 generic arguments but 2 generic arguments were supplied
foo3::<usize, String, true>(&123, "".to_string());
foo4::<usize>(123, "".to_string());
bar3::<'static, usize, i32, 123, String, false>(&mut 123, "".to_string());
bar4::<'static, usize, usize, 321>(&mut 123, vec![123]);
}

View File

@@ -0,0 +1,123 @@
error[E0277]: the trait bound `Struct: Bound<T>` is not satisfied
--> $DIR/free-to-trait-self-reuse.rs:31:49
|
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
| ^^^^^^ unsatisfied trait bound
|
help: the trait `Bound<T>` is not implemented for `Struct`
--> $DIR/free-to-trait-self-reuse.rs:30:1
|
LL | struct Struct;
| ^^^^^^^^^^^^^
help: the trait `Bound<T>` is implemented for `usize`
--> $DIR/free-to-trait-self-reuse.rs:15:1
|
LL | impl<T> Bound<T> for usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `Trait`
--> $DIR/free-to-trait-self-reuse.rs:7:11
|
LL | trait Trait<'a, T, const X: usize>
| ----- required by a bound in this trait
LL | where
LL | Self: Bound<T> + Sized,
| ^^^^^^^^ required by this bound in `Trait`
error[E0277]: the trait bound `String: Trait<'a, T, X>` is not satisfied
--> $DIR/free-to-trait-self-reuse.rs:27:8
|
LL | reuse <String as Trait>::method as error5;
| ^^^^^^ the trait `Trait<'a, T, X>` is not implemented for `String`
|
help: the following other types implement trait `Trait<'a, T, X>`
--> $DIR/free-to-trait-self-reuse.rs:14:1
|
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `usize`
...
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Struct`
error[E0277]: the trait bound `Struct: Bound<T>` is not satisfied
--> $DIR/free-to-trait-self-reuse.rs:34:8
|
LL | reuse <Struct as Trait>::method as error6;
| ^^^^^^ unsatisfied trait bound
|
help: the trait `Bound<T>` is not implemented for `Struct`
--> $DIR/free-to-trait-self-reuse.rs:30:1
|
LL | struct Struct;
| ^^^^^^^^^^^^^
help: the trait `Bound<T>` is implemented for `usize`
--> $DIR/free-to-trait-self-reuse.rs:15:1
|
LL | impl<T> Bound<T> for usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `Trait::method`
--> $DIR/free-to-trait-self-reuse.rs:7:11
|
LL | Self: Bound<T> + Sized,
| ^^^^^^^^ required by this bound in `Trait::method`
LL | {
LL | fn method<U, const B: bool>(&self, x: U) {}
| ------ required by a bound in this associated function
error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied
--> $DIR/free-to-trait-self-reuse.rs:43:5
|
LL | foo3::<String, true>(&123, "".to_string());
| ^^^^ ------ ---- supplied 2 generic arguments
| |
| expected 3 generic arguments
|
note: function defined here, with 3 generic parameters: `Self`, `U`, `B`
--> $DIR/free-to-trait-self-reuse.rs:22:45
|
LL | reuse Trait::<'static, i32, 123>::method as foo3;
| ------ ^^^^
help: add missing generic argument
|
LL | foo3::<String, true, B>(&123, "".to_string());
| +++
error[E0107]: function takes 5 generic arguments but 4 generic arguments were supplied
--> $DIR/free-to-trait-self-reuse.rs:46:5
|
LL | bar3::<'static, i32, 123, bool, false>(&mut 123, true);
| ^^^^ --- --- ---- ----- supplied 4 generic arguments
| |
| expected 5 generic arguments
|
note: function defined here, with 5 generic parameters: `Self`, `T`, `X`, `U`, `B`
--> $DIR/free-to-trait-self-reuse.rs:24:25
|
LL | reuse Trait::method3 as bar3;
| ------- ^^^^
help: add missing generic argument
|
LL | bar3::<'static, i32, 123, bool, false, B>(&mut 123, true);
| +++
error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied
--> $DIR/free-to-trait-self-reuse.rs:48:5
|
LL | bar4::<'static, usize, 321>(&mut 123, vec![123]);
| ^^^^ ----- --- supplied 2 generic arguments
| |
| expected 3 generic arguments
|
note: function defined here, with 3 generic parameters: `Self`, `T`, `X`
--> $DIR/free-to-trait-self-reuse.rs:25:44
|
LL | reuse Trait::method3::<Vec<i32>, false> as bar4;
| ------- ^^^^
help: add missing generic argument
|
LL | bar4::<'static, usize, 321, X>(&mut 123, vec![123]);
| +++
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0107, E0277.
For more information about an error, try `rustc --explain E0107`.

View File

@@ -0,0 +1,45 @@
#![feature(fn_delegation)]
trait Bound<T> {}
trait Trait<'a, T, const X: usize>
where
Self: Bound<T>,
{
fn static_method<'c: 'c, U, const B: bool>(x: usize) {}
}
impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
impl<T> Bound<T> for usize {}
reuse <usize as Trait<'static, i32, 123>>::static_method as foo { self + 2 }
reuse <usize as Trait<'static, i32, 123>>::static_method::<'static, String, false> as foo2;
reuse <usize as Trait>::static_method as bar { self + 1 }
reuse <usize as Trait>::static_method::<'static, Vec<i32>, false> as bar2;
reuse Trait::static_method as error { self - 123 }
//~^ ERROR: type annotations needed
reuse Trait::<'static, i32, 123>::static_method as error2;
//~^ ERROR: type annotations needed
reuse Trait::<'static, i32, 123>::static_method::<'static, String, false> as error3;
//~^ ERROR: type annotations needed
reuse Trait::static_method::<'static, Vec<i32>, false> as error4 { self + 4 }
//~^ ERROR: type annotations needed
reuse <String as Trait>::static_method as error5;
//~^ ERROR: the trait bound `String: Trait<'a, T, X>` is not satisfied
struct Struct;
impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
//~^ ERROR: the trait bound `Struct: Bound<T>` is not satisfied
reuse <Struct as Trait>::static_method as error6;
//~^ ERROR: the trait bound `Struct: Bound<T>` is not satisfied
fn main() {
foo::<'static, String, true>(123);
foo2(123);
bar::<'static, 'static, i32, 123, String, false>(123);
bar2::<'static, usize, 321>(123);
}

View File

@@ -0,0 +1,129 @@
error[E0277]: the trait bound `Struct: Bound<T>` is not satisfied
--> $DIR/free-to-trait-static-reuse.rs:33:49
|
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
| ^^^^^^ unsatisfied trait bound
|
help: the trait `Bound<T>` is not implemented for `Struct`
--> $DIR/free-to-trait-static-reuse.rs:32:1
|
LL | struct Struct;
| ^^^^^^^^^^^^^
help: the trait `Bound<T>` is implemented for `usize`
--> $DIR/free-to-trait-static-reuse.rs:13:1
|
LL | impl<T> Bound<T> for usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `Trait`
--> $DIR/free-to-trait-static-reuse.rs:7:11
|
LL | trait Trait<'a, T, const X: usize>
| ----- required by a bound in this trait
LL | where
LL | Self: Bound<T>,
| ^^^^^^^^ required by this bound in `Trait`
error[E0283]: type annotations needed
--> $DIR/free-to-trait-static-reuse.rs:20:14
|
LL | reuse Trait::static_method as error { self - 123 }
| ^^^^^^^^^^^^^ cannot infer type
|
note: multiple `impl`s satisfying `_: Trait<'a, T, X>` found
--> $DIR/free-to-trait-static-reuse.rs:12:1
|
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/free-to-trait-static-reuse.rs:22:35
|
LL | reuse Trait::<'static, i32, 123>::static_method as error2;
| ^^^^^^^^^^^^^ cannot infer type
|
note: multiple `impl`s satisfying `_: Trait<'static, i32, 123>` found
--> $DIR/free-to-trait-static-reuse.rs:12:1
|
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/free-to-trait-static-reuse.rs:24:35
|
LL | reuse Trait::<'static, i32, 123>::static_method::<'static, String, false> as error3;
| ^^^^^^^^^^^^^ cannot infer type
|
note: multiple `impl`s satisfying `_: Trait<'static, i32, 123>` found
--> $DIR/free-to-trait-static-reuse.rs:12:1
|
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/free-to-trait-static-reuse.rs:26:14
|
LL | reuse Trait::static_method::<'static, Vec<i32>, false> as error4 { self + 4 }
| ^^^^^^^^^^^^^ cannot infer type
|
note: multiple `impl`s satisfying `_: Trait<'a, T, X>` found
--> $DIR/free-to-trait-static-reuse.rs:12:1
|
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `String: Trait<'a, T, X>` is not satisfied
--> $DIR/free-to-trait-static-reuse.rs:29:8
|
LL | reuse <String as Trait>::static_method as error5;
| ^^^^^^ the trait `Trait<'a, T, X>` is not implemented for `String`
|
help: the following other types implement trait `Trait<'a, T, X>`
--> $DIR/free-to-trait-static-reuse.rs:12:1
|
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `usize`
...
LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Struct`
error[E0277]: the trait bound `Struct: Bound<T>` is not satisfied
--> $DIR/free-to-trait-static-reuse.rs:36:8
|
LL | reuse <Struct as Trait>::static_method as error6;
| ^^^^^^ unsatisfied trait bound
|
help: the trait `Bound<T>` is not implemented for `Struct`
--> $DIR/free-to-trait-static-reuse.rs:32:1
|
LL | struct Struct;
| ^^^^^^^^^^^^^
help: the trait `Bound<T>` is implemented for `usize`
--> $DIR/free-to-trait-static-reuse.rs:13:1
|
LL | impl<T> Bound<T> for usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `Trait::static_method`
--> $DIR/free-to-trait-static-reuse.rs:7:11
|
LL | Self: Bound<T>,
| ^^^^^^^^ required by this bound in `Trait::static_method`
LL | {
LL | fn static_method<'c: 'c, U, const B: bool>(x: usize) {}
| ------------- required by a bound in this associated function
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0277, E0283.
For more information about an error, try `rustc --explain E0277`.

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait<'a, 'b, 'c, A = usize, B = u32, C = String, const N: usize = 123> {
fn foo<T = usize>(&self) {

View File

@@ -1,5 +1,5 @@
error: defaults for generic parameters are not allowed here
--> $DIR/generic-params-defaults.rs:5:12
--> $DIR/generic-params-defaults.rs:4:12
|
LL | fn foo<T = usize>(&self) {
| ^^^^^^^^^
@@ -12,7 +12,7 @@ error: aborting due to 1 previous error
Future incompatibility report: Future breakage diagnostic:
error: defaults for generic parameters are not allowed here
--> $DIR/generic-params-defaults.rs:5:12
--> $DIR/generic-params-defaults.rs:4:12
|
LL | fn foo<T = usize>(&self) {
| ^^^^^^^^^

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait<'a, 'b, 'c, A, B, C, const N: usize> {
fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) {

View File

@@ -1,5 +1,5 @@
error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scope
--> $DIR/generic-params-same-names.rs:5:12
--> $DIR/generic-params-same-names.rs:4:12
|
LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> {
| -- first declared here
@@ -7,7 +7,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) {
| ^^ lifetime `'a` already in scope
error[E0496]: lifetime name `'b` shadows a lifetime name that is already in scope
--> $DIR/generic-params-same-names.rs:5:16
--> $DIR/generic-params-same-names.rs:4:16
|
LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> {
| -- first declared here
@@ -15,7 +15,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) {
| ^^ lifetime `'b` already in scope
error[E0496]: lifetime name `'c` shadows a lifetime name that is already in scope
--> $DIR/generic-params-same-names.rs:5:20
--> $DIR/generic-params-same-names.rs:4:20
|
LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> {
| -- first declared here
@@ -23,7 +23,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) {
| ^^ lifetime `'c` already in scope
error[E0403]: the name `A` is already used for a generic parameter in this item's generic parameters
--> $DIR/generic-params-same-names.rs:5:24
--> $DIR/generic-params-same-names.rs:4:24
|
LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> {
| - first use of `A`
@@ -31,7 +31,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) {
| ^ already used
error[E0403]: the name `B` is already used for a generic parameter in this item's generic parameters
--> $DIR/generic-params-same-names.rs:5:27
--> $DIR/generic-params-same-names.rs:4:27
|
LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> {
| - first use of `B`
@@ -39,7 +39,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) {
| ^ already used
error[E0403]: the name `C` is already used for a generic parameter in this item's generic parameters
--> $DIR/generic-params-same-names.rs:5:30
--> $DIR/generic-params-same-names.rs:4:30
|
LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> {
| - first use of `C`
@@ -47,7 +47,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) {
| ^ already used
error[E0403]: the name `N` is already used for a generic parameter in this item's generic parameters
--> $DIR/generic-params-same-names.rs:5:39
--> $DIR/generic-params-same-names.rs:4:39
|
LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> {
| - first use of `N`

View File

@@ -2,7 +2,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
reuse generics::foo as bar;
reuse generics::Trait::foo as trait_foo;

View File

@@ -1,7 +1,6 @@
//@ compile-flags: -Z deduplicate-diagnostics=yes
#![feature(fn_delegation)]
#![allow(incomplete_features)]
mod test_1 {
fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {}

View File

@@ -1,5 +1,5 @@
error[E0401]: can't use generic parameters from outer item
--> $DIR/generics-gen-args-errors.rs:34:21
--> $DIR/generics-gen-args-errors.rs:33:21
|
LL | fn check<A, B, C>() {
| - type parameter from outer item
@@ -12,7 +12,7 @@ LL | reuse foo::<A, B, C> 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:34:24
--> $DIR/generics-gen-args-errors.rs:33:24
|
LL | fn check<A, B, C>() {
| - type parameter from outer item
@@ -25,7 +25,7 @@ LL | reuse foo::<A, B, C> 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:34:27
--> $DIR/generics-gen-args-errors.rs:33:27
|
LL | fn check<A, B, C>() {
| - type parameter from outer item
@@ -38,7 +38,7 @@ LL | reuse foo::<A, B, C> 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:53:29
--> $DIR/generics-gen-args-errors.rs:52: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:70:50
--> $DIR/generics-gen-args-errors.rs:69: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:117:19
--> $DIR/generics-gen-args-errors.rs:116:19
|
LL | reuse Trait::<Trait, Clone, _, 'static, dyn Send, _>::foo::<1, 2, 3, _, 6> as bar7;
| ^^^^^ expected 3 lifetime parameters
@@ -71,7 +71,7 @@ LL | reuse Trait::<Trait<'a, 'a, 'a>, Clone, _, 'static, dyn Send, _>::foo'a
| ++++++++++++ +++
error[E0423]: expected value, found struct `String`
--> $DIR/generics-gen-args-errors.rs:14:33
--> $DIR/generics-gen-args-errors.rs:13:33
|
LL | bar::<String, String, { String }>();
| ^^^^^^
@@ -81,7 +81,7 @@ LL | bar::<String, String, { String }>();
= note: `String` defined here
error[E0425]: cannot find type `asd` in this scope
--> $DIR/generics-gen-args-errors.rs:28:15
--> $DIR/generics-gen-args-errors.rs:27:15
|
LL | bar::<asd, asd, asd>();
| ^^^ not found in this scope
@@ -92,7 +92,7 @@ LL | fn check<A, B, C, asd>() {
| +++++
error[E0425]: cannot find type `asd` in this scope
--> $DIR/generics-gen-args-errors.rs:28:20
--> $DIR/generics-gen-args-errors.rs:27:20
|
LL | bar::<asd, asd, asd>();
| ^^^ not found in this scope
@@ -103,7 +103,7 @@ LL | fn check<A, B, C, asd>() {
| +++++
error[E0425]: cannot find type `asd` in this scope
--> $DIR/generics-gen-args-errors.rs:28:25
--> $DIR/generics-gen-args-errors.rs:27:25
|
LL | bar::<asd, asd, asd>();
| ^^^ not found in this scope
@@ -114,73 +114,73 @@ LL | fn check<A, B, C, asd>() {
| +++++
error[E0425]: cannot find type `asdasd` in this scope
--> $DIR/generics-gen-args-errors.rs:57:39
--> $DIR/generics-gen-args-errors.rs:56:39
|
LL | reuse foo::<String, 'static, 123, asdasd> as bar4;
| ^^^^^^ not found in this scope
error[E0425]: cannot find type `asd` in this scope
--> $DIR/generics-gen-args-errors.rs:65:22
--> $DIR/generics-gen-args-errors.rs:64: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:70:27
--> $DIR/generics-gen-args-errors.rs:69: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:85:19
--> $DIR/generics-gen-args-errors.rs:84:19
|
LL | reuse Trait::<asd, asd, asd, asd, asd, asdasa>::foo as bar1;
| ^^^ not found in this scope
error[E0425]: cannot find type `asd` in this scope
--> $DIR/generics-gen-args-errors.rs:85:24
--> $DIR/generics-gen-args-errors.rs:84:24
|
LL | reuse Trait::<asd, asd, asd, asd, asd, asdasa>::foo as bar1;
| ^^^ not found in this scope
error[E0425]: cannot find type `asd` in this scope
--> $DIR/generics-gen-args-errors.rs:85:29
--> $DIR/generics-gen-args-errors.rs:84:29
|
LL | reuse Trait::<asd, asd, asd, asd, asd, asdasa>::foo as bar1;
| ^^^ not found in this scope
error[E0425]: cannot find type `asd` in this scope
--> $DIR/generics-gen-args-errors.rs:85:34
--> $DIR/generics-gen-args-errors.rs:84:34
|
LL | reuse Trait::<asd, asd, asd, asd, asd, asdasa>::foo as bar1;
| ^^^ not found in this scope
error[E0425]: cannot find type `asd` in this scope
--> $DIR/generics-gen-args-errors.rs:85:39
--> $DIR/generics-gen-args-errors.rs:84:39
|
LL | reuse Trait::<asd, asd, asd, asd, asd, asdasa>::foo as bar1;
| ^^^ not found in this scope
error[E0425]: cannot find type `asdasa` in this scope
--> $DIR/generics-gen-args-errors.rs:85:44
--> $DIR/generics-gen-args-errors.rs:84:44
|
LL | reuse Trait::<asd, asd, asd, asd, asd, asdasa>::foo as bar1;
| ^^^^^^ not found in this scope
error[E0425]: cannot find type `DDDD` in this scope
--> $DIR/generics-gen-args-errors.rs:110:34
--> $DIR/generics-gen-args-errors.rs:109:34
|
LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6;
| ^^^^ not found in this scope
error[E0107]: function takes 2 lifetime arguments but 0 lifetime arguments were supplied
--> $DIR/generics-gen-args-errors.rs:34:15
--> $DIR/generics-gen-args-errors.rs:33:15
|
LL | reuse foo::<A, B, C> as xd;
| ^^^ expected 2 lifetime arguments
|
note: function defined here, with 2 lifetime parameters: `'a`, `'b`
--> $DIR/generics-gen-args-errors.rs:7:8
--> $DIR/generics-gen-args-errors.rs:6:8
|
LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {}
| ^^^ -- --
@@ -190,19 +190,19 @@ LL | reuse foo::<'a, 'b, A, B, C> as xd;
| +++++++
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
--> $DIR/generics-gen-args-errors.rs:46:11
--> $DIR/generics-gen-args-errors.rs:45:11
|
LL | reuse foo::<> as bar1;
| ^^^ not allowed in type signatures
error[E0107]: function takes 2 lifetime arguments but 0 lifetime arguments were supplied
--> $DIR/generics-gen-args-errors.rs:49:11
--> $DIR/generics-gen-args-errors.rs:48:11
|
LL | reuse foo::<String, String> as bar2;
| ^^^ 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>() {}
| ^^^ -- --
@@ -212,7 +212,7 @@ LL | reuse foo::<'a, 'b, String, String> as bar2;
| +++++++
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::<String, String> as bar2;
| ^^^ ------ ------ supplied 2 generic arguments
@@ -220,7 +220,7 @@ LL | reuse foo::<String, String> 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>() {}
| ^^^ - - --------------
@@ -230,7 +230,7 @@ LL | reuse foo::<String, String, N> as bar2;
| +++
error[E0107]: function takes 2 lifetime arguments but 5 lifetime arguments were supplied
--> $DIR/generics-gen-args-errors.rs:53:11
--> $DIR/generics-gen-args-errors.rs:52:11
|
LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3;
| ^^^ --------------------------- help: remove the lifetime arguments
@@ -238,19 +238,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:53:11
--> $DIR/generics-gen-args-errors.rs:52: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>() {}
| ^^^ - - --------------
@@ -260,7 +260,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:57:11
--> $DIR/generics-gen-args-errors.rs:56:11
|
LL | reuse foo::<String, 'static, 123, asdasd> as bar4;
| ^^^ ------ supplied 1 lifetime argument
@@ -268,7 +268,7 @@ LL | reuse foo::<String, 'static, 123, asdasd> 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>() {}
| ^^^ -- --
@@ -278,13 +278,13 @@ LL | reuse foo::<String, 'static, 'static, 123, asdasd> as bar4;
| +++++++++
error[E0107]: function takes 2 lifetime arguments but 0 lifetime arguments were supplied
--> $DIR/generics-gen-args-errors.rs:61:11
--> $DIR/generics-gen-args-errors.rs:60:11
|
LL | reuse foo::<1, 2, _, 4, 5, _> as bar5;
| ^^^ 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>() {}
| ^^^ -- --
@@ -294,7 +294,7 @@ LL | reuse foo::<'a, 'b, 1, 2, _, 4, 5, _> as bar5;
| +++++++
error[E0107]: function takes 3 generic arguments but 6 generic arguments were supplied
--> $DIR/generics-gen-args-errors.rs:61:11
--> $DIR/generics-gen-args-errors.rs:60:11
|
LL | reuse foo::<1, 2, _, 4, 5, _> as bar5;
| ^^^ --------- help: remove the unnecessary generic arguments
@@ -302,19 +302,19 @@ 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 2 lifetime arguments but 0 lifetime arguments were supplied
--> $DIR/generics-gen-args-errors.rs:65:11
--> $DIR/generics-gen-args-errors.rs:64:11
|
LL | reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6;
| ^^^ 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>() {}
| ^^^ -- --
@@ -324,7 +324,7 @@ LL | reuse foo::<'a, 'b, 1, 2,asd,String, { let x = 0; }> as bar6;
| +++++++
error[E0107]: function takes 3 generic arguments but 5 generic arguments were supplied
--> $DIR/generics-gen-args-errors.rs:65:11
--> $DIR/generics-gen-args-errors.rs:64:11
|
LL | reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6;
| ^^^ ----------------------- help: remove the unnecessary generic arguments
@@ -332,25 +332,25 @@ 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:70:17
--> $DIR/generics-gen-args-errors.rs:69:17
|
LL | reuse foo::<"asdasd", asd, "askdn", 'static, 'a> as bar7;
| ^^^^^^^^
error[E0107]: function takes 2 lifetime arguments but 0 lifetime arguments were supplied
--> $DIR/generics-gen-args-errors.rs:75:11
--> $DIR/generics-gen-args-errors.rs:74:11
|
LL | reuse foo::<{}, {}, {}> as bar8;
| ^^^ 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>() {}
| ^^^ -- --
@@ -360,13 +360,13 @@ LL | reuse foo::<'a, 'b, {}, {}, {}> as bar8;
| +++++++
error[E0107]: trait takes 3 lifetime arguments but 0 lifetime arguments were supplied
--> $DIR/generics-gen-args-errors.rs:85:11
--> $DIR/generics-gen-args-errors.rs:84:11
|
LL | reuse Trait::<asd, asd, asd, asd, asd, asdasa>::foo as bar1;
| ^^^^^ expected 3 lifetime arguments
|
note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a`
--> $DIR/generics-gen-args-errors.rs:81:11
--> $DIR/generics-gen-args-errors.rs:80:11
|
LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized {
| ^^^^^ -- -- --
@@ -376,7 +376,7 @@ 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:85:11
--> $DIR/generics-gen-args-errors.rs:84:11
|
LL | reuse Trait::<asd, asd, asd, asd, asd, asdasa>::foo as bar1;
| ^^^^^ ----------------------- help: remove the unnecessary generic arguments
@@ -384,13 +384,13 @@ LL | reuse Trait::<asd, asd, asd, asd, asd, asdasa>::foo as bar1;
| expected 2 generic arguments
|
note: trait defined here, with 2 generic parameters: `T`, `N`
--> $DIR/generics-gen-args-errors.rs:81:11
--> $DIR/generics-gen-args-errors.rs:80:11
|
LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized {
| ^^^^^ - --------------
error[E0107]: trait takes 3 lifetime arguments but 2 lifetime arguments were supplied
--> $DIR/generics-gen-args-errors.rs:95:11
--> $DIR/generics-gen-args-errors.rs:94:11
|
LL | reuse Trait::<'static, 'static>::foo as bar2;
| ^^^^^ ------- ------- supplied 2 lifetime arguments
@@ -398,7 +398,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:81:11
--> $DIR/generics-gen-args-errors.rs:80:11
|
LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized {
| ^^^^^ -- -- --
@@ -408,19 +408,19 @@ 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:95:11
--> $DIR/generics-gen-args-errors.rs:94: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:98:11
--> $DIR/generics-gen-args-errors.rs:97: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:81:11
--> $DIR/generics-gen-args-errors.rs:80:11
|
LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized {
| ^^^^^ -- -- --
@@ -430,7 +430,7 @@ 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:98:11
--> $DIR/generics-gen-args-errors.rs:97:11
|
LL | reuse Trait::<1, 2, 3, 4, 5>::foo as bar3;
| ^^^^^ --------- help: remove the unnecessary generic arguments
@@ -438,19 +438,19 @@ 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:81:11
--> $DIR/generics-gen-args-errors.rs:80: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:102:11
--> $DIR/generics-gen-args-errors.rs:101: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:81:11
--> $DIR/generics-gen-args-errors.rs:80:11
|
LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized {
| ^^^^^ -- -- --
@@ -460,7 +460,7 @@ 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:102:11
--> $DIR/generics-gen-args-errors.rs:101:11
|
LL | reuse Trait::<1, 2, true>::foo as bar4;
| ^^^^^ ------ help: remove the unnecessary generic argument
@@ -468,13 +468,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:81:11
--> $DIR/generics-gen-args-errors.rs:80: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:106:11
--> $DIR/generics-gen-args-errors.rs:105:11
|
LL | reuse Trait::<'static>::foo as bar5;
| ^^^^^ ------- supplied 1 lifetime argument
@@ -482,7 +482,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:81:11
--> $DIR/generics-gen-args-errors.rs:80:11
|
LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized {
| ^^^^^ -- -- --
@@ -492,13 +492,13 @@ LL | reuse Trait::<'static, 'static, 'static>::foo as bar5;
| ++++++++++++++++++
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
--> $DIR/generics-gen-args-errors.rs:106:11
--> $DIR/generics-gen-args-errors.rs:105: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:110:11
--> $DIR/generics-gen-args-errors.rs:109:11
|
LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6;
| ^^^^^ - supplied 1 lifetime argument
@@ -506,7 +506,7 @@ LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6;
| expected 3 lifetime arguments
|
note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a`
--> $DIR/generics-gen-args-errors.rs:81:11
--> $DIR/generics-gen-args-errors.rs:80:11
|
LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized {
| ^^^^^ -- -- --
@@ -516,7 +516,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:110:11
--> $DIR/generics-gen-args-errors.rs:109:11
|
LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6;
| ^^^^^ --------------- help: remove the unnecessary generic argument
@@ -524,19 +524,19 @@ 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:81:11
--> $DIR/generics-gen-args-errors.rs:80:11
|
LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized {
| ^^^^^ - --------------
error[E0107]: method takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/generics-gen-args-errors.rs:110:41
--> $DIR/generics-gen-args-errors.rs:109:41
|
LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6;
| ^^^ expected 1 lifetime argument
|
note: method defined here, with 1 lifetime parameter: `'d`
--> $DIR/generics-gen-args-errors.rs:82:12
--> $DIR/generics-gen-args-errors.rs:81:12
|
LL | fn foo<'d: 'd, U, const M: bool>(self) {}
| ^^^ --
@@ -546,7 +546,7 @@ LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<'d, 1, 2, 3, 4, 5, 6> as bar6
| +++
error[E0107]: method takes 2 generic arguments but 6 generic arguments were supplied
--> $DIR/generics-gen-args-errors.rs:110:41
--> $DIR/generics-gen-args-errors.rs:109:41
|
LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6;
| ^^^ ------------ help: remove the unnecessary generic arguments
@@ -554,13 +554,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:82:12
--> $DIR/generics-gen-args-errors.rs:81: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:117:11
--> $DIR/generics-gen-args-errors.rs:116:11
|
LL | reuse Trait::<Trait, Clone, _, 'static, dyn Send, _>::foo::<1, 2, 3, _, 6> as bar7;
| ^^^^^ ----- supplied 1 lifetime argument
@@ -568,7 +568,7 @@ LL | reuse Trait::<Trait, Clone, _, 'static, dyn Send, _>::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:81:11
--> $DIR/generics-gen-args-errors.rs:80:11
|
LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized {
| ^^^^^ -- -- --
@@ -578,7 +578,7 @@ LL | reuse Trait::<Trait, 'static, 'static, Clone, _, 'static, dyn Send, _>:
| ++++++++++++++++++
error[E0107]: trait takes 2 generic arguments but 5 generic arguments were supplied
--> $DIR/generics-gen-args-errors.rs:117:11
--> $DIR/generics-gen-args-errors.rs:116:11
|
LL | reuse Trait::<Trait, Clone, _, 'static, dyn Send, _>::foo::<1, 2, 3, _, 6> as bar7;
| ^^^^^ --- help: remove the unnecessary generic argument
@@ -586,19 +586,19 @@ LL | reuse Trait::<Trait, Clone, _, 'static, dyn Send, _>::foo::<1, 2, 3, _,
| expected 2 generic arguments
|
note: trait defined here, with 2 generic parameters: `T`, `N`
--> $DIR/generics-gen-args-errors.rs:81:11
--> $DIR/generics-gen-args-errors.rs:80:11
|
LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized {
| ^^^^^ - --------------
error[E0107]: method takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/generics-gen-args-errors.rs:117:59
--> $DIR/generics-gen-args-errors.rs:116:59
|
LL | reuse Trait::<Trait, Clone, _, 'static, dyn Send, _>::foo::<1, 2, 3, _, 6> as bar7;
| ^^^ expected 1 lifetime argument
|
note: method defined here, with 1 lifetime parameter: `'d`
--> $DIR/generics-gen-args-errors.rs:82:12
--> $DIR/generics-gen-args-errors.rs:81:12
|
LL | fn foo<'d: 'd, U, const M: bool>(self) {}
| ^^^ --
@@ -608,7 +608,7 @@ LL | reuse Trait::<Trait, Clone, _, 'static, dyn Send, _>::foo::<'d, 1, 2, 3
| +++
error[E0107]: method takes 2 generic arguments but 5 generic arguments were supplied
--> $DIR/generics-gen-args-errors.rs:117:59
--> $DIR/generics-gen-args-errors.rs:116:59
|
LL | reuse Trait::<Trait, Clone, _, 'static, dyn Send, _>::foo::<1, 2, 3, _, 6> as bar7;
| ^^^ --------- help: remove the unnecessary generic arguments
@@ -616,13 +616,13 @@ LL | reuse Trait::<Trait, Clone, _, 'static, dyn Send, _>::foo::<1, 2, 3, _,
| expected 2 generic arguments
|
note: method defined here, with 2 generic parameters: `U`, `M`
--> $DIR/generics-gen-args-errors.rs:82:12
--> $DIR/generics-gen-args-errors.rs:81:12
|
LL | fn foo<'d: 'd, U, const M: bool>(self) {}
| ^^^ - -------------
error[E0107]: function takes 3 generic arguments but 6 generic arguments were supplied
--> $DIR/generics-gen-args-errors.rs:11:9
--> $DIR/generics-gen-args-errors.rs:10:9
|
LL | bar::<1, 2, 3, 4, 5, 6>();
| ^^^ --------- help: remove the unnecessary generic arguments
@@ -630,13 +630,13 @@ LL | bar::<1, 2, 3, 4, 5, 6>();
| expected 3 generic arguments
|
note: function defined here, with 3 generic parameters: `T`, `U`, `N`
--> $DIR/generics-gen-args-errors.rs:8:18
--> $DIR/generics-gen-args-errors.rs:7:18
|
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
--> $DIR/generics-gen-args-errors.rs:16:9
|
LL | bar::<'static, 'static, 'static, 'static, 'static>();
| ^^^ --------------------------- help: remove the lifetime arguments
@@ -644,19 +644,19 @@ LL | bar::<'static, 'static, 'static, 'static, 'static>();
| expected 2 lifetime arguments
|
note: function defined here, with 2 lifetime parameters: `'a`, `'b`
--> $DIR/generics-gen-args-errors.rs:8:18
--> $DIR/generics-gen-args-errors.rs:7:18
|
LL | reuse foo as bar;
| --- ^^^
error[E0747]: constant provided when a type was expected
--> $DIR/generics-gen-args-errors.rs:20:23
--> $DIR/generics-gen-args-errors.rs:19:23
|
LL | bar::<String, 1, 'static, i32, 'static>();
| ^
error[E0107]: function takes 3 generic arguments but 5 generic arguments were supplied
--> $DIR/generics-gen-args-errors.rs:25:9
--> $DIR/generics-gen-args-errors.rs:24:9
|
LL | bar::<_, _, _, _, _>();
| ^^^ ------ help: remove the unnecessary generic arguments
@@ -664,13 +664,13 @@ LL | bar::<_, _, _, _, _>();
| expected 3 generic arguments
|
note: function defined here, with 3 generic parameters: `T`, `U`, `N`
--> $DIR/generics-gen-args-errors.rs:8:18
--> $DIR/generics-gen-args-errors.rs:7:18
|
LL | reuse foo as bar;
| --- ^^^
error[E0747]: unresolved item provided when a constant was expected
--> $DIR/generics-gen-args-errors.rs:28:25
--> $DIR/generics-gen-args-errors.rs:27:25
|
LL | bar::<asd, asd, asd>();
| ^^^
@@ -681,7 +681,7 @@ LL | bar::<asd, asd, { asd }>();
| + +
error[E0747]: unresolved item provided when a constant was expected
--> $DIR/generics-gen-args-errors.rs:34:27
--> $DIR/generics-gen-args-errors.rs:33:27
|
LL | reuse foo::<A, B, C> as xd;
| ^
@@ -692,7 +692,7 @@ LL | reuse foo::<A, B, { C }> as xd;
| + +
error[E0747]: constant provided when a type was expected
--> $DIR/generics-gen-args-errors.rs:75:17
--> $DIR/generics-gen-args-errors.rs:74:17
|
LL | reuse foo::<{}, {}, {}> as bar8;
| ^^

View File

@@ -1,6 +1,5 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
mod to_reuse {
pub fn foo<T, U>(_: T, y: U) -> U { y }

View File

@@ -1,5 +1,4 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
mod bounds {
trait Trait0 {}

View File

@@ -1,16 +1,16 @@
error[E0277]: the trait bound `bounds::S: Trait0` is not satisfied
--> $DIR/impl-to-trait-method.rs:12:19
--> $DIR/impl-to-trait-method.rs:11:19
|
LL | Self: Trait0,
| ^^^^^^ unsatisfied trait bound
|
help: the trait `Trait0` is not implemented for `bounds::S`
--> $DIR/impl-to-trait-method.rs:21:5
--> $DIR/impl-to-trait-method.rs:20:5
|
LL | struct S(F);
| ^^^^^^^^
help: this trait has no implementations, consider adding one
--> $DIR/impl-to-trait-method.rs:5:5
--> $DIR/impl-to-trait-method.rs:4:5
|
LL | trait Trait0 {}
| ^^^^^^^^^^^^
@@ -20,7 +20,7 @@ LL + #![feature(trivial_bounds)]
|
error[E0277]: the trait bound `bounds::F: Trait0` is not satisfied
--> $DIR/impl-to-trait-method.rs:24:34
--> $DIR/impl-to-trait-method.rs:23:34
|
LL | reuse Trait1::<T>::foo { &self.0 }
| --- ^^^^^^^ unsatisfied trait bound
@@ -28,17 +28,17 @@ LL | reuse Trait1::<T>::foo { &self.0 }
| required by a bound introduced by this call
|
help: the trait `Trait0` is not implemented for `bounds::F`
--> $DIR/impl-to-trait-method.rs:18:5
--> $DIR/impl-to-trait-method.rs:17:5
|
LL | struct F;
| ^^^^^^^^
help: this trait has no implementations, consider adding one
--> $DIR/impl-to-trait-method.rs:5:5
--> $DIR/impl-to-trait-method.rs:4:5
|
LL | trait Trait0 {}
| ^^^^^^^^^^^^
note: required by a bound in `Trait1::foo`
--> $DIR/impl-to-trait-method.rs:12:19
--> $DIR/impl-to-trait-method.rs:11:19
|
LL | fn foo<U>(&self)
| --- required by a bound in this associated function
@@ -47,7 +47,7 @@ LL | Self: Trait0,
| ^^^^^^ required by this bound in `Trait1::foo`
error[E0282]: type annotations needed
--> $DIR/impl-to-trait-method.rs:39:22
--> $DIR/impl-to-trait-method.rs:38:22
|
LL | reuse Trait::foo { &self.0 }
| ^^^ cannot infer type for type parameter `T` declared on the trait `Trait`

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
use std::iter::{Iterator, Map};

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait<T> {
fn foo<U>(&self, x: T, y: U) -> (T, U) {

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
//! This is one of the mapping tests, which tests mapping of delegee parent and child
//! generic params, whose main goal is to create cases with

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
//! This is one of the mapping tests, which tests mapping of delegee parent and child
//! generic params, whose main goal is to create cases with
@@ -171,14 +170,14 @@ mod test_10 {
pub fn check() {
fn with_ctx<'a, 'b, 'c, A, B, C, const N: usize, const M: bool>() {
reuse <u8 as Trait>::foo as bar;
bar::<'a, 'b, 'c, u8, C, A, M>();
bar::<'static, 'static, 'static, u8, i32, i32, false>();
bar::<'a, 'b, 'c, C, A, M>();
bar::<'static, 'static, 'static, i32, i32, false>();
reuse <u8 as Trait::<'static, 'static, i32>>::foo as bar1;
bar1::<'static, u8, i32, true>();
bar1::<'static, i32, true>();
reuse <u8 as Trait::<'static, 'static, i32>>::foo::<'static, u32, true> as bar2;
bar2::<u8>();
bar2();
}
with_ctx::<i32, i32, i32, 1, true>();
@@ -211,7 +210,7 @@ mod test_11 {
pub fn check<'b>() {
reuse <usize as Trait>::foo;
foo::<'static, 'b, usize, u32, Struct, String, false>();
foo::<'static, 'b, u32, Struct, String, false>();
}
}

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
#![allow(late_bound_lifetime_arguments)]
//! This is one of the mapping tests, which tests mapping of delegee parent and child

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
#![allow(late_bound_lifetime_arguments)]
//! This is one of the mapping tests, which tests mapping of delegee parent and child

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
//! This is one of the mapping tests, which tests mapping of delegee parent and child
//! generic params, whose main goal is to create cases with

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
#![allow(late_bound_lifetime_arguments)]
//! This is one of the mapping tests, which tests mapping of delegee parent and child

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
//! This is one of the mapping tests, which tests mapping of delegee parent and child
//! generic params, whose main goal is to create cases with

View File

@@ -1,7 +1,6 @@
//@ run-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
#![allow(late_bound_lifetime_arguments)]
//! This is one of the mapping tests, which tests mapping of delegee parent and child

View File

@@ -1,7 +1,6 @@
//@ check-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
#![feature(staged_api)]
#![unstable(feature = "foo", issue = "none")]

Some files were not shown because too many files have changed in this diff Show More