Skip to content

Commit 4d3437f

Browse files
committed
clean up TODOs
1 parent c5abf08 commit 4d3437f

File tree

14 files changed

+26
-102
lines changed

14 files changed

+26
-102
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

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

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-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(crate) struct ConfusablesParser {
1414
impl AttributeParser for ConfusablesParser {
1515
const ATTRIBUTES: AcceptMapping<Self> = &[(&[sym::rustc_confusables], |this, cx, args| {
1616
let Some(list) = args.list() else {
17-
// TODO: error when not a list? Bring validation code here.
17+
// FIXME(jdonszelmann): error when not a list? Bring validation code here.
1818
// NOTE: currently subsequent attributes are silently ignored using
1919
// tcx.get_attr().
2020
return;

compiler/rustc_attr_parsing/src/attributes/repr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ macro_rules! int_pat {
7070
};
7171
}
7272

73-
// TODO: inline
7473
fn int_type_of_word(s: Symbol) -> Option<IntType> {
7574
use IntType::*;
7675

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 TransparencyParser;
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 SingleAttributeParser for TransparencyParser {

compiler/rustc_attr_parsing/src/attributes/util.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub fn parse_version(s: Symbol) -> Option<RustcVersion> {
1919
Some(RustcVersion { major, minor, patch })
2020
}
2121

22-
// TODO: create single word attribute map
2322
pub fn is_builtin_attr(attr: &impl AttributeExt) -> bool {
2423
attr.is_doc_comment() || attr.ident().is_some_and(|ident| is_builtin_attr_name(ident.name))
2524
}

compiler/rustc_attr_parsing/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
6262
///
6363
/// A little like `matches` but for attributes.
6464
///
65-
/// ```rust,no_run
65+
/// ```rust,ignore (illustrative)
6666
/// // finds the repr attribute
6767
/// if let Some(r) = find_attr!(attrs, AttributeKind::Repr(r) => r) {
6868
///

compiler/rustc_attr_parsing/src/parser.rs

+13-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use core::panic;
21
use std::fmt::{Debug, Display};
32
use std::iter::Peekable;
43

@@ -231,7 +230,7 @@ impl<'a> Debug for MetaItemParser<'a> {
231230

232231
impl<'a> MetaItemParser<'a> {
233232
/// Create a new parser from a [`NormalAttr`], which is stored inside of any
234-
/// [`ast::Attribute`](Attribute)
233+
/// [`ast::Attribute`](rustc_ast::Attribute)
235234
pub fn from_attr(attr: &'a NormalAttr, dcx: DiagCtxtHandle<'a>) -> Self {
236235
Self {
237236
path: PathParser::Ast(&attr.item.path),
@@ -268,8 +267,6 @@ impl<'a> MetaItemParser<'a> {
268267
/// - `#[rustfmt::skip]`: `rustfmt::skip` is a path
269268
/// - `#[allow(clippy::complexity)]`: `clippy::complexity` is a path
270269
/// - `#[inline]`: `inline` is a single segment path
271-
/// - `#[inline(always)]`: `always` is a single segment path, but `inline` is *not and
272-
/// should be parsed using [`list`](Self::list)
273270
pub fn path(&self) -> (PathParser<'a>, &ArgParser<'a>) {
274271
self.deconstruct()
275272
}
@@ -291,11 +288,8 @@ impl<'a> MetaItemParser<'a> {
291288
///
292289
/// Some examples:
293290
/// - `#[inline]`: `inline` is a word
294-
/// - `#[rustfmt::skip]`: `rustfmt::skip` is a path, and not a word
295-
/// - `#[inline(always)]`: `always` is a word, but `inline` is *not and should be parsed
296-
/// using [`path_list`](Self::path_list)
297-
/// - `#[allow(clippy::complexity)]`: `clippy::complexity` is *not* a word, and should instead be parsed
298-
/// using [`path`](Self::path)
291+
/// - `#[rustfmt::skip]`: `rustfmt::skip` is a path,
292+
/// and not a word and should instead be parsed using [`path`](Self::path)
299293
pub fn word(&self) -> Option<(Ident, &ArgParser<'a>)> {
300294
let (path, args) = self.deconstruct();
301295
Some((path.word()?, args))
@@ -406,7 +400,7 @@ impl<'a> MetaItemListParserContext<'a> {
406400
{
407401
segments.push(Ident::new(name, span));
408402
} else {
409-
unreachable!()
403+
return None;
410404
}
411405
if let Some(TokenTree::Token(Token { kind: token::PathSep, .. }, _)) =
412406
self.inside_delimiters.peek()
@@ -422,16 +416,14 @@ impl<'a> MetaItemListParserContext<'a> {
422416
Some(TokenTree::Token(
423417
Token { kind: token::OpenDelim(_) | token::CloseDelim(_), .. },
424418
_,
425-
)) => {
426-
panic!("Should be `AttrTokenTree::Delimited`, not delim tokens: {:?}", tt);
427-
}
428-
Some(x) => {
419+
)) => None,
420+
Some(_) => {
429421
// malformed attributes can get here. We can't crash, but somewhere else should've
430422
// already warned for this.
431-
self.dcx.span_delayed_bug(
432-
x.span(),
433-
format!("unexpected token {x:?} in built-in attribute path"),
434-
);
423+
// self.dcx.span_delayed_bug(
424+
// x.span(),
425+
// format!("unexpected token {x:?} in built-in attribute path"),
426+
// );
435427
None
436428
}
437429
None => None,
@@ -450,7 +442,7 @@ impl<'a> MetaItemListParserContext<'a> {
450442
Some(TokenTree::Token(ref token, _)) => {
451443
if let Some(s) = MetaItemLit::from_token(token) { Some(s) } else { None }
452444
}
453-
x => unreachable!("{x:?}"),
445+
x => None,
454446
}
455447
}
456448

@@ -532,9 +524,9 @@ impl<'a> MetaItemListParserContext<'a> {
532524
)),
533525
}
534526
}
535-
Some(TokenTree::Delimited(span, ..)) => {
527+
Some(TokenTree::Delimited(_, ..)) => {
536528
self.inside_delimiters.next();
537-
self.dcx.span_delayed_bug(span.entire(), "wrong delimiters");
529+
// self.dcx.span_delayed_bug(span.entire(), "wrong delimiters");
538530
return None;
539531
}
540532
Some(TokenTree::Token(Token { kind: token::Eq, span }, _)) => {

compiler/rustc_hir/src/hir.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,7 @@ impl AttributeExt for Attribute {
11071107
Attribute::Unparsed(u) => u.span,
11081108
// FIXME: should not be needed anymore when all attrs are parsed
11091109
Attribute::Parsed(AttributeKind::Deprecation { span, .. }) => *span,
1110+
Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
11101111
a => panic!("can't get the span of an arbitrary parsed attribute: {a:?}"),
11111112
}
11121113
}
@@ -1149,6 +1150,7 @@ impl AttributeExt for Attribute {
11491150
fn style(&self) -> AttrStyle {
11501151
match &self {
11511152
Attribute::Unparsed(u) => u.style,
1153+
Attribute::Parsed(AttributeKind::DocComment { style, .. }) => *style,
11521154
_ => panic!(),
11531155
}
11541156
}

compiler/rustc_lint/src/expect.rs

-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
4040
// We are an `eval_always` query, so looking at the attribute's `AttrId` is ok.
4141
let attr_id = tcx.hir().attrs(hir_id)[attr_index as usize].id();
4242

43-
// TODO: we're only dealling with allow/deny/etc lint attributes. They can have an
44-
// ID, while other attributes don't necessarily. however, how do we assert that
45-
// nicely?
46-
// let attr_id = todo!();
4743
(attr_id, lint_index)
4844
}
4945
_ => panic!("fulfilled expectations must have a lint index"),

compiler/rustc_middle/src/ty/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1767,8 +1767,6 @@ impl<'tcx> TyCtxt<'tcx> {
17671767
if let Some(did) = did.as_local() {
17681768
self.hir().attrs(self.local_def_id_to_hir_id(did)).iter()
17691769
} else {
1770-
// TODO: commented this check because we don't have the attr symbol from get_attrs here
1771-
// debug_assert!(rustc_feature::encode_cross_crate(attr));
17721770
self.attrs_for_def(did).iter()
17731771
}
17741772
}

compiler/rustc_passes/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,7 @@ pub(crate) struct NoSanitize<'a> {
18681868
pub attr_str: &'a str,
18691869
}
18701870

1871-
// TODO: move back to rustc_attr
1871+
// FIXME(jdonszelmann): move back to rustc_attr
18721872
#[derive(Diagnostic)]
18731873
#[diag(passes_rustc_const_stable_indirect_pairing)]
18741874
pub(crate) struct RustcConstStableIndirectPairing {

compiler/rustc_passes/src/stability.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
187187
}
188188

189189
if let Some(body_stab) = body_stab {
190-
// TODO: check that this item can have body stability
190+
// FIXME: check that this item can have body stability
191191

192192
self.index.default_body_stab_map.insert(def_id, body_stab);
193193
debug!(?self.index.default_body_stab_map);
@@ -801,8 +801,6 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
801801
let features = self.tcx.features();
802802
if features.staged_api() {
803803
let attrs = self.tcx.hir().attrs(item.hir_id());
804-
// TODO: check with https://github.com/rust-lang/rust/commit/e96808162ad7ff5906d7b58d32a25abe139e998c#diff-5f57ad10e1bdde3d046b258d390fd2ecc6f1511158aa130cebb72093da16ef29
805-
806804
let stab = attr::find_attr!(attrs, AttributeKind::Stability{stability, span} => (*stability, *span));
807805

808806
// FIXME(jdonszelmann): make it impossible to miss the or_else in the typesystem

src/librustdoc/clean/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2732,7 +2732,11 @@ fn add_without_unwanted_attributes<'hir>(
27322732
}
27332733
}
27342734
}
2735-
_ => unreachable!(),
2735+
hir::Attribute::Parsed(..) => {
2736+
if is_inline {
2737+
attrs.push((Cow::Owned(attr), import_parent));
2738+
}
2739+
}
27362740
}
27372741
}
27382742
}

0 commit comments

Comments
 (0)