authorbors <bors@rust-lang.org> 2026-05-30 17:09:19 UTC
committerbors <bors@rust-lang.org> 2026-05-30 17:09:19 UTC
logf8a08b688cbe60acc386ed1fbd1b7cbaaf5576b1
tree66a4b62d07b8f928687102f29de606648b3b5557
parentc58275e0369d09fc3959b8ba87dcbcbe73797465
parent62cc8069e99a83c3202d7c3106c1fcc091d21407

Auto merge of #157161 - JonathanBrouwer:rollup-3MNUPwu, r=JonathanBrouwer

Rollup of 8 pull requests Successful merges: - rust-lang/rust#156863 (Make hint::cold_path #[cold] so that it works even if the MIR inliner can't inline it) - rust-lang/rust#156875 (Correct and document semantics of `yield` terminator) - rust-lang/rust#157115 ([rustdoc] Fix foreign items macro expansion) - rust-lang/rust#157150 (Revert "drop derive helpers during ast lowering" ) - rust-lang/rust#156887 (Rename `-Zdebuginfo-for-profiling` switch) - rust-lang/rust#157039 (rustdoc: correctly propagate cfgs for glob reexports) - rust-lang/rust#157125 (Rewrite the `#[repr]` attribute parser) - rust-lang/rust#157154 (Revert workaround used to select the gcc codegen in the coretests CI)

65 files changed, 753 insertions(+), 650 deletions(-)

