parse const trait Trait
This commit is contained in:
parent
f8f6997469
commit
69326878ee
94 changed files with 365 additions and 299 deletions
|
|
@ -3690,6 +3690,7 @@ impl Default for FnHeader {
|
|||
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct Trait {
|
||||
pub constness: Const,
|
||||
pub safety: Safety,
|
||||
pub is_auto: IsAuto,
|
||||
pub ident: Ident,
|
||||
|
|
|
|||
|
|
@ -738,7 +738,8 @@ macro_rules! common_visitor_and_walkers {
|
|||
try_visit!(vis.visit_ty(self_ty));
|
||||
visit_assoc_items(vis, items, AssocCtxt::Impl { of_trait: of_trait.is_some() })
|
||||
}
|
||||
ItemKind::Trait(box Trait { safety, is_auto: _, ident, generics, bounds, items }) => {
|
||||
ItemKind::Trait(box Trait { constness, safety, is_auto: _, ident, generics, bounds, items }) => {
|
||||
try_visit!(visit_constness(vis, constness));
|
||||
try_visit!(visit_safety(vis, safety));
|
||||
try_visit!(vis.visit_ident(ident));
|
||||
try_visit!(vis.visit_generics(generics));
|
||||
|
|
|
|||
|
|
@ -417,7 +417,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
items: new_impl_items,
|
||||
}))
|
||||
}
|
||||
ItemKind::Trait(box Trait { is_auto, safety, ident, generics, bounds, items }) => {
|
||||
ItemKind::Trait(box Trait {
|
||||
constness,
|
||||
is_auto,
|
||||
safety,
|
||||
ident,
|
||||
generics,
|
||||
bounds,
|
||||
items,
|
||||
}) => {
|
||||
let constness = self.lower_constness(*constness);
|
||||
let ident = self.lower_ident(*ident);
|
||||
let (generics, (safety, items, bounds)) = self.lower_generics(
|
||||
generics,
|
||||
|
|
@ -435,7 +444,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
(safety, items, bounds)
|
||||
},
|
||||
);
|
||||
hir::ItemKind::Trait(*is_auto, safety, ident, generics, bounds, items)
|
||||
hir::ItemKind::Trait(constness, *is_auto, safety, ident, generics, bounds, items)
|
||||
}
|
||||
ItemKind::TraitAlias(ident, generics, bounds) => {
|
||||
let ident = self.lower_ident(*ident);
|
||||
|
|
|
|||
|
|
@ -240,10 +240,10 @@ ast_passes_static_without_body =
|
|||
ast_passes_tilde_const_disallowed = `[const]` is not allowed here
|
||||
.closure = closures cannot have `[const]` trait bounds
|
||||
.function = this function is not `const`, so it cannot have `[const]` trait bounds
|
||||
.trait = this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
.trait = this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
.trait_impl = this impl is not `const`, so it cannot have `[const]` trait bounds
|
||||
.impl = inherent impls cannot have `[const]` trait bounds
|
||||
.trait_assoc_ty = associated types in non-`#[const_trait]` traits cannot have `[const]` trait bounds
|
||||
.trait_assoc_ty = associated types in non-`const` traits cannot have `[const]` trait bounds
|
||||
.trait_impl_assoc_ty = associated types in non-const impls cannot have `[const]` trait bounds
|
||||
.inherent_assoc_ty = inherent associated types cannot have `[const]` trait bounds
|
||||
.object = trait objects cannot have `[const]` trait bounds
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ enum SelfSemantic {
|
|||
}
|
||||
|
||||
enum TraitOrTraitImpl {
|
||||
Trait { span: Span, constness_span: Option<Span> },
|
||||
Trait { span: Span, constness: Const },
|
||||
TraitImpl { constness: Const, polarity: ImplPolarity, trait_ref_span: Span },
|
||||
}
|
||||
|
||||
impl TraitOrTraitImpl {
|
||||
fn constness(&self) -> Option<Span> {
|
||||
match self {
|
||||
Self::Trait { constness_span: Some(span), .. }
|
||||
Self::Trait { constness: Const::Yes(span), .. }
|
||||
| Self::TraitImpl { constness: Const::Yes(span), .. } => Some(*span),
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -110,15 +110,10 @@ impl<'a> AstValidator<'a> {
|
|||
self.outer_trait_or_trait_impl = old;
|
||||
}
|
||||
|
||||
fn with_in_trait(
|
||||
&mut self,
|
||||
span: Span,
|
||||
constness_span: Option<Span>,
|
||||
f: impl FnOnce(&mut Self),
|
||||
) {
|
||||
fn with_in_trait(&mut self, span: Span, constness: Const, f: impl FnOnce(&mut Self)) {
|
||||
let old = mem::replace(
|
||||
&mut self.outer_trait_or_trait_impl,
|
||||
Some(TraitOrTraitImpl::Trait { span, constness_span }),
|
||||
Some(TraitOrTraitImpl::Trait { span, constness }),
|
||||
);
|
||||
f(self);
|
||||
self.outer_trait_or_trait_impl = old;
|
||||
|
|
@ -273,7 +268,7 @@ impl<'a> AstValidator<'a> {
|
|||
};
|
||||
|
||||
let make_trait_const_sugg = if const_trait_impl
|
||||
&& let TraitOrTraitImpl::Trait { span, constness_span: None } = parent
|
||||
&& let TraitOrTraitImpl::Trait { span, constness: ast::Const::No } = parent
|
||||
{
|
||||
Some(span.shrink_to_lo())
|
||||
} else {
|
||||
|
|
@ -1131,10 +1126,23 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
visit::walk_item(self, item)
|
||||
}
|
||||
ItemKind::Trait(box Trait { is_auto, generics, ident, bounds, items, .. }) => {
|
||||
ItemKind::Trait(box Trait {
|
||||
constness,
|
||||
is_auto,
|
||||
generics,
|
||||
ident,
|
||||
bounds,
|
||||
items,
|
||||
..
|
||||
}) => {
|
||||
self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident);
|
||||
let is_const_trait =
|
||||
// FIXME(const_trait_impl) remove this
|
||||
let alt_const_trait_span =
|
||||
attr::find_by_name(&item.attrs, sym::const_trait).map(|attr| attr.span);
|
||||
let constness = match (*constness, alt_const_trait_span) {
|
||||
(Const::Yes(span), _) | (Const::No, Some(span)) => Const::Yes(span),
|
||||
(Const::No, None) => Const::No,
|
||||
};
|
||||
if *is_auto == IsAuto::Yes {
|
||||
// Auto traits cannot have generics, super traits nor contain items.
|
||||
self.deny_generic_params(generics, ident.span);
|
||||
|
|
@ -1145,13 +1153,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
|
||||
// Equivalent of `visit::walk_item` for `ItemKind::Trait` that inserts a bound
|
||||
// context for the supertraits.
|
||||
let disallowed =
|
||||
is_const_trait.is_none().then(|| TildeConstReason::Trait { span: item.span });
|
||||
let disallowed = matches!(constness, ast::Const::No)
|
||||
.then(|| TildeConstReason::Trait { span: item.span });
|
||||
self.with_tilde_const(disallowed, |this| {
|
||||
this.visit_generics(generics);
|
||||
walk_list!(this, visit_param_bound, bounds, BoundKind::SuperTraits)
|
||||
});
|
||||
self.with_in_trait(item.span, is_const_trait, |this| {
|
||||
self.with_in_trait(item.span, constness, |this| {
|
||||
walk_list!(this, visit_assoc_item, items, AssocCtxt::Trait);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -590,7 +590,7 @@ pub(crate) struct ConstBoundTraitObject {
|
|||
}
|
||||
|
||||
// FIXME(const_trait_impl): Consider making the note/reason the message of the diagnostic.
|
||||
// FIXME(const_trait_impl): Provide structured suggestions (e.g., add `const` / `#[const_trait]` here).
|
||||
// FIXME(const_trait_impl): Provide structured suggestions (e.g., add `const` here).
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_passes_tilde_const_disallowed)]
|
||||
pub(crate) struct TildeConstDisallowed {
|
||||
|
|
|
|||
|
|
@ -357,6 +357,7 @@ impl<'a> State<'a> {
|
|||
self.bclose(item.span, empty, cb);
|
||||
}
|
||||
ast::ItemKind::Trait(box ast::Trait {
|
||||
constness,
|
||||
safety,
|
||||
is_auto,
|
||||
ident,
|
||||
|
|
@ -366,6 +367,7 @@ impl<'a> State<'a> {
|
|||
}) => {
|
||||
let (cb, ib) = self.head("");
|
||||
self.print_visibility(&item.vis);
|
||||
self.print_constness(*constness);
|
||||
self.print_safety(*safety);
|
||||
self.print_is_auto(*is_auto);
|
||||
self.word_nbsp("trait");
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ impl<S: Stage> NoArgsAttributeParser<S> for DoNotImplementViaObjectParser {
|
|||
const CREATE: fn(Span) -> AttributeKind = AttributeKind::DoNotImplementViaObject;
|
||||
}
|
||||
|
||||
// FIXME(const_trait_impl): remove this
|
||||
// Const traits
|
||||
|
||||
pub(crate) struct ConstTraitParser;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ pub fn rustc_allow_const_fn_unstable(
|
|||
/// world into two functions: those that are safe to expose on stable (and hence may not use
|
||||
/// unstable features, not even recursively), and those that are not.
|
||||
pub fn is_fn_or_trait_safe_to_expose_on_stable(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
// A default body in a `#[const_trait]` is const-stable when the trait is const-stable.
|
||||
// A default body in a `const trait` is const-stable when the trait is const-stable.
|
||||
if tcx.is_const_default_method(def_id) {
|
||||
return is_fn_or_trait_safe_to_expose_on_stable(tcx, tcx.parent(def_id));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -363,8 +363,8 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
|
|||
if let ty::InstanceKind::Item(def) = instance.def {
|
||||
// Execution might have wandered off into other crates, so we cannot do a stability-
|
||||
// sensitive check here. But we can at least rule out functions that are not const at
|
||||
// all. That said, we have to allow calling functions inside a trait marked with
|
||||
// #[const_trait]. These *are* const-checked!
|
||||
// all. That said, we have to allow calling functions inside a `const trait`. These
|
||||
// *are* const-checked!
|
||||
if !ecx.tcx.is_const_fn(def) || ecx.tcx.has_attr(def, sym::rustc_do_not_const_check) {
|
||||
// We certainly do *not* want to actually call the fn
|
||||
// though, so be sure we return here.
|
||||
|
|
|
|||
|
|
@ -614,6 +614,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
),
|
||||
|
||||
// RFC 2632
|
||||
// FIXME(const_trait_impl) remove this
|
||||
gated!(
|
||||
const_trait, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, const_trait_impl,
|
||||
"`const_trait` is a temporary placeholder for marking a trait that is suitable for `const` \
|
||||
|
|
|
|||
|
|
@ -4163,6 +4163,7 @@ impl<'hir> Item<'hir> {
|
|||
|
||||
expect_trait,
|
||||
(
|
||||
Constness,
|
||||
IsAuto,
|
||||
Safety,
|
||||
Ident,
|
||||
|
|
@ -4170,8 +4171,8 @@ impl<'hir> Item<'hir> {
|
|||
GenericBounds<'hir>,
|
||||
&'hir [TraitItemId]
|
||||
),
|
||||
ItemKind::Trait(is_auto, safety, ident, generics, bounds, items),
|
||||
(*is_auto, *safety, *ident, generics, bounds, items);
|
||||
ItemKind::Trait(constness, is_auto, safety, ident, generics, bounds, items),
|
||||
(*constness, *is_auto, *safety, *ident, generics, bounds, items);
|
||||
|
||||
expect_trait_alias, (Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
|
||||
ItemKind::TraitAlias(ident, generics, bounds), (*ident, generics, bounds);
|
||||
|
|
@ -4341,7 +4342,15 @@ pub enum ItemKind<'hir> {
|
|||
/// A union definition, e.g., `union Foo<A, B> {x: A, y: B}`.
|
||||
Union(Ident, &'hir Generics<'hir>, VariantData<'hir>),
|
||||
/// A trait definition.
|
||||
Trait(IsAuto, Safety, Ident, &'hir Generics<'hir>, GenericBounds<'hir>, &'hir [TraitItemId]),
|
||||
Trait(
|
||||
Constness,
|
||||
IsAuto,
|
||||
Safety,
|
||||
Ident,
|
||||
&'hir Generics<'hir>,
|
||||
GenericBounds<'hir>,
|
||||
&'hir [TraitItemId],
|
||||
),
|
||||
/// A trait alias.
|
||||
TraitAlias(Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
|
||||
|
||||
|
|
@ -4385,7 +4394,7 @@ impl ItemKind<'_> {
|
|||
| ItemKind::Enum(ident, ..)
|
||||
| ItemKind::Struct(ident, ..)
|
||||
| ItemKind::Union(ident, ..)
|
||||
| ItemKind::Trait(_, _, ident, ..)
|
||||
| ItemKind::Trait(_, _, _, ident, ..)
|
||||
| ItemKind::TraitAlias(ident, ..) => Some(ident),
|
||||
|
||||
ItemKind::Use(_, UseKind::Glob | UseKind::ListStem)
|
||||
|
|
@ -4403,7 +4412,7 @@ impl ItemKind<'_> {
|
|||
| ItemKind::Enum(_, generics, _)
|
||||
| ItemKind::Struct(_, generics, _)
|
||||
| ItemKind::Union(_, generics, _)
|
||||
| ItemKind::Trait(_, _, _, generics, _, _)
|
||||
| ItemKind::Trait(_, _, _, _, generics, _, _)
|
||||
| ItemKind::TraitAlias(_, generics, _)
|
||||
| ItemKind::Impl(Impl { generics, .. }) => generics,
|
||||
_ => return None,
|
||||
|
|
|
|||
|
|
@ -618,7 +618,15 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
|
|||
try_visit!(visitor.visit_generics(generics));
|
||||
try_visit!(visitor.visit_variant_data(struct_definition));
|
||||
}
|
||||
ItemKind::Trait(_is_auto, _safety, ident, ref generics, bounds, trait_item_refs) => {
|
||||
ItemKind::Trait(
|
||||
_constness,
|
||||
_is_auto,
|
||||
_safety,
|
||||
ident,
|
||||
ref generics,
|
||||
bounds,
|
||||
trait_item_refs,
|
||||
) => {
|
||||
try_visit!(visitor.visit_ident(ident));
|
||||
try_visit!(visitor.visit_generics(generics));
|
||||
walk_list!(visitor, visit_param_bound, bounds);
|
||||
|
|
|
|||
|
|
@ -117,15 +117,15 @@ hir_analysis_coercion_between_struct_same_note = expected coercion between the s
|
|||
|
||||
hir_analysis_coercion_between_struct_single_note = expected a single field to be coerced, none found
|
||||
|
||||
hir_analysis_const_bound_for_non_const_trait = `{$modifier}` can only be applied to `#[const_trait]` traits
|
||||
hir_analysis_const_bound_for_non_const_trait = `{$modifier}` can only be applied to `const` traits
|
||||
.label = can't be applied to `{$trait_name}`
|
||||
.note = `{$trait_name}` can't be used with `{$modifier}` because it isn't annotated with `#[const_trait]`
|
||||
.suggestion = {$suggestion_pre}mark `{$trait_name}` as `#[const_trait]` to allow it to have `const` implementations
|
||||
.note = `{$trait_name}` can't be used with `{$modifier}` because it isn't `const`
|
||||
.suggestion = {$suggestion_pre}mark `{$trait_name}` as `const` to allow it to have `const` implementations
|
||||
|
||||
hir_analysis_const_impl_for_non_const_trait = const `impl` for trait `{$trait_name}` which is not marked with `#[const_trait]`
|
||||
hir_analysis_const_impl_for_non_const_trait = const `impl` for trait `{$trait_name}` which is not `const`
|
||||
.label = this trait is not `const`
|
||||
.suggestion = {$suggestion_pre}mark `{$trait_name}` as `#[const_trait]` to allow it to have `const` implementations
|
||||
.note = marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
.suggestion = {$suggestion_pre}mark `{$trait_name}` as `const` to allow it to have `const` implementations
|
||||
.note = marking a trait with `const` ensures all default method bodies are `const`
|
||||
.adding = adding a non-const method body in the future would be a breaking change
|
||||
|
||||
hir_analysis_const_param_ty_impl_on_non_adt =
|
||||
|
|
|
|||
|
|
@ -844,15 +844,20 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
|
|||
fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
||||
let item = tcx.hir_expect_item(def_id);
|
||||
|
||||
let (is_alias, is_auto, safety) = match item.kind {
|
||||
hir::ItemKind::Trait(is_auto, safety, ..) => (false, is_auto == hir::IsAuto::Yes, safety),
|
||||
hir::ItemKind::TraitAlias(..) => (true, false, hir::Safety::Safe),
|
||||
let (constness, is_alias, is_auto, safety) = match item.kind {
|
||||
hir::ItemKind::Trait(constness, is_auto, safety, ..) => {
|
||||
(constness, false, is_auto == hir::IsAuto::Yes, safety)
|
||||
}
|
||||
hir::ItemKind::TraitAlias(..) => (hir::Constness::NotConst, true, false, hir::Safety::Safe),
|
||||
_ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"),
|
||||
};
|
||||
|
||||
let attrs = tcx.get_all_attrs(def_id);
|
||||
// Only regular traits can be const.
|
||||
let constness = if !is_alias && find_attr!(attrs, AttributeKind::ConstTrait(_)) {
|
||||
// FIXME(const_trait_impl): remove this
|
||||
let constness = if constness == hir::Constness::Const
|
||||
|| !is_alias && find_attr!(attrs, AttributeKind::ConstTrait(_))
|
||||
{
|
||||
hir::Constness::Const
|
||||
} else {
|
||||
hir::Constness::NotConst
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
.map(|t| ty::Binder::dummy(t.instantiate_identity()));
|
||||
}
|
||||
}
|
||||
ItemKind::Trait(_, _, _, _, self_bounds, ..)
|
||||
ItemKind::Trait(_, _, _, _, _, self_bounds, ..)
|
||||
| ItemKind::TraitAlias(_, _, self_bounds) => {
|
||||
is_trait = Some((self_bounds, item.span));
|
||||
}
|
||||
|
|
@ -1022,7 +1022,7 @@ pub(super) fn const_conditions<'tcx>(
|
|||
Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Impl(impl_) => (impl_.generics, None, false),
|
||||
hir::ItemKind::Fn { generics, .. } => (generics, None, false),
|
||||
hir::ItemKind::Trait(_, _, _, generics, supertraits, _) => {
|
||||
hir::ItemKind::Trait(_, _, _, _, generics, supertraits, _) => {
|
||||
(generics, Some((item.owner_id.def_id, supertraits)), false)
|
||||
}
|
||||
_ => bug!("const_conditions called on wrong item: {def_id:?}"),
|
||||
|
|
|
|||
|
|
@ -634,7 +634,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
| hir::ItemKind::Enum(_, generics, _)
|
||||
| hir::ItemKind::Struct(_, generics, _)
|
||||
| hir::ItemKind::Union(_, generics, _)
|
||||
| hir::ItemKind::Trait(_, _, _, generics, ..)
|
||||
| hir::ItemKind::Trait(_, _, _, _, generics, ..)
|
||||
| hir::ItemKind::TraitAlias(_, generics, ..)
|
||||
| hir::ItemKind::Impl(&hir::Impl { generics, .. }) => {
|
||||
// These kinds of items have only early-bound lifetime parameters.
|
||||
|
|
|
|||
|
|
@ -525,6 +525,7 @@ pub(crate) struct ConstImplForNonConstTrait {
|
|||
pub trait_name: String,
|
||||
#[suggestion(
|
||||
applicability = "machine-applicable",
|
||||
// FIXME(const_trait_impl) fix this suggestion
|
||||
code = "#[const_trait] ",
|
||||
style = "verbose"
|
||||
)]
|
||||
|
|
@ -548,6 +549,7 @@ pub(crate) struct ConstBoundForNonConstTrait {
|
|||
pub suggestion_pre: &'static str,
|
||||
#[suggestion(
|
||||
applicability = "machine-applicable",
|
||||
// FIXME(const_trait_impl) fix this suggestion
|
||||
code = "#[const_trait] ",
|
||||
style = "verbose"
|
||||
)]
|
||||
|
|
|
|||
|
|
@ -635,7 +635,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
self.suggest_adding_type_and_const_args(err);
|
||||
}
|
||||
ExcessTypesOrConsts { .. } => {
|
||||
// this can happen with `[const] T` where T isn't a const_trait.
|
||||
// this can happen with `[const] T` where T isn't a `const trait`.
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
};
|
||||
|
||||
let (trait_generics, trait_bounds) = match parent_trait.kind {
|
||||
hir::ItemKind::Trait(_, _, _, generics, supertraits, _) => (generics, supertraits),
|
||||
hir::ItemKind::Trait(_, _, _, _, generics, supertraits, _) => (generics, supertraits),
|
||||
hir::ItemKind::TraitAlias(_, generics, supertraits) => (generics, supertraits),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -735,8 +735,17 @@ impl<'a> State<'a> {
|
|||
}
|
||||
self.bclose(item.span, cb);
|
||||
}
|
||||
hir::ItemKind::Trait(is_auto, safety, ident, generics, bounds, trait_items) => {
|
||||
hir::ItemKind::Trait(
|
||||
constness,
|
||||
is_auto,
|
||||
safety,
|
||||
ident,
|
||||
generics,
|
||||
bounds,
|
||||
trait_items,
|
||||
) => {
|
||||
let (cb, ib) = self.head("");
|
||||
self.print_constness(constness);
|
||||
self.print_is_auto(is_auto);
|
||||
self.print_safety(safety);
|
||||
self.word_nbsp("trait");
|
||||
|
|
|
|||
|
|
@ -1189,7 +1189,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
entry.1.insert((self_ty.span, ""));
|
||||
}
|
||||
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,
|
||||
..
|
||||
})) => {
|
||||
|
|
@ -1201,7 +1201,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
Some(
|
||||
Node::Item(hir::Item {
|
||||
kind:
|
||||
hir::ItemKind::Trait(_, _, ident, ..)
|
||||
hir::ItemKind::Trait(_, _, _, ident, ..)
|
||||
| hir::ItemKind::TraitAlias(ident, ..),
|
||||
..
|
||||
})
|
||||
|
|
@ -4084,7 +4084,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
return;
|
||||
}
|
||||
Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Trait(_, _, ident, _, bounds, _),
|
||||
kind: hir::ItemKind::Trait(_, _, _, ident, _, bounds, _),
|
||||
..
|
||||
}) => {
|
||||
let (sp, sep, article) = if bounds.is_empty() {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable {
|
|||
let def_id = item.owner_id.to_def_id();
|
||||
// NOTE(nbdd0121): use `dyn_compatibility_violations` instead of `is_dyn_compatible` because
|
||||
// the latter will report `where_clause_object_safety` lint.
|
||||
if let hir::ItemKind::Trait(_, _, ident, ..) = item.kind
|
||||
if let hir::ItemKind::Trait(_, _, _, ident, ..) = item.kind
|
||||
&& cx.tcx.is_dyn_compatible(def_id)
|
||||
{
|
||||
let direct_super_traits_iter = cx
|
||||
|
|
|
|||
|
|
@ -1131,7 +1131,7 @@ fn should_encode_mir(
|
|||
&& reachable_set.contains(&def_id)
|
||||
&& (generics.requires_monomorphization(tcx)
|
||||
|| tcx.cross_crate_inlinable(def_id)));
|
||||
// The function has a `const` modifier or is in a `#[const_trait]`.
|
||||
// The function has a `const` modifier or is in a `const trait`.
|
||||
let is_const_fn = tcx.is_const_fn(def_id.to_def_id())
|
||||
|| tcx.is_const_default_method(def_id.to_def_id());
|
||||
(is_const_fn, opt)
|
||||
|
|
|
|||
|
|
@ -940,7 +940,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}) => until_within(*outer_span, ty.span),
|
||||
// With generics and bounds.
|
||||
Node::Item(Item {
|
||||
kind: ItemKind::Trait(_, _, _, generics, bounds, _),
|
||||
kind: ItemKind::Trait(_, _, _, _, generics, bounds, _),
|
||||
span: outer_span,
|
||||
..
|
||||
})
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ pub struct TraitDef {
|
|||
|
||||
pub safety: hir::Safety,
|
||||
|
||||
/// Whether this trait has been annotated with `#[const_trait]`.
|
||||
/// Whether this trait is `const`.
|
||||
pub constness: hir::Constness,
|
||||
|
||||
/// If `true`, then this trait had the `#[rustc_paren_sugar]`
|
||||
|
|
|
|||
|
|
@ -855,6 +855,7 @@ parse_trailing_vert_not_allowed = a trailing `|` is not allowed in an or-pattern
|
|||
.suggestion = remove the `{$token}`
|
||||
|
||||
parse_trait_alias_cannot_be_auto = trait aliases cannot be `auto`
|
||||
parse_trait_alias_cannot_be_const = trait aliases cannot be `const`
|
||||
parse_trait_alias_cannot_be_unsafe = trait aliases cannot be `unsafe`
|
||||
|
||||
parse_transpose_dyn_or_impl = `for<...>` expected after `{$kw}`, not before
|
||||
|
|
|
|||
|
|
@ -1961,6 +1961,14 @@ pub(crate) struct TraitAliasCannotBeAuto {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(parse_trait_alias_cannot_be_const)]
|
||||
pub(crate) struct TraitAliasCannotBeConst {
|
||||
#[primary_span]
|
||||
#[label(parse_trait_alias_cannot_be_const)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(parse_trait_alias_cannot_be_unsafe)]
|
||||
pub(crate) struct TraitAliasCannotBeUnsafe {
|
||||
|
|
|
|||
|
|
@ -244,6 +244,9 @@ impl<'a> Parser<'a> {
|
|||
self.bump(); // `static`
|
||||
let mutability = self.parse_mutability();
|
||||
self.parse_static_item(safety, mutability)?
|
||||
} else if self.check_keyword(exp!(Trait)) || self.check_trait_front_matter() {
|
||||
// TRAIT ITEM
|
||||
self.parse_item_trait(attrs, lo)?
|
||||
} else if let Const::Yes(const_span) = self.parse_constness(Case::Sensitive) {
|
||||
// CONST ITEM
|
||||
if self.token.is_keyword(kw::Impl) {
|
||||
|
|
@ -262,9 +265,6 @@ impl<'a> Parser<'a> {
|
|||
define_opaque: None,
|
||||
}))
|
||||
}
|
||||
} else if self.check_keyword(exp!(Trait)) || self.check_auto_or_unsafe_trait_item() {
|
||||
// TRAIT ITEM
|
||||
self.parse_item_trait(attrs, lo)?
|
||||
} else if self.check_keyword(exp!(Impl))
|
||||
|| self.check_keyword(exp!(Unsafe)) && self.is_keyword_ahead(1, &[kw::Impl])
|
||||
{
|
||||
|
|
@ -373,7 +373,7 @@ impl<'a> Parser<'a> {
|
|||
pub(super) fn is_path_start_item(&mut self) -> bool {
|
||||
self.is_kw_followed_by_ident(kw::Union) // no: `union::b`, yes: `union U { .. }`
|
||||
|| self.is_reuse_path_item()
|
||||
|| self.check_auto_or_unsafe_trait_item() // no: `auto::b`, yes: `auto trait X { .. }`
|
||||
|| self.check_trait_front_matter() // no: `auto::b`, yes: `auto trait X { .. }`
|
||||
|| self.is_async_fn() // no(2015): `async::b`, yes: `async fn`
|
||||
|| matches!(self.is_macro_rules_item(), IsMacroRulesItem::Yes{..}) // no: `macro_rules::b`, yes: `macro_rules! mac`
|
||||
}
|
||||
|
|
@ -872,16 +872,19 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Is this an `(unsafe auto? | auto) trait` item?
|
||||
fn check_auto_or_unsafe_trait_item(&mut self) -> bool {
|
||||
/// Is this an `(const unsafe? auto?| unsafe auto? | auto) trait` item?
|
||||
fn check_trait_front_matter(&mut self) -> bool {
|
||||
// auto trait
|
||||
self.check_keyword(exp!(Auto)) && self.is_keyword_ahead(1, &[kw::Trait])
|
||||
// unsafe auto trait
|
||||
|| self.check_keyword(exp!(Unsafe)) && self.is_keyword_ahead(1, &[kw::Trait, kw::Auto])
|
||||
|| self.check_keyword(exp!(Const)) && ((self.is_keyword_ahead(1, &[kw::Trait]) || self.is_keyword_ahead(1, &[kw::Auto]) && self.is_keyword_ahead(2, &[kw::Trait]))
|
||||
|| self.is_keyword_ahead(1, &[kw::Unsafe]) && self.is_keyword_ahead(2, &[kw::Trait, kw::Auto]))
|
||||
}
|
||||
|
||||
/// Parses `unsafe? auto? trait Foo { ... }` or `trait Foo = Bar;`.
|
||||
fn parse_item_trait(&mut self, attrs: &mut AttrVec, lo: Span) -> PResult<'a, ItemKind> {
|
||||
let constness = self.parse_constness(Case::Sensitive);
|
||||
let safety = self.parse_safety(Case::Sensitive);
|
||||
// Parse optional `auto` prefix.
|
||||
let is_auto = if self.eat_keyword(exp!(Auto)) {
|
||||
|
|
@ -913,6 +916,9 @@ impl<'a> Parser<'a> {
|
|||
self.expect_semi()?;
|
||||
|
||||
let whole_span = lo.to(self.prev_token.span);
|
||||
if let Const::Yes(_) = constness {
|
||||
self.dcx().emit_err(errors::TraitAliasCannotBeConst { span: whole_span });
|
||||
}
|
||||
if is_auto == IsAuto::Yes {
|
||||
self.dcx().emit_err(errors::TraitAliasCannotBeAuto { span: whole_span });
|
||||
}
|
||||
|
|
@ -927,7 +933,15 @@ impl<'a> Parser<'a> {
|
|||
// It's a normal trait.
|
||||
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 { is_auto, safety, ident, generics, bounds, items })))
|
||||
Ok(ItemKind::Trait(Box::new(Trait {
|
||||
constness,
|
||||
is_auto,
|
||||
safety,
|
||||
ident,
|
||||
generics,
|
||||
bounds,
|
||||
items,
|
||||
})))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@ passes_unused_capture_maybe_capture_ref = value captured by `{$name}` is never r
|
|||
.help = did you mean to capture by reference instead?
|
||||
|
||||
passes_unused_default_method_body_const_note =
|
||||
`default_method_body_is_const` has been replaced with `#[const_trait]` on traits
|
||||
`default_method_body_is_const` has been replaced with `const` on traits
|
||||
|
||||
passes_unused_duplicate =
|
||||
unused attribute
|
||||
|
|
|
|||
|
|
@ -1160,7 +1160,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
match item.kind {
|
||||
ItemKind::Enum(_, generics, _) | ItemKind::Struct(_, generics, _)
|
||||
if generics.params.len() != 0 => {}
|
||||
ItemKind::Trait(_, _, _, generics, _, items)
|
||||
ItemKind::Trait(_, _, _, _, generics, _, items)
|
||||
if generics.params.len() != 0
|
||||
|| items.iter().any(|item| {
|
||||
matches!(self.tcx.def_kind(item.owner_id), DefKind::AssocTy)
|
||||
|
|
|
|||
|
|
@ -453,7 +453,7 @@ pub fn report_dyn_incompatibility<'tcx>(
|
|||
let trait_str = tcx.def_path_str(trait_def_id);
|
||||
let trait_span = tcx.hir_get_if_local(trait_def_id).and_then(|node| match node {
|
||||
hir::Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Trait(_, _, ident, ..) | hir::ItemKind::TraitAlias(ident, _, _) => {
|
||||
hir::ItemKind::Trait(_, _, _, ident, ..) | hir::ItemKind::TraitAlias(ident, _, _) => {
|
||||
Some(ident.span)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
let node = self.tcx.hir_node_by_def_id(body_id);
|
||||
match node {
|
||||
hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Trait(_, _, ident, generics, bounds, _),
|
||||
kind: hir::ItemKind::Trait(_, _, _, ident, generics, bounds, _),
|
||||
..
|
||||
}) if self_ty == self.tcx.types.self_param => {
|
||||
assert!(param_ty);
|
||||
|
|
@ -330,7 +330,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
}
|
||||
hir::Node::Item(hir::Item {
|
||||
kind:
|
||||
hir::ItemKind::Trait(_, _, _, generics, ..)
|
||||
hir::ItemKind::Trait(_, _, _, _, generics, ..)
|
||||
| hir::ItemKind::Impl(hir::Impl { generics, .. }),
|
||||
..
|
||||
}) if projection.is_some() => {
|
||||
|
|
@ -354,7 +354,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
hir::ItemKind::Struct(_, generics, _)
|
||||
| hir::ItemKind::Enum(_, generics, _)
|
||||
| hir::ItemKind::Union(_, generics, _)
|
||||
| hir::ItemKind::Trait(_, _, _, generics, ..)
|
||||
| hir::ItemKind::Trait(_, _, _, _, generics, ..)
|
||||
| hir::ItemKind::Impl(hir::Impl { generics, .. })
|
||||
| hir::ItemKind::Fn { generics, .. }
|
||||
| hir::ItemKind::TyAlias(_, generics, _)
|
||||
|
|
@ -414,7 +414,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
hir::ItemKind::Struct(_, generics, _)
|
||||
| hir::ItemKind::Enum(_, generics, _)
|
||||
| hir::ItemKind::Union(_, generics, _)
|
||||
| hir::ItemKind::Trait(_, _, _, generics, ..)
|
||||
| hir::ItemKind::Trait(_, _, _, _, generics, ..)
|
||||
| hir::ItemKind::Impl(hir::Impl { generics, .. })
|
||||
| hir::ItemKind::Fn { generics, .. }
|
||||
| hir::ItemKind::TyAlias(_, generics, _)
|
||||
|
|
@ -3436,7 +3436,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
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> {
|
|||
match self.tcx.parent_hir_node(self.tcx.local_def_id_to_hir_id(anon_reg.scope))
|
||||
{
|
||||
hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Trait(_, _, _, generics, ..),
|
||||
kind: hir::ItemKind::Trait(_, _, _, _, generics, ..),
|
||||
..
|
||||
})
|
||||
| hir::Node::Item(hir::Item {
|
||||
|
|
|
|||
|
|
@ -67,10 +67,8 @@ in [`wfcheck::check_impl`].
|
|||
Here's an example:
|
||||
|
||||
```rust
|
||||
#[const_trait]
|
||||
trait Bar {}
|
||||
#[const_trait]
|
||||
trait Foo: ~const Bar {}
|
||||
const trait Bar {}
|
||||
const trait Foo: ~const Bar {}
|
||||
// `const_conditions` contains `HostEffect(Self: Bar, maybe)`
|
||||
|
||||
impl const Bar for () {}
|
||||
|
|
@ -85,8 +83,7 @@ predicates of the trait method, and we attempt to prove the predicates of the
|
|||
impl method. We do the same for `const_conditions`:
|
||||
|
||||
```rust
|
||||
#[const_trait]
|
||||
trait Foo {
|
||||
const trait Foo {
|
||||
fn hi<T: ~const Default>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2865,7 +2865,7 @@ fn clean_maybe_renamed_item<'tcx>(
|
|||
ItemKind::Fn { ref sig, generics, body: body_id, .. } => {
|
||||
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
|
||||
}
|
||||
ItemKind::Trait(_, _, _, generics, bounds, item_ids) => {
|
||||
ItemKind::Trait(_, _, _, _, generics, bounds, item_ids) => {
|
||||
let items = item_ids
|
||||
.iter()
|
||||
.map(|&ti| clean_trait_item(cx.tcx.hir_trait_item(ti), cx))
|
||||
|
|
|
|||
|
|
@ -648,7 +648,7 @@ impl Item {
|
|||
let sig = tcx.fn_sig(def_id).skip_binder();
|
||||
let constness = if tcx.is_const_fn(def_id) {
|
||||
// rustc's `is_const_fn` returns `true` for associated functions that have an `impl const` parent
|
||||
// or that have a `#[const_trait]` parent. Do not display those as `const` in rustdoc because we
|
||||
// or that have a `const trait` parent. Do not display those as `const` in rustdoc because we
|
||||
// won't be printing correct syntax plus the syntax is unstable.
|
||||
match tcx.opt_associated_item(def_id) {
|
||||
Some(ty::AssocItem {
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
|
|||
cur_f = Some(field);
|
||||
}
|
||||
},
|
||||
ItemKind::Trait(is_auto, _safety, _ident, _generics, _generic_bounds, item_ref)
|
||||
ItemKind::Trait(_constness, is_auto, _safety, _ident, _generics, _generic_bounds, item_ref)
|
||||
if self.enable_ordering_for_trait && *is_auto == IsAuto::No =>
|
||||
{
|
||||
let mut cur_t: Option<(TraitItemId, Ident)> = None;
|
||||
|
|
|
|||
|
|
@ -740,7 +740,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
|
|||
);
|
||||
}
|
||||
},
|
||||
ItemKind::Trait(_, unsafety, ..) => match (headers.safety, unsafety) {
|
||||
ItemKind::Trait(_, _, unsafety, ..) => match (headers.safety, unsafety) {
|
||||
(false, Safety::Unsafe) => span_lint(
|
||||
cx,
|
||||
MISSING_SAFETY_DOC,
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ declare_lint_pass!(LenZero => [LEN_ZERO, LEN_WITHOUT_IS_EMPTY, COMPARISON_TO_EMP
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for LenZero {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
|
||||
if let ItemKind::Trait(_, _, ident, _, _, trait_items) = item.kind
|
||||
if let ItemKind::Trait(_, _, _, ident, _, _, trait_items) = item.kind
|
||||
&& !item.span.from_expansion()
|
||||
{
|
||||
check_trait_items(cx, item, ident, trait_items);
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
|||
let attrs = cx.tcx.hir_attrs(it.hir_id());
|
||||
check_missing_inline_attrs(cx, attrs, it.span, desc);
|
||||
},
|
||||
hir::ItemKind::Trait(ref _is_auto, ref _unsafe, _ident, _generics, _bounds, trait_items) => {
|
||||
hir::ItemKind::Trait(ref _constness, ref _is_auto, ref _unsafe, _ident, _generics, _bounds, trait_items) => {
|
||||
// note: we need to check if the trait is exported so we can't use
|
||||
// `LateLintPass::check_trait_item` here.
|
||||
for &tit in trait_items {
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
|
|||
// special handling for self trait bounds as these are not considered generics
|
||||
// ie. trait Foo: Display {}
|
||||
if let Item {
|
||||
kind: ItemKind::Trait(_, _, _, _, bounds, ..),
|
||||
kind: ItemKind::Trait(_, _, _, _, _, bounds, ..),
|
||||
..
|
||||
} = item
|
||||
{
|
||||
|
|
@ -133,7 +133,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
|
|||
..
|
||||
}) = segments.first()
|
||||
&& let Some(Node::Item(Item {
|
||||
kind: ItemKind::Trait(_, _, _, _, self_bounds, _),
|
||||
kind: ItemKind::Trait(_, _, _, _, _, self_bounds, _),
|
||||
..
|
||||
})) = cx.tcx.hir_get_if_local(*def_id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ impl LateLintPass<'_> for UpperCaseAcronyms {
|
|||
return;
|
||||
}
|
||||
match it.kind {
|
||||
ItemKind::TyAlias(ident, ..) | ItemKind::Struct(ident, ..) | ItemKind::Trait(_, _, ident, ..) => {
|
||||
ItemKind::TyAlias(ident, ..) | ItemKind::Struct(ident, ..) | ItemKind::Trait(_, _, _, ident, ..) => {
|
||||
check_ident(cx, &ident, it.hir_id(), self.upper_case_acronyms_aggressive);
|
||||
},
|
||||
ItemKind::Enum(ident, _, ref enumdef) => {
|
||||
|
|
|
|||
|
|
@ -444,6 +444,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
|
|||
},
|
||||
(
|
||||
Trait(box ast::Trait {
|
||||
constness: lc,
|
||||
is_auto: la,
|
||||
safety: lu,
|
||||
ident: li,
|
||||
|
|
@ -452,6 +453,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
|
|||
items: lis,
|
||||
}),
|
||||
Trait(box ast::Trait {
|
||||
constness: rc,
|
||||
is_auto: ra,
|
||||
safety: ru,
|
||||
ident: ri,
|
||||
|
|
@ -460,7 +462,8 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
|
|||
items: ris,
|
||||
}),
|
||||
) => {
|
||||
la == ra
|
||||
matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
|
||||
&& la == ra
|
||||
&& matches!(lu, Safety::Default) == matches!(ru, Safety::Default)
|
||||
&& eq_id(*li, *ri)
|
||||
&& eq_generics(lg, rg)
|
||||
|
|
|
|||
|
|
@ -252,11 +252,11 @@ 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 {
|
||||
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("}")),
|
||||
_ => return (Pat::Str(""), Pat::Str("")),
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ mod issue14871 {
|
|||
const ONE: Self;
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait NumberConstants {
|
||||
pub const trait NumberConstants {
|
||||
fn constant(value: usize) -> Self;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ mod issue14871 {
|
|||
const ONE: Self;
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait NumberConstants {
|
||||
pub const trait NumberConstants {
|
||||
fn constant(value: usize) -> Self;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
// Reduced test case from https://github.com/rust-lang/rust-clippy/issues/14658
|
||||
|
||||
#[const_trait]
|
||||
trait ConstTrait {
|
||||
const trait ConstTrait {
|
||||
fn method(self);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
// Reduced test case from https://github.com/rust-lang/rust-clippy/issues/14658
|
||||
|
||||
#[const_trait]
|
||||
trait ConstTrait {
|
||||
const trait ConstTrait {
|
||||
fn method(self);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this could be a `const fn`
|
||||
--> tests/ui/missing_const_for_fn/const_trait.rs:24:1
|
||||
--> tests/ui/missing_const_for_fn/const_trait.rs:23:1
|
||||
|
|
||||
LL | / fn can_be_const() {
|
||||
LL | | 0u64.method();
|
||||
|
|
|
|||
|
|
@ -167,8 +167,7 @@ where
|
|||
}
|
||||
|
||||
// #13476
|
||||
#[const_trait]
|
||||
trait ConstTrait {}
|
||||
const trait ConstTrait {}
|
||||
const fn const_trait_bounds_good<T: ConstTrait + [const] ConstTrait>() {}
|
||||
|
||||
const fn const_trait_bounds_bad<T: [const] ConstTrait>() {}
|
||||
|
|
|
|||
|
|
@ -167,8 +167,7 @@ where
|
|||
}
|
||||
|
||||
// #13476
|
||||
#[const_trait]
|
||||
trait ConstTrait {}
|
||||
const trait ConstTrait {}
|
||||
const fn const_trait_bounds_good<T: ConstTrait + [const] ConstTrait>() {}
|
||||
|
||||
const fn const_trait_bounds_bad<T: [const] ConstTrait + [const] ConstTrait>() {}
|
||||
|
|
|
|||
|
|
@ -59,19 +59,19 @@ LL | fn bad_trait_object(arg0: &(dyn Any + Send + Send)) {
|
|||
| ^^^^^^^^^^^^^^^^^ help: try: `Any + Send`
|
||||
|
||||
error: these bounds contain repeated elements
|
||||
--> tests/ui/trait_duplication_in_bounds.rs:174:36
|
||||
--> tests/ui/trait_duplication_in_bounds.rs:173:36
|
||||
|
|
||||
LL | const fn const_trait_bounds_bad<T: [const] ConstTrait + [const] ConstTrait>() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[const] ConstTrait`
|
||||
|
||||
error: these where clauses contain repeated elements
|
||||
--> tests/ui/trait_duplication_in_bounds.rs:181:8
|
||||
--> tests/ui/trait_duplication_in_bounds.rs:180:8
|
||||
|
|
||||
LL | T: IntoIterator<Item = U::Owned> + IntoIterator<Item = U::Owned>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `IntoIterator<Item = U::Owned>`
|
||||
|
||||
error: these where clauses contain repeated elements
|
||||
--> tests/ui/trait_duplication_in_bounds.rs:203:8
|
||||
--> tests/ui/trait_duplication_in_bounds.rs:202:8
|
||||
|
|
||||
LL | T: AssocConstTrait<ASSOC = 0> + AssocConstTrait<ASSOC = 0>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `AssocConstTrait<ASSOC = 0>`
|
||||
|
|
|
|||
|
|
@ -1011,8 +1011,7 @@ pub mod ops {
|
|||
}
|
||||
|
||||
#[lang = "add_assign"]
|
||||
#[const_trait]
|
||||
pub trait AddAssign<Rhs = Self> {
|
||||
pub const trait AddAssign<Rhs = Self> {
|
||||
fn add_assign(&mut self, rhs: Rhs);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1172,6 +1172,7 @@ pub(crate) fn format_trait(
|
|||
unreachable!();
|
||||
};
|
||||
let ast::Trait {
|
||||
constness,
|
||||
is_auto,
|
||||
safety,
|
||||
ident,
|
||||
|
|
@ -1182,7 +1183,8 @@ pub(crate) fn format_trait(
|
|||
|
||||
let mut result = String::with_capacity(128);
|
||||
let header = format!(
|
||||
"{}{}{}trait ",
|
||||
"{}{}{}{}trait ",
|
||||
format_constness(constness),
|
||||
format_visibility(context, &item.vis),
|
||||
format_safety(safety),
|
||||
format_auto(is_auto),
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
#![feature(const_trait_impl)]
|
||||
|
||||
#[const_trait]
|
||||
trait Tr {
|
||||
const trait Tr {
|
||||
async fn ft1() {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: `[const]` is not allowed here
|
|||
LL | trait Bar: ~const Foo {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
LL | trait Bar: ~const Foo {}
|
||||
|
|
@ -30,24 +30,24 @@ LL | const fn foo<T: ~const Bar>(x: &T) {
|
|||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
LL | trait Bar: ~const Foo {}
|
||||
| ^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> const-super-trait.rs:9:17
|
||||
|
|
||||
LL | const fn foo<T: ~const Bar>(x: &T) {
|
||||
| ^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Bar: ~const Foo {}
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -4,30 +4,30 @@ error: `[const]` is not allowed here
|
|||
LL | trait Bar: ~const Foo {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
LL | trait Bar: ~const Foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
LL | trait Bar: ~const Foo {}
|
||||
| ^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> const-super-trait.rs:9:17
|
||||
|
|
||||
LL | const fn foo<T: ~const Bar>(x: &T) {
|
||||
| ^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Bar` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Bar: ~const Foo {}
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: `[const]` is not allowed here
|
|||
7 | trait Bar: ~const Foo {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
|
|
@ -26,25 +26,25 @@ error[E0658]: const trait impls are experimental
|
|||
|
|
||||
= note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
| ^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
note: `Foo` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
note: `Foo` can't be used with `[const]` because it isn't `const`
|
||||
--> const-super-trait.rs:3:1
|
||||
|
|
||||
3 | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> const-super-trait.rs:9:17
|
||||
|
|
||||
9 | const fn foo<T: ~const Bar>(x: &T) {
|
||||
| ^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
note: `Bar` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
note: `Bar` can't be used with `[const]` because it isn't `const`
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: `[const]` is not allowed here
|
|||
7 | trait Bar: ~const Foo {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
|
|
@ -16,25 +16,25 @@ error[E0554]: `#![feature]` may not be used on the NIGHTLY release channel
|
|||
1 | #![cfg_attr(feature_enabled, feature(const_trait_impl))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> const-super-trait.rs:7:12
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
| ^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
note: `Foo` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
note: `Foo` can't be used with `[const]` because it isn't `const`
|
||||
--> const-super-trait.rs:3:1
|
||||
|
|
||||
3 | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> const-super-trait.rs:9:17
|
||||
|
|
||||
9 | const fn foo<T: ~const Bar>(x: &T) {
|
||||
| ^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
note: `Bar` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
note: `Bar` can't be used with `[const]` because it isn't `const`
|
||||
--> const-super-trait.rs:7:1
|
||||
|
|
||||
7 | trait Bar: ~const Foo {}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ fn main() {
|
|||
.env("RUSTC_BOOTSTRAP", "-1")
|
||||
.cfg("feature_enabled")
|
||||
.run_fail()
|
||||
.assert_stderr_not_contains(
|
||||
"as `#[const_trait]` to allow it to have `const` implementations",
|
||||
)
|
||||
.assert_stderr_not_contains("as `const` to allow it to have `const` implementations")
|
||||
.stderr_utf8();
|
||||
diff()
|
||||
.expected_file("const-super-trait-stable-enabled.stderr")
|
||||
|
|
@ -29,7 +27,7 @@ fn main() {
|
|||
.ui_testing()
|
||||
.run_fail()
|
||||
.assert_stderr_not_contains("enable `#![feature(const_trait_impl)]` in your crate and mark")
|
||||
.assert_stderr_contains("as `#[const_trait]` to allow it to have `const` implementations")
|
||||
.assert_stderr_contains("as `const` to allow it to have `const` implementations")
|
||||
.stderr_utf8();
|
||||
diff()
|
||||
.expected_file("const-super-trait-nightly-enabled.stderr")
|
||||
|
|
@ -40,9 +38,7 @@ fn main() {
|
|||
.env("RUSTC_BOOTSTRAP", "-1")
|
||||
.run_fail()
|
||||
.assert_stderr_not_contains("enable `#![feature(const_trait_impl)]` in your crate and mark")
|
||||
.assert_stderr_not_contains(
|
||||
"as `#[const_trait]` to allow it to have `const` implementations",
|
||||
)
|
||||
.assert_stderr_not_contains("as `const` to allow it to have `const` implementations")
|
||||
.stderr_utf8();
|
||||
diff()
|
||||
.expected_file("const-super-trait-stable-disabled.stderr")
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ struct TryMe;
|
|||
struct Error;
|
||||
|
||||
impl const FromResidual<Error> for TryMe {
|
||||
//~^ ERROR const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
|
||||
//~^ ERROR const `impl` for trait `FromResidual` which is not `const`
|
||||
fn from_residual(residual: Error) -> Self {
|
||||
TryMe
|
||||
}
|
||||
}
|
||||
|
||||
impl const Try for TryMe {
|
||||
//~^ ERROR const `impl` for trait `Try` which is not marked with `#[const_trait]`
|
||||
//~^ ERROR const `impl` for trait `Try` which is not `const`
|
||||
type Output = ();
|
||||
type Residual = Error;
|
||||
fn from_output(output: Self::Output) -> Self {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `FromResidual` which is not `const`
|
||||
--> $DIR/const-try.rs:15:12
|
||||
|
|
||||
LL | impl const FromResidual<Error> for TryMe {
|
||||
| ^^^^^^^^^^^^^^^^^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error: const `impl` for trait `Try` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `Try` which is not `const`
|
||||
--> $DIR/const-try.rs:22:12
|
||||
|
|
||||
LL | impl const Try for TryMe {
|
||||
| ^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error[E0015]: `?` is not allowed on `TryMe` in constant functions
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error: const `impl` for trait `Debug` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `Debug` which is not `const`
|
||||
--> $DIR/rustc-impl-const-stability.rs:15:12
|
||||
|
|
||||
LL | impl const std::fmt::Debug for Data {
|
||||
| ^^^^^^^^^^^^^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,57 +1,57 @@
|
|||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/const_trait_impl.rs:36:9
|
||||
|
|
||||
LL | impl<T: [const] Debug> const A for T {
|
||||
| ^^^^^^^ can't be applied to `Debug`
|
||||
|
|
||||
note: `Debug` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
note: `Debug` can't be used with `[const]` because it isn't `const`
|
||||
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/const_trait_impl.rs:42:9
|
||||
|
|
||||
LL | impl<T: [const] Debug + [const] Sup> const A for T {
|
||||
| ^^^^^^^ can't be applied to `Debug`
|
||||
|
|
||||
note: `Debug` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
note: `Debug` can't be used with `[const]` because it isn't `const`
|
||||
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/const_trait_impl.rs:48:9
|
||||
|
|
||||
LL | impl<T: [const] Debug + [const] Sub> const A for T {
|
||||
| ^^^^^^^ can't be applied to `Debug`
|
||||
|
|
||||
note: `Debug` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
note: `Debug` can't be used with `[const]` because it isn't `const`
|
||||
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/const_trait_impl.rs:42:9
|
||||
|
|
||||
LL | impl<T: [const] Debug + [const] Sup> const A for T {
|
||||
| ^^^^^^^ can't be applied to `Debug`
|
||||
|
|
||||
note: `Debug` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
note: `Debug` can't be used with `[const]` because it isn't `const`
|
||||
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/const_trait_impl.rs:36:9
|
||||
|
|
||||
LL | impl<T: [const] Debug> const A for T {
|
||||
| ^^^^^^^ can't be applied to `Debug`
|
||||
|
|
||||
note: `Debug` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
note: `Debug` can't be used with `[const]` because it isn't `const`
|
||||
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/const_trait_impl.rs:48:9
|
||||
|
|
||||
LL | impl<T: [const] Debug + [const] Sub> const A for T {
|
||||
| ^^^^^^^ can't be applied to `Debug`
|
||||
|
|
||||
note: `Debug` can't be used with `[const]` because it isn't annotated with `#[const_trait]`
|
||||
note: `Debug` can't be used with `[const]` because it isn't `const`
|
||||
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ impl Foo {
|
|||
}
|
||||
|
||||
#[stable(feature = "stable", since = "1.0.0")]
|
||||
#[const_trait]
|
||||
pub trait Bar {
|
||||
pub const trait Bar {
|
||||
//~^ ERROR trait has missing const stability attribute
|
||||
#[stable(feature = "stable", since = "1.0.0")]
|
||||
fn fun();
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ LL | pub const fn foo() {}
|
|||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait has missing const stability attribute
|
||||
--> $DIR/missing-const-stability.rs:24:1
|
||||
--> $DIR/missing-const-stability.rs:23:1
|
||||
|
|
||||
LL | / pub trait Bar {
|
||||
LL | / pub const trait Bar {
|
||||
LL | |
|
||||
LL | | #[stable(feature = "stable", since = "1.0.0")]
|
||||
LL | | fn fun();
|
||||
|
|
@ -15,7 +15,7 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: function has missing const stability attribute
|
||||
--> $DIR/missing-const-stability.rs:37:1
|
||||
--> $DIR/missing-const-stability.rs:36:1
|
||||
|
|
||||
LL | pub const unsafe fn size_of_val<T>(x: *const T) -> usize { 42 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ error: `[const]` is not allowed here
|
|||
LL | type Type<T: [const] Trait>: [const] Trait;
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: associated types in non-`#[const_trait]` traits cannot have `[const]` trait bounds
|
||||
note: associated types in non-`const` traits cannot have `[const]` trait bounds
|
||||
--> $DIR/conditionally-const-invalid-places.rs:25:5
|
||||
|
|
||||
LL | type Type<T: [const] Trait>: [const] Trait;
|
||||
|
|
@ -84,7 +84,7 @@ error: `[const]` is not allowed here
|
|||
LL | type Type<T: [const] Trait>: [const] Trait;
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: associated types in non-`#[const_trait]` traits cannot have `[const]` trait bounds
|
||||
note: associated types in non-`const` traits cannot have `[const]` trait bounds
|
||||
--> $DIR/conditionally-const-invalid-places.rs:25:5
|
||||
|
|
||||
LL | type Type<T: [const] Trait>: [const] Trait;
|
||||
|
|
@ -180,7 +180,7 @@ error: `[const]` is not allowed here
|
|||
LL | trait Child0: [const] Trait {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> $DIR/conditionally-const-invalid-places.rs:52:1
|
||||
|
|
||||
LL | trait Child0: [const] Trait {}
|
||||
|
|
@ -192,7 +192,7 @@ error: `[const]` is not allowed here
|
|||
LL | trait Child1 where Self: [const] Trait {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> $DIR/conditionally-const-invalid-places.rs:53:1
|
||||
|
|
||||
LL | trait Child1 where Self: [const] Trait {}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@
|
|||
trait NonConst {}
|
||||
|
||||
const fn perform<T: [const] NonConst>() {}
|
||||
//~^ ERROR `[const]` can only be applied to `#[const_trait]` traits
|
||||
//~| ERROR `[const]` can only be applied to `#[const_trait]` traits
|
||||
//~^ ERROR `[const]` can only be applied to `const` traits
|
||||
//~| ERROR `[const]` can only be applied to `const` traits
|
||||
|
||||
fn operate<T: const NonConst>() {}
|
||||
//~^ ERROR `const` can only be applied to `#[const_trait]` traits
|
||||
//~^ ERROR `const` can only be applied to `const` traits
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,33 @@
|
|||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/const-bounds-non-const-trait.rs:6:21
|
||||
|
|
||||
LL | const fn perform<T: [const] NonConst>() {}
|
||||
| ^^^^^^^ can't be applied to `NonConst`
|
||||
|
|
||||
help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `NonConst` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait NonConst {}
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/const-bounds-non-const-trait.rs:6:21
|
||||
|
|
||||
LL | const fn perform<T: [const] NonConst>() {}
|
||||
| ^^^^^^^ can't be applied to `NonConst`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `NonConst` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait NonConst {}
|
||||
| ++++++++++++++
|
||||
|
||||
error: `const` can only be applied to `#[const_trait]` traits
|
||||
error: `const` can only be applied to `const` traits
|
||||
--> $DIR/const-bounds-non-const-trait.rs:10:15
|
||||
|
|
||||
LL | fn operate<T: const NonConst>() {}
|
||||
| ^^^^^ can't be applied to `NonConst`
|
||||
|
|
||||
help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `NonConst` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait NonConst {}
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@
|
|||
pub trait A {}
|
||||
|
||||
impl const A for () {}
|
||||
//~^ ERROR: const `impl` for trait `A` which is not marked with `#[const_trait]`
|
||||
//~^ ERROR: const `impl` for trait `A` which is not `const`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
error: const `impl` for trait `A` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `A` which is not `const`
|
||||
--> $DIR/const-impl-requires-const-trait.rs:6:12
|
||||
|
|
||||
LL | impl const A for () {}
|
||||
| ^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
help: mark `A` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `A` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] pub trait A {}
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
#![feature(const_trait_impl)]
|
||||
// FIXME(const_trait_impl) add effects
|
||||
//@ edition: 2021
|
||||
|
||||
#[const_trait]
|
||||
trait Trait {}
|
||||
const trait Trait {}
|
||||
|
||||
fn main() {
|
||||
let _: &dyn const Trait; //~ ERROR const trait bounds are not allowed in trait object types
|
||||
|
|
@ -14,7 +12,7 @@ fn main() {
|
|||
trait NonConst {}
|
||||
const fn handle(_: &dyn const NonConst) {}
|
||||
//~^ ERROR const trait bounds are not allowed in trait object types
|
||||
//~| ERROR `const` can only be applied to `#[const_trait]` traits
|
||||
//~| ERROR `const` can only be applied to `const` traits
|
||||
const fn take(_: &dyn [const] NonConst) {}
|
||||
//~^ ERROR `[const]` is not allowed here
|
||||
//~| ERROR `[const]` can only be applied to `#[const_trait]` traits
|
||||
//~| ERROR `[const]` can only be applied to `const` traits
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error: const trait bounds are not allowed in trait object types
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:9:17
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:7:17
|
||||
|
|
||||
LL | let _: &dyn const Trait;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: `[const]` is not allowed here
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:10:17
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:8:17
|
||||
|
|
||||
LL | let _: &dyn [const] Trait;
|
||||
| ^^^^^^^
|
||||
|
|
@ -13,37 +13,37 @@ LL | let _: &dyn [const] Trait;
|
|||
= note: trait objects cannot have `[const]` trait bounds
|
||||
|
||||
error: const trait bounds are not allowed in trait object types
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:15:25
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:13:25
|
||||
|
|
||||
LL | const fn handle(_: &dyn const NonConst) {}
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: `[const]` is not allowed here
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:18:23
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:16:23
|
||||
|
|
||||
LL | const fn take(_: &dyn [const] NonConst) {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: trait objects cannot have `[const]` trait bounds
|
||||
|
||||
error: `const` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:15:25
|
||||
error: `const` can only be applied to `const` traits
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:13:25
|
||||
|
|
||||
LL | const fn handle(_: &dyn const NonConst) {}
|
||||
| ^^^^^ can't be applied to `NonConst`
|
||||
|
|
||||
help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `NonConst` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait NonConst {}
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:18:23
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/const-trait-bounds-trait-objects.rs:16:23
|
||||
|
|
||||
LL | const fn take(_: &dyn [const] NonConst) {}
|
||||
| ^^^^^^^ can't be applied to `NonConst`
|
||||
|
|
||||
help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `NonConst` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait NonConst {}
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#[derive_const(Debug)] //~ ERROR use of unstable library feature
|
||||
//~^ ERROR const `impl` for trait `Debug` which is not marked with `#[const_trait]`
|
||||
//~^ ERROR const `impl` for trait `Debug` which is not `const`
|
||||
//~| ERROR cannot call non-const method
|
||||
pub struct S;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ LL | #[derive_const(Debug)]
|
|||
= help: add `#![feature(derive_const)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: const `impl` for trait `Debug` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `Debug` which is not `const`
|
||||
--> $DIR/derive-const-gate.rs:1:16
|
||||
|
|
||||
LL | #[derive_const(Debug)]
|
||||
| ^^^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error[E0015]: cannot call non-const method `Formatter::<'_>::write_str` in constant functions
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error: const `impl` for trait `Debug` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `Debug` which is not `const`
|
||||
--> $DIR/derive-const-non-const-type.rs:12:16
|
||||
|
|
||||
LL | #[derive_const(Debug)]
|
||||
| ^^^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error[E0015]: cannot call non-const method `Formatter::<'_>::debug_tuple_field1_finish` in constant functions
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
use std::ops::FromResidual;
|
||||
|
||||
impl<T> const FromResidual for T {
|
||||
//~^ ERROR const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
|
||||
//~^ ERROR const `impl` for trait `FromResidual` which is not `const`
|
||||
//~| ERROR type parameter `T` must be used as the type parameter for some local type
|
||||
fn from_residual(t: T) -> _ {
|
||||
//~^ ERROR the placeholder `_` is not allowed
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `FromResidual` which is not `const`
|
||||
--> $DIR/ice-119717-constant-lifetime.rs:6:15
|
||||
|
|
||||
LL | impl<T> const FromResidual for T {
|
||||
| ^^^^^^^^^^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ struct TryMe;
|
|||
struct Error;
|
||||
|
||||
impl const FromResidual<Error> for TryMe {}
|
||||
//~^ ERROR const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
|
||||
//~^ ERROR const `impl` for trait `FromResidual` which is not `const`
|
||||
//~| ERROR not all trait items implemented
|
||||
|
||||
impl const Try for TryMe {
|
||||
//~^ ERROR const `impl` for trait `Try` which is not marked with `#[const_trait]`
|
||||
//~^ ERROR const `impl` for trait `Try` which is not `const`
|
||||
//~| ERROR not all trait items implemented
|
||||
type Output = ();
|
||||
type Residual = Error;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `FromResidual` which is not `const`
|
||||
--> $DIR/ice-126148-failed-to-normalize.rs:8:12
|
||||
|
|
||||
LL | impl const FromResidual<Error> for TryMe {}
|
||||
| ^^^^^^^^^^^^^^^^^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error[E0046]: not all trait items implemented, missing: `from_residual`
|
||||
|
|
@ -15,13 +15,13 @@ LL | impl const FromResidual<Error> for TryMe {}
|
|||
|
|
||||
= help: implement the missing item: `fn from_residual(_: Error) -> Self { todo!() }`
|
||||
|
||||
error: const `impl` for trait `Try` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `Try` which is not `const`
|
||||
--> $DIR/ice-126148-failed-to-normalize.rs:12:12
|
||||
|
|
||||
LL | impl const Try for TryMe {
|
||||
| ^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error[E0046]: not all trait items implemented, missing: `from_output`, `branch`
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ trait Specialize {}
|
|||
trait Foo {}
|
||||
|
||||
impl<T> const Foo for T {}
|
||||
//~^ error: const `impl` for trait `Foo` which is not marked with `#[const_trait]`
|
||||
//~^ error: const `impl` for trait `Foo` which is not `const`
|
||||
|
||||
impl<T> const Foo for T where T: const Specialize {}
|
||||
//~^ error: const `impl` for trait `Foo` which is not marked with `#[const_trait]`
|
||||
//~| error: `const` can only be applied to `#[const_trait]` traits
|
||||
//~^ error: const `impl` for trait `Foo` which is not `const`
|
||||
//~| error: `const` can only be applied to `const` traits
|
||||
//~| error: specialization impl does not specialize any associated items
|
||||
//~| error: cannot specialize on trait `Specialize`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,36 +1,36 @@
|
|||
error: const `impl` for trait `Foo` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `Foo` which is not `const`
|
||||
--> $DIR/spec-effectvar-ice.rs:10:15
|
||||
|
|
||||
LL | impl<T> const Foo for T {}
|
||||
| ^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {}
|
||||
| ++++++++++++++
|
||||
|
||||
error: const `impl` for trait `Foo` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `Foo` which is not `const`
|
||||
--> $DIR/spec-effectvar-ice.rs:13:15
|
||||
|
|
||||
LL | impl<T> const Foo for T where T: const Specialize {}
|
||||
| ^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {}
|
||||
| ++++++++++++++
|
||||
|
||||
error: `const` can only be applied to `#[const_trait]` traits
|
||||
error: `const` can only be applied to `const` traits
|
||||
--> $DIR/spec-effectvar-ice.rs:13:34
|
||||
|
|
||||
LL | impl<T> const Foo for T where T: const Specialize {}
|
||||
| ^^^^^ can't be applied to `Specialize`
|
||||
|
|
||||
help: mark `Specialize` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Specialize` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Specialize {}
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -4,43 +4,43 @@ error: `[const]` is not allowed here
|
|||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> $DIR/super-traits-fail-2.rs:11:1
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-2.rs:11:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-2.rs:11:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-2.rs:11:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -1,58 +1,58 @@
|
|||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-2.rs:11:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-2.rs:11:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-2.rs:11:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-2.rs:11:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-2.rs:11:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ trait Foo {
|
|||
|
||||
#[cfg_attr(any(yy, ny), const_trait)]
|
||||
trait Bar: [const] Foo {}
|
||||
//[ny,nn]~^ ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[ny,nn]~| ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[ny,nn]~| ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[ny]~| ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[ny]~| ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[ny,nn]~^ ERROR: `[const]` can only be applied to `const` traits
|
||||
//[ny,nn]~| ERROR: `[const]` can only be applied to `const` traits
|
||||
//[ny,nn]~| ERROR: `[const]` can only be applied to `const` traits
|
||||
//[ny]~| ERROR: `[const]` can only be applied to `const` traits
|
||||
//[ny]~| ERROR: `[const]` can only be applied to `const` traits
|
||||
//[yn,nn]~^^^^^^ ERROR: `[const]` is not allowed here
|
||||
|
||||
const fn foo<T: Bar>(x: &T) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: `[const]` is not allowed here
|
|||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> $DIR/super-traits-fail-2.rs:11:1
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: `[const]` is not allowed here
|
|||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> $DIR/super-traits-fail-3.rs:23:1
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
|
|
@ -30,60 +30,60 @@ LL | const fn foo<T: [const] Bar>(x: &T) {
|
|||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:32:17
|
||||
|
|
||||
LL | const fn foo<T: [const] Bar>(x: &T) {
|
||||
| ^^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Bar: [const] Foo {}
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:32:17
|
||||
|
|
||||
LL | const fn foo<T: [const] Bar>(x: &T) {
|
||||
| ^^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Bar: [const] Foo {}
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: `[const]` is not allowed here
|
|||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> $DIR/super-traits-fail-3.rs:23:1
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
|
|
@ -30,60 +30,60 @@ LL | const fn foo<T: [const] Bar>(x: &T) {
|
|||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:32:17
|
||||
|
|
||||
LL | const fn foo<T: [const] Bar>(x: &T) {
|
||||
| ^^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Bar: [const] Foo {}
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:32:17
|
||||
|
|
||||
LL | const fn foo<T: [const] Bar>(x: &T) {
|
||||
| ^^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Bar: [const] Foo {}
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -21,17 +21,17 @@ trait Foo {
|
|||
#[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)]
|
||||
//[nyy,nyn]~^ ERROR: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future
|
||||
trait Bar: [const] Foo {}
|
||||
//[yny,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[yny]~^^^^ ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[yny]~| ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[yny,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `const` traits
|
||||
//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `const` traits
|
||||
//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `const` traits
|
||||
//[yny]~^^^^ ERROR: `[const]` can only be applied to `const` traits
|
||||
//[yny]~| ERROR: `[const]` can only be applied to `const` traits
|
||||
//[yyn,ynn,nny,nnn]~^^^^^^ ERROR: `[const]` is not allowed here
|
||||
//[nyy,nyn,nny,nnn]~^^^^^^^ ERROR: const trait impls are experimental
|
||||
|
||||
const fn foo<T: [const] Bar>(x: &T) {
|
||||
//[yyn,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[yyn,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `#[const_trait]`
|
||||
//[yyn,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `const` traits
|
||||
//[yyn,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `const` traits
|
||||
//[nyy,nyn,nny,nnn]~^^^ ERROR: const trait impls are experimental
|
||||
x.a();
|
||||
//[yyn]~^ ERROR: the trait bound `T: [const] Foo` is not satisfied
|
||||
|
|
|
|||
|
|
@ -4,66 +4,66 @@ error: `[const]` is not allowed here
|
|||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> $DIR/super-traits-fail-3.rs:23:1
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:32:17
|
||||
|
|
||||
LL | const fn foo<T: [const] Bar>(x: &T) {
|
||||
| ^^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Bar` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Bar: [const] Foo {}
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:32:17
|
||||
|
|
||||
LL | const fn foo<T: [const] Bar>(x: &T) {
|
||||
| ^^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Bar` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Bar: [const] Foo {}
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -1,58 +1,58 @@
|
|||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:23:12
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^ can't be applied to `Foo`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Foo` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Foo {
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -4,31 +4,31 @@ error: `[const]` is not allowed here
|
|||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
|
||||
note: this trait is not `const`, so it cannot have `[const]` trait bounds
|
||||
--> $DIR/super-traits-fail-3.rs:23:1
|
||||
|
|
||||
LL | trait Bar: [const] Foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:32:17
|
||||
|
|
||||
LL | const fn foo<T: [const] Bar>(x: &T) {
|
||||
| ^^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Bar` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Bar: [const] Foo {}
|
||||
| ++++++++++++++
|
||||
|
||||
error: `[const]` can only be applied to `#[const_trait]` traits
|
||||
error: `[const]` can only be applied to `const` traits
|
||||
--> $DIR/super-traits-fail-3.rs:32:17
|
||||
|
|
||||
LL | const fn foo<T: [const] Bar>(x: &T) {
|
||||
| ^^^^^^^ can't be applied to `Bar`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
||||
help: mark `Bar` as `const` to allow it to have `const` implementations
|
||||
|
|
||||
LL | #[const_trait] trait Bar: [const] Foo {}
|
||||
| ++++++++++++++
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
error: const `impl` for trait `Try` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `Try` which is not `const`
|
||||
--> $DIR/trait-default-body-stability.rs:19:12
|
||||
|
|
||||
LL | impl const Try for T {
|
||||
| ^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
|
||||
error: const `impl` for trait `FromResidual` which is not `const`
|
||||
--> $DIR/trait-default-body-stability.rs:34:12
|
||||
|
|
||||
LL | impl const FromResidual for T {
|
||||
| ^^^^^^^^^^^^ this trait is not `const`
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: marking a trait with `const` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error[E0015]: `?` is not allowed on `T` in constant functions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue