Skip to content

Commit b12ff66

Browse files
committed
Auto merge of #113488 - RalfJung:miri, r=RalfJung
update Miri
2 parents ba37a69 + 9ed4669 commit b12ff66

33 files changed

+253
-100
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -5406,9 +5406,9 @@ checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81"
54065406

54075407
[[package]]
54085408
name = "ui_test"
5409-
version = "0.11.6"
5409+
version = "0.11.7"
54105410
source = "registry+https://github.com/rust-lang/crates.io-index"
5411-
checksum = "24a2e70adc9d18b9b4dd80ea57aeec447103c6fbb354a07c080adad451c645e1"
5411+
checksum = "c21899b59f53717dfad29e4f46e5b21a200a1b6888ab86532a07cfc8b48dd78c"
54125412
dependencies = [
54135413
"bstr",
54145414
"cargo-platform",

src/tools/miri/.github/workflows/ci.yml

+27-20
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
env:
1616
CARGO_UNSTABLE_SPARSE_REGISTRY: 'true'
1717

18+
defaults:
19+
run:
20+
shell: bash
21+
1822
jobs:
1923
build:
2024
runs-on: ${{ matrix.os }}
@@ -59,12 +63,9 @@ jobs:
5963

6064
- name: Install rustup-toolchain-install-master
6165
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
62-
shell: bash
63-
run: |
64-
cargo install -f rustup-toolchain-install-master
66+
run: cargo install -f rustup-toolchain-install-master
6567

6668
- name: Install "master" toolchain
67-
shell: bash
6869
run: |
6970
if [[ ${{ github.event_name }} == 'schedule' ]]; then
7071
echo "Building against latest rustc git version"
@@ -79,7 +80,7 @@ jobs:
7980
cargo -V
8081
8182
- name: Test
82-
run: bash ./ci.sh
83+
run: ./ci.sh
8384

8485
style:
8586
name: style checks
@@ -111,14 +112,10 @@ jobs:
111112

112113
- name: Install rustup-toolchain-install-master
113114
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
114-
shell: bash
115-
run: |
116-
cargo install -f rustup-toolchain-install-master
115+
run: cargo install -f rustup-toolchain-install-master
117116

118117
- name: Install "master" toolchain
119-
shell: bash
120-
run: |
121-
./miri toolchain
118+
run: ./miri toolchain
122119

123120
- name: Show Rust version
124121
run: |
@@ -138,7 +135,6 @@ jobs:
138135
# workflow is successful listening to webhooks only.
139136
#
140137
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
141-
# (`fmt` is deliberately not listed, we want bors to ignore it.)
142138
end-success:
143139
name: bors build finished
144140
runs-on: ubuntu-latest
@@ -166,12 +162,12 @@ jobs:
166162
- name: Install zulip-send
167163
run: pip3 install zulip
168164
- name: Send Zulip notification
169-
shell: bash
170165
env:
171166
ZULIP_BOT_EMAIL: ${{ secrets.ZULIP_BOT_EMAIL }}
172167
ZULIP_API_TOKEN: ${{ secrets.ZULIP_API_TOKEN }}
173168
run: |
174-
~/.local/bin/zulip-send --stream miri --subject "Cron Job Failure (miri, $(date -u +%Y-%m))" \
169+
~/.local/bin/zulip-send --user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com \
170+
--stream miri --subject "Cron Job Failure (miri, $(date -u +%Y-%m))" \
175171
--message 'Dear @*T-miri*,
176172
177173
It would appear that the [Miri cron job build]('"https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"') failed.
@@ -183,9 +179,12 @@ jobs:
183179
184180
Thanks in advance!
185181
Sincerely,
186-
The Miri Cronjobs Bot' \
187-
--user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com
182+
The Miri Cronjobs Bot'
183+
188184
# Attempt to auto-sync with rustc
185+
- uses: actions/checkout@v3
186+
with:
187+
fetch-depth: 256 # get a bit more of the history
189188
- name: install josh-proxy
190189
run: cargo +stable install josh-proxy --git https://github.com/josh-project/josh --tag r22.12.06
191190
- name: start josh-proxy
@@ -196,16 +195,24 @@ jobs:
196195
git config --global user.email '[email protected]'
197196
- name: get changes from rustc
198197
run: ./miri rustc-pull
198+
- name: Install rustup-toolchain-install-master
199+
run: cargo install -f rustup-toolchain-install-master
199200
- name: format changes (if any)
200201
run: |
201202
./miri toolchain
202203
./miri fmt --check || (./miri fmt && git commit -am "fmt")
203204
- name: Push changes to a branch
204205
run: |
205-
git switch -c "rustup$(date -u +%Y-%m)"
206-
git push
206+
BRANCH="rustup$(date -u +%Y-%m-%d)"
207+
git switch -c $BRANCH
208+
git push -u origin $BRANCH
207209
- name: Create Pull Request
208-
run: gh pr create -B master --title 'Automatic sync from rustc' --body ''
210+
run: |
211+
PR=$(gh pr create -B master --title 'Automatic sync from rustc' --body '')
212+
~/.local/bin/zulip-send --user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com \
213+
--stream miri --subject "Cron Job Failure (miri, $(date -u +%Y-%m))" \
214+
--message "A PR doing a rustc-pull [has been automatically created]($PR) for your convenience."
209215
env:
210216
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
211-
217+
ZULIP_BOT_EMAIL: ${{ secrets.ZULIP_BOT_EMAIL }}
218+
ZULIP_API_TOKEN: ${{ secrets.ZULIP_API_TOKEN }}

src/tools/miri/Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -842,9 +842,9 @@ dependencies = [
842842

843843
[[package]]
844844
name = "ui_test"
845-
version = "0.11.6"
845+
version = "0.11.7"
846846
source = "registry+https://github.com/rust-lang/crates.io-index"
847-
checksum = "24a2e70adc9d18b9b4dd80ea57aeec447103c6fbb354a07c080adad451c645e1"
847+
checksum = "c21899b59f53717dfad29e4f46e5b21a200a1b6888ab86532a07cfc8b48dd78c"
848848
dependencies = [
849849
"bstr",
850850
"cargo-platform",

src/tools/miri/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ libloading = "0.7"
3636

3737
[dev-dependencies]
3838
colored = "2"
39-
ui_test = "0.11.6"
39+
ui_test = "0.11.7"
4040
rustc_version = "0.4"
4141
# Features chosen to match those required by env_logger, to avoid rebuilds
4242
regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] }

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ fn main() {
8080
match first.as_str() {
8181
"miri" => phase_cargo_miri(args),
8282
"runner" => phase_runner(args, RunnerPhase::Cargo),
83-
arg if arg == env::var("RUSTC").unwrap() => {
83+
arg if arg == env::var("RUSTC").unwrap_or_else(|_| {
84+
show_error!(
85+
"`cargo-miri` called without RUSTC set; please only invoke this binary through `cargo miri`"
86+
)
87+
}) => {
8488
// If the first arg is equal to the RUSTC env variable (which should be set at this
8589
// point), then we need to behave as rustc. This is the somewhat counter-intuitive
8690
// behavior of having both RUSTC and RUSTC_WRAPPER set

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub enum MiriCommand {
8282
pub fn escape_for_toml(s: &str) -> String {
8383
// We want to surround this string in quotes `"`. So we first escape all quotes,
8484
// and also all backslashes (that are used to escape quotes).
85-
let s = s.replace('\\', r#"\\"#).replace('"', r#"\""#);
85+
let s = s.replace('\\', r"\\").replace('"', r#"\""#);
8686
format!("\"{s}\"")
8787
}
8888

@@ -130,7 +130,7 @@ pub fn exec(mut cmd: Command) -> ! {
130130
{
131131
use std::os::unix::process::CommandExt;
132132
let error = cmd.exec();
133-
Err(error).expect("failed to run command")
133+
panic!("failed to run command: {error}")
134134
}
135135
}
136136

src/tools/miri/miri

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ rustc-pull)
124124
git commit rust-version -m "Preparing for merge from rustc" || (echo "FAILED to commit rust-version file, something went wrong"; exit 1)
125125
# Fetch given rustc commit and note down which one that was
126126
git fetch http://localhost:8000/rust-lang/rust.git@$FETCH_COMMIT$JOSH_FILTER.git || (echo "FAILED to fetch new commits, something went wrong"; exit 1)
127-
git merge FETCH_HEAD --no-ff -m "Merge from rustc" || (echo "FAILED to merge new commits, something went wrong"; exit 1)
127+
git merge FETCH_HEAD --no-ff -m "Merge from rustc" || (echo "FAILED to merge new commits ($(git rev-parse FETCH_HEAD)), something went wrong"; exit 1)
128128
exit 0
129129
;;
130130
rustc-push)
@@ -325,6 +325,7 @@ run|run-dep)
325325
MIRIFLAGS="$MIRIFLAGS --target $MIRI_TEST_TARGET"
326326
fi
327327

328+
CARGO="$CARGO --quiet"
328329
# First build and get a sysroot.
329330
$CARGO build $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml
330331
find_sysroot

src/tools/miri/rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
75726cae37317c7262b69d3e9fd11a3496a88d04
1+
d4096e0412ac5de785d739a0aa2b1c1c7b9d3b7d

src/tools/miri/src/bin/miri.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
6767
if tcx.sess.compile_status().is_err() {
6868
tcx.sess.fatal("miri cannot be run on programs that fail compilation");
6969
}
70-
;
70+
7171
init_late_loggers(handler, tcx);
7272
if !tcx.sess.crate_types().contains(&CrateType::Executable) {
7373
tcx.sess.fatal("miri only makes sense on bin crates");

src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs

+19-10
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ impl AllocHistory {
221221
impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
222222
pub fn start_grant(&mut self, perm: Permission) {
223223
let Operation::Retag(op) = &mut self.operation else {
224-
unreachable!("start_grant must only be called during a retag, this is: {:?}", self.operation)
224+
unreachable!(
225+
"start_grant must only be called during a retag, this is: {:?}",
226+
self.operation
227+
)
225228
};
226229
op.permission = Some(perm);
227230

@@ -286,7 +289,8 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
286289
tag: BorTag,
287290
protector_tag: Option<BorTag>,
288291
) -> Option<TagHistory> {
289-
let Some(created) = self.history
292+
let Some(created) = self
293+
.history
290294
.creations
291295
.iter()
292296
.rev()
@@ -315,22 +319,27 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
315319
None
316320
}
317321
})
318-
}).or_else(|| {
322+
})
323+
.or_else(|| {
319324
// If we didn't find a retag that created this tag, it might be the base tag of
320325
// this allocation.
321326
if self.history.base.0.tag() == tag {
322327
Some((
323-
format!("{tag:?} was created here, as the base tag for {:?}", self.history.id),
324-
self.history.base.1.data()
328+
format!(
329+
"{tag:?} was created here, as the base tag for {:?}",
330+
self.history.id
331+
),
332+
self.history.base.1.data(),
325333
))
326334
} else {
327335
None
328336
}
329-
}) else {
330-
// But if we don't have a creation event, this is related to a wildcard, and there
331-
// is really nothing we can do to help.
332-
return None;
333-
};
337+
})
338+
else {
339+
// But if we don't have a creation event, this is related to a wildcard, and there
340+
// is really nothing we can do to help.
341+
return None;
342+
};
334343

335344
let invalidated = self.history.invalidations.iter().rev().find_map(|event| {
336345
if event.tag == tag { Some(event.generate_diagnostic()) } else { None }

src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,15 @@ impl<'tcx> Stack {
430430
.find_granting(AccessKind::Write, derived_from, exposed_tags)
431431
.map_err(|()| dcx.grant_error(self))?;
432432

433-
let (Some(granting_idx), ProvenanceExtra::Concrete(_)) = (granting_idx, derived_from) else {
433+
let (Some(granting_idx), ProvenanceExtra::Concrete(_)) = (granting_idx, derived_from)
434+
else {
434435
// The parent is a wildcard pointer or matched the unknown bottom.
435436
// This is approximate. Nobody knows what happened, so forget everything.
436437
// The new thing is SRW anyway, so we cannot push it "on top of the unknown part"
437438
// (for all we know, it might join an SRW group inside the unknown).
438-
trace!("reborrow: forgetting stack entirely due to SharedReadWrite reborrow from wildcard or unknown");
439+
trace!(
440+
"reborrow: forgetting stack entirely due to SharedReadWrite reborrow from wildcard or unknown"
441+
);
439442
self.set_unknown_bottom(global.next_ptr_tag);
440443
return Ok(());
441444
};
@@ -1008,7 +1011,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
10081011

10091012
// We have to turn the place into a pointer to use the existing code.
10101013
// (The pointer type does not matter, so we use a raw pointer.)
1011-
let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx,return_place.layout.ty))?;
1014+
let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx, return_place.layout.ty))?;
10121015
let val = ImmTy::from_immediate(return_place.to_ref(this), ptr_layout);
10131016
// Reborrow it. With protection! That is part of the point.
10141017
let new_perm = NewPermission::Uniform {

src/tools/miri/src/borrow_tracker/stacked_borrows/stack.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,19 @@ impl<'tcx> Stack {
196196
let ProvenanceExtra::Concrete(tag) = tag else {
197197
// Handle the wildcard case.
198198
// Go search the stack for an exposed tag.
199-
if let Some(idx) =
200-
self.borrows
201-
.iter()
202-
.enumerate() // we also need to know *where* in the stack
203-
.rev() // search top-to-bottom
204-
.find_map(|(idx, item)| {
205-
// If the item fits and *might* be this wildcard, use it.
206-
if item.perm().grants(access) && exposed_tags.contains(&item.tag()) {
207-
Some(idx)
208-
} else {
209-
None
210-
}
211-
})
199+
if let Some(idx) = self
200+
.borrows
201+
.iter()
202+
.enumerate() // we also need to know *where* in the stack
203+
.rev() // search top-to-bottom
204+
.find_map(|(idx, item)| {
205+
// If the item fits and *might* be this wildcard, use it.
206+
if item.perm().grants(access) && exposed_tags.contains(&item.tag()) {
207+
Some(idx)
208+
} else {
209+
None
210+
}
211+
})
212212
{
213213
return Ok(Some(idx));
214214
}

src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,13 @@ impl DisplayRepr {
570570
extraction_aux(tree, tree.root, show_unnamed, &mut v);
571571
let Some(root) = v.pop() else {
572572
if show_unnamed {
573-
unreachable!("This allocation contains no tags, not even a root. This should not happen.");
573+
unreachable!(
574+
"This allocation contains no tags, not even a root. This should not happen."
575+
);
574576
}
575-
eprintln!("This allocation does not contain named tags. Use `miri_print_borrow_state(_, true)` to also print unnamed tags.");
577+
eprintln!(
578+
"This allocation does not contain named tags. Use `miri_print_borrow_state(_, true)` to also print unnamed tags."
579+
);
576580
return None;
577581
};
578582
assert!(v.is_empty());

src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
256256
ptr_size.bytes()
257257
);
258258

259-
let Some(new_perm) = new_perm else { return Ok(Some((alloc_id, orig_tag))); };
259+
let Some(new_perm) = new_perm else {
260+
return Ok(Some((alloc_id, orig_tag)));
261+
};
260262

261263
if let Some(protect) = new_perm.protector {
262264
// We register the protection in two different places.
@@ -509,7 +511,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
509511

510512
// We have to turn the place into a pointer to use the existing code.
511513
// (The pointer type does not matter, so we use a raw pointer.)
512-
let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx,return_place.layout.ty))?;
514+
let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx, return_place.layout.ty))?;
513515
let val = ImmTy::from_immediate(return_place.to_ref(this), ptr_layout);
514516
// Reborrow it. With protection! That is part of the point.
515517
// FIXME: do we truly want a 2phase borrow here?

0 commit comments

Comments
 (0)