Skip to content

Commit

Permalink
Auto merge of rust-lang#2583 - RalfJung:rustup, r=oli-obk
Browse files Browse the repository at this point in the history
initial josh subtree sync

This demonstrates what a josh-based rustup would look like with my patched josh. To create it I did
```
git fetch http://localhost:8000/rust-lang/rust.git:start=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/tools/miri]:/src/tools/miri.git master
git merge FETCH_HEAD
./rustup-toolchain HEAD && ./miri fmt
git commit -am rustup
```
Unlike the [previous attempt](rust-lang/miri#2554), this does not add a new root commit to the repo.

Once we merge this, we committed to using josh for subtree syncing, and in particular a version of josh that includes josh-project/josh#961 (or something compatible).
  • Loading branch information
bors committed Oct 8, 2022
2 parents ce4620b + 5243ae9 commit 7b30b26
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 23 deletions.
9 changes: 4 additions & 5 deletions src/tools/miri/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,10 @@ Moreover, Miri recognizes some environment variables:
purpose.
* `MIRI_NO_STD` (recognized by `cargo miri` and the test suite) makes sure that the target's
sysroot is built without libstd. This allows testing and running no_std programs.
* `MIRI_BLESS` (recognized by the test suite) overwrite all `stderr` and `stdout` files
instead of checking whether the output matches.
* `MIRI_SKIP_UI_CHECKS` (recognized by the test suite) don't check whether the
`stderr` or `stdout` files match the actual output. Useful for the rustc test suite
which has subtle differences that we don't care about.
* `MIRI_BLESS` (recognized by the test suite and `cargo-miri-test/run-test.py`): overwrite all
`stderr` and `stdout` files instead of checking whether the output matches.
* `MIRI_SKIP_UI_CHECKS` (recognized by the test suite): don't check whether the
`stderr` or `stdout` files match the actual output.

The following environment variables are *internal* and must not be used by
anyone but Miri itself. They are used to communicate between different Miri
Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/cargo-miri/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg_attr(bootstrap, feature(let_else))]
#![allow(clippy::useless_format, clippy::derive_partial_eq_without_eq, rustc::internal)]

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
acb8934fd57b3c2740c4abac0a5728c2c9b1423b
e42c4d7218b2596276152c5eb1e69335621f3086
4 changes: 3 additions & 1 deletion src/tools/miri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#![feature(int_log)]
#![feature(variant_count)]
#![feature(yeet_expr)]
#![feature(is_some_with)]
#![feature(is_some_and)]
#![feature(nonzero_ops)]
#![feature(local_key_cell_methods)]
#![cfg_attr(bootstrap, feature(let_else))]
// Configure clippy and other lints
#![allow(
clippy::collapsible_else_if,
Expand All @@ -27,6 +28,7 @@
clippy::type_complexity,
clippy::single_element_loop,
clippy::needless_return,
clippy::bool_to_int_with_if,
// We are not implementing queries here so it's fine
rustc::potential_query_instability
)]
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/shims/unix/android/dlsym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
);
}

let &[ref _sig, ref _func] = check_arg_count(args)?;
let [_sig, _func] = check_arg_count(args)?;
this.write_null(dest)?;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/tools/miri/src/shims/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,23 +1073,23 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
mask |= this.eval_libc("STATX_ATIME")?.to_u32()?;
InterpResult::Ok(tup)
})
.unwrap_or(Ok((0, 0)))?;
.unwrap_or_else(|| Ok((0, 0)))?;

let (created_sec, created_nsec) = metadata
.created
.map(|tup| {
mask |= this.eval_libc("STATX_BTIME")?.to_u32()?;
InterpResult::Ok(tup)
})
.unwrap_or(Ok((0, 0)))?;
.unwrap_or_else(|| Ok((0, 0)))?;

let (modified_sec, modified_nsec) = metadata
.modified
.map(|tup| {
mask |= this.eval_libc("STATX_MTIME")?.to_u32()?;
InterpResult::Ok(tup)
})
.unwrap_or(Ok((0, 0)))?;
.unwrap_or_else(|| Ok((0, 0)))?;

