Skip to content

Commit 4196e19

Browse files
committed
Auto merge of rust-lang#137856 - matthiaskrgr:rollup-oa7ibs8, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#136865 (Perform deeper compiletest path normalization for `$TEST_BUILD_DIR` to account for compare-mode/debugger cases, and normalize long type file filename hashes) - rust-lang#136922 (Pattern types: Avoid having to handle an Option for range ends in the type system or the HIR) - rust-lang#137081 (change config.toml to bootstrap.toml) - rust-lang#137103 ({json|html}docck: catch and error on deprecated syntax) - rust-lang#137632 (rustdoc: when merging target features, keep the highest stability) - rust-lang#137684 (Add rustdoc support for `--emit=dep-info[=path]`) - rust-lang#137794 (make qnx pass a test) - rust-lang#137801 (tests: Unignore target modifier tests on all platforms) - rust-lang#137826 (test(codegen): add looping_over_ne_bytes test for rust-lang#133528) Failed merges: - rust-lang#137147 (Add exclude to config.toml) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1c3b035 + f1f63f3 commit 4196e19

File tree

257 files changed

+1423
-1124
lines changed

Some content is hidden

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

257 files changed

+1423
-1124
lines changed

Diff for: .github/ISSUE_TEMPLATE/bootstrap.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Describe what you expected to happen.
3232
Describe what actually happened.
3333
-->
3434

35-
### Bootstrap configuration (config.toml)
35+
### Bootstrap configuration (bootstrap.toml)
3636
```toml
3737
<config>
3838
```

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file should only ignore things that are generated during a `x.py` build,
22
# generated by common IDEs, and optional files controlled by the user that
3-
# affect the build (such as config.toml).
3+
# affect the build (such as bootstrap.toml).
44
# In particular, things like `mir_dump` should not be listed here; they are only
55
# created during manual debugging and many people like to clean up instead of
66
# having git ignore such leftovers. You can use `.git/info/exclude` to
@@ -34,6 +34,7 @@ Session.vim
3434
!/tests/run-make/thumb-none-qemu/example/.cargo
3535

3636
## Configuration
37+
/bootstrap.toml
3738
/config.toml
3839
/Makefile
3940
config.mk

Diff for: .ignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# Make vscode *not* count `config.toml` as ignored, so it is included in search
1+
# Make vscode *not* count `bootstrap.toml` and `config.toml` as ignored, so it is included in search
2+
!/bootstrap.toml
23
!/config.toml

Diff for: INSTALL.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ If you just want to install Rust, check out the [README.md](README.md) instead.*
66

77
The Rust build system uses a Python script called `x.py` to build the compiler,
88
which manages the bootstrapping process. It lives at the root of the project.
9-
It also uses a file named `config.toml` to determine various configuration
9+
It also uses a file named `bootstrap.toml` to determine various configuration
1010
settings for the build. You can see a full list of options in
11-
`config.example.toml`.
11+
`bootstrap.example.toml`.
1212

1313
The `x.py` command can be run directly on most Unix systems in the following
1414
format:
@@ -115,15 +115,15 @@ See [the rustc-dev-guide for more info][sysllvm].
115115

