Skip to content

Commit 6bb3b1f

Browse files
committed
clean up TODOs
1 parent 6064db8 commit 6bb3b1f

File tree

19 files changed

+203
-249
lines changed

19 files changed

+203
-249
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

+1-64
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,16 @@ impl Deprecation {
142142
/// happen.
143143
///
144144
/// For more docs, look in [`rustc_attr`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_attr/index.html)
145-
// FIXME(jdonszelmann): rename to AttributeKind once hir::AttributeKind is dissolved
146145
#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable)]
147146
pub enum AttributeKind {
148147
// tidy-alphabetical-start
149-
Allow,
150148
AllowConstFnUnstable(ThinVec<Symbol>),
151-
AllowInternalUnsafe,
152149
AllowInternalUnstable(ThinVec<(Symbol, Span)>),
153-
AutoDiff,
154-
AutomaticallyDerived,
155150
BodyStability {
156151
stability: DefaultBodyStability,
157152
/// Span of the `#[rustc_default_body_unstable(...)]` attribute
158153
span: Span,
159154
},
160-
Cfg,
161-
CfgAttr,
162-
CfiEncoding, // FIXME(cfi_encoding)
163-
Cold,
164-
CollapseDebuginfo,
165155
Confusables {
166156
symbols: ThinVec<Symbol>,
167157
// FIXME(jdonszelmann): remove when target validation code is moved
@@ -173,14 +163,6 @@ pub enum AttributeKind {
173163
span: Span,
174164
},
175165
ConstStabilityIndirect,
176-
ConstTrait,
177-
Coroutine,
178-
Coverage,
179-
CustomMir,
180-
DebuggerVisualizer,
181-
DefaultLibAllocator,
182-
Deny,
183-
DeprecatedSafe, // FIXME(deprecated_safe)
184166
Deprecation {
185167
deprecation: Deprecation,
186168
span: Span,
@@ -196,57 +178,12 @@ pub enum AttributeKind {
196178
span: Span,
197179
comment: Symbol,
198180
},
199-
Expect,
200-
ExportName,
201-
FfiConst,
202-
FfiPure,
203-
Forbid,
204-
Fundamental,
205-
Ignore,
206-
// TODO: must contain span for clippy
207-
Inline,
208-
InstructionSet, // broken on stable!!!
209-
Lang,
210-
Link,
211-
Linkage,
212-
LinkName,
213-
LinkOrdinal,
214-
LinkSection,
215-
MacroExport,
216181
MacroTransparency(Transparency),
217-
MacroUse,
218-
Marker,
219-
MayDangle,
220-
MustNotSuspend,
221-
MustUse,
222-
NeedsAllocator,
223-
NoImplicitPrelude,
224-
NoLink,
225-
NoMangle,
226-
NonExhaustive,
227-
NoSanitize,
228-
OmitGdbPrettyPrinterSection, // FIXME(omit_gdb_pretty_printer_section)
229-
PanicHandler,
230-
PatchableFunctionEntry, // FIXME(patchable_function_entry)
231-
Path,
232-
Pointee, // FIXME(derive_smart_pointer)
233-
PreludeImport,
234-
ProcMacro,
235-
ProcMacroAttribute,
236-
ProcMacroDerive,
237182
Repr(ThinVec<(ReprAttr, Span)>),
238183
Stability {
239184
stability: Stability,
240185
/// Span of the `#[stable(...)]` or `#[unstable(...)]` attribute
241186
span: Span,
242187
},
243-
Start,
244-
TargetFeature,
245-
ThreadLocal,
246-
TrackCaller,
247-
Unstable,
248-
Used,
249-
Warn,
250-
WindowsSubsystem, // broken on stable!!!
251-
// tidy-alphabetical-end
188+
// tidy-alphabetical-end
252189
}

compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::iter;
22

33
use rustc_attr_data_structures::AttributeKind;
4-
use rustc_span::{sym, Span, Symbol};
4+
use rustc_span::{Span, Symbol, sym};
55

66
use super::{CombineAttributeGroup, ConvertFn};
77
use crate::context::AttributeAcceptContext;

compiler/rustc_attr_parsing/src/attributes/cfg.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// TODO: convert cfg properly.... And learn how cfg works I guess
21
use rustc_ast::{LitKind, MetaItem, MetaItemInner, MetaItemKind, MetaItemLit, NodeId};
32
use rustc_ast_pretty::pprust;
43
use rustc_attr_data_structures::RustcVersion;

compiler/rustc_attr_parsing/src/attributes/confusables.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use rustc_attr_data_structures::AttributeKind;
32
use rustc_span::{Span, Symbol, sym};
43
use thin_vec::ThinVec;
@@ -17,7 +16,7 @@ pub(crate) struct ConfusablesGroup {
1716
impl AttributeGroup for ConfusablesGroup {
1817
const ATTRIBUTES: AttributeMapping<Self> = &[(&[sym::rustc_confusables], |this, cx, args| {
1918
let Some(list) = args.list() else {
20-
// TODO: error when not a list? Bring validation code here.
19+
// FIXME(jdonszelmann): error when not a list? Bring validation code here.
2120
// NOTE: currently subsequent attributes are silently ignored using
2221
// tcx.get_attr().
2322
return;

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ fn get(
4141
}
4242
} else {
4343
// FIXME(jdonszelmann): suggestion?
44-
cx.emit_err(session_diagnostics::IncorrectMetaItem {
45-
span: param_span,
46-
suggestion: None,
47-
});
44+
cx.emit_err(session_diagnostics::IncorrectMetaItem { span: param_span, suggestion: None });
4845
false
4946
}
5047
}

compiler/rustc_attr_parsing/src/attributes/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ impl<T: CombineAttributeGroup> AttributeGroup for Combine<T> {
141141
&[(T::PATH, |group: &mut Combine<T>, cx, args| group.1.extend(T::extend(cx, args)))];
142142

143143
fn finalize(self, _cx: &AttributeGroupContext<'_>) -> Option<AttributeKind> {
144-
if self.1.is_empty() {
145-
None
146-
} else {
147-
// TODO: what filter here?
148-
Some(T::CONVERT(self.1))
149-
}
144+
if self.1.is_empty() { None } else { Some(T::CONVERT(self.1)) }
150145
}
151146
}

compiler/rustc_attr_parsing/src/attributes/repr.rs

+42-45
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ impl CombineAttributeGroup for ReprGroup {
4141

4242
for param in list.mixed() {
4343
if let Some(_) = param.lit() {
44-
cx.emit_err(session_diagnostics::ReprIdent {
45-
span: cx.attr_span,
46-
});
44+
cx.emit_err(session_diagnostics::ReprIdent { span: cx.attr_span });
4745
continue;
4846
}
4947

@@ -57,22 +55,21 @@ impl CombineAttributeGroup for ReprGroup {
5755

5856
macro_rules! int_pat {
5957
() => {
60-
sym::i8
61-
| sym::u8
62-
| sym::i16
63-
| sym::u16
64-
| sym::i32
65-
| sym::u32
66-
| sym::i64
67-
| sym::u64
68-
| sym::i128
69-
| sym::u128
70-
| sym::isize
71-
| sym::usize
58+
sym::i8
59+
| sym::u8
60+
| sym::i16
61+
| sym::u16
62+
| sym::i32
63+
| sym::u32
64+
| sym::i64
65+
| sym::u64
66+
| sym::i128
67+
| sym::u128
68+
| sym::isize
69+
| sym::usize
7270
};
7371
}
7472

75-
// TODO: inline
7673
fn int_type_of_word(s: Symbol) -> Option<IntType> {
7774
use IntType::*;
7875

@@ -93,27 +90,26 @@ fn int_type_of_word(s: Symbol) -> Option<IntType> {
9390
}
9491
}
9592

96-
fn parse_repr(
97-
cx: &AttributeAcceptContext<'_>,
98-
param: &MetaItemParser<'_>,
99-
) -> Option<ReprAttr> {
93+
fn parse_repr(cx: &AttributeAcceptContext<'_>, param: &MetaItemParser<'_>) -> Option<ReprAttr> {
10094
use ReprAttr::*;
10195

10296
// FIXME(jdonszelmann): invert the parsing here to match on the word first and then the
10397
// structure.
10498
let (ident, args) = param.word_or_empty();
10599

106100
match (ident.name, args) {
107-
(sym::align, ArgParser::NoArgs) => {
101+
(sym::align, ArgParser::NoArgs) => {
108102
cx.emit_err(session_diagnostics::InvalidReprAlignNeedArg { span: ident.span });
109103
None
110104
}
111105
(sym::align, ArgParser::List(l)) => parse_repr_align(cx, l, param.span(), AlignKind::Align),
112106

113107
(sym::packed, ArgParser::NoArgs) => Some(ReprPacked(Align::ONE)),
114-
(sym::packed, ArgParser::List(l)) => parse_repr_align(cx, l, param.span(), AlignKind::Packed),
108+
(sym::packed, ArgParser::List(l)) => {
109+
parse_repr_align(cx, l, param.span(), AlignKind::Packed)
110+
}
115111

116-
(sym::align | sym::packed, ArgParser::NameValue(l)) => {
112+
(sym::align | sym::packed, ArgParser::NameValue(l)) => {
117113
cx.emit_err(session_diagnostics::IncorrectReprFormatGeneric {
118114
span: param.span(),
119115
// FIXME(jdonszelmann) can just be a string in the diag type
@@ -127,24 +123,19 @@ fn parse_repr(
127123
None
128124
}
129125

130-
(sym::Rust, ArgParser::NoArgs) => {
131-
Some(ReprRust)
132-
}
133-
(sym::C, ArgParser::NoArgs) => {
134-
Some(ReprC)
135-
}
136-
(sym::simd, ArgParser::NoArgs) => {
137-
Some(ReprSimd)
138-
}
139-
(sym::transparent, ArgParser::NoArgs) => {
140-
Some(ReprTransparent)
141-
}
142-
(i@int_pat!(), ArgParser::NoArgs) => {
126+
(sym::Rust, ArgParser::NoArgs) => Some(ReprRust),
127+
(sym::C, ArgParser::NoArgs) => Some(ReprC),
128+
(sym::simd, ArgParser::NoArgs) => Some(ReprSimd),
129+
(sym::transparent, ArgParser::NoArgs) => Some(ReprTransparent),
130+
(i @ int_pat!(), ArgParser::NoArgs) => {
143131
// int_pat!() should make sure it always parses
144132
Some(ReprInt(int_type_of_word(i).unwrap()))
145133
}
146134

147-
(sym::Rust | sym::C | sym::simd | sym::transparent | int_pat!(), ArgParser::NameValue(_)) => {
135+
(
136+
sym::Rust | sym::C | sym::simd | sym::transparent | int_pat!(),
137+
ArgParser::NameValue(_),
138+
) => {
148139
cx.emit_err(session_diagnostics::InvalidReprHintNoValue {
149140
span: param.span(),
150141
name: ident.to_string(),
@@ -168,10 +159,15 @@ fn parse_repr(
168159

169160
enum AlignKind {
170161
Packed,
171-
Align
162+
Align,
172163
}
173164

174-
fn parse_repr_align(cx: &AttributeAcceptContext<'_>, list: &MetaItemListParser<'_>, param_span: Span, align_kind: AlignKind) -> Option<ReprAttr> {
165+
fn parse_repr_align(
166+
cx: &AttributeAcceptContext<'_>,
167+
list: &MetaItemListParser<'_>,
168+
param_span: Span,
169+
align_kind: AlignKind,
170+
) -> Option<ReprAttr> {
175171
use AlignKind::*;
176172

177173
let Some(align) = list.single() else {
@@ -180,14 +176,15 @@ fn parse_repr_align(cx: &AttributeAcceptContext<'_>, list: &MetaItemListParser<'
180176
cx.emit_err(session_diagnostics::IncorrectReprFormatPackedOneOrZeroArg {
181177
span: param_span,
182178
});
183-
},
179+
}
184180
Align => {
185-
cx.dcx()
186-
.emit_err(session_diagnostics::IncorrectReprFormatAlignOneArg { span: param_span });
181+
cx.dcx().emit_err(session_diagnostics::IncorrectReprFormatAlignOneArg {
182+
span: param_span,
183+
});
187184
}
188185
}
189186

190-
return None
187+
return None;
191188
};
192189

193190
let Some(lit) = align.lit() else {
@@ -196,15 +193,15 @@ fn parse_repr_align(cx: &AttributeAcceptContext<'_>, list: &MetaItemListParser<'
196193
cx.emit_err(session_diagnostics::IncorrectReprFormatPackedExpectInteger {
197194
span: align.span(),
198195
});
199-
},
196+
}
200197
Align => {
201198
cx.emit_err(session_diagnostics::IncorrectReprFormatExpectInteger {
202199
span: align.span(),
203200
});
204201
}
205202
}
206203

207-
return None
204+
return None;
208205
};
209206

210207
match parse_alignment(&lit.kind) {

compiler/rustc_attr_parsing/src/attributes/stability.rs

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use std::num::NonZero;
22

33
use rustc_attr_data_structures::{
4-
AllowedThroughUnstableModules, AttributeKind, DefaultBodyStability, PartialConstStability, Stability, StabilityLevel, StableSince, UnstableReason, VERSION_PLACEHOLDER
4+
AllowedThroughUnstableModules, AttributeKind, DefaultBodyStability, PartialConstStability,
5+
Stability, StabilityLevel, StableSince, UnstableReason, VERSION_PLACEHOLDER,
56
};
67
use rustc_span::{ErrorGuaranteed, Span, Symbol, sym};
78

@@ -16,7 +17,7 @@ macro_rules! reject_outside_std {
1617
// Emit errors for non-staged-api crates.
1718
if !$cx.features().staged_api() {
1819
$cx.emit_err(session_diagnostics::StabilityOutsideStd { span: $cx.attr_span });
19-
return
20+
return;
2021
}
2122
};
2223
}
@@ -59,16 +60,24 @@ impl AttributeGroup for StabilityGroup {
5960
}),
6061
(&[sym::rustc_allowed_through_unstable_modules], |this, cx, args| {
6162
reject_outside_std!(cx);
62-
this.allowed_through_unstable_modules = Some(match args.name_value().and_then(|i| i.value_as_str()) {
63-
Some(msg) => AllowedThroughUnstableModules::WithDeprecation(msg),
64-
None => AllowedThroughUnstableModules::WithoutDeprecation,
65-
});
63+
this.allowed_through_unstable_modules =
64+
Some(match args.name_value().and_then(|i| i.value_as_str()) {
65+
Some(msg) => AllowedThroughUnstableModules::WithDeprecation(msg),
66+
None => AllowedThroughUnstableModules::WithoutDeprecation,
67+
});
6668
}),
6769
];
6870

6971
fn finalize(mut self, cx: &AttributeGroupContext<'_>) -> Option<AttributeKind> {
7072
if let Some(atum) = self.allowed_through_unstable_modules {
71-
if let Some((Stability{level: StabilityLevel::Stable { ref mut allowed_through_unstable_modules, .. }, ..}, _)) = self.stability {
73+
if let Some((
74+
Stability {
75+
level: StabilityLevel::Stable { ref mut allowed_through_unstable_modules, .. },
76+
..
77+
},
78+
_,
79+
)) = self.stability
80+
{
7281
*allowed_through_unstable_modules = Some(atum);
7382
} else {
7483
cx.dcx().emit_err(session_diagnostics::RustcAllowedUnstablePairing {
@@ -358,8 +367,8 @@ pub(crate) fn parse_unstability(
358367
None => Err(cx.emit_err(session_diagnostics::MissingFeature { span: cx.attr_span })),
359368
};
360369

361-
let issue = issue
362-
.ok_or_else(|| cx.emit_err(session_diagnostics::MissingIssue { span: cx.attr_span }));
370+
let issue =
371+
issue.ok_or_else(|| cx.emit_err(session_diagnostics::MissingIssue { span: cx.attr_span }));
363372

364373
match (feature, issue) {
365374
(Ok(feature), Ok(_)) => {

compiler/rustc_attr_parsing/src/attributes/transparency.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::parser::ArgParser;
77

88
pub(crate) struct TransparencyGroup;
99

10-
// TODO: fix this but I don't want to rn
10+
// FIXME(jdonszelmann): make these proper diagnostics
1111
#[allow(rustc::untranslatable_diagnostic)]
1212
#[allow(rustc::diagnostic_outside_of_impl)]
1313
impl SingleAttributeGroup for TransparencyGroup {

0 commit comments

Comments
 (0)