Skip to content

Commit

Permalink
Auto merge of rust-lang#102097 - Dylan-DPC:rollup-gc75oh4, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - rust-lang#89891 (`alloc`: add unstable cfg features `no_rc` and `no_sync`)
 - rust-lang#101995 (Add another example for `uN::carrying_mul`)
 - rust-lang#102031 (Adding ignore fuchsia tests for Backtrace, ErrorKind cases)
 - rust-lang#102041 (Improve `-Zmeta-stats` some more)
 - rust-lang#102045 (fix ConstProp handling of written_only_inside_own_block_locals)
 - rust-lang#102058 (Clarify Path::extension() semantics in docs abstract)
 - rust-lang#102059 (Use rebind instead of dummy binder in `SameTypeModuloInfer` relation)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Sep 21, 2022
2 parents b79b7d8 + 39bb2a7 commit db4b4d3
Show file tree
Hide file tree
Showing 23 changed files with 391 additions and 242 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,7 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
where
T: relate::Relate<'tcx>,
{
Ok(ty::Binder::dummy(self.relate(a.skip_binder(), b.skip_binder())?))
Ok(a.rebind(self.relate(a.skip_binder(), b.skip_binder())?))
}

fn consts(
Expand Down
365 changes: 152 additions & 213 deletions compiler/rustc_metadata/src/rmeta/encoder.rs

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions compiler/rustc_mir_transform/src/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,32 +1066,32 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
let source_info = terminator.source_info;
self.source_info = Some(source_info);
self.super_terminator(terminator, location);
// Do NOT early return in this function, it does some crucial fixup of the state at the end!
match &mut terminator.kind {
TerminatorKind::Assert { expected, ref mut cond, .. } => {
if let Some(ref value) = self.eval_operand(&cond) {
trace!("assertion on {:?} should be {:?}", value, expected);
let expected = Scalar::from_bool(*expected);
let Ok(value_const) = self.ecx.read_scalar(&value) else {
// FIXME should be used use_ecx rather than a local match... but we have
// quite a few of these read_scalar/read_immediate that need fixing.
return
};
if expected != value_const {
// Poison all places this operand references so that further code
// doesn't use the invalid value
match cond {
Operand::Move(ref place) | Operand::Copy(ref place) => {
Self::remove_const(&mut self.ecx, place.local);
// FIXME should be used use_ecx rather than a local match... but we have
// quite a few of these read_scalar/read_immediate that need fixing.
if let Ok(value_const) = self.ecx.read_scalar(&value) {
if expected != value_const {
// Poison all places this operand references so that further code
// doesn't use the invalid value
match cond {
Operand::Move(ref place) | Operand::Copy(ref place) => {
Self::remove_const(&mut self.ecx, place.local);
}
Operand::Constant(_) => {}
}
} else {
if self.should_const_prop(value) {
*cond = self.operand_from_scalar(
value_const,
self.tcx.types.bool,
source_info.span,
);
}
Operand::Constant(_) => {}
}
} else {
if self.should_const_prop(value) {
*cond = self.operand_from_scalar(
value_const,
self.tcx.types.bool,
source_info.span,
);
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
any(not(feature = "miri-test-libstd"), test, doctest),
no_global_oom_handling,
not(no_global_oom_handling),
not(no_rc),
not(no_sync),
target_has_atomic = "ptr"
))]
#![no_std]
Expand Down Expand Up @@ -225,16 +227,17 @@ mod boxed {
}
pub mod borrow;
pub mod collections;
#[cfg(not(no_global_oom_handling))]
#[cfg(all(not(no_rc), not(no_sync), not(no_global_oom_handling)))]
pub mod ffi;
pub mod fmt;
#[cfg(not(no_rc))]
pub mod rc;
pub mod slice;
pub mod str;
pub mod string;
#[cfg(target_has_atomic = "ptr")]
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
pub mod sync;
#[cfg(all(not(no_global_oom_handling), target_has_atomic = "ptr"))]
#[cfg(all(not(no_global_oom_handling), not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
pub mod task;
#[cfg(test)]
mod tests;
Expand Down
30 changes: 30 additions & 0 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ macro_rules! widening_impl {
/// This returns the low-order (wrapping) bits and the high-order (overflow) bits
/// of the result as two separate values, in that order.
///
/// If you also need to add a carry to the wide result, then you want
/// [`Self::carrying_mul`] instead.
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -148,6 +151,8 @@ macro_rules! widening_impl {
/// additional amount of overflow. This allows for chaining together multiple
/// multiplications to create "big integers" which represent larger values.
///
/// If you don't need the `carry`, then you can use [`Self::widening_mul`] instead.
///
/// # Examples
///
/// Basic usage:
Expand All @@ -167,6 +172,31 @@ macro_rules! widening_impl {
)]
/// ```
///
/// This is the core operation needed for scalar multiplication when
/// implementing it for wider-than-native types.
///
/// ```
/// #![feature(bigint_helper_methods)]
/// fn scalar_mul_eq(little_endian_digits: &mut Vec<u16>, multiplicand: u16) {
/// let mut carry = 0;
/// for d in little_endian_digits.iter_mut() {
/// (*d, carry) = d.carrying_mul(multiplicand, carry);
/// }
/// if carry != 0 {
/// little_endian_digits.push(carry);
/// }
/// }
///
/// let mut v = vec![10, 20];
/// scalar_mul_eq(&mut v, 3);
/// assert_eq!(v, [30, 60]);
///
/// assert_eq!(0x87654321_u64 * 0xFEED, 0x86D3D159E38D);
/// let mut v = vec![0x4321, 0x8765];
/// scalar_mul_eq(&mut v, 0xFEED);
/// assert_eq!(v, [0xE38D, 0xD159, 0x86D3]);
/// ```
///
/// If `carry` is zero, this is similar to [`overflowing_mul`](Self::overflowing_mul),
/// except that it gives the value of the overflow instead of just whether one happened:
///
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2401,7 +2401,7 @@ impl Path {
self.file_name().map(split_file_at_dot).and_then(|(before, _after)| Some(before))
}

/// Extracts the extension of [`self.file_name`], if possible.
/// Extracts the extension (without the leading dot) of [`self.file_name`], if possible.
///
/// The extension is:
///
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &'static str, Option<&[&'static str]>)]
(Some(Mode::Std), "stdarch_intel_sde", None),
(Some(Mode::Std), "no_fp_fmt_parse", None),
(Some(Mode::Std), "no_global_oom_handling", None),
(Some(Mode::Std), "no_rc", None),
(Some(Mode::Std), "no_sync", None),
(Some(Mode::Std), "freebsd12", None),
(Some(Mode::Std), "backtrace_in_libstd", None),
/* Extra values not defined in the built-in targets yet, but used in std */
Expand Down
20 changes: 20 additions & 0 deletions src/test/mir-opt/issue-101973.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// compile-flags: -O -C debug-assertions=on
// This needs inlining followed by ConstProp to reproduce, so we cannot use "unit-test".

#[inline]
pub fn imm8(x: u32) -> u32 {
let mut out = 0u32;
out |= (x >> 0) & 0xff;
out
}

// EMIT_MIR issue_101973.inner.ConstProp.diff
#[inline(never)]
pub fn inner(fields: u32) -> i64 {
imm8(fields).rotate_right(((fields >> 8) & 0xf) << 1) as i32 as i64
}

fn main() {
let val = inner(0xe32cf20f);
assert_eq!(val as u64, 0xfffffffff0000000);
}
100 changes: 100 additions & 0 deletions src/test/mir-opt/issue_101973.inner.ConstProp.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
- // MIR for `inner` before ConstProp
+ // MIR for `inner` after ConstProp

fn inner(_1: u32) -> i64 {
debug fields => _1; // in scope 0 at $DIR/issue-101973.rs:+0:14: +0:20
let mut _0: i64; // return place in scope 0 at $DIR/issue-101973.rs:+0:30: +0:33
let mut _2: i32; // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:65
let mut _3: u32; // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:58
let mut _4: u32; // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:17
let mut _5: u32; // in scope 0 at $DIR/issue-101973.rs:+1:10: +1:16
let mut _6: u32; // in scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
let mut _7: u32; // in scope 0 at $DIR/issue-101973.rs:+1:31: +1:52
let mut _8: u32; // in scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
let mut _9: u32; // in scope 0 at $DIR/issue-101973.rs:+1:33: +1:39
let mut _10: (u32, bool); // in scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
let mut _11: (u32, bool); // in scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
scope 1 (inlined imm8) { // at $DIR/issue-101973.rs:14:5: 14:17
debug x => _5; // in scope 1 at $DIR/issue-101973.rs:5:13: 5:14
let mut _12: u32; // in scope 1 at $DIR/issue-101973.rs:7:12: 7:27
let mut _13: u32; // in scope 1 at $DIR/issue-101973.rs:7:12: 7:20
let mut _14: u32; // in scope 1 at $DIR/issue-101973.rs:7:13: 7:14
let mut _15: (u32, bool); // in scope 1 at $DIR/issue-101973.rs:7:12: 7:20
scope 2 {
debug out => _4; // in scope 2 at $DIR/issue-101973.rs:6:9: 6:16
}
}
scope 3 (inlined core::num::<impl u32>::rotate_right) { // at $DIR/issue-101973.rs:14:5: 14:58
debug self => _4; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
debug n => _6; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
let mut _16: u32; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
let mut _17: u32; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
}

bb0: {
StorageLive(_2); // scope 0 at $DIR/issue-101973.rs:+1:5: +1:65
StorageLive(_3); // scope 0 at $DIR/issue-101973.rs:+1:5: +1:58
StorageLive(_4); // scope 0 at $DIR/issue-101973.rs:+1:5: +1:17
StorageLive(_5); // scope 0 at $DIR/issue-101973.rs:+1:10: +1:16
_5 = _1; // scope 0 at $DIR/issue-101973.rs:+1:10: +1:16
_4 = const 0_u32; // scope 1 at $DIR/issue-101973.rs:6:19: 6:23
StorageLive(_12); // scope 2 at $DIR/issue-101973.rs:7:12: 7:27
StorageLive(_13); // scope 2 at $DIR/issue-101973.rs:7:12: 7:20
StorageLive(_14); // scope 2 at $DIR/issue-101973.rs:7:13: 7:14
_14 = _5; // scope 2 at $DIR/issue-101973.rs:7:13: 7:14
_15 = CheckedShr(_14, const 0_i32); // scope 2 at $DIR/issue-101973.rs:7:12: 7:20
assert(!move (_15.1: bool), "attempt to shift right by `{}`, which would overflow", const 0_i32) -> bb3; // scope 2 at $DIR/issue-101973.rs:7:12: 7:20
}

bb1: {
_8 = move (_10.0: u32); // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
StorageDead(_9); // scope 0 at $DIR/issue-101973.rs:+1:44: +1:45
_7 = BitAnd(move _8, const 15_u32); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:52
StorageDead(_8); // scope 0 at $DIR/issue-101973.rs:+1:51: +1:52
_11 = CheckedShl(_7, const 1_i32); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
assert(!move (_11.1: bool), "attempt to shift left by `{}`, which would overflow", const 1_i32) -> bb2; // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
}

bb2: {
_6 = move (_11.0: u32); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
StorageDead(_7); // scope 0 at $DIR/issue-101973.rs:+1:56: +1:57
StorageLive(_16); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
_16 = _4; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
StorageLive(_17); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
_17 = _6; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
_3 = rotate_right::<u32>(move _16, move _17) -> bb4; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
// mir::Constant
// + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
// + literal: Const { ty: extern "rust-intrinsic" fn(u32, u32) -> u32 {rotate_right::<u32>}, val: Value(<ZST>) }
}

bb3: {
_13 = move (_15.0: u32); // scope 2 at $DIR/issue-101973.rs:7:12: 7:20
StorageDead(_14); // scope 2 at $DIR/issue-101973.rs:7:19: 7:20
_12 = BitAnd(move _13, const 255_u32); // scope 2 at $DIR/issue-101973.rs:7:12: 7:27
StorageDead(_13); // scope 2 at $DIR/issue-101973.rs:7:26: 7:27
_4 = BitOr(_4, move _12); // scope 2 at $DIR/issue-101973.rs:7:5: 7:27
StorageDead(_12); // scope 2 at $DIR/issue-101973.rs:7:26: 7:27
StorageDead(_5); // scope 0 at $DIR/issue-101973.rs:+1:16: +1:17
StorageLive(_6); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57
StorageLive(_7); // scope 0 at $DIR/issue-101973.rs:+1:31: +1:52
StorageLive(_8); // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
StorageLive(_9); // scope 0 at $DIR/issue-101973.rs:+1:33: +1:39
_9 = _1; // scope 0 at $DIR/issue-101973.rs:+1:33: +1:39
_10 = CheckedShr(_9, const 8_i32); // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
assert(!move (_10.1: bool), "attempt to shift right by `{}`, which would overflow", const 8_i32) -> bb1; // scope 0 at $DIR/issue-101973.rs:+1:32: +1:45
}

bb4: {
StorageDead(_17); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
StorageDead(_16); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL
StorageDead(_6); // scope 0 at $DIR/issue-101973.rs:+1:57: +1:58
StorageDead(_4); // scope 0 at $DIR/issue-101973.rs:+1:57: +1:58
_2 = move _3 as i32 (Misc); // scope 0 at $DIR/issue-101973.rs:+1:5: +1:65
StorageDead(_3); // scope 0 at $DIR/issue-101973.rs:+1:64: +1:65
_0 = move _2 as i64 (Misc); // scope 0 at $DIR/issue-101973.rs:+1:5: +1:72
StorageDead(_2); // scope 0 at $DIR/issue-101973.rs:+1:71: +1:72
return; // scope 0 at $DIR/issue-101973.rs:+2:2: +2:2
}
}

4 changes: 4 additions & 0 deletions src/test/run-make-fulldeps/alloc-no-rc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include ../tools.mk

all:
$(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../../library/alloc/src/lib.rs --cfg no_rc
4 changes: 4 additions & 0 deletions src/test/run-make-fulldeps/alloc-no-sync/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include ../tools.mk

all:
$(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../../library/alloc/src/lib.rs --cfg no_sync
1 change: 1 addition & 0 deletions src/test/ui/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// ignore-openbsd no support for libbacktrace without filename
// ignore-sgx no processes
// ignore-msvc see #62897 and `backtrace-debuginfo.rs` test
// ignore-fuchsia Backtraces not symbolized
// compile-flags:-g
// compile-flags:-Cstrip=none

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:22:5
thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:23:5
stack backtrace:
0: std::panicking::begin_panic
1: issue_47429_short_backtraces::main
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/panics/issue-47429-short-backtraces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// ignore-wasm no panic or subprocess support
// ignore-emscripten no panic or subprocess support
// ignore-sgx no subprocess support
// ignore-fuchsia Backtraces not symbolized

// NOTE(eddyb) output differs between symbol mangling schemes
// revisions: legacy v0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:22:5
thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:23:5
stack backtrace:
0: std::panicking::begin_panic::<&str>
1: issue_47429_short_backtraces::main
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/panics/runtime-switch.legacy.run.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:25:5
thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:26:5
stack backtrace:
0: std::panicking::begin_panic
1: runtime_switch::main
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/panics/runtime-switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// ignore-wasm no panic or subprocess support
// ignore-emscripten no panic or subprocess support
// ignore-sgx no subprocess support
// ignore-fuchsia Backtrace not symbolized

// NOTE(eddyb) output differs between symbol mangling schemes
// revisions: legacy v0
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/panics/runtime-switch.v0.run.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:25:5
thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:26:5
stack backtrace:
0: std::panicking::begin_panic::<&str>
1: runtime_switch::main
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/process/process-spawn-nonexistent.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// run-pass
// ignore-emscripten no processes
// ignore-sgx no processes
// ignore-fuchsia ErrorKind not translated

use std::io::ErrorKind;
use std::process::Command;
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/runtime/backtrace-debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// ignore-pretty issue #37195
// ignore-emscripten spawning processes is not supported
// ignore-sgx no processes
// ignore-fuchsia Backtrace not symbolized, trace different line alignment

use std::env;

Expand Down
1 change: 1 addition & 0 deletions src/test/ui/std-backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// ignore-openbsd no support for libbacktrace without filename
// ignore-sgx no processes
// ignore-msvc see #62897 and `backtrace-debuginfo.rs` test
// ignore-fuchsia Backtraces not symbolized
// compile-flags:-g
// compile-flags:-Cstrip=none

Expand Down
27 changes: 27 additions & 0 deletions src/test/ui/suggestions/issue-101984.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use std::marker::PhantomData;

type Component = fn(&());

struct Wrapper {
router: Router<(Component, Box<Self>)>,
}

struct Match<C>(PhantomData<C>);

struct Router<T>(PhantomData<T>);

impl<T> Router<T> {
pub fn at(&self) -> Result<Match<&T>, ()> {
todo!()
}
}

impl Wrapper {
fn at(&self, path: &str) -> Result<(Component, Box<Self>), ()> {
let (cmp, router) = self.router.at()?;
//~^ ERROR mismatched types
todo!()
}
}

fn main() {}
Loading

0 comments on commit db4b4d3

Please sign in to comment.