Skip to content

Commit f4babc6

Browse files
committed
Auto merge of #147308 - matthiaskrgr:rollup-ov04tbi, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #147245 (only replace the intended comma in pattern suggestions) - #147269 (Add regression test for 123953) - #147277 (Extract common logic for iterating over features) - #147292 (Respect `-Z` unstable options in `rustdoc --test`) - #147300 (Add xtensa arch to object file creation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 595b9a4 + 30442dc commit f4babc6

37 files changed

+386
-175
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,7 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
622622
}
623623

624624
fn check_incompatible_features(sess: &Session, features: &Features) {
625-
let enabled_lang_features =
626-
features.enabled_lang_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
627-
let enabled_lib_features =
628-
features.enabled_lib_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
629-
let enabled_features = enabled_lang_features.chain(enabled_lib_features);
625+
let enabled_features = features.enabled_features_iter_stable_order();
630626

631627
for (f1, f2) in rustc_feature::INCOMPATIBLE_FEATURES
632628
.iter()

compiler/rustc_feature/src/unstable.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ impl Features {
9393
&self.enabled_features
9494
}
9595

96+
/// Returns a iterator of enabled features in stable order.
97+
pub fn enabled_features_iter_stable_order(
98+
&self,
99+
) -> impl Iterator<Item = (Symbol, Span)> + Clone {
100+
self.enabled_lang_features
101+
.iter()
102+
.map(|feat| (feat.gate_name, feat.attr_sp))
103+
.chain(self.enabled_lib_features.iter().map(|feat| (feat.gate_name, feat.attr_sp)))
104+
}
105+
96106
/// Is the given feature enabled (via `#[feature(...)]`)?
97107
pub fn enabled(&self, feature: Symbol) -> bool {
98108
self.enabled_features.contains(&feature)

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,13 +2331,9 @@ declare_lint_pass!(
23312331
impl EarlyLintPass for IncompleteInternalFeatures {
23322332
fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
23332333
let features = cx.builder.features();
2334-
let lang_features =
2335-
features.enabled_lang_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
2336-
let lib_features =
2337-
features.enabled_lib_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
23382334

2339-
lang_features
2340-
.chain(lib_features)
2335+
features
2336+
.enabled_features_iter_stable_order()
23412337
.filter(|(name, _)| features.incomplete(*name) || features.internal(*name))
23422338
.for_each(|(name, span)| {
23432339
if features.incomplete(name) {

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,26 +2939,24 @@ impl<'a> Parser<'a> {
29392939
}
29402940
let seq_span = lo.to(self.prev_token.span);
29412941
let mut err = self.dcx().struct_span_err(comma_span, "unexpected `,` in pattern");
2942-
if let Ok(seq_snippet) = self.span_to_snippet(seq_span) {
2943-
err.multipart_suggestion(
2944-
format!(
2945-
"try adding parentheses to match on a tuple{}",
2946-
if let CommaRecoveryMode::LikelyTuple = rt { "" } else { "..." },
2947-
),
2948-
vec![
2949-
(seq_span.shrink_to_lo(), "(".to_string()),
2950-
(seq_span.shrink_to_hi(), ")".to_string()),
2951-
],
2942+
err.multipart_suggestion(
2943+
format!(
2944+
"try adding parentheses to match on a tuple{}",
2945+
if let CommaRecoveryMode::LikelyTuple = rt { "" } else { "..." },
2946+
),
2947+
vec![
2948+
(seq_span.shrink_to_lo(), "(".to_string()),
2949+
(seq_span.shrink_to_hi(), ")".to_string()),
2950+
],
2951+
Applicability::MachineApplicable,
2952+
);
2953+
if let CommaRecoveryMode::EitherTupleOrPipe = rt {
2954+
err.span_suggestion(
2955+
comma_span,
2956+
"...or a vertical bar to match on alternatives",
2957+
" |",
29522958
Applicability::MachineApplicable,
29532959
);
2954-
if let CommaRecoveryMode::EitherTupleOrPipe = rt {
2955-
err.span_suggestion(
2956-
seq_span,
2957-
"...or a vertical bar to match on multiple alternatives",
2958-
seq_snippet.replace(',', " |"),
2959-
Applicability::MachineApplicable,
2960-
);
2961-
}
29622960
}
29632961
Err(err)
29642962
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,6 +3182,7 @@ impl Target {
31823182
"avr" => (Architecture::Avr, None),
31833183
"msp430" => (Architecture::Msp430, None),
31843184
"hexagon" => (Architecture::Hexagon, None),
3185+
"xtensa" => (Architecture::Xtensa, None),
31853186
"bpf" => (Architecture::Bpf, None),
31863187
"loongarch32" => (Architecture::LoongArch32, None),
31873188
"loongarch64" => (Architecture::LoongArch64, None),

src/librustdoc/doctest.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
173173
target_triple: options.target.clone(),
174174
crate_name: options.crate_name.clone(),
175175
remap_path_prefix: options.remap_path_prefix.clone(),
176+
unstable_opts: options.unstable_opts.clone(),
177+
error_format: options.error_format.clone(),
176178
..config::Options::default()
177179
};
178180

tests/rustdoc-ui/doctest/check-attr-test.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,39 @@
22

33
#![deny(rustdoc::invalid_codeblock_attributes)]
44

5+
//~vvv ERROR unknown attribute `compile-fail`
6+
//~| ERROR unknown attribute `compilefail`
7+
//~| ERROR unknown attribute `comPile_fail`
58
/// foo
69
///
710
/// ```compile-fail,compilefail,comPile_fail
811
/// boo
912
/// ```
1013
pub fn foo() {}
1114

15+
//~vvv ERROR unknown attribute `should-panic`
16+
//~| ERROR unknown attribute `shouldpanic`
17+
//~| ERROR unknown attribute `shOuld_panic`
1218
/// bar
1319
///
1420
/// ```should-panic,shouldpanic,shOuld_panic
1521
/// boo
1622
/// ```
1723
pub fn bar() {}
1824

25+
//~vvv ERROR unknown attribute `no-run`
26+
//~| ERROR unknown attribute `norun`
27+
//~| ERROR unknown attribute `nO_run`
1928
/// foobar
2029
///
2130
/// ```no-run,norun,nO_run
2231
/// boo
2332
/// ```
2433
pub fn foobar() {}
2534

35+
//~vvv ERROR unknown attribute `test-harness`
36+
//~| ERROR unknown attribute `testharness`
37+
//~| ERROR unknown attribute `tesT_harness`
2638
/// b
2739
///
2840
/// ```test-harness,testharness,tesT_harness

tests/rustdoc-ui/doctest/check-attr-test.stderr

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,159 @@
11
error: unknown attribute `compile-fail`
2-
--> $DIR/check-attr-test.rs:5:1
3-
|
4-
5 | / /// foo
5-
6 | | ///
6-
7 | | /// ```compile-fail,compilefail,comPile_fail
7-
8 | | /// boo
8-
9 | | /// ```
9-
| |_______^
10-
|
11-
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
12-
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
2+
--> $DIR/check-attr-test.rs:8:1
3+
|
4+
LL | / /// foo
5+
LL | | ///
6+
LL | | /// ```compile-fail,compilefail,comPile_fail
7+
LL | | /// boo
8+
LL | | /// ```
9+
| |_______^
10+
|
11+
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
12+
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
1313
note: the lint level is defined here
14-
--> $DIR/check-attr-test.rs:3:9
15-
|
16-
3 | #![deny(rustdoc::invalid_codeblock_attributes)]
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
--> $DIR/check-attr-test.rs:3:9
15+
|
16+
LL | #![deny(rustdoc::invalid_codeblock_attributes)]
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: unknown attribute `compilefail`
20-
--> $DIR/check-attr-test.rs:5:1
21-
|
22-
5 | / /// foo
23-
6 | | ///
24-
7 | | /// ```compile-fail,compilefail,comPile_fail
25-
8 | | /// boo
26-
9 | | /// ```
27-
| |_______^
28-
|
29-
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
30-
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
20+
--> $DIR/check-attr-test.rs:8:1
21+
|
22+
LL | / /// foo
23+
LL | | ///
24+
LL | | /// ```compile-fail,compilefail,comPile_fail
25+
LL | | /// boo
26+
LL | | /// ```
27+
| |_______^
28+
|
29+
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
30+
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
3131

3232
error: unknown attribute `comPile_fail`
33-
--> $DIR/check-attr-test.rs:5:1
34-
|
35-
5 | / /// foo
36-
6 | | ///
37-
7 | | /// ```compile-fail,compilefail,comPile_fail
38-
8 | | /// boo
39-
9 | | /// ```
40-
| |_______^
41-
|
42-
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
43-
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
33+
--> $DIR/check-attr-test.rs:8:1
34+
|
35+
LL | / /// foo
36+
LL | | ///
37+
LL | | /// ```compile-fail,compilefail,comPile_fail
38+
LL | | /// boo
39+
LL | | /// ```
40+
| |_______^
41+
|
42+
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
43+
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
4444

4545
error: unknown attribute `should-panic`
46-
--> $DIR/check-attr-test.rs:12:1
46+
--> $DIR/check-attr-test.rs:18:1
4747
|
48-
12 | / /// bar
49-
13 | | ///
50-
14 | | /// ```should-panic,shouldpanic,shOuld_panic
51-
15 | | /// boo
52-
16 | | /// ```
48+
LL | / /// bar
49+
LL | | ///
50+
LL | | /// ```should-panic,shouldpanic,shOuld_panic
51+
LL | | /// boo
52+
LL | | /// ```
5353
| |_______^
5454
|
5555
= help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not
5656
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
5757

5858
error: unknown attribute `shouldpanic`
59-
--> $DIR/check-attr-test.rs:12:1
59+
--> $DIR/check-attr-test.rs:18:1
6060
|
61-
12 | / /// bar
62-
13 | | ///
63-
14 | | /// ```should-panic,shouldpanic,shOuld_panic
64-
15 | | /// boo
65-
16 | | /// ```
61+
LL | / /// bar
62+
LL | | ///
63+
LL | | /// ```should-panic,shouldpanic,shOuld_panic
64+
LL | | /// boo
65+
LL | | /// ```
6666
| |_______^
6767
|
6868
= help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not
6969
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
7070

7171
error: unknown attribute `shOuld_panic`
72-
--> $DIR/check-attr-test.rs:12:1
72+
--> $DIR/check-attr-test.rs:18:1
7373
|
74-
12 | / /// bar
75-
13 | | ///
76-
14 | | /// ```should-panic,shouldpanic,shOuld_panic
77-
15 | | /// boo
78-
16 | | /// ```
74+
LL | / /// bar
75+
LL | | ///
76+
LL | | /// ```should-panic,shouldpanic,shOuld_panic
77+
LL | | /// boo
78+
LL | | /// ```
7979
| |_______^
8080
|
8181
= help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not
8282
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
8383

8484
error: unknown attribute `no-run`
85-
--> $DIR/check-attr-test.rs:19:1
85+
--> $DIR/check-attr-test.rs:28:1
8686
|
87-
19 | / /// foobar
88-
20 | | ///
89-
21 | | /// ```no-run,norun,nO_run
90-
22 | | /// boo
91-
23 | | /// ```
87+
LL | / /// foobar
88+
LL | | ///
89+
LL | | /// ```no-run,norun,nO_run
90+
LL | | /// boo
91+
LL | | /// ```
9292
| |_______^
9393
|
9494
= help: use `no_run` to compile, but not run, the code sample during testing
9595
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
9696

9797
error: unknown attribute `norun`
98-
--> $DIR/check-attr-test.rs:19:1
98+
--> $DIR/check-attr-test.rs:28:1
9999
|
100-
19 | / /// foobar
101-
20 | | ///
102-
21 | | /// ```no-run,norun,nO_run
103-
22 | | /// boo
104-
23 | | /// ```
100+
LL | / /// foobar
101+
LL | | ///
102+
LL | | /// ```no-run,norun,nO_run
103+
LL | | /// boo
104+
LL | | /// ```
105105
| |_______^
106106
|
107107
= help: use `no_run` to compile, but not run, the code sample during testing
108108
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
109109

110110
error: unknown attribute `nO_run`
111-
--> $DIR/check-attr-test.rs:19:1
111+
--> $DIR/check-attr-test.rs:28:1
112112
|
113-
19 | / /// foobar
114-
20 | | ///
115-
21 | | /// ```no-run,norun,nO_run
116-
22 | | /// boo
117-
23 | | /// ```
113+
LL | / /// foobar
114+
LL | | ///
115+
LL | | /// ```no-run,norun,nO_run
116+
LL | | /// boo
117+
LL | | /// ```
118118
| |_______^
119119
|
120120
= help: use `no_run` to compile, but not run, the code sample during testing
121121
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
122122

123123
error: unknown attribute `test-harness`
124-
--> $DIR/check-attr-test.rs:26:1
124+
--> $DIR/check-attr-test.rs:38:1
125125
|
126-
26 | / /// b
127-
27 | | ///
128-
28 | | /// ```test-harness,testharness,tesT_harness
129-
29 | | /// boo
130-
30 | | /// ```
126+
LL | / /// b
127+
LL | | ///
128+
LL | | /// ```test-harness,testharness,tesT_harness
129+
LL | | /// boo
130+
LL | | /// ```
131131
| |_______^
132132
|
133133
= help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function
134134
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
135135

136136
error: unknown attribute `testharness`
137-
--> $DIR/check-attr-test.rs:26:1
137+
--> $DIR/check-attr-test.rs:38:1
138138
|
139-
26 | / /// b
140-
27 | | ///
141-
28 | | /// ```test-harness,testharness,tesT_harness
142-
29 | | /// boo
143-
30 | | /// ```
139+
LL | / /// b
140+
LL | | ///
141+
LL | | /// ```test-harness,testharness,tesT_harness
142+
LL | | /// boo
143+
LL | | /// ```
144144
| |_______^
145145
|
146146
= help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function
147147
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
148148

149149
error: unknown attribute `tesT_harness`
150-
--> $DIR/check-attr-test.rs:26:1
150+
--> $DIR/check-attr-test.rs:38:1
151151
|
152-
26 | / /// b
153-
27 | | ///
154-
28 | | /// ```test-harness,testharness,tesT_harness
155-
29 | | /// boo
156-
30 | | /// ```
152+
LL | / /// b
153+
LL | | ///
154+
LL | | /// ```test-harness,testharness,tesT_harness
155+
LL | | /// boo
156+
LL | | /// ```
157157
| |_______^
158158
|
159159
= help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function

0 commit comments

Comments
 (0)