Skip to content

Commit c5abf08

Browse files
committed
Fix all tests
1 parent c0da9ee commit c5abf08

File tree

55 files changed

+526
-571
lines changed

Some content is hidden

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

55 files changed

+526
-571
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

+4-2
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

@@ -146,7 +148,7 @@ pub enum AttributeKind {
146148
Allow,
147149
AllowConstFnUnstable(ThinVec<Symbol>),
148150
AllowInternalUnsafe,
149-
AllowInternalUnstable(ThinVec<Symbol>),
151+
AllowInternalUnstable(ThinVec<(Symbol, Span)>),
150152
AutoDiff,
151153
AutomaticallyDerived,
152154
BodyStability {
@@ -231,7 +233,7 @@ pub enum AttributeKind {
231233
ProcMacro,
232234
ProcMacroAttribute,
233235
ProcMacroDerive,
234-
Repr(ThinVec<ReprAttr>),
236+
Repr(ThinVec<(ReprAttr, Span)>),
235237
Stability {
236238
stability: Stability,
237239
/// Span of the `#[stable(...)]` or `#[unstable(...)]` attribute

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/confusables.rs

+3-4
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 {
@@ -22,14 +21,14 @@ impl AttributeParser for ConfusablesParser {
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)