Skip to content

Commit 618c300

Browse files
committed
Auto merge of #123897 - matthiaskrgr:rollup-v0vvcw2, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #123530 (Enable building tier2 target riscv32im-unknown-none-elf) - #123642 (do not allow using local llvm while using rustc from ci) - #123716 (Update documentation of Path::to_path_buf and Path::ancestors) - #123876 (Update backtrace submodule) - #123888 (Replace a `DefiningOpaqueTypes::No` with `Yes` by asserting that one side of the comparison is a type variable.) - #123890 (removed (mostly) unused code) - #123891 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3a0db6c + f8ef61d commit 618c300

File tree

14 files changed

+129
-227
lines changed

14 files changed

+129
-227
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
505505
}
506506

507507
pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
508-
let _indenter = indenter();
509508
match tcx.def_kind(def_id) {
510509
DefKind::Static { .. } => {
511510
tcx.ensure().typeck(def_id);

compiler/rustc_hir_analysis/src/check/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ use rustc_trait_selection::traits::ObligationCtxt;
103103

104104
use crate::errors;
105105
use crate::require_c_abi_if_c_variadic;
106-
use crate::util::common::indenter;
107106

108107
use self::compare_impl_item::collect_return_position_impl_trait_in_trait_tys;
109108
use self::region::region_scope_tree;

compiler/rustc_hir_analysis/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ use rustc_middle::middle;
103103
use rustc_middle::mir::interpret::GlobalId;
104104
use rustc_middle::query::Providers;
105105
use rustc_middle::ty::{self, Ty, TyCtxt};
106-
use rustc_middle::util;
107106
use rustc_session::parse::feature_err;
108107
use rustc_span::{symbol::sym, Span};
109108
use rustc_target::spec::abi::Abi;

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
561561

562562
// Unify `interior` with `witness` and collect all the resulting obligations.
563563
let span = self.tcx.hir().body(body_id).value.span;
564+
let ty::Infer(ty::InferTy::TyVar(_)) = interior.kind() else {
565+
span_bug!(span, "coroutine interior witness not infer: {:?}", interior.kind())
566+
};
564567
let ok = self
565568
.at(&self.misc(span), self.param_env)
566-
.eq(DefineOpaqueTypes::No, interior, witness)
569+
// Will never define opaque types, as all we do is instantiate a type variable.
570+
.eq(DefineOpaqueTypes::Yes, interior, witness)
567571
.expect("Failed to unify coroutine interior type");
568572
let mut obligations = ok.obligations;
569573

compiler/rustc_middle/src/util/common.rs

-45
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
use rustc_data_structures::sync::Lock;
2-
3-
use std::fmt::Debug;
4-
use std::time::{Duration, Instant};
5-
61
#[cfg(test)]
72
mod tests;
83

@@ -26,46 +21,6 @@ pub fn to_readable_str(mut val: usize) -> String {
2621
groups.join("_")
2722
}
2823

29-
pub fn record_time<T, F>(accu: &Lock<Duration>, f: F) -> T
30-
where
31-
F: FnOnce() -> T,
32-
{
33-
let start = Instant::now();
34-
let rv = f();
35-
let duration = start.elapsed();
36-
let mut accu = accu.lock();
37-
*accu += duration;
38-
rv
39-
}
40-
41-
pub fn indent<R, F>(op: F) -> R
42-
where
43-
R: Debug,
44-
F: FnOnce() -> R,
45-
{
46-
// Use in conjunction with the log post-processor like `src/etc/indenter`
47-
// to make debug output more readable.
48-
debug!(">>");
49-
let r = op();
50-
debug!("<< (Result = {:?})", r);
51-
r
52-
}
53-
54-
pub struct Indenter {
55-
_cannot_construct_outside_of_this_module: (),
56-
}
57-
58-
impl Drop for Indenter {
59-
fn drop(&mut self) {
60-
debug!("<<");
61-
}
62-
}
63-
64-
pub fn indenter() -> Indenter {
65-
debug!(">>");
66-
Indenter { _cannot_construct_outside_of_this_module: () }
67-
}
68-
6924
// const wrapper for `if let Some((_, tail)) = name.rsplit_once(':') { tail } else { name }`
7025
pub const fn c_name(name: &'static str) -> &'static str {
7126
// FIXME Simplify the implementation once more `str` methods get const-stable.

compiler/rustc_type_ir/src/ty_kind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ pub enum TyKind<I: Interner> {
181181
/// Looking at the following example, the witness for this coroutine
182182
/// may end up as something like `for<'a> [Vec<i32>, &'a Vec<i32>]`:
183183
///
184-
/// ```ignore UNSOLVED (ask @compiler-errors, should this error? can we just swap the yields?)
184+
/// ```
185185
/// #![feature(coroutines)]
186-
/// |a| {
186+
/// static |a| {
187187
/// let x = &vec![3];
188188
/// yield a;
189189
/// yield x[0];

config.example.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#
5151
# Note that many of the LLVM options are not currently supported for
5252
# downloading. Currently only the "assertions" option can be toggled.
53-
#download-ci-llvm = if rust.channel == "dev" { "if-unchanged" } else { false }
53+
#download-ci-llvm = if rust.channel == "dev" || rust.download-rustc != false { "if-unchanged" } else { false }
5454

5555
# Indicates whether the LLVM build is a Release or Debug build
5656
#optimize = true

library/std/src/path.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -2143,10 +2143,10 @@ impl Path {
21432143
/// # Examples
21442144
///
21452145
/// ```
2146-
/// use std::path::Path;
2146+
/// use std::path::{Path, PathBuf};
21472147
///
21482148
/// let path_buf = Path::new("foo.txt").to_path_buf();
2149-
/// assert_eq!(path_buf, std::path::PathBuf::from("foo.txt"));
2149+
/// assert_eq!(path_buf, PathBuf::from("foo.txt"));
21502150
/// ```
21512151
#[rustc_conversion_suggestion]
21522152
#[must_use = "this returns the result of the operation, \
@@ -2278,10 +2278,9 @@ impl Path {
22782278
/// Produces an iterator over `Path` and its ancestors.
22792279
///
22802280
/// The iterator will yield the `Path` that is returned if the [`parent`] method is used zero
2281-
/// or more times. That means, the iterator will yield `&self`, `&self.parent().unwrap()`,
2282-
/// `&self.parent().unwrap().parent().unwrap()` and so on. If the [`parent`] method returns
2283-
/// [`None`], the iterator will do likewise. The iterator will always yield at least one value,
2284-
/// namely `&self`.
2281+
/// or more times. If the [`parent`] method returns [`None`], the iterator will do likewise.
2282+
/// The iterator will always yield at least one value, namely `Some(&self)`. Next it will yield
2283+
/// `&self.parent()`, `&self.parent().and_then(Path::parent)` and so on.
22852284
///
22862285
/// # Examples
22872286
///

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

+13-2
Original file line numberDiff line numberDiff line change
@@ -2483,9 +2483,20 @@ impl Config {
24832483
llvm::is_ci_llvm_available(self, asserts)
24842484
}
24852485
};
2486+
24862487
match download_ci_llvm {
2487-
None => self.channel == "dev" && if_unchanged(),
2488-
Some(StringOrBool::Bool(b)) => b,
2488+
None => {
2489+
(self.channel == "dev" || self.download_rustc_commit.is_some()) && if_unchanged()
2490+
}
2491+
Some(StringOrBool::Bool(b)) => {
2492+
if !b && self.download_rustc_commit.is_some() {
2493+
panic!(
2494+
"`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
2495+
);
2496+
}
2497+
2498+
b
2499+
}
24892500
// FIXME: "if-available" is deprecated. Remove this block later (around mid 2024)
24902501
// to not break builds between the recent-to-old checkouts.
24912502
Some(StringOrBool::String(s)) if s == "if-available" => {

src/ci/docker/host-x86_64/dist-various-1/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ ENV TARGETS=$TARGETS,thumbv8m.base-none-eabi
9999
ENV TARGETS=$TARGETS,thumbv8m.main-none-eabi
100100
ENV TARGETS=$TARGETS,thumbv8m.main-none-eabihf
101101
ENV TARGETS=$TARGETS,riscv32i-unknown-none-elf
102+
ENV TARGETS=$TARGETS,riscv32im-unknown-none-elf
102103
ENV TARGETS=$TARGETS,riscv32imc-unknown-none-elf
103104
ENV TARGETS=$TARGETS,riscv32imac-unknown-none-elf
104105
ENV TARGETS=$TARGETS,riscv32imafc-unknown-none-elf
@@ -130,6 +131,8 @@ ENV CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft
130131
CFLAGS_aarch64_unknown_none=-mstrict-align -march=armv8-a+fp+simd \
131132
CC_riscv32i_unknown_none_elf=riscv32-unknown-elf-gcc \
132133
CFLAGS_riscv32i_unknown_none_elf=-march=rv32i -mabi=ilp32 \
134+
CC_riscv32im_unknown_none_elf=riscv32-unknown-elf-gcc \
135+
CFLAGS_riscv32im_unknown_none_elf=-march=rv32im -mabi=ilp32 \
133136
CC_riscv32imc_unknown_none_elf=riscv32-unknown-elf-gcc \
134137
CFLAGS_riscv32imc_unknown_none_elf=-march=rv32imc -mabi=ilp32 \
135138
CC_riscv32imac_unknown_none_elf=riscv32-unknown-elf-gcc \

src/tools/miri/cargo-miri/src/phases.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -454,15 +454,10 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
454454
continue;
455455
}
456456
// If the REPLACE_LIBRS hack is enabled and we are building a `lib.rs` file, and a
457-
// `lib.miri.rs` file exists, then build that instead. We only consider relative paths
458-
// as cargo uses those for files in the workspace; dependencies from crates.io get
459-
// absolute paths.
457+
// `lib.miri.rs` file exists, then build that instead.
460458
if replace_librs {
461459
let path = Path::new(&arg);
462-
if path.is_relative()
463-
&& path.file_name().is_some_and(|f| f == "lib.rs")
464-
&& path.is_file()
465-
{
460+
if path.file_name().is_some_and(|f| f == "lib.rs") && path.is_file() {
466461
let miri_rs = Path::new(&arg).with_extension("miri.rs");
467462
if miri_rs.is_file() {
468463
if verbose > 0 {

src/tools/miri/src/shims/x86/mod.rs

+80
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,86 @@ fn unary_op_ps<'tcx>(
468468
Ok(())
469469
}
470470

471+
enum ShiftOp {
472+
/// Shift left, logically (shift in zeros) -- same as shift left, arithmetically
473+
Left,
474+
/// Shift right, logically (shift in zeros)
475+
RightLogic,
476+
/// Shift right, arithmetically (shift in sign)
477+
RightArith,
478+
}
479+
480+
/// Shifts each element of `left` by a scalar amount. The shift amount
481+
/// is determined by the lowest 64 bits of `right` (which is a 128-bit vector).
482+
///
483+
/// For logic shifts, when right is larger than BITS - 1, zero is produced.
484+
/// For arithmetic right-shifts, when right is larger than BITS - 1, the sign
485+
/// bit is copied to remaining bits.
486+
fn shift_simd_by_scalar<'tcx>(
487+
this: &mut crate::MiriInterpCx<'_, 'tcx>,
488+
left: &OpTy<'tcx, Provenance>,
489+
right: &OpTy<'tcx, Provenance>,
490+
which: ShiftOp,
491+
dest: &MPlaceTy<'tcx, Provenance>,
492+
) -> InterpResult<'tcx, ()> {
493+
let (left, left_len) = this.operand_to_simd(left)?;
494+
let (dest, dest_len) = this.mplace_to_simd(dest)?;
495+
496+
assert_eq!(dest_len, left_len);
497+
// `right` may have a different length, and we only care about its
498+
// lowest 64bit anyway.
499+
500+
// Get the 64-bit shift operand and convert it to the type expected
501+
// by checked_{shl,shr} (u32).
502+
// It is ok to saturate the value to u32::MAX because any value
503+
// above BITS - 1 will produce the same result.
504+
let shift = u32::try_from(extract_first_u64(this, right)?).unwrap_or(u32::MAX);
505+
506+
for i in 0..dest_len {
507+
let left = this.read_scalar(&this.project_index(&left, i)?)?;
508+
let dest = this.project_index(&dest, i)?;
509+
510+
let res = match which {
511+
ShiftOp::Left => {
512+
let left = left.to_uint(dest.layout.size)?;
513+
let res = left.checked_shl(shift).unwrap_or(0);
514+
// `truncate` is needed as left-shift can make the absolute value larger.
515+
Scalar::from_uint(dest.layout.size.truncate(res), dest.layout.size)
516+
}
517+
ShiftOp::RightLogic => {
518+
let left = left.to_uint(dest.layout.size)?;
519+
let res = left.checked_shr(shift).unwrap_or(0);
520+
// No `truncate` needed as right-shift can only make the absolute value smaller.
521+
Scalar::from_uint(res, dest.layout.size)
522+
}
523+
ShiftOp::RightArith => {
524+
let left = left.to_int(dest.layout.size)?;
525+
// On overflow, copy the sign bit to the remaining bits
526+
let res = left.checked_shr(shift).unwrap_or(left >> 127);
527+
// No `truncate` needed as right-shift can only make the absolute value smaller.
528+
Scalar::from_int(res, dest.layout.size)
529+
}
530+
};
531+
this.write_scalar(res, &dest)?;
532+
}
533+
534+
Ok(())
535+
}
536+
537+
/// Takes a 128-bit vector, transmutes it to `[u64; 2]` and extracts
538+
/// the first value.
539+
fn extract_first_u64<'tcx>(
540+
this: &crate::MiriInterpCx<'_, 'tcx>,
541+
op: &OpTy<'tcx, Provenance>,
542+
) -> InterpResult<'tcx, u64> {
543+
// Transmute vector to `[u64; 2]`
544+
let array_layout = this.layout_of(Ty::new_array(this.tcx.tcx, this.tcx.types.u64, 2))?;
545+
let op = op.transmute(array_layout, this)?;
546+
547+
// Get the first u64 from the array
548+
this.read_scalar(&this.project_index(&op, 0)?)?.to_u64()
549+
}
550+
471551
// Rounds the first element of `right` according to `rounding`
472552
// and copies the remaining elements from `left`.
473553
fn round_first<'tcx, F: rustc_apfloat::Float>(

0 commit comments

Comments
 (0)