Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,7 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
}

fn check_incompatible_features(sess: &Session, features: &Features) {
let enabled_lang_features =
features.enabled_lang_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
let enabled_lib_features =
features.enabled_lib_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
let enabled_features = enabled_lang_features.chain(enabled_lib_features);
let enabled_features = features.enabled_features_iter_stable_order();

for (f1, f2) in rustc_feature::INCOMPATIBLE_FEATURES
.iter()
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ impl Features {
&self.enabled_features
}

/// Returns a iterator of enabled features in stable order.
pub fn enabled_features_iter_stable_order(
&self,
) -> impl Iterator<Item = (Symbol, Span)> + Clone {
self.enabled_lang_features
.iter()
.map(|feat| (feat.gate_name, feat.attr_sp))
.chain(self.enabled_lib_features.iter().map(|feat| (feat.gate_name, feat.attr_sp)))
}

/// Is the given feature enabled (via `#[feature(...)]`)?
pub fn enabled(&self, feature: Symbol) -> bool {
self.enabled_features.contains(&feature)
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2331,13 +2331,9 @@ declare_lint_pass!(
impl EarlyLintPass for IncompleteInternalFeatures {
fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
let features = cx.builder.features();
let lang_features =
features.enabled_lang_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
let lib_features =
features.enabled_lib_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));

lang_features
.chain(lib_features)
features
.enabled_features_iter_stable_order()
.filter(|(name, _)| features.incomplete(*name) || features.internal(*name))
.for_each(|(name, span)| {
if features.incomplete(name) {
Expand Down
34 changes: 16 additions & 18 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2939,26 +2939,24 @@ impl<'a> Parser<'a> {
}
let seq_span = lo.to(self.prev_token.span);
let mut err = self.dcx().struct_span_err(comma_span, "unexpected `,` in pattern");
if let Ok(seq_snippet) = self.span_to_snippet(seq_span) {
err.multipart_suggestion(
format!(
"try adding parentheses to match on a tuple{}",
if let CommaRecoveryMode::LikelyTuple = rt { "" } else { "..." },
),
vec![
(seq_span.shrink_to_lo(), "(".to_string()),
(seq_span.shrink_to_hi(), ")".to_string()),
],
err.multipart_suggestion(
format!(
"try adding parentheses to match on a tuple{}",
if let CommaRecoveryMode::LikelyTuple = rt { "" } else { "..." },
),
vec![
(seq_span.shrink_to_lo(), "(".to_string()),
(seq_span.shrink_to_hi(), ")".to_string()),
],
Applicability::MachineApplicable,
);
if let CommaRecoveryMode::EitherTupleOrPipe = rt {
err.span_suggestion(
comma_span,
"...or a vertical bar to match on alternatives",
" |",
Applicability::MachineApplicable,
);
if let CommaRecoveryMode::EitherTupleOrPipe = rt {
err.span_suggestion(
seq_span,
"...or a vertical bar to match on multiple alternatives",
seq_snippet.replace(',', " |"),
Applicability::MachineApplicable,
);
}
}
Err(err)
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3182,6 +3182,7 @@ impl Target {
"avr" => (Architecture::Avr, None),
"msp430" => (Architecture::Msp430, None),
"hexagon" => (Architecture::Hexagon, None),
"xtensa" => (Architecture::Xtensa, None),
"bpf" => (Architecture::Bpf, None),
"loongarch32" => (Architecture::LoongArch32, None),
"loongarch64" => (Architecture::LoongArch64, None),
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
target_triple: options.target.clone(),
crate_name: options.crate_name.clone(),
remap_path_prefix: options.remap_path_prefix.clone(),
unstable_opts: options.unstable_opts.clone(),
error_format: options.error_format.clone(),
..config::Options::default()
};

Expand Down
12 changes: 12 additions & 0 deletions tests/rustdoc-ui/doctest/check-attr-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,39 @@

#![deny(rustdoc::invalid_codeblock_attributes)]

//~vvv ERROR unknown attribute `compile-fail`
//~| ERROR unknown attribute `compilefail`
//~| ERROR unknown attribute `comPile_fail`
/// foo
///
/// ```compile-fail,compilefail,comPile_fail
/// boo
/// ```
pub fn foo() {}

//~vvv ERROR unknown attribute `should-panic`
//~| ERROR unknown attribute `shouldpanic`
//~| ERROR unknown attribute `shOuld_panic`
/// bar
///
/// ```should-panic,shouldpanic,shOuld_panic
/// boo
/// ```
pub fn bar() {}

//~vvv ERROR unknown attribute `no-run`
//~| ERROR unknown attribute `norun`
//~| ERROR unknown attribute `nO_run`
/// foobar
///
/// ```no-run,norun,nO_run
/// boo
/// ```
pub fn foobar() {}

//~vvv ERROR unknown attribute `test-harness`
//~| ERROR unknown attribute `testharness`
//~| ERROR unknown attribute `tesT_harness`
/// b
///
/// ```test-harness,testharness,tesT_harness
Expand Down
182 changes: 91 additions & 91 deletions tests/rustdoc-ui/doctest/check-attr-test.stderr
Original file line number Diff line number Diff line change
@@ -1,159 +1,159 @@
error: unknown attribute `compile-fail`
--> $DIR/check-attr-test.rs:5:1
|
5 | / /// foo
6 | | ///
7 | | /// ```compile-fail,compilefail,comPile_fail
8 | | /// boo
9 | | /// ```
| |_______^
|
= 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
= 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`
--> $DIR/check-attr-test.rs:8:1
|
LL | / /// foo
LL | | ///
LL | | /// ```compile-fail,compilefail,comPile_fail
LL | | /// boo
LL | | /// ```
| |_______^
|
= 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
= 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`
note: the lint level is defined here
--> $DIR/check-attr-test.rs:3:9
|
3 | #![deny(rustdoc::invalid_codeblock_attributes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--> $DIR/check-attr-test.rs:3:9
|
LL | #![deny(rustdoc::invalid_codeblock_attributes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unknown attribute `compilefail`
--> $DIR/check-attr-test.rs:5:1
|
5 | / /// foo
6 | | ///
7 | | /// ```compile-fail,compilefail,comPile_fail
8 | | /// boo
9 | | /// ```
| |_______^
|
= 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
= 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`
--> $DIR/check-attr-test.rs:8:1
|
LL | / /// foo
LL | | ///
LL | | /// ```compile-fail,compilefail,comPile_fail
LL | | /// boo
LL | | /// ```
| |_______^
|
= 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
= 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`

error: unknown attribute `comPile_fail`
--> $DIR/check-attr-test.rs:5:1
|
5 | / /// foo
6 | | ///
7 | | /// ```compile-fail,compilefail,comPile_fail
8 | | /// boo
9 | | /// ```
| |_______^
|
= 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
= 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`
--> $DIR/check-attr-test.rs:8:1
|
LL | / /// foo
LL | | ///
LL | | /// ```compile-fail,compilefail,comPile_fail
LL | | /// boo
LL | | /// ```
| |_______^
|
= 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
= 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`

error: unknown attribute `should-panic`
--> $DIR/check-attr-test.rs:12:1
--> $DIR/check-attr-test.rs:18:1
|
12 | / /// bar
13 | | ///
14 | | /// ```should-panic,shouldpanic,shOuld_panic
15 | | /// boo
16 | | /// ```
LL | / /// bar
LL | | ///
LL | | /// ```should-panic,shouldpanic,shOuld_panic
LL | | /// boo
LL | | /// ```
| |_______^
|
= help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not
= 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`

error: unknown attribute `shouldpanic`
--> $DIR/check-attr-test.rs:12:1
--> $DIR/check-attr-test.rs:18:1
|
12 | / /// bar
13 | | ///
14 | | /// ```should-panic,shouldpanic,shOuld_panic
15 | | /// boo
16 | | /// ```
LL | / /// bar
LL | | ///
LL | | /// ```should-panic,shouldpanic,shOuld_panic
LL | | /// boo
LL | | /// ```
| |_______^
|
= help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not
= 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`

error: unknown attribute `shOuld_panic`
--> $DIR/check-attr-test.rs:12:1
--> $DIR/check-attr-test.rs:18:1
|
12 | / /// bar
13 | | ///
14 | | /// ```should-panic,shouldpanic,shOuld_panic
15 | | /// boo
16 | | /// ```
LL | / /// bar
LL | | ///
LL | | /// ```should-panic,shouldpanic,shOuld_panic
LL | | /// boo
LL | | /// ```
| |_______^
|
= help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not
= 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`

error: unknown attribute `no-run`
--> $DIR/check-attr-test.rs:19:1
--> $DIR/check-attr-test.rs:28:1
|
19 | / /// foobar
20 | | ///
21 | | /// ```no-run,norun,nO_run
22 | | /// boo
23 | | /// ```
LL | / /// foobar
LL | | ///
LL | | /// ```no-run,norun,nO_run
LL | | /// boo
LL | | /// ```
| |_______^
|
= help: use `no_run` to compile, but not run, the code sample during testing
= 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`

error: unknown attribute `norun`
--> $DIR/check-attr-test.rs:19:1
--> $DIR/check-attr-test.rs:28:1
|
19 | / /// foobar
20 | | ///
21 | | /// ```no-run,norun,nO_run
22 | | /// boo
23 | | /// ```
LL | / /// foobar
LL | | ///
LL | | /// ```no-run,norun,nO_run
LL | | /// boo
LL | | /// ```
| |_______^
|
= help: use `no_run` to compile, but not run, the code sample during testing
= 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`

error: unknown attribute `nO_run`
--> $DIR/check-attr-test.rs:19:1
--> $DIR/check-attr-test.rs:28:1
|
19 | / /// foobar
20 | | ///
21 | | /// ```no-run,norun,nO_run
22 | | /// boo
23 | | /// ```
LL | / /// foobar
LL | | ///
LL | | /// ```no-run,norun,nO_run
LL | | /// boo
LL | | /// ```
| |_______^
|
= help: use `no_run` to compile, but not run, the code sample during testing
= 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`

error: unknown attribute `test-harness`
--> $DIR/check-attr-test.rs:26:1
--> $DIR/check-attr-test.rs:38:1
|
26 | / /// b
27 | | ///
28 | | /// ```test-harness,testharness,tesT_harness
29 | | /// boo
30 | | /// ```
LL | / /// b
LL | | ///
LL | | /// ```test-harness,testharness,tesT_harness
LL | | /// boo
LL | | /// ```
| |_______^
|
= help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function
= 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`

error: unknown attribute `testharness`
--> $DIR/check-attr-test.rs:26:1
--> $DIR/check-attr-test.rs:38:1
|
26 | / /// b
27 | | ///
28 | | /// ```test-harness,testharness,tesT_harness
29 | | /// boo
30 | | /// ```
LL | / /// b
LL | | ///
LL | | /// ```test-harness,testharness,tesT_harness
LL | | /// boo
LL | | /// ```
| |_______^
|
= help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function
= 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`

error: unknown attribute `tesT_harness`
--> $DIR/check-attr-test.rs:26:1
--> $DIR/check-attr-test.rs:38:1
|
26 | / /// b
27 | | ///
28 | | /// ```test-harness,testharness,tesT_harness
29 | | /// boo
30 | | /// ```
LL | / /// b
LL | | ///
LL | | /// ```test-harness,testharness,tesT_harness
LL | | /// boo
LL | | /// ```
| |_______^
|
= help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function
Expand Down
Loading
Loading