Skip to content

Commit af952c1

Browse files
committed
Auto merge of #135725 - GuillaumeGomez:rollup-dxn3use, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - #134858 (Provide structured suggestion for `#![feature(..)]` in more cases) - #135679 (create an issue template for bootstrap) - #135685 (Remove unused `item-row` CSS class) - #135716 (Don't skip argument parsing when running `rustc` with no arguments) - #135723 (Fix dev guide docs for error-pattern) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 678e669 + 78d9a52 commit af952c1

File tree

15 files changed

+182
-34
lines changed

15 files changed

+182
-34
lines changed

.github/ISSUE_TEMPLATE/bootstrap.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
name: Bootstrap (Rust Build System) Report
3+
about: Issues encountered on bootstrap build system
4+
labels: C-bug, T-bootstrap
5+
---
6+
7+
<!--
8+
Thank you for submitting a bootstrap report! Please provide detailed information to help us reproduce and diagnose the issue.
9+
-->
10+
11+
### Summary
12+
13+
<!--
14+
Provide a brief description of the problem you are experiencing.
15+
-->
16+
17+
### Command used
18+
19+
```sh
20+
<command>
21+
```
22+
23+
### Expected behaviour
24+
25+
<!--
26+
Describe what you expected to happen.
27+
-->
28+
29+
### Actual behaviour
30+
31+
<!--
32+
Describe what actually happened.
33+
-->
34+
35+
### Bootstrap configuration (config.toml)
36+
```toml
37+
<config>
38+
```
39+
40+
### Operating system
41+
42+
<!--
43+
e.g., Ubuntu 22.04, macOS 12, Windows 10
44+
-->
45+
46+
### HEAD
47+
48+
<!--
49+
Output of `git rev-parse HEAD` command, or content of the `git-commit-hash` file if using a tarball source.
50+
-->
51+
52+
### Additional context
53+
<!--
54+
Include any other relevant information (e.g., if you have custom patches or modifications on the project).
55+
-->
56+
57+
58+
<!--
59+
Include the complete build log in the section below.
60+
Enable backtrace and verbose mode if possible for more detailed information e.g., with `RUST_BACKTRACE=1 ./x build -v`.
61+
-->
62+
<details><summary>Build Log</summary>
63+
<p>
64+
65+
```txt
66+
<log>
67+
```
68+
69+
</p>
70+
</details>

compiler/rustc_const_eval/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ const_eval_unstable_in_stable_exposed =
424424
.bypass_sugg = otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
425425
426426
const_eval_unstable_intrinsic = `{$name}` is not yet stable as a const intrinsic
427-
.help = add `#![feature({$feature})]` to the crate attributes to enable
427+
const_eval_unstable_intrinsic_suggestion = add `#![feature({$feature})]` to the crate attributes to enable
428428
429429
const_eval_unterminated_c_string =
430430
reading a null-terminated string starting at {$pointer} with no null found before end of allocation

compiler/rustc_const_eval/src/check_consts/check.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,12 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
464464
err_span,
465465
);
466466
}
467+
468+
fn crate_inject_span(&self) -> Option<Span> {
469+
self.tcx.hir_crate_items(()).definitions().next().and_then(|id| {
470+
self.tcx.crate_level_attribute_injection_span(self.tcx.local_def_id_to_hir_id(id))
471+
})
472+
}
467473
}
468474

469475
impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
@@ -809,6 +815,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
809815
name: intrinsic.name,
810816
feature,
811817
const_stable_indirect: is_const_stable,
818+
suggestion: self.crate_inject_span(),
812819
});
813820
}
814821
Some(ConstStability { level: StabilityLevel::Stable { .. }, .. }) => {
@@ -897,7 +904,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
897904
// regular stability.
898905
feature == sym::rustc_private
899906
&& issue == NonZero::new(27812)
900-
&& self.tcx.sess.opts.unstable_opts.force_unstable_if_unmarked
907+
&& tcx.sess.opts.unstable_opts.force_unstable_if_unmarked
901908
};
902909
// Even if the feature is enabled, we still need check_op to double-check
903910
// this if the callee is not safe to expose on stable.
@@ -907,6 +914,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
907914
feature,
908915
feature_enabled,
909916
safe_to_expose_on_stable: callee_safe_to_expose_on_stable,
917+
suggestion_span: self.crate_inject_span(),
910918
});
911919
}
912920
}

compiler/rustc_const_eval/src/check_consts/ops.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Concrete error types for all operations which may be invalid in a certain const context.
22
33
use hir::{ConstContext, LangItem};
4-
use rustc_errors::Diag;
54
use rustc_errors::codes::*;
5+
use rustc_errors::{Applicability, Diag};
66
use rustc_hir as hir;
77
use rustc_hir::def_id::DefId;
88
use rustc_infer::infer::TyCtxtInferExt;
@@ -388,6 +388,7 @@ pub(crate) struct FnCallUnstable {
388388
/// expose on stable.
389389
pub feature_enabled: bool,
390390
pub safe_to_expose_on_stable: bool,
391+
pub suggestion_span: Option<Span>,
391392
}
392393

