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 3612b27 commit c07df71Copy full SHA for c07df71
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
@@ -37,7 +37,8 @@ use crate::attributes::stability::{
37
BodyStabilityParser, ConstStabilityIndirectParser, ConstStabilityParser, StabilityParser,
38
};
39
use crate::attributes::traits::{
40
- ConstTraitParser, DenyExplicitImplParser, SkipDuringMethodDispatchParser,
+ ConstTraitParser, DenyExplicitImplParser, DoNotImplementViaObjectParser,
41
+ SkipDuringMethodDispatchParser,
42
43
use crate::attributes::transparency::TransparencyParser;
44
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
@@ -144,6 +145,7 @@ attribute_parsers!(
144
145
Single<WithoutArgs<ConstStabilityIndirectParser>>,
146
Single<WithoutArgs<ConstTraitParser>>,
147
Single<WithoutArgs<DenyExplicitImplParser>>,
148
+ Single<WithoutArgs<DoNotImplementViaObjectParser>>,
149
Single<WithoutArgs<LoopMatchParser>>,
150
Single<WithoutArgs<MayDangleParser>>,
151
Single<WithoutArgs<NoImplicitPreludeParser>>,
compiler/rustc_hir_analysis/src/collect.rs
@@ -966,8 +966,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
966
});
967
968
let deny_explicit_impl = find_attr!(attrs, AttributeKind::DenyExplicitImpl(_));
969
- let implement_via_object =
970
- !attrs.iter().any(|attr| attr.has_name(sym::rustc_do_not_implement_via_object));
+ let implement_via_object = !find_attr!(attrs, AttributeKind::DoNotImplementViaObject(_));
971
972
ty::TraitDef {
973
def_id: def_id.to_def_id(),
compiler/rustc_parse/src/validate_attr.rs
@@ -295,6 +295,7 @@ fn emit_malformed_attribute(
295
| sym::rustc_skip_during_method_dispatch
296
| sym::rustc_pass_by_value
297
| sym::rustc_deny_explicit_impl
298
+ | sym::rustc_do_not_implement_via_object
299
| sym::const_trait
300
| sym::repr
301
| 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
@@ -282,7 +283,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
282
283
| [sym::rustc_then_this_would_need, ..] => self.check_rustc_dirty_clean(attr),
284
[sym::rustc_coinductive, ..]
285
| [sym::rustc_must_implement_one_of, ..]
- | [sym::rustc_do_not_implement_via_object, ..]
286
=> self.check_must_be_applied_to_trait(attr.span(), span, target),
287
[sym::collapse_debuginfo, ..] => self.check_collapse_debuginfo(attr, span, target),
288
[sym::must_not_suspend, ..] => self.check_must_not_suspend(attr, span, target),
0 commit comments