Skip to content

Commit 8a8b464

Browse files
committed
Auto merge of rust-lang#136525 - matthiaskrgr:rollup-m8kqlek, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#134807 (fix(rustdoc): always use a channel when linking to doc.rust-lang.org) - rust-lang#134814 (Add `kl` and `widekl` target features, and the feature gate) - rust-lang#135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL) - rust-lang#136022 (Port ui/simd tests to use the intrinsic macro) - rust-lang#136309 (set rustc dylib on manually constructed rustc command) - rust-lang#136462 (mir_build: Simplify `lower_pattern_range_endpoint`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c705b7d + e7c09a8 commit 8a8b464

File tree

78 files changed

+630
-420
lines changed

Some content is hidden

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

78 files changed

+630
-420
lines changed

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ declare_features! (
529529
(unstable, inline_const_pat, "1.58.0", Some(76001)),
530530
/// Allows using `pointer` and `reference` in intra-doc links
531531
(unstable, intra_doc_pointers, "1.51.0", Some(80896)),
532+
// Allows using the `kl` and `widekl` target features and the associated intrinsics
533+
(unstable, keylocker_x86, "CURRENT_RUSTC_VERSION", Some(134813)),
532534
// Allows setting the threshold for the `large_assignments` lint.
533535
(unstable, large_assignments, "1.52.0", Some(83518)),
534536
/// Allow to have type alias types for inter-crate use.

compiler/rustc_mir_build/src/thir/pattern/mod.rs

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -155,42 +155,41 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
155155
fn lower_pattern_range_endpoint(
156156
&mut self,
157157
expr: Option<&'tcx hir::PatExpr<'tcx>>,
158-
) -> Result<
159-
(Option<PatRangeBoundary<'tcx>>, Option<Ascription<'tcx>>, Option<LocalDefId>),
160-
ErrorGuaranteed,
161-
> {
162-
match expr {
163-
None => Ok((None, None, None)),
164-
Some(expr) => {
165-
let (kind, ascr, inline_const) = match self.lower_lit(expr) {
166-
PatKind::ExpandedConstant { subpattern, def_id, is_inline: true } => {
167-
(subpattern.kind, None, def_id.as_local())
168-
}
169-
PatKind::ExpandedConstant { subpattern, is_inline: false, .. } => {
170-
(subpattern.kind, None, None)
171-
}
172-
PatKind::AscribeUserType { ascription, subpattern: box Pat { kind, .. } } => {
173-
(kind, Some(ascription), None)
174-
}
175-
kind => (kind, None, None),
176-
};
177-
let value = match kind {
178-
PatKind::Constant { value } => value,
179-
PatKind::ExpandedConstant { subpattern, .. }
180-
if let PatKind::Constant { value } = subpattern.kind =>
181-
{
182-
value
183-
}
184-
_ => {
185-
let msg = format!(
186-
"found bad range pattern endpoint `{expr:?}` outside of error recovery"
187-
);
188-
return Err(self.tcx.dcx().span_delayed_bug(expr.span, msg));
158+
// Out-parameters collecting extra data to be reapplied by the caller
159+
ascriptions: &mut Vec<Ascription<'tcx>>,
160+
inline_consts: &mut Vec<LocalDefId>,
161+
) -> Result<Option<PatRangeBoundary<'tcx>>, ErrorGuaranteed> {
162+
let Some(expr) = expr else { return Ok(None) };
163+
164+
// Lower the endpoint into a temporary `PatKind` that will then be
165+
// deconstructed to obtain the constant value and other data.
166+
let mut kind: PatKind<'tcx> = self.lower_lit(expr);
167+
168+
// Unpeel any ascription or inline-const wrapper nodes.
169+
loop {
170+
match kind {
171+
PatKind::AscribeUserType { ascription, subpattern } => {
172+
ascriptions.push(ascription);
173+
kind = subpattern.kind;
174+
}
175+
PatKind::ExpandedConstant { is_inline, def_id, subpattern } => {
176+
if is_inline {
177+
inline_consts.extend(def_id.as_local());
189178
}
190-
};
191-
Ok((Some(PatRangeBoundary::Finite(value)), ascr, inline_const))
179+
kind = subpattern.kind;
180+
}
181+
_ => break,
192182
}
193183
}
184+
185+
// The unpeeled kind should now be a constant, giving us the endpoint value.
186+
let PatKind::Constant { value } = kind else {
187+
let msg =
188+
format!("found bad range pattern endpoint `{expr:?}` outside of error recovery");
189+
return Err(self.tcx.dcx().span_delayed_bug(expr.span, msg));
190+
};
191+
192+
Ok(Some(PatRangeBoundary::Finite(value)))
194193
}
195194

196195
/// Overflowing literals are linted against in a late pass. This is mostly fine, except when we
@@ -253,11 +252,15 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
253252
self.tcx.dcx().span_bug(span, msg);
254253
}
255254

256-
let (lo, lo_ascr, lo_inline) = self.lower_pattern_range_endpoint(lo_expr)?;
257-
let (hi, hi_ascr, hi_inline) = self.lower_pattern_range_endpoint(hi_expr)?;
255+
// Collect extra data while lowering the endpoints, to be reapplied later.
256+
let mut ascriptions = vec![];
257+
let mut inline_consts = vec![];
258+
259+
let mut lower_endpoint =
260+
|expr| self.lower_pattern_range_endpoint(expr, &mut ascriptions, &mut inline_consts);
258261

259-
let lo = lo.unwrap_or(PatRangeBoundary::NegInfinity);
260-
let hi = hi.unwrap_or(PatRangeBoundary::PosInfinity);
262+
let lo = lower_endpoint(lo_expr)?.unwrap_or(PatRangeBoundary::NegInfinity);
263+
let hi = lower_endpoint(hi_expr)?.unwrap_or(PatRangeBoundary::PosInfinity);
261264

262265
let cmp = lo.compare_with(hi, ty, self.tcx, self.typing_env);
263266
let mut kind = PatKind::Range(Box::new(PatRange { lo, hi, end, ty }));
@@ -298,13 +301,13 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
298301
// If we are handling a range with associated constants (e.g.
299302
// `Foo::<'a>::A..=Foo::B`), we need to put the ascriptions for the associated
300303
// constants somewhere. Have them on the range pattern.
301-
for ascription in [lo_ascr, hi_ascr].into_iter().flatten() {
304+
for ascription in ascriptions {
302305
kind = PatKind::AscribeUserType {
303306
ascription,
304307
subpattern: Box::new(Pat { span, ty, kind }),
305308
};
306309
}
307-
for def in [lo_inline, hi_inline].into_iter().flatten() {
310+
for def in inline_consts {
308311
kind = PatKind::ExpandedConstant {
309312
def_id: def.to_def_id(),
310313
is_inline: true,

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,7 @@ symbols! {
11481148
iterator,
11491149
iterator_collect_fn,
11501150
kcfi,
1151+
keylocker_x86,
11511152
keyword,
11521153
kind,
11531154
kreg,

compiler/rustc_target/src/target_features.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
409409
("fma", Stable, &["avx"]),
410410
("fxsr", Stable, &[]),
411411
("gfni", Unstable(sym::avx512_target_feature), &["sse2"]),
412+
("kl", Unstable(sym::keylocker_x86), &["sse2"]),
412413
("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
413414
("lzcnt", Stable, &[]),
414415
("movbe", Stable, &[]),
@@ -435,6 +436,7 @@ const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
435436
("tbm", Unstable(sym::tbm_target_feature), &[]),
436437
("vaes", Unstable(sym::avx512_target_feature), &["avx2", "aes"]),
437438
("vpclmulqdq", Unstable(sym::avx512_target_feature), &["avx", "pclmulqdq"]),
439+
("widekl", Unstable(sym::keylocker_x86), &["kl"]),
438440
("x87", Unstable(sym::x87_target_feature), &[]),
439441
("xop", Unstable(sym::xop_target_feature), &[/*"fma4", */ "avx", "sse4a"]),
440442
("xsave", Stable, &[]),

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ fn copy_self_contained_objects(
339339
// to using gcc from a glibc-targeting toolchain for linking.
340340
// To do that we have to distribute musl startup objects as a part of Rust toolchain
341341
// and link with them manually in the self-contained mode.
342-
if target.contains("musl") && !target.contains("unikraft") {
342+
if target.needs_crt_begin_end() {
343343
let srcdir = builder.musl_libdir(target).unwrap_or_else(|| {
344344
panic!("Target {:?} does not have a \"musl-libdir\" key", target.triple)
345345
});

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,9 @@ impl Step for CrtBeginEnd {
12951295
}
12961296

12971297
fn make_run(run: RunConfig<'_>) {
1298-
run.builder.ensure(CrtBeginEnd { target: run.target });
1298+
if run.target.needs_crt_begin_end() {
1299+
run.builder.ensure(CrtBeginEnd { target: run.target });
1300+
}
12991301
}
13001302

13011303
/// Build crtbegin.o/crtend.o for musl target.

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,14 +659,18 @@ impl Builder<'_> {
659659
// Build proc macros both for the host and the target unless proc-macros are not
660660
// supported by the target.
661661
if target != compiler.host && cmd_kind != Kind::Check {
662-
let error = command(self.rustc(compiler))
662+
let mut rustc_cmd = command(self.rustc(compiler));
663+
self.add_rustc_lib_path(compiler, &mut rustc_cmd);
664+
665+
let error = rustc_cmd
663666
.arg("--target")
664667
.arg(target.rustc_target_arg())
665668
.arg("--print=file-names")
666669
.arg("--crate-type=proc-macro")
667670
.arg("-")
668671
.run_capture(self)
669672
.stderr();
673+
670674
let not_supported = error
671675
.lines()
672676
.any(|line| line.contains("unsupported crate type `proc-macro`"));

src/bootstrap/src/core/config/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,10 @@ impl TargetSelection {
575575
env::var("OSTYPE").is_ok_and(|v| v.to_lowercase().contains("cygwin"))
576576
}
577577

578+
pub fn needs_crt_begin_end(&self) -> bool {
579+
self.contains("musl") && !self.contains("unikraft")
580+
}
581+
578582
/// Path to the file defining the custom target, if any.
579583
pub fn filepath(&self) -> Option<&Path> {
580584
self.file.as_ref().map(Path::new)

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@ fn can_elide_trait_object_lifetime_bound<'tcx>(
19461946
preds: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
19471947
tcx: TyCtxt<'tcx>,
19481948
) -> bool {
1949-
// Below we quote extracts from https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes
1949+
// Below we quote extracts from https://doc.rust-lang.org/stable/reference/lifetime-elision.html#default-trait-object-lifetimes
19501950

19511951
// > If the trait object is used as a type argument of a generic type then the containing type is
19521952
// > first used to try to infer a bound.

src/librustdoc/clean/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,9 @@ pub(crate) fn attrs_have_doc_flag<'a>(
588588
/// so that the channel is consistent.
589589
///
590590
/// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable.
591-
pub(crate) const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
592-
pub(crate) static DOC_CHANNEL: Lazy<&'static str> =
593-
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').find(|c| !c.is_empty()).unwrap());
591+
pub(crate) const DOC_RUST_LANG_ORG_VERSION: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
592+
pub(crate) static RUSTDOC_VERSION: Lazy<&'static str> =
593+
Lazy::new(|| DOC_RUST_LANG_ORG_VERSION.rsplit('/').find(|c| !c.is_empty()).unwrap());
594594

595595
/// Render a sequence of macro arms in a format suitable for displaying to the user
596596
/// as part of an item declaration.

0 commit comments

Comments
 (0)