393394
impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
@@ -407,8 +408,18 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
407408
def_path: ccx.tcx.def_path_str(self.def_id),
408409
});
409410
// FIXME: make this translatable
411+
let msg = format!("add `#![feature({})]` to the crate attributes to enable", self.feature);
410412
#[allow(rustc::untranslatable_diagnostic)]
411-
err.help(format!("add `#![feature({})]` to the crate attributes to enable", self.feature));
413+
if let Some(span) = self.suggestion_span {
414+
err.span_suggestion_verbose(
415+
span,
416+
msg,
417+
format!("#![feature({})]\n", self.feature),
418+
Applicability::MachineApplicable,
419+
);
420+
} else {
421+
err.help(msg);
422+
}
412423

413424
err
414425
}
@@ -436,6 +447,7 @@ pub(crate) struct IntrinsicUnstable {
436447
pub name: Symbol,
437448
pub feature: Symbol,
438449
pub const_stable_indirect: bool,
450+
pub suggestion: Option<Span>,
439451
}
440452

441453
impl<'tcx> NonConstOp<'tcx> for IntrinsicUnstable {
@@ -455,6 +467,8 @@ impl<'tcx> NonConstOp<'tcx> for IntrinsicUnstable {
455467
span,
456468
name: self.name,
457469
feature: self.feature,
470+
suggestion: self.suggestion,
471+
help: self.suggestion.is_none(),
458472
})
459473
}
460474
}

compiler/rustc_const_eval/src/errors.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,19 @@ pub(crate) struct UnstableConstFn {
123123

124124
#[derive(Diagnostic)]
125125
#[diag(const_eval_unstable_intrinsic)]
126-
#[help]
127126
pub(crate) struct UnstableIntrinsic {
128127
#[primary_span]
129128
pub span: Span,
130129
pub name: Symbol,
131130
pub feature: Symbol,
131+
#[suggestion(
132+
const_eval_unstable_intrinsic_suggestion,
133+
code = "#![feature({feature})]\n",
134+
applicability = "machine-applicable"
135+
)]
136+
pub suggestion: Option<Span>,
137+
#[help(const_eval_unstable_intrinsic_suggestion)]
138+
pub help: bool,
132139
}
133140

134141
#[derive(Diagnostic)]