compiler/rustc_attr_parsing/src/attributes/prelude.rs+1-1
......@@ -6,7 +6,7 @@ pub(super) use rustc_hir::attrs::AttributeKind;
66#[doc(hidden)]
77pub(super) use rustc_hir::{MethodKind, Target};
88#[doc(hidden)]
9pub(super) use rustc_span::{DUMMY_SP, Ident, Span, Symbol, sym};
9pub(super) use rustc_span::{Ident, Span, Symbol, sym};
1010#[doc(hidden)]
1111pub(super) use thin_vec::ThinVec;
1212
compiler/rustc_attr_parsing/src/attributes/repr.rs+80-171
......@@ -1,18 +1,20 @@
11use rustc_abi::{Align, Size};
22use rustc_ast::{IntTy, LitIntType, LitKind, UintTy};
3use rustc_hir::attrs::{IntType, ReprAttr};
3use rustc_hir::attrs::IntType::{SignedInt, UnsignedInt};
4use rustc_hir::attrs::ReprAttr;
45
56use super::prelude::*;
6use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
7use crate::session_diagnostics;
78
89/// Parse #[repr(...)] forms.
910///
10/// Valid repr contents: any of the primitive integral type names (see
11/// `int_type_of_word`, below) to specify enum discriminant type; `C`, to use
12/// the same discriminant size that the corresponding C enum would or C
13/// structure layout, `packed` to remove padding, and `transparent` to delegate representation
14/// concerns to the only non-ZST field.
15// FIXME(jdonszelmann): is a vec the right representation here even? isn't it just a struct?
11/// Valid repr contents:
12/// * any of the primitive integral type names to specify enum discriminant type
13/// * `Rust`, to use the default `Rust` layout of the type
14/// * `C`, to use the same layout for the type that C would use
15/// * `align(...)`, to change the alignment requirements of the type
16/// * `packed`, to remove padding
17/// * `transparent`, to delegate representation concerns to the only non-ZST field.
1618pub(crate) struct ReprParser;
1719
1820impl CombineAttributeParser for ReprParser {
......@@ -20,7 +22,6 @@ impl CombineAttributeParser for ReprParser {
2022 const PATH: &[Symbol] = &[sym::repr];
2123 const CONVERT: ConvertFn<Self::Item> =
2224 |items, first_span| AttributeKind::Repr { reprs: items, first_span };
23 // FIXME(jdonszelmann): never used
2425 const TEMPLATE: AttributeTemplate = template!(
2526 List: &["C", "Rust", "transparent", "align(...)", "packed(...)", "<integer type>"],
2627 "https://doc.rust-lang.org/reference/type-layout.html#representations"
......@@ -30,29 +31,24 @@ impl CombineAttributeParser for ReprParser {
3031 cx: &mut AcceptContext<'_, '_>,
3132 args: &ArgParser,
3233 ) -> impl IntoIterator<Item = Self::Item> {
33 let mut reprs = Vec::new();
34
3534 let Some(list) = cx.expect_list(args, cx.attr_span) else {
36 return reprs;
35 return vec![];
3736 };
3837
3938 if list.is_empty() {
4039 let attr_span = cx.attr_span;
4140 cx.adcx().warn_empty_attribute(attr_span);
42 return reprs;
41 return vec![];
4342 }
4443
44 let mut reprs = Vec::new();
4545 for param in list.mixed() {
46 if let Some(_) = param.as_lit() {
47 cx.emit_err(session_diagnostics::ReprIdent { span: cx.attr_span });
46 let Some(item) = param.meta_item() else {
47 cx.adcx().expected_identifier(param.span());
4848 continue;
49 }
50
51 reprs.extend(
52 param.meta_item().and_then(|mi| parse_repr(cx, &mi)).map(|r| (r, param.span())),
53 );
49 };
50 reprs.extend(parse_repr(cx, &item).map(|r| (r, param.span())));
5451 }
55
5652 reprs
5753 }
5854
......@@ -61,122 +57,69 @@ impl CombineAttributeParser for ReprParser {
6157 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
6258}
6359
64macro_rules! int_pat {
65 () => {
66 sym::i8
67 | sym::u8
68 | sym::i16
69 | sym::u16
70 | sym::i32
71 | sym::u32
72 | sym::i64
73 | sym::u64
74 | sym::i128
75 | sym::u128
76 | sym::isize
77 | sym::usize
78 };
79}
80
81fn int_type_of_word(s: Symbol) -> Option<IntType> {
82 use IntType::*;
83
84 match s {
85 sym::i8 => Some(SignedInt(IntTy::I8)),
86 sym::u8 => Some(UnsignedInt(UintTy::U8)),
87 sym::i16 => Some(SignedInt(IntTy::I16)),
88 sym::u16 => Some(UnsignedInt(UintTy::U16)),
89 sym::i32 => Some(SignedInt(IntTy::I32)),
90 sym::u32 => Some(UnsignedInt(UintTy::U32)),
91 sym::i64 => Some(SignedInt(IntTy::I64)),
92 sym::u64 => Some(UnsignedInt(UintTy::U64)),
93 sym::i128 => Some(SignedInt(IntTy::I128)),
94 sym::u128 => Some(UnsignedInt(UintTy::U128)),
95 sym::isize => Some(SignedInt(IntTy::Isize)),
96 sym::usize => Some(UnsignedInt(UintTy::Usize)),
97 _ => None,
98 }
99}
100
101fn parse_repr(cx: &AcceptContext<'_, '_>, param: &MetaItemParser) -> Option<ReprAttr> {
60fn parse_repr(cx: &mut AcceptContext<'_, '_>, param: &MetaItemParser) -> Option<ReprAttr> {
10261 use ReprAttr::*;
10362
104 // FIXME(jdonszelmann): invert the parsing here to match on the word first and then the
105 // structure.
106 let (name, ident_span) = if let Some(ident) = param.path().word() {
107 (Some(ident.name), ident.span)
108 } else {
109 (None, DUMMY_SP)
110 };
111
112 let args = param.args();
113
114 match (name, args) {
115 (Some(sym::align), ArgParser::NoArgs) => {
116 cx.emit_err(session_diagnostics::InvalidReprAlignNeedArg { span: ident_span });
117 None
118 }
119 (Some(sym::align), ArgParser::List(l)) => {
120 parse_repr_align(cx, l, param.span(), AlignKind::Align)
121 }
122
123 (Some(sym::packed), ArgParser::NoArgs) => Some(ReprPacked(Align::ONE)),
124 (Some(sym::packed), ArgParser::List(l)) => {
125 parse_repr_align(cx, l, param.span(), AlignKind::Packed)
126 }
127
128 (Some(name @ sym::align | name @ sym::packed), ArgParser::NameValue(l)) => {
129 cx.emit_err(session_diagnostics::IncorrectReprFormatGeneric {
130 span: param.span(),
131 // FIXME(jdonszelmann) can just be a string in the diag type
132 repr_arg: name,
133 cause: IncorrectReprFormatGenericCause::from_lit_kind(
134 param.span(),
135 &l.value_as_lit().kind,
136 name,
137 ),
138 });
139 None
140 }
141
142 (Some(sym::Rust), ArgParser::NoArgs) => Some(ReprRust),
143 (Some(sym::C), ArgParser::NoArgs) => Some(ReprC),
144 (Some(sym::simd), ArgParser::NoArgs) => Some(ReprSimd),
145 (Some(sym::transparent), ArgParser::NoArgs) => Some(ReprTransparent),
146 (Some(name @ int_pat!()), ArgParser::NoArgs) => {
147 // int_pat!() should make sure it always parses
148 Some(ReprInt(int_type_of_word(name).unwrap()))
149 }
63 macro_rules! no_args {
64 ($constructor: expr) => {{
65 cx.expect_no_args(param.args())?;
66 Some($constructor)
67 }};
68 }
15069
151 (
152 Some(
153 name @ sym::Rust
154 | name @ sym::C
155 | name @ sym::simd
156 | name @ sym::transparent
157 | name @ int_pat!(),
158 ),
159 ArgParser::NameValue(_),
160 ) => {
161 cx.emit_err(session_diagnostics::InvalidReprHintNoValue { span: param.span(), name });
162 None
163 }
164 (
165 Some(
166 name @ sym::Rust
167 | name @ sym::C
168 | name @ sym::simd
169 | name @ sym::transparent
170 | name @ int_pat!(),
171 ),
172 ArgParser::List(_),
173 ) => {
174 cx.emit_err(session_diagnostics::InvalidReprHintNoParen { span: param.span(), name });
175 None
70 match param.path().word_sym() {
71 Some(sym::align) => {
72 let l = cx.expect_list(param.args(), param.span())?;
73 parse_repr_align(cx, l, AlignKind::Align)
17674 }
177
75 Some(sym::packed) => match param.args() {
76 ArgParser::NoArgs => Some(ReprPacked(Align::ONE)),
77 ArgParser::List(l) => parse_repr_align(cx, l, AlignKind::Packed),
78 ArgParser::NameValue(_) => {
79 cx.adcx().expected_list_or_no_args(param.span());
80 None
81 }
82 },
83 Some(sym::Rust) => no_args!(ReprRust),
84 Some(sym::C) => no_args!(ReprC),
85 Some(sym::simd) => no_args!(ReprSimd),
86 Some(sym::transparent) => no_args!(ReprTransparent),
87 Some(sym::i8) => no_args!(ReprInt(SignedInt(IntTy::I8))),
88 Some(sym::u8) => no_args!(ReprInt(UnsignedInt(UintTy::U8))),
89 Some(sym::i16) => no_args!(ReprInt(SignedInt(IntTy::I16))),
90 Some(sym::u16) => no_args!(ReprInt(UnsignedInt(UintTy::U16))),
91 Some(sym::i32) => no_args!(ReprInt(SignedInt(IntTy::I32))),
92 Some(sym::u32) => no_args!(ReprInt(UnsignedInt(UintTy::U32))),
93 Some(sym::i64) => no_args!(ReprInt(SignedInt(IntTy::I64))),
94 Some(sym::u64) => no_args!(ReprInt(UnsignedInt(UintTy::U64))),
95 Some(sym::i128) => no_args!(ReprInt(SignedInt(IntTy::I128))),
96 Some(sym::u128) => no_args!(ReprInt(UnsignedInt(UintTy::U128))),
97 Some(sym::isize) => no_args!(ReprInt(SignedInt(IntTy::Isize))),
98 Some(sym::usize) => no_args!(ReprInt(UnsignedInt(UintTy::Usize))),
17899 _ => {
179 cx.emit_err(session_diagnostics::UnrecognizedReprHint { span: param.span() });
100 cx.adcx().expected_specific_argument(
101 param.span(),
102 &[
103 sym::align,
104 sym::packed,
105 sym::Rust,
106 sym::C,
107 sym::simd,
108 sym::transparent,
109 sym::i8,
110 sym::u8,
111 sym::i16,
112 sym::u16,
113 sym::i32,
114 sym::u32,
115 sym::i64,
116 sym::u64,
117 sym::i128,
118 sym::u128,
119 sym::isize,
120 sym::usize,
121 ],
122 );
180123 None
181124 }
182125 }
......@@ -188,44 +131,17 @@ enum AlignKind {
188131}
189132
190133fn parse_repr_align(
191 cx: &AcceptContext<'_, '_>,
134 cx: &mut AcceptContext<'_, '_>,
192135 list: &MetaItemListParser,
193 param_span: Span,
194136 align_kind: AlignKind,
195137) -> Option<ReprAttr> {
196 use AlignKind::*;
197
198138 let Some(align) = list.as_single() else {
199 match align_kind {
200 Packed => {
201 cx.emit_err(session_diagnostics::IncorrectReprFormatPackedOneOrZeroArg {
202 span: param_span,
203 });
204 }
205 Align => {
206 cx.emit_err(session_diagnostics::IncorrectReprFormatAlignOneArg {
207 span: param_span,
208 });
209 }
210 }
211
139 cx.adcx().expected_single_argument(list.span, list.len());
212140 return None;
213141 };
214142
215143 let Some(lit) = align.as_lit() else {
216 match align_kind {
217 Packed => {
218 cx.emit_err(session_diagnostics::IncorrectReprFormatPackedExpectInteger {
219 span: align.span(),
220 });
221 }
222 Align => {
223 cx.emit_err(session_diagnostics::IncorrectReprFormatExpectInteger {
224 span: align.span(),
225 });
226 }
227 }
228
144 cx.adcx().expected_integer_literal(align.span());
229145 return None;
230146 };
231147
......@@ -235,12 +151,8 @@ fn parse_repr_align(
235151 AlignKind::Align => ReprAttr::ReprAlign(literal),
236152 }),
237153 Err(message) => {
238 cx.emit_err(session_diagnostics::InvalidReprGeneric {
154 cx.emit_err(session_diagnostics::InvalidAlignmentValue {
239155 span: lit.span,
240 repr_arg: match align_kind {
241 Packed => "packed".to_string(),
242 Align => "align".to_string(),
243 },
244156 error_part: message,
245157 });
246158 None
......@@ -294,10 +206,7 @@ impl RustcAlignParser {
294206 };
295207
296208 let Some(lit) = align.as_lit() else {
297 cx.emit_err(session_diagnostics::IncorrectReprFormatExpectInteger {
298 span: align.span(),
299 });
300
209 cx.adcx().expected_integer_literal(align.span());
301210 return;
302211 };
303212
compiler/rustc_attr_parsing/src/interface.rs+3-20
......@@ -285,11 +285,6 @@ impl<'sess> AttributeParser<'sess> {
285285 mut emit_lint: impl FnMut(LintId, MultiSpan, EmitAttribute),
286286 ) -> Vec<Attribute> {
287287 let mut attributes = Vec::new();
288 // We store the attributes we intend to discard at the end of this function in order to
289 // check they are applied to the right target and error out if necessary. In practice, we
290 // end up dropping only derive attributes and derive helpers, both being fully processed
291 // at macro expansion.
292 let mut dropped_attributes = Vec::new();
293288 let mut attr_paths: Vec<RefPathParser<'_>> = Vec::new();
294289 let mut early_parsed_state = EarlyParsedState::default();
295290
......@@ -437,20 +432,8 @@ impl<'sess> AttributeParser<'sess> {
437432 self.check_invalid_crate_level_attr_item(&attr, n.item.span());
438433 }
439434
440 let attr = Attribute::Unparsed(Box::new(attr));
441
442 if self.tools.is_some_and(|tools| {
443 tools.iter().any(|tool| tool.name == parts[0])
444 // FIXME: this can be removed once #152369 has been merged.
445 // https://github.com/rust-lang/rust/pull/152369
446 || [sym::allow, sym::deny, sym::expect, sym::forbid, sym::warn]
447 .contains(&parts[0])
448 }) {
449 attributes.push(attr);
450 } else {
451 dropped_attributes.push(attr);
452 }
453 }
435 attributes.push(Attribute::Unparsed(Box::new(attr)));
436 };
454437 }
455438 }
456439 }
......@@ -466,7 +449,7 @@ impl<'sess> AttributeParser<'sess> {
466449 }
467450
468451 if !matches!(self.should_emit, ShouldEmit::Nothing) && target == Target::WherePredicate {
469 self.check_invalid_where_predicate_attrs(attributes.iter().chain(&dropped_attributes));
452 self.check_invalid_where_predicate_attrs(attributes.iter());
470453 }
471454
472455 attributes
compiler/rustc_attr_parsing/src/session_diagnostics.rs+1-141
......@@ -1,6 +1,5 @@
11use std::num::IntErrorKind;
22
3use rustc_ast as ast;
43use rustc_errors::codes::*;
54use rustc_errors::{
65 Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level,
......@@ -183,126 +182,6 @@ pub(crate) struct MissingIssue {
183182 pub span: Span,
184183}
185184
186// FIXME: Why is this the same error code as `InvalidReprHintNoParen` and `InvalidReprHintNoValue`?
187// It is more similar to `IncorrectReprFormatGeneric`.
188#[derive(Diagnostic)]
189#[diag("incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all", code = E0552)]
190pub(crate) struct IncorrectReprFormatPackedOneOrZeroArg {
191 #[primary_span]
192 pub span: Span,
193}
194#[derive(Diagnostic)]
195#[diag("incorrect `repr(packed)` attribute format: `packed` expects a literal integer as argument", code = E0552)]
196pub(crate) struct IncorrectReprFormatPackedExpectInteger {
197 #[primary_span]
198 pub span: Span,
199}
200
201#[derive(Diagnostic)]
202#[diag("invalid representation hint: `{$name}` does not take a parenthesized argument list", code = E0552)]
203pub(crate) struct InvalidReprHintNoParen {
204 #[primary_span]
205 pub span: Span,
206
207 pub name: Symbol,
208}
209
210#[derive(Diagnostic)]
211#[diag("invalid representation hint: `{$name}` does not take a value", code = E0552)]
212pub(crate) struct InvalidReprHintNoValue {
213 #[primary_span]
214 pub span: Span,
215
216 pub name: Symbol,
217}
218
219#[derive(Diagnostic)]
220#[diag("invalid `repr(align)` attribute: `align` needs an argument", code = E0589)]
221pub(crate) struct InvalidReprAlignNeedArg {
222 #[primary_span]
223 #[suggestion(
224 "supply an argument here",
225 code = "align(...)",
226 applicability = "has-placeholders"
227 )]
228 pub span: Span,
229}
230
231#[derive(Diagnostic)]
232#[diag("invalid `repr({$repr_arg})` attribute: {$error_part}", code = E0589)]
233pub(crate) struct InvalidReprGeneric {
234 #[primary_span]
235 pub span: Span,
236
237 pub repr_arg: String,
238 pub error_part: String,
239}
240
241#[derive(Diagnostic)]
242#[diag("incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses", code = E0693)]
243pub(crate) struct IncorrectReprFormatAlignOneArg {
244 #[primary_span]
245 pub span: Span,
246}
247
248#[derive(Diagnostic)]
249#[diag("incorrect `repr(align)` attribute format: `align` expects a literal integer as argument", code = E0693)]
250pub(crate) struct IncorrectReprFormatExpectInteger {
251 #[primary_span]
252 pub span: Span,
253}
254
255#[derive(Diagnostic)]
256#[diag("incorrect `repr({$repr_arg})` attribute format", code = E0693)]
257pub(crate) struct IncorrectReprFormatGeneric {
258 #[primary_span]
259 pub span: Span,
260
261 pub repr_arg: Symbol,
262
263 #[subdiagnostic]
264 pub cause: Option<IncorrectReprFormatGenericCause>,
265}
266
267#[derive(Subdiagnostic)]
268pub(crate) enum IncorrectReprFormatGenericCause {
269 #[suggestion(
270 "use parentheses instead",
271 code = "{name}({value})",
272 applicability = "machine-applicable"
273 )]
274 Int {
275 #[primary_span]
276 span: Span,
277 name: Symbol,
278 value: u128,
279 },
280
281 #[suggestion(
282 "use parentheses instead",
283 code = "{name}({value})",
284 applicability = "machine-applicable"
285 )]
286 Symbol {
287 #[primary_span]
288 span: Span,
289 name: Symbol,
290 value: Symbol,
291 },
292}
293
294impl IncorrectReprFormatGenericCause {
295 pub(crate) fn from_lit_kind(span: Span, kind: &ast::LitKind, name: Symbol) -> Option<Self> {
296 match *kind {
297 ast::LitKind::Int(value, ast::LitIntType::Unsuffixed) => {
298 Some(Self::Int { span, name, value: value.get() })
299 }
300 ast::LitKind::Str(value, _) => Some(Self::Symbol { span, name, value }),
301 _ => None,
302 }
303 }
304}
305
306185#[derive(Diagnostic)]
307186#[diag("`rustc_promotable` attribute must be paired with either a `rustc_const_unstable` or a `rustc_const_stable` attribute", code = E0717)]
308187pub(crate) struct RustcPromotablePairing {
......@@ -484,26 +363,6 @@ pub(crate) struct InvalidAlignmentValue {
484363 pub error_part: String,
485364}
486365
487#[derive(Diagnostic)]
488#[diag("meta item in `repr` must be an identifier", code = E0565)]
489pub(crate) struct ReprIdent {
490 #[primary_span]
491 pub span: Span,
492}
493
494#[derive(Diagnostic)]
495#[diag("unrecognized representation hint", code = E0552)]
496#[help(
497 "valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`"
498)]
499#[note(
500 "for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations>"
501)]
502pub(crate) struct UnrecognizedReprHint {
503 #[primary_span]
504 pub span: Span,
505}
506
507366#[derive(Diagnostic)]
508367#[diag("item annotated with `#[unstable_feature_bound]` should not be stable")]
509368#[help(
......@@ -849,6 +708,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError<'_> {
849708 }
850709 AttributeParseErrorReason::ExpectedIdentifier => {
851710 diag.span_label(self.span, "expected a valid identifier here");
711 diag.code(E0565);
852712 }
853713 }
854714
compiler/rustc_codegen_ssa/src/back/write.rs+1-1
......@@ -180,7 +180,7 @@ impl ModuleConfig {
180180 ),
181181 pgo_use: if_regular!(sess.opts.cg.profile_use.clone(), None),
182182 pgo_sample_use: if_regular!(sess.opts.unstable_opts.profile_sample_use.clone(), None),
183 debug_info_for_profiling: sess.opts.unstable_opts.debug_info_for_profiling,
183 debug_info_for_profiling: sess.opts.unstable_opts.debuginfo_for_profiling,
184184 instrument_coverage: if_regular!(sess.instrument_coverage(), false),
185185
186186 sanitizer: if_regular!(sess.sanitizers(), SanitizerSet::empty()),
compiler/rustc_error_codes/src/error_codes/E0552.md+4-1
......@@ -1,8 +1,11 @@
1#### Note: this error code is no longer emitted by the compiler.
2This error code was replaced by `E0539`.
3
14A unrecognized representation attribute was used.
25
36Erroneous code example:
47
5```compile_fail,E0552
8```compile_fail
69#[repr(D)] // error: unrecognized representation hint
710struct MyStruct {
811 my_field: usize
compiler/rustc_error_codes/src/error_codes/E0693.md+4-1
......@@ -1,8 +1,11 @@
1#### Note: this error code is no longer emitted by the compiler.
2This error code was replaced by `E0539`.
3
14`align` representation hint was incorrectly declared.
25
36Erroneous code examples:
47
5```compile_fail,E0693
8```compile_fail
69#[repr(align=8)] // error!
710struct Align8(i8);
811
compiler/rustc_interface/src/tests.rs+1-1
......@@ -782,8 +782,8 @@ fn test_unstable_options_tracking_hash() {
782782 );
783783 tracked!(crate_attr, vec!["abc".to_string()]);
784784 tracked!(cross_crate_inline_threshold, InliningThreshold::Always);
785 tracked!(debug_info_for_profiling, true);
786785 tracked!(debug_info_type_line_numbers, true);
786 tracked!(debuginfo_for_profiling, true);
787787 tracked!(default_visibility, Some(rustc_target::spec::SymbolVisibility::Hidden));
788788 tracked!(dep_info_omit_d_target, true);
789789 tracked!(direct_access_external_data, Some(true));
compiler/rustc_middle/src/mir/syntax.rs+12-7
......@@ -872,11 +872,18 @@ pub enum TerminatorKind<'tcx> {
872872 /// Marks a suspend point.
873873 ///
874874 /// Like `Return` terminators in coroutine bodies, this computes `value` and then a
875 /// `CoroutineState::Yielded(value)` as if by `Aggregate` rvalue. That value is then assigned to
876 /// the return place of the function calling this one, and execution continues in the calling
877 /// function. When next invoked with the same first argument, execution of this function
878 /// continues at the `resume` basic block, with the second argument written to the `resume_arg`
879 /// place. If the coroutine is dropped before then, the `drop` basic block is invoked.
875 /// `CoroutineState::Yielded(value)` as if by `Aggregate` rvalue. That value is then assigned
876 /// to the return place provided by the caller function, and execution continues in this caller
877 /// function.
878 ///
879 /// When the coroutine is resumed/polled, execution of this function continues at the `resume`
880 /// basic block, the `resume_arg` place is evaluated and the second argument to `resume/poll`
881 /// is written to it.
882 ///
883 /// If the coroutine is dropped before then, execution of this function continues at the `drop`
884 /// basic block and the `resume_arg` place expression is evaluated. For async drop, the second
885 /// argument to the destructor `resume/poll` method is written to `resume_arg`. For synchronous
886 /// drops, uninitialized bytes are written to `resume_arg`.
880887 ///
881888 /// Note that coroutines can be (unstably) cloned under certain conditions, which means that
882889 /// this terminator can **return multiple times**! MIR optimizations that reorder code into
......@@ -884,8 +891,6 @@ pub enum TerminatorKind<'tcx> {
884891 /// See <https://github.com/rust-lang/rust/issues/95360>.
885892 ///
886893 /// Not permitted in bodies that are not coroutine bodies, or after coroutine lowering.
887 ///
888 /// **Needs clarification**: What about the evaluation order of the `resume_arg` and `value`?
889894 Yield {
890895 /// The value to return.
891896 value: Operand<'tcx>,
compiler/rustc_middle/src/mir/terminator.rs+13-19
......@@ -674,7 +674,7 @@ impl<'tcx> TerminatorKind<'tcx> {
674674 }
675675}
676676
677#[derive(Copy, Clone, Debug)]
677#[derive(Debug)]
678678pub enum TerminatorEdges<'mir, 'tcx> {
679679 /// For terminators that have no successor, like `return`.
680680 None,
......@@ -686,7 +686,7 @@ pub enum TerminatorEdges<'mir, 'tcx> {
686686 Double(BasicBlock, BasicBlock),
687687 /// Special action for `Yield`, `Call` and `InlineAsm` terminators.
688688 AssignOnReturn {
689 return_: &'mir [BasicBlock],
689 return_: Box<[BasicBlock]>,
690690 /// The cleanup block, if it exists.
691691 cleanup: Option<BasicBlock>,
692692 place: CallReturnPlaces<'mir, 'tcx>,
......@@ -755,27 +755,21 @@ impl<'tcx> TerminatorKind<'tcx> {
755755 TerminatorEdges::Double(real_target, imaginary_target)
756756 }
757757
758 Yield { resume: ref target, drop, resume_arg, value: _ } => {
758 Yield { resume: target, drop, resume_arg, value: _ } => {
759759 TerminatorEdges::AssignOnReturn {
760 return_: slice::from_ref(target),
761 cleanup: drop,
760 return_: [target].into_iter().chain(drop.into_iter()).collect(),
761 cleanup: None,
762762 place: CallReturnPlaces::Yield(resume_arg),
763763 }
764764 }
765765
766 Call {
767 unwind,
768 destination,
769 ref target,
770 func: _,
771 args: _,
772 fn_span: _,
773 call_source: _,
774 } => TerminatorEdges::AssignOnReturn {
775 return_: target.as_ref().map(slice::from_ref).unwrap_or_default(),
776 cleanup: unwind.cleanup_block(),
777 place: CallReturnPlaces::Call(destination),
778 },
766 Call { unwind, destination, target, func: _, args: _, fn_span: _, call_source: _ } => {
767 TerminatorEdges::AssignOnReturn {
768 return_: target.into_iter().collect(),
769 cleanup: unwind.cleanup_block(),
770 place: CallReturnPlaces::Call(destination),
771 }
772 }
779773
780774 InlineAsm {
781775 asm_macro: _,
......@@ -786,7 +780,7 @@ impl<'tcx> TerminatorKind<'tcx> {
786780 ref targets,
787781 unwind,
788782 } => TerminatorEdges::AssignOnReturn {
789 return_: targets,
783 return_: targets.to_owned(),
790784 cleanup: unwind.cleanup_block(),
791785 place: CallReturnPlaces::InlineAsm(operands),
792786 },
compiler/rustc_mir_dataflow/src/framework/direction.rs+5-3
......@@ -101,11 +101,13 @@ impl Direction for Backward {
101101 propagate(pred, &tmp);
102102 }
103103
104 mir::TerminatorKind::Yield { resume, resume_arg, .. } if resume == block => {
104 mir::TerminatorKind::Yield { resume, drop, resume_arg, .. }
105 if resume == block || drop == Some(block) =>
106 {
105107 let mut tmp = exit_state.clone();
106108 analysis.apply_call_return_effect(
107109 &mut tmp,
108 resume,
110 block,
109111 CallReturnPlaces::Yield(resume_arg),
110112 );
111113 propagate(pred, &tmp);
......@@ -275,7 +277,7 @@ impl Direction for Forward {
275277
276278 if !return_.is_empty() {
277279 analysis.apply_call_return_effect(exit_state, block, place);
278 for &target in return_ {
280 for target in return_ {
279281 propagate(target, exit_state);
280282 }
281283 }
compiler/rustc_mir_transform/src/coroutine.rs+14-4
......@@ -1302,13 +1302,21 @@ fn create_coroutine_resume_function<'tcx>(
13021302enum Operation {
13031303 Resume,
13041304 Drop,
1305 AsyncDrop,
13051306}
13061307
13071308impl Operation {
13081309 fn target_block(self, point: &SuspensionPoint<'_>) -> Option<BasicBlock> {
13091310 match self {
13101311 Operation::Resume => Some(point.resume),
1311 Operation::Drop => point.drop,
1312 Operation::Drop | Operation::AsyncDrop => point.drop,
1313 }
1314 }
1315
1316 fn resume_place<'tcx>(self, point: &SuspensionPoint<'tcx>) -> Option<Place<'tcx>> {
1317 match self {
1318 Operation::Resume | Operation::AsyncDrop => Some(point.resume_arg),
1319 Operation::Drop => None,
13121320 }
13131321 }
13141322}
......@@ -1339,12 +1347,14 @@ fn create_cases<'tcx>(
13391347 }
13401348 }
13411349
1342 if operation == Operation::Resume && point.resume_arg != CTX_ARG.into() {
1343 // Move the resume argument to the destination place of the `Yield` terminator
1350 // Move the resume argument to the destination place of the `Yield` terminator
1351 if let Some(resume_arg) = operation.resume_place(point)
1352 && resume_arg != CTX_ARG.into()
1353 {
13441354 statements.push(Statement::new(
13451355 source_info,
13461356 StatementKind::Assign(Box::new((
1347 point.resume_arg,
1357 resume_arg,
13481358 Rvalue::Use(Operand::Move(CTX_ARG.into()), WithRetag::Yes),
13491359 ))),
13501360 ));
compiler/rustc_mir_transform/src/coroutine/drop.rs+1-1
......@@ -646,7 +646,7 @@ pub(super) fn create_coroutine_drop_shim_async<'tcx>(
646646
647647 let source_info = SourceInfo::outermost(body.span);
648648
649 let mut cases = create_cases(&mut body, transform, Operation::Drop);
649 let mut cases = create_cases(&mut body, transform, Operation::AsyncDrop);
650650
651651 cases.insert(0, (CoroutineArgs::UNRESUMED, drop_clean));
652652
compiler/rustc_session/src/options.rs+2-2
......@@ -2252,12 +2252,12 @@ options! {
22522252 "inject the given attribute in the crate"),
22532253 cross_crate_inline_threshold: InliningThreshold = (InliningThreshold::Sometimes(100), parse_inlining_threshold, [TRACKED],
22542254 "threshold to allow cross crate inlining of functions"),
2255 debug_info_for_profiling: bool = (false, parse_bool, [TRACKED],
2256 "emit discriminators and other data necessary for AutoFDO"),
22572255 debug_info_type_line_numbers: bool = (false, parse_bool, [TRACKED],
22582256 "emit type and line information for additional data types (default: no)"),
22592257 debuginfo_compression: DebugInfoCompression = (DebugInfoCompression::None, parse_debuginfo_compression, [TRACKED],
22602258 "compress debug info sections (none, zlib, zstd, default: none)"),
2259 debuginfo_for_profiling: bool = (false, parse_bool, [TRACKED],
2260 "emit discriminators and other data necessary for AutoFDO"),
22612261 deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
22622262 "deduplicate identical diagnostics (default: yes)"),
22632263 default_visibility: Option<SymbolVisibility> = (None, parse_opt_symbol_visibility, [TRACKED],
library/core/src/hint.rs+3
......@@ -778,6 +778,9 @@ pub const fn unlikely(b: bool) -> bool {
778778#[stable(feature = "cold_path", since = "1.95.0")]
779779#[rustc_const_stable(feature = "cold_path", since = "1.95.0")]
780780#[inline(always)]
781// Even if for some reason the cold_path intrinsic is not visible to codegen, the coldness will
782// ensure that branches this is in are still known to be cold.
783#[cold]
781784pub const fn cold_path() {
782785 crate::intrinsics::cold_path()
783786}
src/ci/docker/host-x86_64/x86_64-gnu-gcc-core-tests/Dockerfile+1-2
......@@ -43,5 +43,4 @@ ENV RUST_CONFIGURE_ARGS="--build=x86_64-unknown-linux-gnu \
4343 --set llvm.libzstd=true"
4444ENV SCRIPT="python3 ../x.py \
4545 --stage 1 \
46 test library/coretests \
47 --set rust.codegen-backends=[\\\"gcc\\\"]"
46 test library/coretests"
src/doc/unstable-book/src/compiler-flags/debug_info_for_profiling.md deleted-35
......@@ -1,35 +0,0 @@
1# `debug-info-for-profiling`
2
3---
4
5## Introduction
6
7Automatic Feedback Directed Optimization (AFDO) is a method for using sampling
8based profiles to guide optimizations. This is contrasted with other methods of
9FDO or profile-guided optimization (PGO) which use instrumented profiling.
10
11Unlike PGO (controlled by the `rustc` flags `-Cprofile-generate` and
12`-Cprofile-use`), a binary being profiled does not perform significantly worse,
13and thus it's possible to profile binaries used in real workflows and not
14necessary to construct artificial workflows.
15
16## Use
17
18In order to use AFDO, the target platform must be Linux running on an `x86_64`
19architecture with the performance profiler `perf` available. In addition, the
20external tool `create_llvm_prof` from [this repository] must be used.
21
22Given a Rust file `main.rs`, we can produce an optimized binary as follows:
23
24```shell
25rustc -O -Zdebug-info-for-profiling main.rs -o main
26perf record -b ./main
27create_llvm_prof --binary=main --out=code.prof
28rustc -O -Zprofile-sample-use=code.prof main.rs -o main2
29```
30
31The `perf` command produces a profile `perf.data`, which is then used by the
32`create_llvm_prof` command to create `code.prof`. This final profile is then
33used by `rustc` to guide optimizations in producing the binary `main2`.
34
35[this repository]: https://github.com/google/autofdo
src/doc/unstable-book/src/compiler-flags/debuginfo_for_profiling.md created+35
......@@ -0,0 +1,35 @@
1# `debuginfo-for-profiling`
2
3---
4
5## Introduction
6
7Automatic Feedback Directed Optimization (AFDO) is a method for using sampling
8based profiles to guide optimizations. This is contrasted with other methods of
9FDO or profile-guided optimization (PGO) which use instrumented profiling.
10
11Unlike PGO (controlled by the `rustc` flags `-Cprofile-generate` and
12`-Cprofile-use`), a binary being profiled does not perform significantly worse,
13and thus it's possible to profile binaries used in real workflows and not
14necessary to construct artificial workflows.
15
16## Use
17
18In order to use AFDO, the target platform must be Linux running on an `x86_64`
19architecture with the performance profiler `perf` available. In addition, the
20external tool `create_llvm_prof` from [this repository] must be used.
21
22Given a Rust file `main.rs`, we can produce an optimized binary as follows:
23
24```shell
25rustc -O -Zdebuginfo-for-profiling main.rs -o main
26perf record -b ./main
27create_llvm_prof --binary=main --out=code.prof
28rustc -O -Zprofile-sample-use=code.prof main.rs -o main2
29```
30
31The `perf` command produces a profile `perf.data`, which is then used by the
32`create_llvm_prof` command to create `code.prof`. This final profile is then
33used by `rustc` to guide optimizations in producing the binary `main2`.
34
35[this repository]: https://github.com/google/autofdo
src/doc/unstable-book/src/compiler-flags/profile_sample_use.md+2-2
......@@ -4,7 +4,7 @@
44
55`-Zprofile-sample-use=code.prof` directs `rustc` to use the profile
66`code.prof` as a source for Automatic Feedback Directed Optimization (AFDO).
7See the documentation of [`-Zdebug-info-for-profiling`] for more information
7See the documentation of [`-Zdebuginfo-for-profiling`] for more information
88on using AFDO.
99
10[`-Zdebug-info-for-profiling`]: debug_info_for_profiling.html
10[`-Zdebuginfo-for-profiling`]: debuginfo_for_profiling.html
src/librustdoc/clean/mod.rs+1-1
......@@ -243,8 +243,8 @@ fn generate_item_with_correct_attrs(
243243 ) || (is_glob_import(tcx, import_id)
244244 && (cx.document_hidden() || !tcx.is_doc_hidden(def_id)))
245245 || macro_reexport_is_inline(tcx, import_id, def_id);
246 attrs.extend(get_all_import_attributes(cx, import_id, def_id, is_inline));
247246 is_inline = is_inline || import_is_inline;
247 attrs.extend(get_all_import_attributes(cx, import_id, def_id, is_inline));
248248 }
249249 let keep_target_cfg = is_inline || matches!(kind, ItemKind::TypeAliasItem(..));
250250 add_without_unwanted_attributes(&mut attrs, target_attrs, keep_target_cfg, None);
src/librustdoc/html/macro_expansion.rs+11-1
......@@ -2,7 +2,7 @@ use rustc_ast::visit::{
22 AssocCtxt, Visitor, walk_assoc_item, walk_crate, walk_expr, walk_item, walk_pat, walk_stmt,
33 walk_ty,
44};
5use rustc_ast::{AssocItem, Crate, Expr, Item, Pat, Stmt, Ty};
5use rustc_ast::{AssocItem, Crate, Expr, ForeignItem, Item, Pat, Stmt, Ty};
66use rustc_data_structures::fx::FxHashMap;
77use rustc_span::source_map::SourceMap;
88use rustc_span::{BytePos, Span};
......@@ -174,4 +174,14 @@ impl<'ast> Visitor<'ast> for ExpandedCodeVisitor<'ast> {
174174 walk_assoc_item(self, item, ctxt);
175175 }
176176 }
177
178 fn visit_foreign_item(&mut self, item: &'ast ForeignItem) -> Self::Result {
179 if item.span.from_expansion() {
180 self.handle_new_span(item.span, || {
181 rustc_ast_pretty::pprust::foreign_item_to_string(item)
182 });
183 } else {
184 walk_item(self, item);
185 }
186 }
177187}
tests/assembly-llvm/debuginfo-for-profiling.rs created+56
......@@ -0,0 +1,56 @@
1// Verify that additional discriminators are emitted for profiling with `-Zdebuginfo-for-profiling`:
2// - 0 discriminators are emitted without the flag in the test below
3// - at least 1 discriminator is emitted with the flag in the test below.
4// Actual count depends on the target
5//
6//
7//@ add-minicore
8//@ revisions: DEFAULT-X86 DEFAULT-AARCH64 DEBUGINFO-X86 DEBUGINFO-AARCH64
9//@ assembly-output: emit-asm
10//@ compile-flags: -Copt-level=2 -Cdebuginfo=line-tables-only
11//@ [DEFAULT-X86] compile-flags: --target=x86_64-unknown-linux-gnu
12//@ [DEFAULT-X86] needs-llvm-components: x86
13//@ [DEFAULT-AARCH64] compile-flags: --target=aarch64-unknown-linux-gnu
14//@ [DEFAULT-AARCH64] needs-llvm-components: aarch64
15//@ [DEBUGINFO-X86] compile-flags: -Zdebuginfo-for-profiling --target=x86_64-unknown-linux-gnu
16//@ [DEBUGINFO-X86] needs-llvm-components: x86
17//@ [DEBUGINFO-AARCH64] compile-flags: -Zdebuginfo-for-profiling --target=aarch64-unknown-linux-gnu
18//@ [DEBUGINFO-AARCH64] needs-llvm-components: aarch64
19// DEFAULT-X86-NOT: discriminator
20// DEFAULT-AARCH64-NOT: discriminator
21// DEBUGINFO-X86-COUNT-1: discriminator
22// DEBUGINFO-AARCH64-COUNT-1: discriminator
23
24#![feature(no_core)]
25#![no_std]
26#![no_core]
27#![crate_type = "lib"]
28
29extern crate minicore;
30use minicore::*;
31
32extern "C" {
33 fn add(_x: i32, _y: i32) -> i32;
34 fn mul(_x: i32, _y: i32) -> i32;
35 fn compute(_x: i32) -> i32;
36 fn cond() -> bool;
37}
38
39#[no_mangle]
40pub fn f(limit: i32) -> i32 {
41 unsafe {
42 let mut sum = 0;
43 let mut i = 1;
44
45 while cond() {
46 if cond() {
47 sum = add(sum, compute(i));
48 } else {
49 sum = add(sum, mul(compute(i), 2));
50 }
51 i = add(i, 1);
52 }
53
54 sum
55 }
56}
tests/codegen-llvm/debuginfo-for-profiling.rs created+45
......@@ -0,0 +1,45 @@
1// Verify that additional discriminators are emitted for profiling with `-Zdebuginfo-for-profiling`:
2// - 0 discriminators are emitted without the flag in the test below
3// - at least 1 discriminator is emitted with the flag in the test below
4//
5//
6//@ add-minicore
7//@ revisions: DEFAULT DEBUGINFO
8//@ compile-flags: -Copt-level=2 -Cdebuginfo=line-tables-only
9//@ [DEBUGINFO] compile-flags: -Zdebuginfo-for-profiling
10// DEFAULT-NOT: discriminator
11// DEBUGINFO-COUNT-1: discriminator
12
13#![feature(no_core)]
14#![no_std]
15#![no_core]
16#![crate_type = "lib"]
17
18extern crate minicore;
19use minicore::*;
20
21extern "C" {
22 fn add(_x: i32, _y: i32) -> i32;
23 fn mul(_x: i32, _y: i32) -> i32;
24 fn compute(_x: i32) -> i32;
25 fn cond() -> bool;
26}
27
28#[no_mangle]
29pub fn f(limit: i32) -> i32 {
30 unsafe {
31 let mut sum = 0;
32 let mut i = 1;
33
34 while cond() {
35 if cond() {
36 sum = add(sum, compute(i));
37 } else {
38 sum = add(sum, mul(compute(i), 2));
39 }
40 i = add(i, 1);
41 }
42
43 sum
44 }
45}
tests/codegen-llvm/hint/cold_path-target_feature.rs created+56
......@@ -0,0 +1,56 @@
1//@ compile-flags: -Copt-level=3
2//@ only-x86_64
3#![crate_type = "lib"]
4
5// This test checks that hint::cold_path still works in #[target_feature] functions.
6
7use std::hint::cold_path;
8
9#[inline(never)]
10#[no_mangle]
11pub fn path_a() {
12 println!("path a");
13}
14
15#[inline(never)]
16#[no_mangle]
17pub fn path_b() {
18 println!("path b");
19}
20
21#[no_mangle]
22pub fn test1(x: bool) {
23 if x {
24 path_a();
25 } else {
26 cold_path();
27 path_b();
28 }
29
30 // CHECK-LABEL: @test1(
31 // CHECK: br i1 %x, label %bb1, label %bb2, !prof ![[NUM:[0-9]+]]
32 // CHECK: bb2:
33 // CHECK: path_b
34 // CHECK: bb1:
35 // CHECK: path_a
36}
37
38#[no_mangle]
39#[target_feature(enable = "sse2")]
40pub fn with_target_feature(x: bool) {
41 if x {
42 path_a();
43 } else {
44 cold_path();
45 path_b();
46 }
47
48 // CHECK-LABEL: @with_target_feature(
49 // CHECK: br i1 %x, label %bb1, label %bb2, !prof ![[NUM]]
50 // CHECK: bb2:
51 // CHECK: path_b
52 // CHECK: bb1:
53 // CHECK: path_a
54}
55
56// CHECK: ![[NUM]] = !{!"branch_weights", {{(!"expected", )?}}i32 2000, i32 1}
tests/mir-opt/coroutine/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-abort.mir+2
......@@ -86,10 +86,12 @@ fn a::{closure#0}(_1: Pin<&mut {async fn body of a<T>()}>, _2: &mut Context<'_>)
8686 }
8787
8888 bb12: {
89 _9 = move _2;
8990 goto -> bb4;
9091 }
9192
9293 bb13: {
94 _13 = move _2;
9395 goto -> bb4;
9496 }
9597
tests/mir-opt/coroutine/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-unwind.mir+2
......@@ -105,10 +105,12 @@ fn a::{closure#0}(_1: Pin<&mut {async fn body of a<T>()}>, _2: &mut Context<'_>)
105105 }
106106
107107 bb16: {
108 _9 = move _2;
108109 goto -> bb7;
109110 }
110111
111112 bb17: {
113 _13 = move _2;
112114 goto -> bb7;
113115 }
114116
tests/rustdoc-html/macro-expansion/c-var-args.rs created+19
......@@ -0,0 +1,19 @@
1// Ensure that C var args (`va_list`) work.
2// Regression test for <https://github.com/rust-lang/rust/issues/156486>.
3
4//@ compile-flags: -Zunstable-options --generate-macro-expansion
5
6#![crate_name = "foo"]
7
8//@ has 'src/foo/c-var-args.rs.html'
9
10macro_rules! print {
11 () => {
12 fn printf(...);
13 };
14}
15
16//@ has - '//*[@class="expansion"]/*[@class="expanded"]' 'fn printf(...);'
17extern "C" {
18 print! {}
19}
tests/rustdoc-html/reexport/glob-reexport-feature-combination.rs created+67
......@@ -0,0 +1,67 @@
1// This test ensures that `cfg`s are correctly propagated for re-export chains
2// where the outermost is a glob re-export.
3
4#![crate_name = "foo"]
5#![feature(doc_cfg)]
6
7//@ has 'foo/index.html'
8//@ count - '//*[@class="item-table"]/dt' 3
9
10//@ has 'foo/index.html'
11//@ has - '//dt/a[@title="struct foo::A"]/../*[@class="stab portability"]' 'Non-bar and non-foo'
12
13//@ has 'foo/struct.A.html'
14//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
15// 'Available on non-crate feature bar and non-crate feature foo only.'
16
17mod a {
18 mod inner {
19 pub struct A {}
20 }
21 #[cfg(not(feature = "bar"))]
22 pub use self::inner::A;
23}
24#[cfg(not(feature = "foo"))]
25pub use a::*;
26
27//@ has 'foo/index.html'
28//@ has - '//dt/a[@title="struct foo::B"]/../*[@class="stab portability"]' 'Non-bar and non-baz and non-foo'
29
30//@ has 'foo/struct.B.html'
31//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
32// 'Available on non-crate feature bar and non-crate feature baz and non-crate feature foo only.'
33
34mod b {
35 mod inner {
36 mod innermost {
37 pub struct B {}
38 }
39 #[cfg(not(feature = "baz"))]
40 pub use self::innermost::B;
41 }
42 #[cfg(not(feature = "bar"))]
43 pub use self::inner::*;
44}
45#[cfg(not(feature = "foo"))]
46pub use b::*;
47
48//@ has 'foo/index.html'
49//@ has - '//dt/a[@title="struct foo::C"]/../*[@class="stab portability"]' 'Non-bar and non-baz and non-foo'
50
51//@ has 'foo/struct.C.html'
52//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
53// 'Available on non-crate feature bar and non-crate feature baz and non-crate feature foo only.'
54
55mod c {
56 mod inner {
57 mod innermost {
58 #[cfg(not(feature = "baz"))]
59 pub struct C {}
60 }
61 pub use self::innermost::*;
62 }
63 #[cfg(not(feature = "bar"))]
64 pub use self::inner::*;
65}
66#[cfg(not(feature = "foo"))]
67pub use c::*;
tests/rustdoc-json/attrs/derive_helper.rs created+7
......@@ -0,0 +1,7 @@
1//@ is "$.index[?(@.name=='A')].attrs" '[{"other": "#[default]"}]'
2#[derive(Default)]
3pub enum Test {
4 #[default]
5 A,
6 B,
7}
tests/ui/attributes/arg-error-issue-121425.rs+6-6
......@@ -2,28 +2,28 @@
22
33const N: usize = 8;
44#[repr(align(N))]
5//~^ ERROR: incorrect `repr(align)` attribute format
5//~^ ERROR: malformed `repr` attribute input
66struct T;
77
88#[repr(align('a'))]
9//~^ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer [E0589]
9//~^ ERROR: not an unsuffixed integer [E0589]
1010struct H;
1111
1212#[repr(align("str"))]
13//~^ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer [E0589]
13//~^ ERROR: not an unsuffixed integer [E0589]
1414struct L;
1515
1616#[repr(align())]
17//~^ ERROR: attribute format: `align` takes exactly one argument in parentheses
17//~^ ERROR: malformed `repr` attribute input
1818struct X;
1919
2020const P: usize = 8;
2121#[repr(packed(P))]
22//~^ ERROR: attribute format: `packed` expects a literal integer as argument
22//~^ ERROR: malformed `repr` attribute input
2323struct A;
2424
2525#[repr(packed())]
26//~^ ERROR: attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all
26//~^ ERROR: malformed `repr` attribute input
2727struct B;
2828
2929#[repr(packed)]
tests/ui/attributes/arg-error-issue-121425.stderr+32-16
......@@ -1,40 +1,56 @@
1error[E0693]: incorrect `repr(align)` attribute format: `align` expects a literal integer as argument
2 --> $DIR/arg-error-issue-121425.rs:4:14
1error[E0539]: malformed `repr` attribute input
2 --> $DIR/arg-error-issue-121425.rs:4:1
33 |
44LL | #[repr(align(N))]
5 | ^
5 | ^^^^^^^^^^^^^-^^^
6 | |
7 | expected an integer literal here
8 |
9 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
610
7error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer
11error[E0589]: invalid alignment value: not an unsuffixed integer
812 --> $DIR/arg-error-issue-121425.rs:8:14
913 |
1014LL | #[repr(align('a'))]
1115 | ^^^
1216
13error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer
17error[E0589]: invalid alignment value: not an unsuffixed integer
1418 --> $DIR/arg-error-issue-121425.rs:12:14
1519 |
1620LL | #[repr(align("str"))]
1721 | ^^^^^
1822
19error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
20 --> $DIR/arg-error-issue-121425.rs:16:8
23error[E0805]: malformed `repr` attribute input
24 --> $DIR/arg-error-issue-121425.rs:16:1
2125 |
2226LL | #[repr(align())]
23 | ^^^^^^^
27 | ^^^^^^^^^^^^--^^
28 | |
29 | expected an argument here
30 |
31 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
2432
25error[E0552]: incorrect `repr(packed)` attribute format: `packed` expects a literal integer as argument
26 --> $DIR/arg-error-issue-121425.rs:21:15
33error[E0539]: malformed `repr` attribute input
34 --> $DIR/arg-error-issue-121425.rs:21:1
2735 |
2836LL | #[repr(packed(P))]
29 | ^
37 | ^^^^^^^^^^^^^^-^^^
38 | |
39 | expected an integer literal here
40 |
41 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
3042
31error[E0552]: incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all
32 --> $DIR/arg-error-issue-121425.rs:25:8
43error[E0805]: malformed `repr` attribute input
44 --> $DIR/arg-error-issue-121425.rs:25:1
3345 |
3446LL | #[repr(packed())]
35 | ^^^^^^^^
47 | ^^^^^^^^^^^^^--^^
48 | |
49 | expected an argument here
50 |
51 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
3652
3753error: aborting due to 6 previous errors
3854
39Some errors have detailed explanations: E0552, E0589, E0693.
40For more information about an error, try `rustc --explain E0552`.
55Some errors have detailed explanations: E0539, E0589, E0805.
56For more information about an error, try `rustc --explain E0539`.
tests/ui/attributes/attribute-on-wrong-item-inline-repr.rs+2-2
......@@ -16,13 +16,13 @@ fn main() {
1616
1717 #[repr(nothing)]
1818 let _x = 0;
19 //~^^ ERROR E0552
19 //~^^ ERROR malformed `repr` attribute input
2020
2121 #[repr(something_not_real)]
2222 loop {
2323 ()
2424 };
25 //~^^^^ ERROR E0552
25 //~^^^^ ERROR malformed `repr` attribute input
2626
2727 #[repr]
2828 let _y = "123";
tests/ui/attributes/attribute-on-wrong-item-inline-repr.stderr+13-12
......@@ -35,23 +35,25 @@ LL | #[inline(XYZ)]
3535 |
3636 = help: `#[inline]` can only be applied to functions
3737
38error[E0552]: unrecognized representation hint
39 --> $DIR/attribute-on-wrong-item-inline-repr.rs:17:12
38error[E0539]: malformed `repr` attribute input
39 --> $DIR/attribute-on-wrong-item-inline-repr.rs:17:5
4040 |
4141LL | #[repr(nothing)]
42 | ^^^^^^^
42 | ^^^^^^^-------^^
43 | |
44 | valid arguments are `align`, `packed`, `Rust`, `C`, `simd`, `transparent`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize` or `usize`
4345 |
44 = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
45 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations>
46 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
4647
47error[E0552]: unrecognized representation hint
48 --> $DIR/attribute-on-wrong-item-inline-repr.rs:21:12
48error[E0539]: malformed `repr` attribute input
49 --> $DIR/attribute-on-wrong-item-inline-repr.rs:21:5
4950 |
5051LL | #[repr(something_not_real)]
51 | ^^^^^^^^^^^^^^^^^^
52 | ^^^^^^^------------------^^
53 | |
54 | valid arguments are `align`, `packed`, `Rust`, `C`, `simd`, `transparent`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize` or `usize`
5255 |
53 = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
54 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations>
56 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
5557
5658error[E0539]: malformed `repr` attribute input
5759 --> $DIR/attribute-on-wrong-item-inline-repr.rs:27:5
......@@ -100,5 +102,4 @@ LL | let _z = #[repr] 1;
100102
101103error: aborting due to 9 previous errors
102104
103Some errors have detailed explanations: E0539, E0552.
104For more information about an error, try `rustc --explain E0539`.
105For more information about this error, try `rustc --explain E0539`.
tests/ui/attributes/invalid-macro-use.stderr+2-2
......@@ -28,7 +28,7 @@ LL - #[macro_use = 5]
2828LL + #[macro_use]
2929 |
3030
31error[E0539]: malformed `macro_use` attribute input
31error[E0565]: malformed `macro_use` attribute input
3232 --> $DIR/invalid-macro-use.rs:10:1
3333 |
3434LL | #[macro_use(5)]
......@@ -82,7 +82,7 @@ LL - #[macro_use(a(b))]
8282LL + #[macro_use]
8383 |
8484
85error[E0539]: malformed `macro_use` attribute input
85error[E0565]: malformed `macro_use` attribute input
8686 --> $DIR/invalid-macro-use.rs:28:1
8787 |
8888LL | #[macro_use(a::b)]
tests/ui/attributes/invalid-reprs.rs+1-1
......@@ -1,6 +1,6 @@
11fn main() {
22 let y = #[repr(uwu(4))]
33 //~^ ERROR attributes on expressions are experimental
4 //~| ERROR unrecognized representation hint
4 //~| ERROR malformed `repr` attribute input
55 (&id(5)); //~ ERROR: cannot find function `id` in this scope
66}
tests/ui/attributes/invalid-reprs.stderr+7-6
......@@ -19,16 +19,17 @@ help: consider importing this function
1919LL + use std::process::id;
2020 |
2121
22error[E0552]: unrecognized representation hint
23 --> $DIR/invalid-reprs.rs:2:20
22error[E0539]: malformed `repr` attribute input
23 --> $DIR/invalid-reprs.rs:2:13
2424 |
2525LL | let y = #[repr(uwu(4))]
26 | ^^^^^^
26 | ^^^^^^^------^^
27 | |
28 | valid arguments are `align`, `packed`, `Rust`, `C`, `simd`, `transparent`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize` or `usize`
2729 |
28 = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
29 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations>
30 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
3031
3132error: aborting due to 3 previous errors
3233
33Some errors have detailed explanations: E0425, E0552, E0658.
34Some errors have detailed explanations: E0425, E0539, E0658.
3435For more information about an error, try `rustc --explain E0425`.
tests/ui/attributes/malformed-reprs.rs+1-1
......@@ -7,7 +7,7 @@
77
88// This is a regression test for https://github.com/rust-lang/rust/issues/143479
99#[repr(align(0))]
10//~^ ERROR invalid `repr(align)` attribute: not a power of two
10//~^ ERROR not a power of two
1111//~| ERROR unsupported representation for zero-variant enum [E0084]
1212enum Foo {}
1313
tests/ui/attributes/malformed-reprs.stderr+1-1
......@@ -21,7 +21,7 @@ LL - #![repr]
2121LL + #[repr]
2222 |
2323
24error[E0589]: invalid `repr(align)` attribute: not a power of two
24error[E0589]: invalid alignment value: not a power of two
2525 --> $DIR/malformed-reprs.rs:9:14
2626 |
2727LL | #[repr(align(0))]
tests/ui/attributes/repr-align-in-trait-issue-132391.rs+1-1
......@@ -1,5 +1,5 @@
11trait MyTrait {
2 #[repr(align)] //~ ERROR invalid `repr(align)` attribute: `align` needs an argument
2 #[repr(align)] //~ ERROR malformed `repr` attribute input
33 fn myfun();
44}
55
tests/ui/attributes/repr-align-in-trait-issue-132391.stderr+8-4
......@@ -1,9 +1,13 @@
1error[E0589]: invalid `repr(align)` attribute: `align` needs an argument
2 --> $DIR/repr-align-in-trait-issue-132391.rs:2:12
1error[E0539]: malformed `repr` attribute input
2 --> $DIR/repr-align-in-trait-issue-132391.rs:2:5
33 |
44LL | #[repr(align)]
5 | ^^^^^ help: supply an argument here: `align(...)`
5 | ^^^^^^^-----^^
6 | |
7 | expected this to be a list
8 |
9 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
610
711error: aborting due to 1 previous error
812
9For more information about this error, try `rustc --explain E0589`.
13For more information about this error, try `rustc --explain E0539`.
tests/ui/cfg/cfg-path-error.stderr+5-5
......@@ -1,4 +1,4 @@
1error[E0539]: malformed `cfg` attribute input
1error[E0565]: malformed `cfg` attribute input
22 --> $DIR/cfg-path-error.rs:6:1
33 |
44LL | #[cfg(any(foo, foo::bar))]
......@@ -13,7 +13,7 @@ LL - #[cfg(any(foo, foo::bar))]
1313LL + #[cfg(predicate)]
1414 |
1515
16error[E0539]: malformed `cfg` attribute input
16error[E0565]: malformed `cfg` attribute input
1717 --> $DIR/cfg-path-error.rs:12:1
1818 |
1919LL | #[cfg(any(foo::bar, foo))]
......@@ -28,7 +28,7 @@ LL - #[cfg(any(foo::bar, foo))]
2828LL + #[cfg(predicate)]
2929 |
3030
31error[E0539]: malformed `cfg` attribute input
31error[E0565]: malformed `cfg` attribute input
3232 --> $DIR/cfg-path-error.rs:18:1
3333 |
3434LL | #[cfg(all(foo, foo::bar))]
......@@ -43,7 +43,7 @@ LL - #[cfg(all(foo, foo::bar))]
4343LL + #[cfg(predicate)]
4444 |
4545
46error[E0539]: malformed `cfg` attribute input
46error[E0565]: malformed `cfg` attribute input
4747 --> $DIR/cfg-path-error.rs:24:1
4848 |
4949LL | #[cfg(all(foo::bar, foo))]
......@@ -60,4 +60,4 @@ LL + #[cfg(predicate)]
6060
6161error: aborting due to 4 previous errors
6262
63For more information about this error, try `rustc --explain E0539`.
63For more information about this error, try `rustc --explain E0565`.
tests/ui/cfg/cfg-target-compact-errors.stderr+4-3
......@@ -1,4 +1,4 @@
1error[E0539]: malformed `cfg` attribute input
1error[E0565]: malformed `cfg` attribute input
22 --> $DIR/cfg-target-compact-errors.rs:5:1
33 |
44LL | #[cfg(target(o::o))]
......@@ -73,7 +73,7 @@ LL - #[cfg(target(true))]
7373LL + #[cfg(predicate)]
7474 |
7575
76error[E0539]: malformed `cfg` attribute input
76error[E0565]: malformed `cfg` attribute input
7777 --> $DIR/cfg-target-compact-errors.rs:32:1
7878 |
7979LL | #[cfg(target(clippy::os = "linux"))]
......@@ -90,4 +90,5 @@ LL + #[cfg(predicate)]
9090
9191error: aborting due to 6 previous errors
9292
93For more information about this error, try `rustc --explain E0539`.
93Some errors have detailed explanations: E0539, E0565.
94For more information about an error, try `rustc --explain E0539`.
tests/ui/cfg/path-kw-as-cfg-pred.stderr+33-33
......@@ -118,7 +118,7 @@ error: `_` cannot be a raw identifier
118118LL | #[cfg_attr(r#_, cfg(r#_))]
119119 | ^^^
120120
121error[E0539]: malformed `cfg` attribute input
121error[E0565]: malformed `cfg` attribute input
122122 --> $DIR/path-kw-as-cfg-pred.rs:20:1
123123 |
124124LL | #[cfg(crate)]
......@@ -133,7 +133,7 @@ LL - #[cfg(crate)]
133133LL + #[cfg(predicate)]
134134 |
135135
136error[E0539]: malformed `cfg` attribute input
136error[E0565]: malformed `cfg` attribute input
137137 --> $DIR/path-kw-as-cfg-pred.rs:22:1
138138 |
139139LL | #[cfg(super)]
......@@ -148,7 +148,7 @@ LL - #[cfg(super)]
148148LL + #[cfg(predicate)]
149149 |
150150
151error[E0539]: malformed `cfg` attribute input
151error[E0565]: malformed `cfg` attribute input
152152 --> $DIR/path-kw-as-cfg-pred.rs:24:1
153153 |
154154LL | #[cfg(self)]
......@@ -163,7 +163,7 @@ LL - #[cfg(self)]
163163LL + #[cfg(predicate)]
164164 |
165165
166error[E0539]: malformed `cfg` attribute input
166error[E0565]: malformed `cfg` attribute input
167167 --> $DIR/path-kw-as-cfg-pred.rs:26:1
168168 |
169169LL | #[cfg(Self)]
......@@ -178,7 +178,7 @@ LL - #[cfg(Self)]
178178LL + #[cfg(predicate)]
179179 |
180180
181error[E0539]: malformed `cfg_attr` attribute input
181error[E0565]: malformed `cfg_attr` attribute input
182182 --> $DIR/path-kw-as-cfg-pred.rs:28:1
183183 |
184184LL | #[cfg_attr(crate, path = "foo")]
......@@ -193,7 +193,7 @@ LL - #[cfg_attr(crate, path = "foo")]
193193LL + #[cfg_attr(predicate, attr1, attr2, ...)]
194194 |
195195
196error[E0539]: malformed `cfg_attr` attribute input
196error[E0565]: malformed `cfg_attr` attribute input
197197 --> $DIR/path-kw-as-cfg-pred.rs:30:1
198198 |
199199LL | #[cfg_attr(super, path = "foo")]
......@@ -208,7 +208,7 @@ LL - #[cfg_attr(super, path = "foo")]
208208LL + #[cfg_attr(predicate, attr1, attr2, ...)]
209209 |
210210
211error[E0539]: malformed `cfg_attr` attribute input
211error[E0565]: malformed `cfg_attr` attribute input
212212 --> $DIR/path-kw-as-cfg-pred.rs:32:1
213213 |
214214LL | #[cfg_attr(self, path = "foo")]
......@@ -223,7 +223,7 @@ LL - #[cfg_attr(self, path = "foo")]
223223LL + #[cfg_attr(predicate, attr1, attr2, ...)]
224224 |
225225
226error[E0539]: malformed `cfg_attr` attribute input
226error[E0565]: malformed `cfg_attr` attribute input
227227 --> $DIR/path-kw-as-cfg-pred.rs:34:1
228228 |
229229LL | #[cfg_attr(Self, path = "foo")]
......@@ -238,7 +238,7 @@ LL - #[cfg_attr(Self, path = "foo")]
238238LL + #[cfg_attr(predicate, attr1, attr2, ...)]
239239 |
240240
241error[E0539]: malformed `cfg` attribute input
241error[E0565]: malformed `cfg` attribute input
242242 --> $DIR/path-kw-as-cfg-pred.rs:36:18
243243 |
244244LL | #[cfg_attr(true, cfg(crate))]
......@@ -253,7 +253,7 @@ LL - #[cfg_attr(true, cfg(crate))]
253253LL + #[cfg_attr(true, cfg(predicate))]
254254 |
255255
256error[E0539]: malformed `cfg` attribute input
256error[E0565]: malformed `cfg` attribute input
257257 --> $DIR/path-kw-as-cfg-pred.rs:38:18
258258 |
259259LL | #[cfg_attr(true, cfg(super))]
......@@ -268,7 +268,7 @@ LL - #[cfg_attr(true, cfg(super))]
268268LL + #[cfg_attr(true, cfg(predicate))]
269269 |
270270
271error[E0539]: malformed `cfg` attribute input
271error[E0565]: malformed `cfg` attribute input
272272 --> $DIR/path-kw-as-cfg-pred.rs:40:18
273273 |
274274LL | #[cfg_attr(true, cfg(self))]
......@@ -283,7 +283,7 @@ LL - #[cfg_attr(true, cfg(self))]
283283LL + #[cfg_attr(true, cfg(predicate))]
284284 |
285285
286error[E0539]: malformed `cfg` attribute input
286error[E0565]: malformed `cfg` attribute input
287287 --> $DIR/path-kw-as-cfg-pred.rs:42:18
288288 |
289289LL | #[cfg_attr(true, cfg(Self))]
......@@ -362,7 +362,7 @@ error: expected identifier, found reserved identifier `_`
362362LL | #[cfg_attr(true, cfg(_))]
363363 | ^ expected identifier, found reserved identifier
364364
365error[E0539]: malformed `cfg` attribute input
365error[E0565]: malformed `cfg` attribute input
366366 --> $DIR/path-kw-as-cfg-pred.rs:90:1
367367 |
368368LL | #[cfg(r#crate)]
......@@ -377,7 +377,7 @@ LL - #[cfg(r#crate)]
377377LL + #[cfg(predicate)]
378378 |
379379
380error[E0539]: malformed `cfg` attribute input
380error[E0565]: malformed `cfg` attribute input
381381 --> $DIR/path-kw-as-cfg-pred.rs:93:1
382382 |
383383LL | #[cfg(r#super)]
......@@ -392,7 +392,7 @@ LL - #[cfg(r#super)]
392392LL + #[cfg(predicate)]
393393 |
394394
395error[E0539]: malformed `cfg` attribute input
395error[E0565]: malformed `cfg` attribute input
396396 --> $DIR/path-kw-as-cfg-pred.rs:96:1
397397 |
398398LL | #[cfg(r#self)]
......@@ -407,7 +407,7 @@ LL - #[cfg(r#self)]
407407LL + #[cfg(predicate)]
408408 |
409409
410error[E0539]: malformed `cfg` attribute input
410error[E0565]: malformed `cfg` attribute input
411411 --> $DIR/path-kw-as-cfg-pred.rs:99:1
412412 |
413413LL | #[cfg(r#Self)]
......@@ -422,7 +422,7 @@ LL - #[cfg(r#Self)]
422422LL + #[cfg(predicate)]
423423 |
424424
425error[E0539]: malformed `cfg_attr` attribute input
425error[E0565]: malformed `cfg_attr` attribute input
426426 --> $DIR/path-kw-as-cfg-pred.rs:102:1
427427 |
428428LL | #[cfg_attr(r#crate, cfg(r#crate))]
......@@ -437,7 +437,7 @@ LL - #[cfg_attr(r#crate, cfg(r#crate))]
437437LL + #[cfg_attr(predicate, attr1, attr2, ...)]
438438 |
439439
440error[E0539]: malformed `cfg_attr` attribute input
440error[E0565]: malformed `cfg_attr` attribute input
441441 --> $DIR/path-kw-as-cfg-pred.rs:106:1
442442 |
443443LL | #[cfg_attr(r#super, cfg(r#super))]
......@@ -452,7 +452,7 @@ LL - #[cfg_attr(r#super, cfg(r#super))]
452452LL + #[cfg_attr(predicate, attr1, attr2, ...)]
453453 |
454454
455error[E0539]: malformed `cfg_attr` attribute input
455error[E0565]: malformed `cfg_attr` attribute input
456456 --> $DIR/path-kw-as-cfg-pred.rs:110:1
457457 |
458458LL | #[cfg_attr(r#self, cfg(r#self))]
......@@ -467,7 +467,7 @@ LL - #[cfg_attr(r#self, cfg(r#self))]
467467LL + #[cfg_attr(predicate, attr1, attr2, ...)]
468468 |
469469
470error[E0539]: malformed `cfg_attr` attribute input
470error[E0565]: malformed `cfg_attr` attribute input
471471 --> $DIR/path-kw-as-cfg-pred.rs:114:1
472472 |
473473LL | #[cfg_attr(r#Self, cfg(r#Self))]
......@@ -482,7 +482,7 @@ LL - #[cfg_attr(r#Self, cfg(r#Self))]
482482LL + #[cfg_attr(predicate, attr1, attr2, ...)]
483483 |
484484
485error[E0539]: malformed `cfg` attribute input
485error[E0565]: malformed `cfg` attribute input
486486 --> $DIR/path-kw-as-cfg-pred.rs:9:9
487487 |
488488LL | #[cfg($crate)]
......@@ -501,7 +501,7 @@ LL - #[cfg($crate)]
501501LL + #[cfg(predicate)]
502502 |
503503
504error[E0539]: malformed `cfg_attr` attribute input
504error[E0565]: malformed `cfg_attr` attribute input
505505 --> $DIR/path-kw-as-cfg-pred.rs:11:9
506506 |
507507LL | #[cfg_attr($crate, path = "foo")]
......@@ -520,7 +520,7 @@ LL - #[cfg_attr($crate, path = "foo")]
520520LL + #[cfg_attr(predicate, attr1, attr2, ...)]
521521 |
522522
523error[E0539]: malformed `cfg` attribute input
523error[E0565]: malformed `cfg` attribute input
524524 --> $DIR/path-kw-as-cfg-pred.rs:13:26
525525 |
526526LL | #[cfg_attr(true, cfg($crate))]
......@@ -539,7 +539,7 @@ LL - #[cfg_attr(true, cfg($crate))]
539539LL + #[cfg_attr(true, cfg(predicate))]
540540 |
541541
542error[E0539]: malformed `cfg` macro input
542error[E0565]: malformed `cfg` macro input
543543 --> $DIR/path-kw-as-cfg-pred.rs:16:9
544544 |
545545LL | cfg!($crate);
......@@ -558,7 +558,7 @@ LL - cfg!($crate);
558558LL + cfg!(predicate);
559559 |
560560
561error[E0539]: malformed `cfg` macro input
561error[E0565]: malformed `cfg` macro input
562562 --> $DIR/path-kw-as-cfg-pred.rs:67:5
563563 |
564564LL | cfg!(crate);
......@@ -573,7 +573,7 @@ LL - cfg!(crate);
573573LL + cfg!(predicate);
574574 |
575575
576error[E0539]: malformed `cfg` macro input
576error[E0565]: malformed `cfg` macro input
577577 --> $DIR/path-kw-as-cfg-pred.rs:68:5
578578 |
579579LL | cfg!(super);
......@@ -588,7 +588,7 @@ LL - cfg!(super);
588588LL + cfg!(predicate);
589589 |
590590
591error[E0539]: malformed `cfg` macro input
591error[E0565]: malformed `cfg` macro input
592592 --> $DIR/path-kw-as-cfg-pred.rs:69:5
593593 |
594594LL | cfg!(self);
......@@ -603,7 +603,7 @@ LL - cfg!(self);
603603LL + cfg!(predicate);
604604 |
605605
606error[E0539]: malformed `cfg` macro input
606error[E0565]: malformed `cfg` macro input
607607 --> $DIR/path-kw-as-cfg-pred.rs:70:5
608608 |
609609LL | cfg!(Self);
......@@ -618,7 +618,7 @@ LL - cfg!(Self);
618618LL + cfg!(predicate);
619619 |
620620
621error[E0539]: malformed `cfg` macro input
621error[E0565]: malformed `cfg` macro input
622622 --> $DIR/path-kw-as-cfg-pred.rs:72:5
623623 |
624624LL | cfg!(r#crate);
......@@ -633,7 +633,7 @@ LL - cfg!(r#crate);
633633LL + cfg!(predicate);
634634 |
635635
636error[E0539]: malformed `cfg` macro input
636error[E0565]: malformed `cfg` macro input
637637 --> $DIR/path-kw-as-cfg-pred.rs:74:5
638638 |
639639LL | cfg!(r#super);
......@@ -648,7 +648,7 @@ LL - cfg!(r#super);
648648LL + cfg!(predicate);
649649 |
650650
651error[E0539]: malformed `cfg` macro input
651error[E0565]: malformed `cfg` macro input
652652 --> $DIR/path-kw-as-cfg-pred.rs:76:5
653653 |
654654LL | cfg!(r#self);
......@@ -663,7 +663,7 @@ LL - cfg!(r#self);
663663LL + cfg!(predicate);
664664 |
665665
666error[E0539]: malformed `cfg` macro input
666error[E0565]: malformed `cfg` macro input
667667 --> $DIR/path-kw-as-cfg-pred.rs:78:5
668668 |
669669LL | cfg!(r#Self);
......@@ -698,4 +698,4 @@ LL | cfg!(_);
698698
699699error: aborting due to 64 previous errors
700700
701For more information about this error, try `rustc --explain E0539`.
701For more information about this error, try `rustc --explain E0565`.
tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr+3-3
......@@ -59,7 +59,7 @@ LL - #[cfg(a, b)]
5959LL + #[cfg(any(a, b))]
6060 |
6161
62error[E0539]: malformed `cfg` attribute input
62error[E0565]: malformed `cfg` attribute input
6363 --> $DIR/cfg-attr-syntax-validation.rs:25:1
6464 |
6565LL | #[cfg("str")]
......@@ -74,7 +74,7 @@ LL - #[cfg("str")]
7474LL + #[cfg(predicate)]
7575 |
7676
77error[E0539]: malformed `cfg` attribute input
77error[E0565]: malformed `cfg` attribute input
7878 --> $DIR/cfg-attr-syntax-validation.rs:31:1
7979 |
8080LL | #[cfg(a::b)]
......@@ -133,5 +133,5 @@ LL | generate_s10!(concat!("nonexistent"));
133133
134134error: aborting due to 10 previous errors
135135
136Some errors have detailed explanations: E0537, E0539, E0805.
136Some errors have detailed explanations: E0537, E0539, E0565, E0805.
137137For more information about an error, try `rustc --explain E0537`.
tests/ui/conditional-compilation/cfg_attr-attr-syntax-validation.stderr+3-3
......@@ -37,7 +37,7 @@ help: must be of the form
3737LL | #[cfg_attr(predicate, attr1, attr2, ...)]
3838 | ++++++++++++++++++++++++++++
3939
40error[E0539]: malformed `cfg_attr` attribute input
40error[E0565]: malformed `cfg_attr` attribute input
4141 --> $DIR/cfg_attr-attr-syntax-validation.rs:13:1
4242 |
4343LL | #[cfg_attr("str")]
......@@ -52,7 +52,7 @@ LL - #[cfg_attr("str")]
5252LL + #[cfg_attr(predicate, attr1, attr2, ...)]
5353 |
5454
55error[E0539]: malformed `cfg_attr` attribute input
55error[E0565]: malformed `cfg_attr` attribute input
5656 --> $DIR/cfg_attr-attr-syntax-validation.rs:16:1
5757 |
5858LL | #[cfg_attr(a::b)]
......@@ -177,5 +177,5 @@ LL | #[cfg_attr(true, link_section)]
177177
178178error: aborting due to 13 previous errors; 1 warning emitted
179179
180Some errors have detailed explanations: E0537, E0539, E0805.
180Some errors have detailed explanations: E0537, E0539, E0565, E0805.
181181For more information about an error, try `rustc --explain E0537`.
tests/ui/error-codes/E0565.stderr+6-2
......@@ -1,8 +1,12 @@
1error[E0565]: meta item in `repr` must be an identifier
1error[E0565]: malformed `repr` attribute input
22 --> $DIR/E0565.rs:2:1
33 |
44LL | #[repr("C")]
5 | ^^^^^^^^^^^^
5 | ^^^^^^^---^^
6 | |
7 | expected a valid identifier here
8 |
9 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
610
711error: aborting due to 1 previous error
812
tests/ui/link-native-libs/issue-43925.stderr+3-3
......@@ -7,7 +7,7 @@ LL | #[link(name = "foo", cfg("rlib"))]
77 = help: add `#![feature(link_cfg)]` to the crate attributes to enable
88 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
99
10error[E0539]: malformed `link` attribute input
10error[E0565]: malformed `link` attribute input
1111 --> $DIR/issue-43925.rs:1:1
1212 |
1313LL | #[link(name = "foo", cfg("rlib"))]
......@@ -19,5 +19,5 @@ LL | #[link(name = "foo", cfg("rlib"))]
1919
2020error: aborting due to 2 previous errors
2121
22Some errors have detailed explanations: E0539, E0658.
23For more information about an error, try `rustc --explain E0539`.
22Some errors have detailed explanations: E0565, E0658.
23For more information about an error, try `rustc --explain E0565`.
tests/ui/link-native-libs/link-attr-validation-late.stderr+1-1
......@@ -148,7 +148,7 @@ LL | #[link(name = "...", cfg = "literal")]
148148 |
149149 = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
150150
151error[E0539]: malformed `link` attribute input
151error[E0565]: malformed `link` attribute input
152152 --> $DIR/link-attr-validation-late.rs:25:1
153153 |
154154LL | #[link(name = "...", cfg("literal"))]
tests/ui/macros/cfg.stderr+3-2
......@@ -4,7 +4,7 @@ error: macro requires a cfg-pattern as an argument
44LL | cfg!();
55 | ^^^^^^ cfg-pattern required
66
7error[E0539]: malformed `cfg` macro input
7error[E0565]: malformed `cfg` macro input
88 --> $DIR/cfg.rs:3:5
99 |
1010LL | cfg!(123);
......@@ -53,4 +53,5 @@ LL | cfg!(foo);
5353
5454error: aborting due to 4 previous errors; 1 warning emitted
5555
56For more information about this error, try `rustc --explain E0539`.
56Some errors have detailed explanations: E0539, E0565.
57For more information about an error, try `rustc --explain E0539`.
tests/ui/macros/cfg_select.rs+2-2
......@@ -178,12 +178,12 @@ cfg_select! {
178178
179179cfg_select! {
180180 "str" => {}
181 //~^ ERROR malformed `cfg_select` macro input [E0539]
181 //~^ ERROR malformed `cfg_select` macro input [E0565]
182182}
183183
184184cfg_select! {
185185 a::b => {}
186 //~^ ERROR malformed `cfg_select` macro input [E0539]
186 //~^ ERROR malformed `cfg_select` macro input [E0565]
187187}
188188
189189cfg_select! {
tests/ui/macros/cfg_select.stderr+3-3
......@@ -25,13 +25,13 @@ error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found expres
2525LL | () => {}
2626 | ^^ expressions are not allowed here
2727
28error[E0539]: malformed `cfg_select` macro input
28error[E0565]: malformed `cfg_select` macro input
2929 --> $DIR/cfg_select.rs:180:5
3030 |
3131LL | "str" => {}
3232 | ^^^^^ expected a valid identifier here
3333
34error[E0539]: malformed `cfg_select` macro input
34error[E0565]: malformed `cfg_select` macro input
3535 --> $DIR/cfg_select.rs:185:5
3636 |
3737LL | a::b => {}
......@@ -185,5 +185,5 @@ LL | cfg!() => {}
185185
186186error: aborting due to 17 previous errors; 7 warnings emitted
187187
188Some errors have detailed explanations: E0537, E0539, E0753.
188Some errors have detailed explanations: E0537, E0565, E0753.
189189For more information about an error, try `rustc --explain E0537`.
tests/ui/proc-macro/attribute.stderr+5-5
......@@ -102,7 +102,7 @@ LL - #[proc_macro_derive(d6 = "")]
102102LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))]
103103 |
104104
105error[E0539]: malformed `proc_macro_derive` attribute input
105error[E0565]: malformed `proc_macro_derive` attribute input
106106 --> $DIR/attribute.rs:45:1
107107 |
108108LL | #[proc_macro_derive(m::d7)]
......@@ -138,7 +138,7 @@ LL - #[proc_macro_derive(d8(a))]
138138LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))]
139139 |
140140
141error[E0539]: malformed `proc_macro_derive` attribute input
141error[E0565]: malformed `proc_macro_derive` attribute input
142142 --> $DIR/attribute.rs:57:1
143143 |
144144LL | #[proc_macro_derive(self)]
......@@ -192,7 +192,7 @@ LL - #[proc_macro_derive(d12, attributes)]
192192LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))]
193193 |
194194
195error[E0539]: malformed `proc_macro_derive` attribute input
195error[E0565]: malformed `proc_macro_derive` attribute input
196196 --> $DIR/attribute.rs:78:1
197197 |
198198LL | #[proc_macro_derive(d13, attributes("a"))]
......@@ -228,7 +228,7 @@ LL - #[proc_macro_derive(d14, attributes(a = ""))]
228228LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))]
229229 |
230230
231error[E0539]: malformed `proc_macro_derive` attribute input
231error[E0565]: malformed `proc_macro_derive` attribute input
232232 --> $DIR/attribute.rs:90:1
233233 |
234234LL | #[proc_macro_derive(d15, attributes(m::a))]
......@@ -264,7 +264,7 @@ LL - #[proc_macro_derive(d16, attributes(a(b)))]
264264LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))]
265265 |
266266
267error[E0539]: malformed `proc_macro_derive` attribute input
267error[E0565]: malformed `proc_macro_derive` attribute input
268268 --> $DIR/attribute.rs:102:1
269269 |
270270LL | #[proc_macro_derive(d17, attributes(self))]
tests/ui/repr/invalid_repr_list_help.rs+5-5
......@@ -1,22 +1,22 @@
11#![deny(invalid_doc_attributes)]
22#![crate_type = "lib"]
33
4#[repr(uwu)] //~ERROR: unrecognized representation hint
4#[repr(uwu)] //~ERROR: malformed `repr` attribute input
55pub struct OwO;
66
7#[repr(uwu = "a")] //~ERROR: unrecognized representation hint
7#[repr(uwu = "a")] //~ERROR: malformed `repr` attribute input
88pub struct OwO2(i32);
99
10#[repr(uwu(4))] //~ERROR: unrecognized representation hint
10#[repr(uwu(4))] //~ERROR: malformed `repr` attribute input
1111pub struct OwO3 {
1212 x: i32,
1313}
1414
15#[repr(uwu, u8)] //~ERROR: unrecognized representation hint
15#[repr(uwu, u8)] //~ERROR: malformed `repr` attribute input
1616pub enum OwO4 {
1717 UwU = 1,
1818}
1919
20#[repr(uwu)] //~ERROR: unrecognized representation hint
20#[repr(uwu)] //~ERROR: malformed `repr` attribute input
2121#[doc(owo)] //~ERROR: unknown `doc` attribute
2222pub struct Owo5;
tests/ui/repr/invalid_repr_list_help.stderr+31-26
......@@ -1,47 +1,52 @@
1error[E0552]: unrecognized representation hint
2 --> $DIR/invalid_repr_list_help.rs:4:8
1error[E0539]: malformed `repr` attribute input
2 --> $DIR/invalid_repr_list_help.rs:4:1
33 |
44LL | #[repr(uwu)]
5 | ^^^
5 | ^^^^^^^---^^
6 | |
7 | valid arguments are `align`, `packed`, `Rust`, `C`, `simd`, `transparent`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize` or `usize`
68 |
7 = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
8 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations>
9 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
910
10error[E0552]: unrecognized representation hint
11 --> $DIR/invalid_repr_list_help.rs:7:8
11error[E0539]: malformed `repr` attribute input
12 --> $DIR/invalid_repr_list_help.rs:7:1
1213 |
1314LL | #[repr(uwu = "a")]
14 | ^^^^^^^^^
15 | ^^^^^^^---------^^
16 | |
17 | valid arguments are `align`, `packed`, `Rust`, `C`, `simd`, `transparent`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize` or `usize`
1518 |
16 = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
17 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations>
19 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
1820
19error[E0552]: unrecognized representation hint
20 --> $DIR/invalid_repr_list_help.rs:10:8
21error[E0539]: malformed `repr` attribute input
22 --> $DIR/invalid_repr_list_help.rs:10:1
2123 |
2224LL | #[repr(uwu(4))]
23 | ^^^^^^
25 | ^^^^^^^------^^
26 | |
27 | valid arguments are `align`, `packed`, `Rust`, `C`, `simd`, `transparent`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize` or `usize`
2428 |
25 = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
26 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations>
29 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
2730
28error[E0552]: unrecognized representation hint
29 --> $DIR/invalid_repr_list_help.rs:15:8
31error[E0539]: malformed `repr` attribute input
32 --> $DIR/invalid_repr_list_help.rs:15:1
3033 |
3134LL | #[repr(uwu, u8)]
32 | ^^^
35 | ^^^^^^^---^^^^^^
36 | |
37 | valid arguments are `align`, `packed`, `Rust`, `C`, `simd`, `transparent`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize` or `usize`
3338 |
34 = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
35 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations>
39 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
3640
37error[E0552]: unrecognized representation hint
38 --> $DIR/invalid_repr_list_help.rs:20:8
41error[E0539]: malformed `repr` attribute input
42 --> $DIR/invalid_repr_list_help.rs:20:1
3943 |
4044LL | #[repr(uwu)]
41 | ^^^
45 | ^^^^^^^---^^
46 | |
47 | valid arguments are `align`, `packed`, `Rust`, `C`, `simd`, `transparent`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize` or `usize`
4248 |
43 = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
44 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations>
49 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
4550
4651error: unknown `doc` attribute `owo`
4752 --> $DIR/invalid_repr_list_help.rs:21:7
......@@ -57,4 +62,4 @@ LL | #![deny(invalid_doc_attributes)]
5762
5863error: aborting due to 6 previous errors
5964
60For more information about this error, try `rustc --explain E0552`.
65For more information about this error, try `rustc --explain E0539`.
tests/ui/repr/malformed-repr-hints.rs+10-10
......@@ -4,40 +4,40 @@
44//@ compile-flags: -Zdeduplicate-diagnostics=yes
55
66#[repr(packed())]
7//~^ ERROR: incorrect `repr(packed)` attribute format
7//~^ ERROR: malformed `repr` attribute input
88struct S1;
99
1010#[repr(align)]
11//~^ ERROR: invalid `repr(align)` attribute
11//~^ ERROR: malformed `repr` attribute input
1212struct S2;
1313
1414#[repr(align(2, 4))]
15//~^ ERROR: incorrect `repr(align)` attribute format
15//~^ ERROR: malformed `repr` attribute input
1616struct S3;
1717
1818#[repr(align())]
19//~^ ERROR: incorrect `repr(align)` attribute format
19//~^ ERROR: malformed `repr` attribute input
2020struct S4;
2121
2222// Regression test for issue #118334:
2323#[repr(Rust(u8))]
24//~^ ERROR: invalid representation hint
24//~^ ERROR: malformed `repr` attribute input
2525#[repr(Rust(0))]
26//~^ ERROR: invalid representation hint
26//~^ ERROR: malformed `repr` attribute input
2727#[repr(Rust = 0)]
28//~^ ERROR: invalid representation hint
28//~^ ERROR: malformed `repr` attribute input
2929struct S5;
3030
3131#[repr(i8())]
32//~^ ERROR: invalid representation hint
32//~^ ERROR: malformed `repr` attribute input
3333enum E1 { A, B }
3434
3535#[repr(u32(42))]
36//~^ ERROR: invalid representation hint
36//~^ ERROR: malformed `repr` attribute input
3737enum E2 { A, B }
3838
3939#[repr(i64 = 2)]
40//~^ ERROR: invalid representation hint
40//~^ ERROR: malformed `repr` attribute input
4141enum E3 { A, B }
4242
4343fn main() {}
tests/ui/repr/malformed-repr-hints.stderr+72-32
......@@ -1,64 +1,104 @@
1error[E0552]: incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all
2 --> $DIR/malformed-repr-hints.rs:6:8
1error[E0805]: malformed `repr` attribute input
2 --> $DIR/malformed-repr-hints.rs:6:1
33 |
44LL | #[repr(packed())]
5 | ^^^^^^^^
5 | ^^^^^^^^^^^^^--^^
6 | |
7 | expected an argument here
8 |
9 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
610
7error[E0589]: invalid `repr(align)` attribute: `align` needs an argument
8 --> $DIR/malformed-repr-hints.rs:10:8
11error[E0539]: malformed `repr` attribute input
12 --> $DIR/malformed-repr-hints.rs:10:1
913 |
1014LL | #[repr(align)]
11 | ^^^^^ help: supply an argument here: `align(...)`
15 | ^^^^^^^-----^^
16 | |
17 | expected this to be a list
18 |
19 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
1220
13error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
14 --> $DIR/malformed-repr-hints.rs:14:8
21error[E0805]: malformed `repr` attribute input
22 --> $DIR/malformed-repr-hints.rs:14:1
1523 |
1624LL | #[repr(align(2, 4))]
17 | ^^^^^^^^^^^
25 | ^^^^^^^^^^^^------^^
26 | |
27 | expected a single argument here
28 |
29 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
1830
19error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
20 --> $DIR/malformed-repr-hints.rs:18:8
31error[E0805]: malformed `repr` attribute input
32 --> $DIR/malformed-repr-hints.rs:18:1
2133 |
2234LL | #[repr(align())]
23 | ^^^^^^^
35 | ^^^^^^^^^^^^--^^
36 | |
37 | expected an argument here
38 |
39 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
2440
25error[E0552]: invalid representation hint: `Rust` does not take a parenthesized argument list
26 --> $DIR/malformed-repr-hints.rs:23:8
41error[E0565]: malformed `repr` attribute input
42 --> $DIR/malformed-repr-hints.rs:23:1
2743 |
2844LL | #[repr(Rust(u8))]
29 | ^^^^^^^^
45 | ^^^^^^^^^^^----^^
46 | |
47 | didn't expect any arguments here
48 |
49 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
3050
31error[E0552]: invalid representation hint: `Rust` does not take a parenthesized argument list
32 --> $DIR/malformed-repr-hints.rs:25:8
51error[E0565]: malformed `repr` attribute input
52 --> $DIR/malformed-repr-hints.rs:25:1
3353 |
3454LL | #[repr(Rust(0))]
35 | ^^^^^^^
55 | ^^^^^^^^^^^---^^
56 | |
57 | didn't expect any arguments here
58 |
59 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
3660
37error[E0552]: invalid representation hint: `Rust` does not take a value
38 --> $DIR/malformed-repr-hints.rs:27:8
61error[E0565]: malformed `repr` attribute input
62 --> $DIR/malformed-repr-hints.rs:27:1
3963 |
4064LL | #[repr(Rust = 0)]
41 | ^^^^^^^^
65 | ^^^^^^^^^^^^---^^
66 | |
67 | didn't expect any arguments here
68 |
69 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
4270
43error[E0552]: invalid representation hint: `i8` does not take a parenthesized argument list
44 --> $DIR/malformed-repr-hints.rs:31:8
71error[E0565]: malformed `repr` attribute input
72 --> $DIR/malformed-repr-hints.rs:31:1
4573 |
4674LL | #[repr(i8())]
47 | ^^^^
75 | ^^^^^^^^^--^^
76 | |
77 | didn't expect any arguments here
78 |
79 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
4880
49error[E0552]: invalid representation hint: `u32` does not take a parenthesized argument list
50 --> $DIR/malformed-repr-hints.rs:35:8
81error[E0565]: malformed `repr` attribute input
82 --> $DIR/malformed-repr-hints.rs:35:1
5183 |
5284LL | #[repr(u32(42))]
53 | ^^^^^^^
85 | ^^^^^^^^^^----^^
86 | |
87 | didn't expect any arguments here
88 |
89 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
5490
55error[E0552]: invalid representation hint: `i64` does not take a value
56 --> $DIR/malformed-repr-hints.rs:39:8
91error[E0565]: malformed `repr` attribute input
92 --> $DIR/malformed-repr-hints.rs:39:1
5793 |
5894LL | #[repr(i64 = 2)]
59 | ^^^^^^^
95 | ^^^^^^^^^^^---^^
96 | |
97 | didn't expect any arguments here
98 |
99 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
60100
61101error: aborting due to 10 previous errors
62102
63Some errors have detailed explanations: E0552, E0589, E0693.
64For more information about an error, try `rustc --explain E0552`.
103Some errors have detailed explanations: E0539, E0565, E0805.
104For more information about an error, try `rustc --explain E0539`.
tests/ui/repr/repr-align-assign.fixed deleted-11
......@@ -1,11 +0,0 @@
1//@ run-rustfix
2
3#![allow(dead_code)]
4
5#[repr(align(8))] //~ ERROR incorrect `repr(align)` attribute format
6struct A(u64);
7
8#[repr(align(8))] //~ ERROR incorrect `repr(align)` attribute format
9struct B(u64);
10
11fn main() {}
tests/ui/repr/repr-align-assign.rs+2-4
......@@ -1,11 +1,9 @@
1//@ run-rustfix
2
31#![allow(dead_code)]
42
5#[repr(align=8)] //~ ERROR incorrect `repr(align)` attribute format
3#[repr(align=8)] //~ ERROR malformed `repr` attribute input
64struct A(u64);
75
8#[repr(align="8")] //~ ERROR incorrect `repr(align)` attribute format
6#[repr(align="8")] //~ ERROR malformed `repr` attribute input
97struct B(u64);
108
119fn main() {}
tests/ui/repr/repr-align-assign.stderr+15-7
......@@ -1,15 +1,23 @@
1error[E0693]: incorrect `repr(align)` attribute format
2 --> $DIR/repr-align-assign.rs:5:8
1error[E0539]: malformed `repr` attribute input
2 --> $DIR/repr-align-assign.rs:3:1
33 |
44LL | #[repr(align=8)]
5 | ^^^^^^^ help: use parentheses instead: `align(8)`
5 | ^^^^^^^^^^^^--^^
6 | |
7 | expected this to be a list
8 |
9 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
610
7error[E0693]: incorrect `repr(align)` attribute format
8 --> $DIR/repr-align-assign.rs:8:8
11error[E0539]: malformed `repr` attribute input
12 --> $DIR/repr-align-assign.rs:6:1
913 |
1014LL | #[repr(align="8")]
11 | ^^^^^^^^^ help: use parentheses instead: `align(8)`
15 | ^^^^^^^^^^^^----^^
16 | |
17 | expected this to be a list
18 |
19 = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations>
1220
1321error: aborting due to 2 previous errors
1422
15For more information about this error, try `rustc --explain E0693`.
23For more information about this error, try `rustc --explain E0539`.
tests/ui/repr/repr-align.rs+8-8
......@@ -1,33 +1,33 @@
11#![allow(dead_code)]
22
3#[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer
3#[repr(align(16.0))] //~ ERROR: not an unsuffixed integer
44struct S0(i32);
55
6#[repr(align(15))] //~ ERROR: invalid `repr(align)` attribute: not a power of two
6#[repr(align(15))] //~ ERROR: not a power of two
77struct S1(i32);
88
9#[repr(align(4294967296))] //~ ERROR: invalid `repr(align)` attribute: larger than 2^29
9#[repr(align(4294967296))] //~ ERROR: larger than 2^29
1010struct S2(i32);
1111
1212#[repr(align(536870912))] // ok: this is the largest accepted alignment
1313struct S3(i32);
1414
15#[repr(align(0))] //~ ERROR: invalid `repr(align)` attribute: not a power of two
15#[repr(align(0))] //~ ERROR: not a power of two
1616struct S4(i32);
1717
18#[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer
18#[repr(align(16.0))] //~ ERROR: not an unsuffixed integer
1919enum E0 { A, B }
2020
21#[repr(align(15))] //~ ERROR: invalid `repr(align)` attribute: not a power of two
21#[repr(align(15))] //~ ERROR: not a power of two
2222enum E1 { A, B }
2323
24#[repr(align(4294967296))] //~ ERROR: invalid `repr(align)` attribute: larger than 2^29
24#[repr(align(4294967296))] //~ ERROR: larger than 2^29
2525enum E2 { A, B }
2626
2727#[repr(align(536870912))] // ok: this is the largest accepted alignment
2828enum E3 { A, B }
2929
30#[repr(align(0))] //~ ERROR: invalid `repr(align)` attribute: not a power of two
30#[repr(align(0))] //~ ERROR: not a power of two
3131enum E4 { A, B }
3232
3333fn main() {}
tests/ui/repr/repr-align.stderr+8-8
......@@ -1,46 +1,46 @@
1error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer
1error[E0589]: invalid alignment value: not an unsuffixed integer
22 --> $DIR/repr-align.rs:3:14
33 |
44LL | #[repr(align(16.0))]
55 | ^^^^
66
7error[E0589]: invalid `repr(align)` attribute: not a power of two
7error[E0589]: invalid alignment value: not a power of two
88 --> $DIR/repr-align.rs:6:14
99 |
1010LL | #[repr(align(15))]
1111 | ^^
1212
13error[E0589]: invalid `repr(align)` attribute: larger than 2^29
13error[E0589]: invalid alignment value: larger than 2^29
1414 --> $DIR/repr-align.rs:9:14
1515 |
1616LL | #[repr(align(4294967296))]
1717 | ^^^^^^^^^^
1818
19error[E0589]: invalid `repr(align)` attribute: not a power of two
19error[E0589]: invalid alignment value: not a power of two
2020 --> $DIR/repr-align.rs:15:14
2121 |
2222LL | #[repr(align(0))]
2323 | ^
2424
25error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer
25error[E0589]: invalid alignment value: not an unsuffixed integer
2626 --> $DIR/repr-align.rs:18:14
2727 |
2828LL | #[repr(align(16.0))]
2929 | ^^^^
3030
31error[E0589]: invalid `repr(align)` attribute: not a power of two
31error[E0589]: invalid alignment value: not a power of two
3232 --> $DIR/repr-align.rs:21:14
3333 |
3434LL | #[repr(align(15))]
3535 | ^^
3636
37error[E0589]: invalid `repr(align)` attribute: larger than 2^29
37error[E0589]: invalid alignment value: larger than 2^29
3838 --> $DIR/repr-align.rs:24:14
3939 |
4040LL | #[repr(align(4294967296))]
4141 | ^^^^^^^^^^
4242
43error[E0589]: invalid `repr(align)` attribute: not a power of two
43error[E0589]: invalid alignment value: not a power of two
4444 --> $DIR/repr-align.rs:30:14
4545 |
4646LL | #[repr(align(0))]
tests/ui/repr/repr_align_greater_usize.msp430.stderr+2-2
......@@ -1,10 +1,10 @@
1error[E0589]: invalid `repr(align)` attribute: alignment larger than `isize::MAX` bytes (32767 for the current target)
1error[E0589]: invalid alignment value: alignment larger than `isize::MAX` bytes (32767 for the current target)
22 --> $DIR/repr_align_greater_usize.rs:23:14
33 |
44LL | #[repr(align(32768))]
55 | ^^^^^
66
7error[E0589]: invalid `repr(align)` attribute: alignment larger than `isize::MAX` bytes (32767 for the current target)
7error[E0589]: invalid alignment value: alignment larger than `isize::MAX` bytes (32767 for the current target)
88 --> $DIR/repr_align_greater_usize.rs:26:14
99 |
1010LL | #[repr(align(65536))]
tests/ui/repr/repr_align_greater_usize.rs+2-2
......@@ -20,8 +20,8 @@ use minicore::*;
2020#[repr(align(16384))]
2121struct Kitten;
2222
23#[repr(align(32768))] //[msp430]~ ERROR invalid `repr(align)` attribute: alignment larger than `isize::MAX` bytes (32767 for the current target) [E0589]
23#[repr(align(32768))] //[msp430]~ ERROR alignment larger than `isize::MAX` bytes (32767 for the current target) [E0589]
2424struct Cat;
2525
26#[repr(align(65536))] //[msp430]~ ERROR invalid `repr(align)` attribute: alignment larger than `isize::MAX` bytes (32767 for the current target) [E0589]
26#[repr(align(65536))] //[msp430]~ ERROR alignment larger than `isize::MAX` bytes (32767 for the current target) [E0589]
2727struct BigCat;
tests/ui/tool-attributes/invalid-tool.stderr+2-2
......@@ -1,4 +1,4 @@
1error[E0539]: malformed `register_tool` attribute input
1error[E0565]: malformed `register_tool` attribute input
22 --> $DIR/invalid-tool.rs:3:1
33 |
44LL | #![register_tool(1)]
......@@ -14,4 +14,4 @@ LL + #![register_tool(tool1, tool2, ...)]
1414
1515error: aborting due to 1 previous error
1616
17For more information about this error, try `rustc --explain E0539`.
17For more information about this error, try `rustc --explain E0565`.
tests/ui/tool-attributes/nested-disallowed.stderr+2-2
......@@ -1,4 +1,4 @@
1error[E0539]: malformed `register_tool` attribute input
1error[E0565]: malformed `register_tool` attribute input
22 --> $DIR/nested-disallowed.rs:2:1
33 |
44LL | #![register_tool(foo::bar)]
......@@ -14,4 +14,4 @@ LL + #![register_tool(tool1, tool2, ...)]
1414
1515error: aborting due to 1 previous error
1616
17For more information about this error, try `rustc --explain E0539`.
17For more information about this error, try `rustc --explain E0565`.