// Now we write everything to `statxbuf`. We write a zero for the unavailable fields.
this.write_int_fields_named(
Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/src/stacked_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl SbTag {
}

// The default to be used when SB is disabled
#[allow(clippy::should_implement_trait)]
pub fn default() -> Self {
Self::new(1).unwrap()
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/stacked_borrows/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl<'tcx> Stack {
}

// Couldn't find it in the stack; but if there is an unknown bottom it might be there.
let found = self.unknown_bottom.is_some_and(|&unknown_limit| {
let found = self.unknown_bottom.is_some_and(|unknown_limit| {
tag.0 < unknown_limit.0 // unknown_limit is an upper bound for what can be in the unknown bottom.
});
if found { Ok(None) } else { Err(()) }
Expand Down
5 changes: 4 additions & 1 deletion src/tools/miri/test-cargo-miri/run-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ def normalize_stderr(str):
return str

def check_output(actual, path, name):
if 'MIRI_BLESS' in os.environ:
open(path, mode='w').write(actual)
return True
expected = open(path).read()
if expected == actual:
return True
print(f"{path} did not match reference!")
print(f"{name} output did not match reference in {path}!")
print(f"--- BEGIN diff {name} ---")
for text in difflib.unified_diff(expected.split("\n"), actual.split("\n")):
print(text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out
Expand Down
10 changes: 5 additions & 5 deletions src/tools/miri/test-cargo-miri/test.filter.stdout.ref
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out
Expand All @@ -10,8 +15,3 @@ test simple ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out; finished in $TIME

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | let rc = unsafe { c::WaitForSingleObject(self.handle.as_raw_handle(
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `std::sys::PLATFORM::thread::Thread::join` at RUSTLIB/std/src/sys/PLATFORM/thread.rs:LL:CC
= note: inside `std::thread::JoinInner::<()>::join` at RUSTLIB/std/src/thread/mod.rs:LL:CC
= note: inside `std::thread::JoinInner::<'_, ()>::join` at RUSTLIB/std/src/thread/mod.rs:LL:CC
= note: inside `std::thread::JoinHandle::<()>::join` at RUSTLIB/std/src/thread/mod.rs:LL:CC
note: inside `main` at $DIR/windows_join_detached.rs:LL:CC
--> $DIR/windows_join_detached.rs:LL:CC
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/fail/erroneous_const2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ error: any use of this value will cause an error
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
| -------------- ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: `#[deny(const_err)]` on by default

error[E0080]: evaluation of constant value failed
--> $DIR/erroneous_const2.rs:LL:CC
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/tests/fail/invalid_bool.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Validation makes this fail in the wrong place
// Make sure we find these even with many checks disabled.
//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
#![feature(bench_black_box)]

fn main() {
let b = unsafe { std::mem::transmute::<u8, bool>(2) };
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/pass/float.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(stmt_expr_attributes, bench_black_box)]
#![feature(stmt_expr_attributes)]
#![allow(arithmetic_overflow)]
use std::fmt::Debug;
use std::hint::black_box;
Expand Down
24 changes: 24 additions & 0 deletions src/tools/miri/tests/pass/issues/issue-miri-2433.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#![feature(type_alias_impl_trait)]

trait T {
type Item;
}

type Alias<'a> = impl T<Item = &'a ()>;

struct S;
impl<'a> T for &'a S {
type Item = &'a ();
}

fn filter_positive<'a>() -> Alias<'a> {
&S
}

fn with_positive(fun: impl Fn(Alias<'_>)) {
fun(filter_positive());
}

fn main() {
with_positive(|_| ());
}
1 change: 0 additions & 1 deletion src/tools/miri/tests/pass/u128.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(bench_black_box)]
use std::hint::black_box as b;

fn main() {
Expand Down

0 comments on commit 7b30b26

Please sign in to comment.