Skip to content

Commit b3d6ef4

Browse files
committed
Fix all tests
1 parent 4d38c0b commit b3d6ef4

File tree

63 files changed

+552
-673
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+552
-673
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

+5-66
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ pub enum ReprAttr {
6262
ReprSimd,
6363
ReprTransparent,
6464
ReprAlign(Align),
65+
// this one is just so we can emit a lint for it
66+
ReprEmpty,
6567
}
6668
pub use ReprAttr::*;
6769

@@ -139,26 +141,16 @@ impl Deprecation {
139141
/// happen.
140142
///
141143
/// For more docs, look in [`rustc_attr`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_attr/index.html)
142-
// FIXME(jdonszelmann): rename to AttributeKind once hir::AttributeKind is dissolved
143144
#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable)]
144145
pub enum AttributeKind {
145146
// tidy-alphabetical-start
146-
Allow,
147147
AllowConstFnUnstable(ThinVec<Symbol>),
148-
AllowInternalUnsafe,
149-
AllowInternalUnstable(ThinVec<Symbol>),
150-
AutoDiff,
151-
AutomaticallyDerived,
148+
AllowInternalUnstable(ThinVec<(Symbol, Span)>),
152149
BodyStability {
153150
stability: DefaultBodyStability,
154151
/// Span of the `#[rustc_default_body_unstable(...)]` attribute
155152
span: Span,
156153
},
157-
Cfg,
158-
CfgAttr,
159-
CfiEncoding, // FIXME(cfi_encoding)
160-
Cold,
161-
CollapseDebuginfo,
162154
Confusables {
163155
symbols: ThinVec<Symbol>,
164156
// FIXME(jdonszelmann): remove when target validation code is moved
@@ -170,14 +162,6 @@ pub enum AttributeKind {
170162
span: Span,
171163
},
172164
ConstStabilityIndirect,
173-
ConstTrait,
174-
Coroutine,
175-
Coverage,
176-
CustomMir,
177-
DebuggerVisualizer,
178-
DefaultLibAllocator,
179-
Deny,
180-
DeprecatedSafe, // FIXME(deprecated_safe)
181165
Deprecation {
182166
deprecation: Deprecation,
183167
span: Span,
@@ -193,57 +177,12 @@ pub enum AttributeKind {
193177
span: Span,
194178
comment: Symbol,
195179
},
196-
Expect,
197-
ExportName,
198-
FfiConst,
199-
FfiPure,
200-
Forbid,
201-
Fundamental,
202-
Ignore,
203-
// TODO: must contain span for clippy
204-
Inline,
205-
InstructionSet, // broken on stable!!!
206-
Lang,
207-
Link,
208-
Linkage,
209-
LinkName,
210-
LinkOrdinal,
211-
LinkSection,
212-
MacroExport,
213180
MacroTransparency(Transparency),
214-
MacroUse,
215-
Marker,
216-
MayDangle,
217-
MustNotSuspend,
218-
MustUse,
219-
NeedsAllocator,
220-
NoImplicitPrelude,
221-
NoLink,
222-
NoMangle,
223-
NonExhaustive,
224-
NoSanitize,
225-
OmitGdbPrettyPrinterSection, // FIXME(omit_gdb_pretty_printer_section)
226-
PanicHandler,
227-
PatchableFunctionEntry, // FIXME(patchable_function_entry)
228-
Path,
229-
Pointee, // FIXME(derive_smart_pointer)
230-
PreludeImport,
231-
ProcMacro,
232-
ProcMacroAttribute,
233-
ProcMacroDerive,
234-
Repr(ThinVec<ReprAttr>),
181+
Repr(ThinVec<(ReprAttr, Span)>),
235182
Stability {
236183
stability: Stability,
237184
/// Span of the `#[stable(...)]` or `#[unstable(...)]` attribute
238185
span: Span,
239186
},
240-
Start,
241-
TargetFeature,
242-
ThreadLocal,
243-
TrackCaller,
244-
Unstable,
245-
Used,
246-
Warn,
247-
WindowsSubsystem, // broken on stable!!!
248-
// tidy-alphabetical-end
187+
// tidy-alphabetical-end
249188
}

compiler/rustc_attr_parsing/messages.ftl

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ attr_parsing_non_ident_feature =
9292
9393
attr_parsing_repr_ident =
9494
meta item in `repr` must be an identifier
95+
9596
attr_parsing_rustc_allowed_unstable_pairing =
9697
`rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute
9798

compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
use std::iter;
2+
13
use rustc_attr_data_structures::AttributeKind;
2-
use rustc_span::{Symbol, sym};
4+
use rustc_span::{Span, Symbol, sym};
35

46
use super::{CombineAttributeParser, ConvertFn};
57
use crate::context::AcceptContext;
@@ -9,14 +11,14 @@ use crate::session_diagnostics;
911
pub(crate) struct AllowInternalUnstableParser;
1012
impl CombineAttributeParser for AllowInternalUnstableParser {
1113
const PATH: &'static [rustc_span::Symbol] = &[sym::allow_internal_unstable];
12-
type Item = Symbol;
14+
type Item = (Symbol, Span);
1315
const CONVERT: ConvertFn<Self::Item> = AttributeKind::AllowInternalUnstable;
1416

1517
fn extend<'a>(
1618
cx: &'a AcceptContext<'a>,
1719
args: &'a ArgParser<'a>,
1820
) -> impl IntoIterator<Item = Self::Item> + 'a {
19-
parse_unstable(cx, args, Self::PATH[0])
21+
parse_unstable(cx, args, Self::PATH[0]).into_iter().zip(iter::repeat(cx.attr_span))
2022
}
2123
}
2224

@@ -42,7 +44,7 @@ fn parse_unstable<'a>(
4244
let mut res = Vec::new();
4345

4446
let Some(list) = args.list() else {
45-
cx.dcx().emit_err(session_diagnostics::ExpectsFeatureList {
47+
cx.emit_err(session_diagnostics::ExpectsFeatureList {
4648
span: cx.attr_span,
4749
name: symbol.to_ident_string(),
4850
});
@@ -54,7 +56,7 @@ fn parse_unstable<'a>(
5456
if let Some(ident) = param.meta_item().and_then(|i| i.word_without_args()) {
5557
res.push(ident.name);
5658
} else {
57-
cx.dcx().emit_err(session_diagnostics::ExpectsFeatures {
59+
cx.emit_err(session_diagnostics::ExpectsFeatures {
5860
span: param_span,
5961
name: symbol.to_ident_string(),
6062
});

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use rustc_attr_data_structures::AttributeKind;
22
use rustc_span::{Span, Symbol, sym};
33
use thin_vec::ThinVec;
44

5-
use crate::session_diagnostics;
6-
75
use super::{AcceptMapping, AttributeParser, FinalizeContext};
6+
use crate::session_diagnostics;
87

98
#[derive(Default)]
109
pub(crate) struct ConfusablesParser {
@@ -15,21 +14,21 @@ pub(crate) struct ConfusablesParser {
1514
impl AttributeParser for ConfusablesParser {
1615
const ATTRIBUTES: AcceptMapping<Self> = &[(&[sym::rustc_confusables], |this, cx, args| {
1716
let Some(list) = args.list() else {
18-
// TODO: error when not a list? Bring validation code here.
17+
// FIXME(jdonszelmann): error when not a list? Bring validation code here.
1918
// NOTE: currently subsequent attributes are silently ignored using
2019
// tcx.get_attr().
2120
return;
2221
};
2322

2423
if list.is_empty() {
25-
cx.dcx().emit_err(session_diagnostics::EmptyConfusables { span: cx.attr_span });
24+
cx.emit_err(session_diagnostics::EmptyConfusables { span: cx.attr_span });
2625
}
2726

2827
for param in list.mixed() {
2928
let span = param.span();
3029

3130
let Some(lit) = param.lit() else {
32-
cx.dcx().emit_err(session_diagnostics::IncorrectMetaItem {
31+
cx.emit_err(session_diagnostics::IncorrectMetaItem {
3332
span,
3433
suggestion: Some(session_diagnostics::IncorrectMetaItemSuggestion {
3534
lo: span.shrink_to_lo(),

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn get(
1919
item: &mut Option<Symbol>,
2020
) -> bool {
2121
if item.is_some() {
22-
cx.dcx().emit_err(session_diagnostics::MultipleItem {
22+
cx.emit_err(session_diagnostics::MultipleItem {
2323
span: param_span,
2424
item: ident.to_string(),
2525
});
@@ -31,7 +31,7 @@ fn get(
3131
true
3232
} else {
3333
let lit = v.value_as_lit();
34-
cx.dcx().emit_err(session_diagnostics::UnsupportedLiteral {
34+
cx.emit_err(session_diagnostics::UnsupportedLiteral {
3535
span: v.value_span,
3636
reason: UnsupportedLiteralReason::DeprecatedString,
3737
is_bytestr: lit.kind.is_bytestr(),
@@ -41,10 +41,7 @@ fn get(
4141
}
4242
} else {
4343
// FIXME(jdonszelmann): suggestion?
44-
cx.dcx().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
}
@@ -54,7 +51,7 @@ impl SingleAttributeParser for DeprecationParser {
5451

5552
fn on_duplicate(cx: &AcceptContext<'_>, first_span: rustc_span::Span) {
5653
// FIXME(jdonszelmann): merge with errors from check_attrs.rs
57-
cx.dcx().emit_err(session_diagnostics::UnusedMultiple {
54+
cx.emit_err(session_diagnostics::UnusedMultiple {
5855
this: cx.attr_span,
5956
other: first_span,
6057
name: sym::deprecated,
@@ -78,7 +75,7 @@ impl SingleAttributeParser for DeprecationParser {
7875
for param in list.mixed() {
7976
let param_span = param.span();
8077
let Some(param) = param.meta_item() else {
81-
cx.dcx().emit_err(session_diagnostics::UnsupportedLiteral {
78+
cx.emit_err(session_diagnostics::UnsupportedLiteral {
8279
span: param_span,
8380
reason: UnsupportedLiteralReason::DeprecatedKvPair,
8481
is_bytestr: false,
@@ -102,7 +99,7 @@ impl SingleAttributeParser for DeprecationParser {
10299
}
103100
sym::suggestion => {
104101
if !features.deprecated_suggestion() {
105-
cx.dcx().emit_err(session_diagnostics::DeprecatedItemSuggestion {
102+
cx.emit_err(session_diagnostics::DeprecatedItemSuggestion {
106103
span: param_span,
107104
is_nightly: cx.sess().is_nightly_build(),
108105
details: (),
@@ -114,7 +111,7 @@ impl SingleAttributeParser for DeprecationParser {
114111
}
115112
}
116113
_ => {
117-
cx.dcx().emit_err(session_diagnostics::UnknownMetaItem {
114+
cx.emit_err(session_diagnostics::UnknownMetaItem {
118115
span: param_span,
119116
item: ident.to_string(),
120117
expected: if features.deprecated_suggestion() {
@@ -137,18 +134,18 @@ impl SingleAttributeParser for DeprecationParser {
137134
} else if let Some(version) = parse_version(since) {
138135
DeprecatedSince::RustcVersion(version)
139136
} else {
140-
cx.dcx().emit_err(session_diagnostics::InvalidSince { span: cx.attr_span });
137+
cx.emit_err(session_diagnostics::InvalidSince { span: cx.attr_span });
141138
DeprecatedSince::Err
142139
}
143140
} else if is_rustc {
144-
cx.dcx().emit_err(session_diagnostics::MissingSince { span: cx.attr_span });
141+
cx.emit_err(session_diagnostics::MissingSince { span: cx.attr_span });
145142
DeprecatedSince::Err
146143
} else {
147144
DeprecatedSince::Unspecified
148145
};
149146

150147
if is_rustc && note.is_none() {
151-
cx.dcx().emit_err(session_diagnostics::MissingNote { span: cx.attr_span });
148+
cx.emit_err(session_diagnostics::MissingNote { span: cx.attr_span });
152149
return None;
153150
}
154151

0 commit comments

Comments
 (0)