compiler/rustc_driver_impl/src/lib.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -1191,15 +1191,6 @@ fn print_flag_list<T>(cmdline_opt: &str, flag_list: &[OptionDesc<T>]) {
11911191
/// be public when using rustc as a library, see
11921192
/// <https://github.com/rust-lang/rust/commit/2b4c33817a5aaecabf4c6598d41e190080ec119e>
11931193
pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<getopts::Matches> {
1194-
if args.is_empty() {
1195-
// user did not write `-v` nor `-Z unstable-options`, so do not
1196-
// include that extra information.
1197-
let nightly_build =
1198-
rustc_feature::UnstableFeatures::from_environment(None).is_nightly_build();
1199-
usage(false, false, nightly_build);
1200-
return None;
1201-
}
1202-
12031194
// Parse with *all* options defined in the compiler, we don't worry about
12041195
// option stability here we just want to parse as much as possible.
12051196
let mut options = getopts::Options::new();
@@ -1245,7 +1236,7 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
12451236
// (unstable option being used on stable)
12461237
nightly_options::check_nightly_options(early_dcx, &matches, &config::rustc_optgroups());
12471238

1248-
if matches.opt_present("h") || matches.opt_present("help") {
1239+
if args.is_empty() || matches.opt_present("h") || matches.opt_present("help") {
12491240
// Only show unstable options in --help if we accept unstable options.
12501241
let unstable_enabled = nightly_options::is_unstable_enabled(&matches);
12511242
let nightly_build = nightly_options::match_is_nightly_build(&matches);

compiler/rustc_hir_typeck/src/errors.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@ use crate::fluent_generated as fluent;
1919
pub(crate) struct BaseExpressionDoubleDot {
2020
#[primary_span]
2121
pub span: Span,
22+
#[suggestion(
23+
hir_typeck_base_expression_double_dot_enable_default_field_values,
24+
code = "#![feature(default_field_values)]\n",
25+
applicability = "machine-applicable",
26+
style = "verbose"
27+
)]
28+
pub default_field_values_suggestion: Option<Span>,
2229
#[subdiagnostic]
23-
pub default_field_values: Option<BaseExpressionDoubleDotEnableDefaultFieldValues>,
30+
pub default_field_values_help: Option<BaseExpressionDoubleDotEnableDefaultFieldValues>,
2431
#[subdiagnostic]
2532
pub add_expr: Option<BaseExpressionDoubleDotAddExpr>,
2633
#[subdiagnostic]

compiler/rustc_hir_typeck/src/expr.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -2138,13 +2138,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21382138
}
21392139
}
21402140
if !self.tcx.features().default_field_values() {
2141+
let sugg = self.tcx.crate_level_attribute_injection_span(expr.hir_id);
21412142
self.dcx().emit_err(BaseExpressionDoubleDot {
21422143
span: span.shrink_to_hi(),
21432144
// We only mention enabling the feature if this is a nightly rustc *and* the
21442145
// expression would make sense with the feature enabled.
2145-
default_field_values: if self.tcx.sess.is_nightly_build()
2146+
default_field_values_suggestion: if self.tcx.sess.is_nightly_build()
21462147
&& missing_mandatory_fields.is_empty()
21472148
&& !missing_optional_fields.is_empty()
2149+
&& sugg.is_some()
2150+
{
2151+
sugg
2152+
} else {
2153+
None
2154+
},
2155+
default_field_values_help: if self.tcx.sess.is_nightly_build()
2156+
&& missing_mandatory_fields.is_empty()
2157+
&& !missing_optional_fields.is_empty()
2158+
&& sugg.is_none()
21482159
{
21492160
Some(BaseExpressionDoubleDotEnableDefaultFieldValues)
21502161
} else {

src/doc/rustc-dev-guide/src/tests/directives.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ for more details.
9494
| Directive | Explanation | Supported test suites | Possible values |
9595
|-----------------------------------|--------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|-----------------------------------------------------------------------------------------|
9696
| `check-run-results` | Check run test binary `run-{pass,fail}` output snapshot | `ui`, `crashes`, `incremental` if `run-pass` | N/A |
97-
| `error-pattern` | Check that output contains a regex pattern | `ui`, `crashes`, `incremental` if `run-pass` | Regex |
97+
| `error-pattern` | Check that output contains a specific string | `ui`, `crashes`, `incremental` if `run-pass` | String |
98+
| `regex-error-pattern` | Check that output contains a regex pattern | `ui`, `crashes`, `incremental` if `run-pass` | Regex |
9899
| `check-stdout` | Check `stdout` against `error-pattern`s from running test binary[^check_stdout] | `ui`, `crashes`, `incremental` | N/A |
99100
| `normalize-stderr-32bit` | Normalize actual stderr (for 32-bit platforms) with a rule `"<raw>" -> "<normalized>"` before comparing against snapshot | `ui`, `incremental` | `"<RAW>" -> "<NORMALIZED>"`, `<RAW>`/`<NORMALIZED>` is regex capture and replace syntax |
100101
| `normalize-stderr-64bit` | Normalize actual stderr (for 64-bit platforms) with a rule `"<raw>" -> "<normalized>"` before comparing against snapshot | `ui`, `incremental` | `"<RAW>" -> "<NORMALIZED>"`, `<RAW>`/`<NORMALIZED>` is regex capture and replace syntax |

src/librustdoc/html/static/css/rustdoc.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -2473,7 +2473,7 @@ in src-script.js and main.js
24732473
}
24742474

24752475
/* Display an alternating layout on tablets and phones */
2476-
.item-row, .search-results > a, .search-results > a > div {
2476+
.search-results > a, .search-results > a > div {
24772477
display: block;
24782478
}
24792479

tests/rustdoc/multiple-mods-w-same-name-doc-inline-83375.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub mod sub {
1010
}
1111

1212
//@ count foo/index.html '//a[@class="mod"][@title="mod foo::prelude"]' 1
13-
//@ count foo/prelude/index.html '//div[@class="item-row"]' 0
13+
//@ count foo/prelude/index.html '//ul[@class="item-table"]' 0
1414
pub mod prelude {}
1515

1616
#[doc(inline)]

tests/rustdoc/multiple-mods-w-same-name-doc-inline-last-item-83375.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ pub mod sub {
1313
pub use sub::*;
1414

1515
//@ count foo/index.html '//a[@class="mod"][@title="mod foo::prelude"]' 1
16-
//@ count foo/prelude/index.html '//div[@class="item-row"]' 0
16+
//@ count foo/prelude/index.html '//ul[@class="item-table"]' 0
1717
pub mod prelude {}

tests/ui/consts/const-unstable-intrinsic.stderr

+8-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,21 @@ error: `size_of_val` is not yet stable as a const intrinsic
2424
LL | unstable_intrinsic::size_of_val(&x);
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2626
|
27-
= help: add `#![feature(unstable)]` to the crate attributes to enable
27+
help: add `#![feature(unstable)]` to the crate attributes to enable
28+
|
29+
LL + #![feature(unstable)]
30+
|
2831

2932
error: `min_align_of_val` is not yet stable as a const intrinsic
3033
--> $DIR/const-unstable-intrinsic.rs:20:9
3134
|
3235
LL | unstable_intrinsic::min_align_of_val(&x);
3336
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3437
|
35-
= help: add `#![feature(unstable)]` to the crate attributes to enable
38+
help: add `#![feature(unstable)]` to the crate attributes to enable
39+
|
40+
LL + #![feature(unstable)]
41+
|
3642

3743
error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local)]`
3844
--> $DIR/const-unstable-intrinsic.rs:24:9

0 commit comments

Comments
 (0)