116116
This project provides a configure script and makefile (the latter of which just
117117
invokes `x.py`). `./configure` is the recommended way to programmatically
118-
generate a `config.toml`. `make` is not recommended (we suggest using `x.py`
118+
generate a `bootstrap.toml`. `make` is not recommended (we suggest using `x.py`
119119
directly), but it is supported and we try not to break it unnecessarily.
120120

121121
```sh
122122
./configure
123123
make && sudo make install
124124
```
125125

126-
`configure` generates a `config.toml` which can also be used with normal `x.py`
126+
`configure` generates a `bootstrap.toml` which can also be used with normal `x.py`
127127
invocations.
128128

129129
## Building on Windows
@@ -251,7 +251,7 @@ Windows build triples are:
251251
- `x86_64-pc-windows-msvc`
252252

253253
The build triple can be specified by either specifying `--build=<triple>` when
254-
invoking `x.py` commands, or by creating a `config.toml` file (as described in
254+
invoking `x.py` commands, or by creating a `bootstrap.toml` file (as described in
255255
[Building on a Unix-like system](#building-on-a-unix-like-system)), and passing
256256
`--set build.build=<triple>` to `./configure`.
257257

Diff for: RELEASES.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,7 @@ Compatibility Notes
22822282
- [Cargo denies `CARGO_HOME` in the `[env]` configuration table. Cargo itself doesn't pick up this value, but recursive calls to cargo would, which was not intended.](https://github.com/rust-lang/cargo/pull/11644/)
22832283
- [Debuginfo for build dependencies is now off if not explicitly set. This is expected to improve the overall build time.](https://github.com/rust-lang/cargo/pull/11252/)
22842284
- [The Rust distribution no longer always includes rustdoc](https://github.com/rust-lang/rust/pull/106886)
2285-
If `tools = [...]` is set in config.toml, we will respect a missing rustdoc in that list. By
2285+
If `tools = [...]` is set in bootstrap.toml, we will respect a missing rustdoc in that list. By
22862286
default rustdoc remains included. To retain the prior behavior explicitly add `"rustdoc"` to the
22872287
list.
22882288

@@ -5268,7 +5268,7 @@ related tools.
52685268

52695269
- [Building `rustc` from source now uses `ninja` by default over `make`.][74922]
52705270
You can continue building with `make` by setting `ninja=false` in
5271-
your `config.toml`.
5271+
your `bootstrap.toml`.
52725272
- [cg_llvm: `fewer_names` in `uncached_llvm_type`][76030]
52735273
- [Made `ensure_sufficient_stack()` non-generic][76680]
52745274

Diff for: REUSE.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ path = [
2222
"Cargo.lock",
2323
"Cargo.toml",
2424
"CODE_OF_CONDUCT.md",
25-
"config.example.toml",
25+
"bootstrap.example.toml",
2626
"configure",
2727
"CONTRIBUTING.md",
2828
"COPYRIGHT",

Diff for: config.example.toml renamed to bootstrap.example.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# All options are commented out by default in this file, and they're commented
77
# out with their default values. The build system by default looks for
8-
# `config.toml` in the current directory of a build for build configuration, but
8+
# `bootstrap.toml` in the current directory of a build for build configuration, but
99
# a custom configuration file can also be specified with `--config` to the build
1010
# system.
1111

@@ -16,7 +16,7 @@
1616
# Use different pre-set defaults than the global defaults.
1717
#
1818
# See `src/bootstrap/defaults` for more information.
19-
# Note that this has no default value (x.py uses the defaults in `config.example.toml`).
19+
# Note that this has no default value (x.py uses the defaults in `bootstrap.example.toml`).
2020
#profile = <none>
2121

2222
# Keeps track of major changes made to this configuration.
@@ -325,7 +325,7 @@
325325
# Enable a build of the extended Rust tool set which is not only the compiler
326326
# but also tools such as Cargo. This will also produce "combined installers"
327327
# which are used to install Rust and Cargo together.
328-
# The `tools` (check `config.example.toml` to see its default value) option specifies
328+
# The `tools` (check `bootstrap.example.toml` to see its default value) option specifies
329329
# which tools should be built if `extended = true`.
330330
#
331331
# This is disabled by default.

Diff for: compiler/rustc_ast_lowering/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ struct LoweringContext<'a, 'hir> {
136136

137137
allow_try_trait: Arc<[Symbol]>,
138138
allow_gen_future: Arc<[Symbol]>,
139+
allow_pattern_type: Arc<[Symbol]>,
139140
allow_async_iterator: Arc<[Symbol]>,
140141
allow_for_await: Arc<[Symbol]>,
141142
allow_async_fn_traits: Arc<[Symbol]>,
@@ -176,6 +177,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
176177
impl_trait_defs: Vec::new(),
177178
impl_trait_bounds: Vec::new(),
178179
allow_try_trait: [sym::try_trait_v2, sym::yeet_desugar_details].into(),
180+
allow_pattern_type: [sym::pattern_types, sym::pattern_type_range_trait].into(),
179181
allow_gen_future: if tcx.features().async_fn_track_caller() {
180182
[sym::gen_future, sym::closure_track_caller].into()
181183
} else {
@@ -1365,7 +1367,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13651367
}
13661368
}
13671369
TyKind::Pat(ty, pat) => {
1368-
hir::TyKind::Pat(self.lower_ty(ty, itctx), self.lower_ty_pat(pat))
1370+
hir::TyKind::Pat(self.lower_ty(ty, itctx), self.lower_ty_pat(pat, ty.span))
13691371
}
13701372
TyKind::MacCall(_) => {
13711373
span_bug!(t.span, "`TyKind::MacCall` should have been expanded by now")

Diff for: compiler/rustc_ast_lowering/src/pat.rs

+112-10
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use std::sync::Arc;
33
use rustc_ast::ptr::P;
44
use rustc_ast::*;
55
use rustc_data_structures::stack::ensure_sufficient_stack;
6-
use rustc_hir as hir;
7-
use rustc_hir::def::Res;
6+
use rustc_hir::def::{DefKind, Res};
7+
use rustc_hir::{self as hir, LangItem};
88
use rustc_middle::span_bug;
99
use rustc_span::source_map::{Spanned, respan};
10-
use rustc_span::{Ident, Span};
10+
use rustc_span::{DesugaringKind, Ident, Span, kw};
1111

1212
use super::errors::{
1313
ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding,
@@ -430,22 +430,124 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
430430
self.arena.alloc(hir::PatExpr { hir_id: self.lower_node_id(expr.id), span, kind })
431431
}
432432

433-
pub(crate) fn lower_ty_pat(&mut self, pattern: &TyPat) -> &'hir hir::TyPat<'hir> {
434-
self.arena.alloc(self.lower_ty_pat_mut(pattern))
433+
pub(crate) fn lower_ty_pat(
434+
&mut self,
435+
pattern: &TyPat,
436+
base_type: Span,
437+
) -> &'hir hir::TyPat<'hir> {
438+
self.arena.alloc(self.lower_ty_pat_mut(pattern, base_type))
435439
}
436440

437-
fn lower_ty_pat_mut(&mut self, pattern: &TyPat) -> hir::TyPat<'hir> {
441+
fn lower_ty_pat_mut(&mut self, pattern: &TyPat, base_type: Span) -> hir::TyPat<'hir> {
438442
// loop here to avoid recursion
439443
let pat_hir_id = self.lower_node_id(pattern.id);
440444
let node = match &pattern.kind {
441-
TyPatKind::Range(e1, e2, Spanned { node: end, .. }) => hir::TyPatKind::Range(
442-
e1.as_deref().map(|e| self.lower_anon_const_to_const_arg(e)),
443-
e2.as_deref().map(|e| self.lower_anon_const_to_const_arg(e)),
444-
self.lower_range_end(end, e2.is_some()),
445+
TyPatKind::Range(e1, e2, Spanned { node: end, span }) => hir::TyPatKind::Range(
446+
e1.as_deref().map(|e| self.lower_anon_const_to_const_arg(e)).unwrap_or_else(|| {
447+
self.lower_ty_pat_range_end(
448+
hir::LangItem::RangeMin,
449+
span.shrink_to_lo(),
450+
base_type,
451+
)
452+
}),
453+
e2.as_deref()
454+
.map(|e| match end {
455+
RangeEnd::Included(..) => self.lower_anon_const_to_const_arg(e),
456+
RangeEnd::Excluded => self.lower_excluded_range_end(e),
457+
})
458+
.unwrap_or_else(|| {
459+
self.lower_ty_pat_range_end(
460+
hir::LangItem::RangeMax,
461+
span.shrink_to_hi(),
462+
base_type,
463+
)
464+
}),
445465
),
446466
TyPatKind::Err(guar) => hir::TyPatKind::Err(*guar),
447467
};
448468

449469
hir::TyPat { hir_id: pat_hir_id, kind: node, span: self.lower_span(pattern.span) }
450470
}
471+
472+
/// Lowers the range end of an exclusive range (`2..5`) to an inclusive range 2..=(5 - 1).
473+
/// This way the type system doesn't have to handle the distinction between inclusive/exclusive ranges.
474+
fn lower_excluded_range_end(&mut self, e: &AnonConst) -> &'hir hir::ConstArg<'hir> {
475+
let span = self.lower_span(e.value.span);
476+
let unstable_span = self.mark_span_with_reason(
477+
DesugaringKind::PatTyRange,
478+
span,
479+
Some(Arc::clone(&self.allow_pattern_type)),
480+
);
481+
let anon_const = self.with_new_scopes(span, |this| {
482+
let def_id = this.local_def_id(e.id);
483+
let hir_id = this.lower_node_id(e.id);
484+
let body = this.lower_body(|this| {
485+
// Need to use a custom function as we can't just subtract `1` from a `char`.
486+
let kind = hir::ExprKind::Path(this.make_lang_item_qpath(
487+
hir::LangItem::RangeSub,
488+
unstable_span,
489+
None,
490+
));
491+
let fn_def = this.arena.alloc(hir::Expr { hir_id: this.next_id(), kind, span });
492+
let args = this.arena.alloc([this.lower_expr_mut(&e.value)]);
493+
(
494+
&[],
495+
hir::Expr {
496+
hir_id: this.next_id(),
497+
kind: hir::ExprKind::Call(fn_def, args),
498+
span,
499+
},
500+
)
501+
});
502+
hir::AnonConst { def_id, hir_id, body, span }
503+
});
504+
self.arena.alloc(hir::ConstArg {
505+
hir_id: self.next_id(),
506+
kind: hir::ConstArgKind::Anon(self.arena.alloc(anon_const)),
507+
})
508+
}
509+
510+
/// When a range has no end specified (`1..` or `1..=`) or no start specified (`..5` or `..=5`),
511+
/// we instead use a constant of the MAX/MIN of the type.
512+
/// This way the type system does not have to handle the lack of a start/end.
513+
fn lower_ty_pat_range_end(
514+
&mut self,
515+
lang_item: LangItem,
516+
span: Span,
517+
base_type: Span,
518+
) -> &'hir hir::ConstArg<'hir> {
519+
let parent_def_id = self.current_hir_id_owner.def_id;
520+
let node_id = self.next_node_id();
521+
522+
// Add a definition for the in-band const def.
523+
// We're generating a range end that didn't exist in the AST,
524+
// so the def collector didn't create the def ahead of time. That's why we have to do
525+
// it here.
526+
let def_id = self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, span);
527+
let hir_id = self.lower_node_id(node_id);
528+
529+
let unstable_span = self.mark_span_with_reason(
530+
DesugaringKind::PatTyRange,
531+
self.lower_span(span),
532+
Some(Arc::clone(&self.allow_pattern_type)),
533+
);
534+
let span = self.lower_span(base_type);
535+
536+
let path_expr = hir::Expr {
537+
hir_id: self.next_id(),
538+
kind: hir::ExprKind::Path(self.make_lang_item_qpath(lang_item, unstable_span, None)),
539+
span,
540+
};
541+
542+
let ct = self.with_new_scopes(span, |this| {
543+
self.arena.alloc(hir::AnonConst {
544+
def_id,
545+
hir_id,
546+
body: this.lower_body(|_this| (&[], path_expr)),
547+
span,
548+
})
549+
});
550+
let hir_id = self.next_id();
551+
self.arena.alloc(hir::ConstArg { kind: hir::ConstArgKind::Anon(ct), hir_id })
552+
}
451553
}

Diff for: compiler/rustc_codegen_ssa/src/target_features.rs

+44-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_middle::query::Providers;
1010
use rustc_middle::ty::TyCtxt;
1111
use rustc_session::parse::feature_err;
1212
use rustc_span::{Span, Symbol, sym};
13-
use rustc_target::target_features;
13+
use rustc_target::target_features::{self, Stability};
1414

1515
use crate::errors;
1616

@@ -87,12 +87,17 @@ pub(crate) fn from_target_feature_attr(
8787
// But ensure the ABI does not forbid enabling this.
8888
// Here we do assume that LLVM doesn't add even more implied features
8989
// we don't know about, at least no features that would have ABI effects!
90-
if abi_feature_constraints.incompatible.contains(&name.as_str()) {
91-
tcx.dcx().emit_err(errors::ForbiddenTargetFeatureAttr {
92-
span: item.span(),
93-
feature: name.as_str(),
94-
reason: "this feature is incompatible with the target ABI",
95-
});
90+
// We skip this logic in rustdoc, where we want to allow all target features of
91+
// all targets, so we can't check their ABI compatibility and anyway we are not
92+
// generating code so "it's fine".
93+
if !tcx.sess.opts.actually_rustdoc {
94+
if abi_feature_constraints.incompatible.contains(&name.as_str()) {
95+
tcx.dcx().emit_err(errors::ForbiddenTargetFeatureAttr {
96+
span: item.span(),
97+
feature: name.as_str(),
98+
reason: "this feature is incompatible with the target ABI",
99+
});
100+
}
96101
}
97102
target_features.push(TargetFeature { name, implied: name != feature_sym })
98103
}
@@ -142,11 +147,38 @@ pub(crate) fn provide(providers: &mut Providers) {
142147
rust_target_features: |tcx, cnum| {
143148
assert_eq!(cnum, LOCAL_CRATE);
144149
if tcx.sess.opts.actually_rustdoc {
145-
// rustdoc needs to be able to document functions that use all the features, so
146-
// whitelist them all
147-
rustc_target::target_features::all_rust_features()
148-
.map(|(a, b)| (a.to_string(), b))
149-
.collect()
150+
// HACK: rustdoc would like to pretend that we have all the target features, so we
151+
// have to merge all the lists into one. To ensure an unstable target never prevents
152+
// a stable one from working, we merge the stability info of all instances of the
153+
// same target feature name, with the "most stable" taking precedence. And then we
154+
// hope that this doesn't cause issues anywhere else in the compiler...
155+
let mut result: UnordMap<String, Stability> = Default::default();
156+
for (name, stability) in rustc_target::target_features::all_rust_features() {
157+
use std::collections::hash_map::Entry;
158+
match result.entry(name.to_owned()) {
159+
Entry::Vacant(vacant_entry) => {
160+
vacant_entry.insert(stability);
161+
}
162+
Entry::Occupied(mut occupied_entry) => {
163+
// Merge the two stabilities, "more stable" taking precedence.
164+
match (occupied_entry.get(), stability) {
165+
(Stability::Stable, _)
166+
| (
167+
Stability::Unstable { .. },
168+
Stability::Unstable { .. } | Stability::Forbidden { .. },
169+
)
170+
| (Stability::Forbidden { .. }, Stability::Forbidden { .. }) => {
171+
// The stability in the entry is at least as good as the new one, just keep it.
172+
}
173+
_ => {
174+
// Overwrite stabilite.
175+
occupied_entry.insert(stability);
176+
}
177+
}
178+
}
179+
}
180+
}
181+
result
150182
} else {
151183
tcx.sess
152184
.target

Diff for: compiler/rustc_hir/src/hir.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ pub struct PatField<'hir> {
16001600
pub span: Span,
16011601
}
16021602

1603-
#[derive(Copy, Clone, PartialEq, Debug, HashStable_Generic)]
1603+
#[derive(Copy, Clone, PartialEq, Debug, HashStable_Generic, Hash, Eq, Encodable, Decodable)]
16041604
pub enum RangeEnd {
16051605
Included,
16061606
Excluded,
@@ -1668,7 +1668,7 @@ pub enum PatExprKind<'hir> {
16681668
#[derive(Debug, Clone, Copy, HashStable_Generic)]
16691669
pub enum TyPatKind<'hir> {
16701670
/// A range pattern (e.g., `1..=2` or `1..2`).
1671-
Range(Option<&'hir ConstArg<'hir>>, Option<&'hir ConstArg<'hir>>, RangeEnd),
1671+
Range(&'hir ConstArg<'hir>, &'hir ConstArg<'hir>),
16721672

16731673
/// A placeholder for a pattern that wasn't well formed in some way.
16741674
Err(ErrorGuaranteed),

0 commit comments

Comments
 (0)