We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
#[rustc_do_not_implement_via_object]
1 parent a71b577 commit 0b97865Copy full SHA for 0b97865
compiler/rustc_attr_data_structures/src/attributes.rs
@@ -245,6 +245,9 @@ pub enum AttributeKind {
245
/// Represents [`#[deprecated]`](https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html#the-deprecated-attribute).
246
Deprecation { deprecation: Deprecation, span: Span },
247
248
+ /// Represents `#[rustc_do_not_implement_via_object]`.
249
+ DoNotImplementViaObject(Span),
250
+
251
/// Represents [`#[doc]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html).
252
DocComment { style: AttrStyle, kind: CommentKind, span: Span, comment: Symbol },
253
compiler/rustc_attr_data_structures/src/encode_cross_crate.rs
@@ -26,6 +26,7 @@ impl AttributeKind {
26
ConstTrait(..) => No,
27
DenyExplicitImpl(..) => No,
28
Deprecation { .. } => Yes,
29
+ DoNotImplementViaObject(..) => No,
30
DocComment { .. } => Yes,
31
ExportName { .. } => Yes,
32
Inline(..) => No,
compiler/rustc_attr_parsing/src/attributes/traits.rs
@@ -68,3 +68,10 @@ impl<S: Stage> NoArgsAttributeParser<S> for DenyExplicitImplParser {
68
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
69
const CREATE: fn(Span) -> AttributeKind = AttributeKind::DenyExplicitImpl;
70
}
71
72
+pub(crate) struct DoNotImplementViaObjectParser;
73
+impl<S: Stage> NoArgsAttributeParser<S> for DoNotImplementViaObjectParser {
74
+ const PATH: &[Symbol] = &[sym::rustc_do_not_implement_via_object];
75
+ const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
76
+ const CREATE: fn(Span) -> AttributeKind = AttributeKind::DoNotImplementViaObject;
77
+}
compiler/rustc_attr_parsing/src/context.rs
@@ -36,7 +36,8 @@ use crate::attributes::stability::{
36
BodyStabilityParser, ConstStabilityIndirectParser, ConstStabilityParser, StabilityParser,
37
};
38
use crate::attributes::traits::{
39
- ConstTraitParser, DenyExplicitImplParser, SkipDuringMethodDispatchParser,
+ ConstTraitParser, DenyExplicitImplParser, DoNotImplementViaObjectParser,
40
+ SkipDuringMethodDispatchParser,
41
42
use crate::attributes::transparency::TransparencyParser;
43
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
@@ -143,6 +144,7 @@ attribute_parsers!(
143
144
Single<WithoutArgs<ConstStabilityIndirectParser>>,
145
Single<WithoutArgs<ConstTraitParser>>,
146
Single<WithoutArgs<DenyExplicitImplParser>>,
147
+ Single<WithoutArgs<DoNotImplementViaObjectParser>>,
148
Single<WithoutArgs<LoopMatchParser>>,
149
Single<WithoutArgs<MayDangleParser>>,
150
Single<WithoutArgs<NoMangleParser>>,
compiler/rustc_hir_analysis/src/collect.rs
@@ -965,8 +965,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
965
});
966
967
let deny_explicit_impl = find_attr!(attrs, AttributeKind::DenyExplicitImpl(_));
968
- let implement_via_object =
969
- !attrs.iter().any(|attr| attr.has_name(sym::rustc_do_not_implement_via_object));
+ let implement_via_object = !find_attr!(attrs, AttributeKind::DoNotImplementViaObject(_));
970
971
ty::TraitDef {
972
def_id: def_id.to_def_id(),
compiler/rustc_parse/src/validate_attr.rs
@@ -294,6 +294,7 @@ fn emit_malformed_attribute(
294
| sym::rustc_confusables
295
| sym::rustc_skip_during_method_dispatch
296
| sym::rustc_deny_explicit_impl
297
+ | sym::rustc_do_not_implement_via_object
298
| sym::const_trait
299
| sym::repr
300
| sym::align
compiler/rustc_passes/src/check_attr.rs
@@ -123,7 +123,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
123
Attribute::Parsed(
124
AttributeKind::SkipDuringMethodDispatch { span: attr_span, .. }
125
| AttributeKind::ConstTrait(attr_span)
126
- | AttributeKind::DenyExplicitImpl(attr_span),
+ | AttributeKind::DenyExplicitImpl(attr_span)
127
+ | AttributeKind::DoNotImplementViaObject(attr_span),
128
) => {
129
self.check_must_be_applied_to_trait(*attr_span, span, target);
130
@@ -271,7 +272,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
271
272
| [sym::rustc_then_this_would_need, ..] => self.check_rustc_dirty_clean(attr),
273
[sym::rustc_coinductive, ..]
274
| [sym::rustc_must_implement_one_of, ..]
- | [sym::rustc_do_not_implement_via_object, ..]
275
=> self.check_must_be_applied_to_trait(attr.span(), span, target),
276
[sym::collapse_debuginfo, ..] => self.check_collapse_debuginfo(attr, span, target),
277
[sym::must_not_suspend, ..] => self.check_must_not_suspend(attr, span, target),
0 commit comments