Skip to content

Commit ce66f6f

Browse files
wip
1 parent 80872ec commit ce66f6f

File tree

11 files changed

+42
-38
lines changed

11 files changed

+42
-38
lines changed

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ impl<S: Stage> CombineAttributeParser<S> for TargetFeatureParser {
435435
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
436436
Allow(Target::Fn),
437437
Allow(Target::Method(MethodKind::Inherent)),
438-
Allow(Target::Method(MethodKind::Trait {body: true})),
438+
Allow(Target::Method(MethodKind::Trait { body: true })),
439439
Warn(Target::Statement),
440440
Warn(Target::Field),
441441
Warn(Target::Arm),

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<S: Stage> SingleAttributeParser<S> for DeprecationParser {
5858
Allow(Target::AssocTy),
5959
Allow(Target::AssocConst),
6060
Allow(Target::Variant),
61-
Error(Target::WherePredicate)
61+
Error(Target::WherePredicate),
6262
]);
6363
const TEMPLATE: AttributeTemplate = template!(
6464
Word,

compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ pub(crate) struct PassByValueParser;
3434
impl<S: Stage> NoArgsAttributeParser<S> for PassByValueParser {
3535
const PATH: &[Symbol] = &[sym::rustc_pass_by_value];
3636
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
37-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct), Allow(Target::Enum), Allow(Target::TyAlias)]);
37+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
38+
Allow(Target::Struct),
39+
Allow(Target::Enum),
40+
Allow(Target::TyAlias),
41+
]);
3842
const CREATE: fn(Span) -> AttributeKind = AttributeKind::PassByValue;
3943
}
4044

compiler/rustc_attr_parsing/src/attributes/must_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir::{MethodKind, Target};
55
use rustc_span::{Symbol, sym};
66

77
use crate::attributes::{AttributeOrder, OnDuplicate, SingleAttributeParser};
8-
use crate::context::MaybeWarn::{Allow};
8+
use crate::context::MaybeWarn::Allow;
99
use crate::context::{AcceptContext, AllowedTargets, Stage};
1010
use crate::parser::ArgParser;
1111
use crate::session_diagnostics;

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
3333
Allow(Target::Enum),
3434
Allow(Target::Union),
3535
Allow(Target::Method(MethodKind::Inherent)),
36-
Allow(Target::Method(MethodKind::Trait {body: false})),
37-
Allow(Target::Method(MethodKind::Trait {body: true})),
36+
Allow(Target::Method(MethodKind::Trait { body: false })),
37+
Allow(Target::Method(MethodKind::Trait { body: true })),
3838
Allow(Target::Impl { of_trait: false }),
3939
Allow(Target::Impl { of_trait: true }),
4040
Allow(Target::MacroDef),

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ impl AllowedTargets {
687687
pub(crate) enum MaybeWarn {
688688
Allow(Target),
689689
Warn(Target),
690-
Error(Target)
690+
Error(Target),
691691
}
692692

693693
/// Context created once, for example as part of the ast lowering
@@ -905,11 +905,16 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
905905
emit_lint(AttributeLint {
906906
id: target_id,
907907
span: n.item.span(),
908-
kind: AttributeLintKind::InvalidTarget { },
908+
kind: AttributeLintKind::InvalidTarget {},
909909
});
910910
}
911911
AllowedResult::Error => {
912-
self.dcx().struct_span_err(n.item.span(), "this attribute is not allowed on this target").emit();
912+
self.dcx()
913+
.struct_span_err(
914+
n.item.span(),
915+
"this attribute is not allowed on this target",
916+
)
917+
.emit();
913918
}
914919
}
915920
}

compiler/rustc_attr_parsing/src/lints.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ pub fn emit_attribute_lint<L: LintEmitter>(lint: &AttributeLint<HirId>, lint_emi
3434
*first_span,
3535
session_diagnostics::EmptyAttributeList { attr_span: *first_span },
3636
),
37-
AttributeLintKind::InvalidTarget { } => lint_emitter.emit_node_span_lint(
37+
AttributeLintKind::InvalidTarget {} => lint_emitter.emit_node_span_lint(
3838
rustc_session::lint::builtin::UNUSED_ATTRIBUTES,
3939
*id,
4040
*span,
41-
session_diagnostics::InvalidTarget { },
42-
)
41+
session_diagnostics::InvalidTarget {},
42+
),
4343
}
4444
}

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,7 @@ pub(crate) struct EmptyAttributeList {
482482

483483
#[derive(LintDiagnostic)]
484484
#[diag(attr_parsing_invalid_target)]
485-
pub(crate) struct InvalidTarget {
486-
}
485+
pub(crate) struct InvalidTarget {}
487486

488487
#[derive(Diagnostic)]
489488
#[diag(attr_parsing_invalid_alignment_value, code = E0589)]

compiler/rustc_hir/src/lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ pub enum AttributeLintKind {
3434
UnusedDuplicate { this: Span, other: Span, warning: bool },
3535
IllFormedAttributeInput { suggestions: Vec<String> },
3636
EmptyAttribute { first_span: Span },
37-
InvalidTarget { },
37+
InvalidTarget {},
3838
}

compiler/rustc_hir/src/target.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
77
use std::fmt::{self, Display};
88

9-
use rustc_ast::{AssocItemKind, ForeignItemKind, ast};
109
use rustc_ast::visit::AssocCtxt;
10+
use rustc_ast::{AssocItemKind, ForeignItemKind, ast};
11+
1112
use crate::def::DefKind;
1213
use crate::{Item, ItemKind, TraitItem, TraitItemKind, hir};
1314

@@ -231,10 +232,12 @@ impl Target {
231232
AssocItemKind::Const(_) => Target::AssocConst,
232233
AssocItemKind::Fn(f) => Target::Method(match assoc_ctxt {
233234
AssocCtxt::Trait => MethodKind::Trait { body: f.body.is_some() },
234-
AssocCtxt::Impl { of_trait } => if of_trait {
235-
MethodKind::Trait { body: true }
236-
} else {
237-
MethodKind::Inherent
235+
AssocCtxt::Impl { of_trait } => {
236+
if of_trait {
237+
MethodKind::Trait { body: true }
238+
} else {
239+
MethodKind::Inherent
240+
}
238241
}
239242
}),
240243
AssocItemKind::Type(_) => Target::AssocTy,

0 commit comments

Comments
 (0)