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 887e461 commit 92f7283Copy full SHA for 92f7283
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
@@ -38,7 +38,8 @@ use crate::attributes::stability::{
38
BodyStabilityParser, ConstStabilityIndirectParser, ConstStabilityParser, StabilityParser,
39
};
40
use crate::attributes::traits::{
41
- ConstTraitParser, DenyExplicitImplParser, SkipDuringMethodDispatchParser,
+ ConstTraitParser, DenyExplicitImplParser, DoNotImplementViaObjectParser,
42
+ SkipDuringMethodDispatchParser,
43
44
use crate::attributes::transparency::TransparencyParser;
45
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
@@ -145,6 +146,7 @@ attribute_parsers!(
145
146
Single<WithoutArgs<ConstStabilityIndirectParser>>,
147
Single<WithoutArgs<ConstTraitParser>>,
148
Single<WithoutArgs<DenyExplicitImplParser>>,
149
+ Single<WithoutArgs<DoNotImplementViaObjectParser>>,
150
Single<WithoutArgs<LoopMatchParser>>,
151
Single<WithoutArgs<MayDangleParser>>,
152
Single<WithoutArgs<NoImplicitPreludeParser>>,
compiler/rustc_hir_analysis/src/collect.rs
@@ -962,8 +962,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
962
});
963
964
let deny_explicit_impl = find_attr!(attrs, AttributeKind::DenyExplicitImpl(_));
965
- let implement_via_object =
966
- !attrs.iter().any(|attr| attr.has_name(sym::rustc_do_not_implement_via_object));
+ let implement_via_object = !find_attr!(attrs, AttributeKind::DoNotImplementViaObject(_));
967
968
ty::TraitDef {
969
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
@@ -284,7 +285,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
284
285
| [sym::rustc_then_this_would_need, ..] => self.check_rustc_dirty_clean(attr),
286
[sym::rustc_coinductive, ..]
287
| [sym::rustc_must_implement_one_of, ..]
- | [sym::rustc_do_not_implement_via_object, ..]
288
=> self.check_must_be_applied_to_trait(attr.span(), span, target),
289
[sym::collapse_debuginfo, ..] => self.check_collapse_debuginfo(attr, span, target),
290
[sym::must_not_suspend, ..] => self.check_must_not_suspend(attr, span, target),
0 commit comments