Skip to content

Commit

Permalink
Merge pull request #4169 from rust-lang/rustup-2025-02-01
Browse files Browse the repository at this point in the history
Automatic Rustup
  • Loading branch information
saethlin authored Feb 1, 2025
2 parents 7670709 + 2f40c01 commit 44e9863
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 74 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6c1d960d88dd3755548b3818630acb63fa98187e
9709af79014a150df7807671e6250ed940c488eb
18 changes: 10 additions & 8 deletions src/borrow_tracker/stacked_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
new_perm: NewPermission,
) -> InterpResult<'tcx> {
let val = self.ecx.read_immediate(&self.ecx.place_to_op(place)?)?;
let val = self.ecx.sb_retag_reference(&val, new_perm, RetagInfo {
cause: self.retag_cause,
in_field: self.in_field,
})?;
let val = self.ecx.sb_retag_reference(
&val,
new_perm,
RetagInfo { cause: self.retag_cause, in_field: self.in_field },
)?;
self.ecx.write_immediate(*val, place)?;
interp_ok(())
}
Expand Down Expand Up @@ -996,10 +997,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
access: Some(AccessKind::Write),
protector: Some(ProtectorKind::StrongProtector),
};
this.sb_retag_place(place, new_perm, RetagInfo {
cause: RetagCause::InPlaceFnPassing,
in_field: false,
})
this.sb_retag_place(
place,
new_perm,
RetagInfo { cause: RetagCause::InPlaceFnPassing, in_field: false },
)
}

/// Mark the given tag as exposed. It was found on a pointer with the given AllocId.
Expand Down
20 changes: 12 additions & 8 deletions src/borrow_tracker/tree_borrows/perms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,18 @@ pub mod diagnostics {
use super::*;
impl fmt::Display for PermissionPriv {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", match self {
ReservedFrz { conflicted: false } => "Reserved",
ReservedFrz { conflicted: true } => "Reserved (conflicted)",
ReservedIM => "Reserved (interior mutable)",
Active => "Active",
Frozen => "Frozen",
Disabled => "Disabled",
})
write!(
f,
"{}",
match self {
ReservedFrz { conflicted: false } => "Reserved",
ReservedFrz { conflicted: true } => "Reserved (conflicted)",
ReservedIM => "Reserved (interior mutable)",
Active => "Active",
Frozen => "Frozen",
Disabled => "Disabled",
}
)
}
}

Expand Down
40 changes: 23 additions & 17 deletions src/borrow_tracker/tree_borrows/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,18 @@ impl Tree {
let mut debug_info = NodeDebugInfo::new(root_tag, root_default_perm, span);
// name the root so that all allocations contain one named pointer
debug_info.add_name("root of the allocation");
nodes.insert(root_idx, Node {
tag: root_tag,
parent: None,
children: SmallVec::default(),
default_initial_perm: root_default_perm,
// The root may never be skipped, all accesses will be local.
default_initial_idempotent_foreign_access: IdempotentForeignAccess::None,
debug_info,
});
nodes.insert(
root_idx,
Node {
tag: root_tag,
parent: None,
children: SmallVec::default(),
default_initial_perm: root_default_perm,
// The root may never be skipped, all accesses will be local.
default_initial_idempotent_foreign_access: IdempotentForeignAccess::None,
debug_info,
},
);
nodes
};
let rperms = {
Expand Down Expand Up @@ -624,14 +627,17 @@ impl<'tcx> Tree {
let parent_idx = self.tag_mapping.get(&parent_tag).unwrap();
let strongest_idempotent = default_initial_perm.strongest_idempotent_foreign_access(prot);
// Create the node
self.nodes.insert(idx, Node {
tag: new_tag,
parent: Some(parent_idx),
children: SmallVec::default(),
default_initial_perm,
default_initial_idempotent_foreign_access: strongest_idempotent,
debug_info: NodeDebugInfo::new(new_tag, default_initial_perm, span),
});
self.nodes.insert(
idx,
Node {
tag: new_tag,
parent: Some(parent_idx),
children: SmallVec::default(),
default_initial_perm,
default_initial_idempotent_foreign_access: strongest_idempotent,
debug_info: NodeDebugInfo::new(new_tag, default_initial_perm, span),
},
);
// Register new_tag as a child of parent_tag
self.nodes.get_mut(parent_idx).unwrap().children.push(idx);
// Initialize perms
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub const MIRI_DEFAULT_ARGS: &[&str] = &[
"-Zmir-emit-retag",
"-Zmir-keep-place-mention",
"-Zmir-opt-level=0",
"-Zmir-enable-passes=-CheckAlignment",
"-Zmir-enable-passes=-CheckAlignment,-CheckNull",
// Deduplicating diagnostics means we miss events when tracking what happens during an
// execution. Let's not do that.
"-Zdeduplicate-diagnostics=no",
Expand Down
11 changes: 7 additions & 4 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,10 +1111,13 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
// Call the lang item.
let panic = ecx.tcx.lang_items().get(reason.lang_item()).unwrap();
let panic = ty::Instance::mono(ecx.tcx.tcx, panic);
ecx.call_function(panic, ExternAbi::Rust, &[], None, StackPopCleanup::Goto {
ret: None,
unwind: mir::UnwindAction::Unreachable,
})?;
ecx.call_function(
panic,
ExternAbi::Rust,
&[],
None,
StackPopCleanup::Goto { ret: None, unwind: mir::UnwindAction::Unreachable },
)?;
interp_ok(())
}

Expand Down
8 changes: 4 additions & 4 deletions src/shims/extern_static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ impl<'tcx> MiriMachine<'tcx> {

match ecx.tcx.sess.target.os.as_ref() {
"linux" => {
Self::null_ptr_extern_statics(ecx, &[
"__cxa_thread_atexit_impl",
"__clock_gettime64",
])?;
Self::null_ptr_extern_statics(
ecx,
&["__cxa_thread_atexit_impl", "__clock_gettime64"],
)?;
Self::weak_symbol_extern_statics(ecx, &["getrandom", "statx"])?;
}
"freebsd" => {
Expand Down
11 changes: 7 additions & 4 deletions src/shims/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
// Call the lang item associated with this message.
let fn_item = this.tcx.require_lang_item(msg.panic_function(), None);
let instance = ty::Instance::mono(this.tcx.tcx, fn_item);
this.call_function(instance, ExternAbi::Rust, &[], None, StackPopCleanup::Goto {
ret: None,
unwind,
})?;
this.call_function(
instance,
ExternAbi::Rust,
&[],
None,
StackPopCleanup::Goto { ret: None, unwind },
)?;
}
}
interp_ok(())
Expand Down
24 changes: 12 additions & 12 deletions tests/pass-dep/libc/libc-epoll-no-blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ fn test_two_same_fd_in_same_epoll_instance() {
//Two notification should be received.
let expected_event = u32::try_from(libc::EPOLLIN | libc::EPOLLOUT).unwrap();
let expected_value = 5 as u64;
check_epoll_wait::<8>(epfd, &[
(expected_event, expected_value),
(expected_event, expected_value),
]);
check_epoll_wait::<8>(
epfd,
&[(expected_event, expected_value), (expected_event, expected_value)],
);
}

fn test_epoll_eventfd() {
Expand Down Expand Up @@ -290,10 +290,10 @@ fn test_epoll_socketpair_both_sides() {
let expected_value0 = fds[0] as u64;
let expected_event1 = u32::try_from(libc::EPOLLOUT).unwrap();
let expected_value1 = fds[1] as u64;
check_epoll_wait::<8>(epfd, &[
(expected_event0, expected_value0),
(expected_event1, expected_value1),
]);
check_epoll_wait::<8>(
epfd,
&[(expected_event0, expected_value0), (expected_event1, expected_value1)],
);

// Read from fds[0].
let mut buf: [u8; 5] = [0; 5];
Expand Down Expand Up @@ -453,10 +453,10 @@ fn test_socketpair_read() {
let expected_value0 = fds[0] as u64;
let expected_event1 = u32::try_from(libc::EPOLLOUT).unwrap();
let expected_value1 = fds[1] as u64;
check_epoll_wait::<8>(epfd, &[
(expected_event0, expected_value0),
(expected_event1, expected_value1),
]);
check_epoll_wait::<8>(
epfd,
&[(expected_event0, expected_value0), (expected_event1, expected_value1)],
);

// Read 3 bytes from fds[0].
let mut buf: [u8; 3] = [0; 3];
Expand Down
52 changes: 52 additions & 0 deletions tests/pass/dyn-upcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ fn main() {
replace_vptr();
vtable_nop_cast();
drop_principal();
modulo_binder();
modulo_assoc();
}

fn vtable_nop_cast() {
Expand Down Expand Up @@ -482,3 +484,53 @@ fn drop_principal() {
println!("before");
drop(y);
}

// Test for <https://github.com/rust-lang/rust/issues/135316>.
fn modulo_binder() {
trait Supertrait<T> {
fn _print_numbers(&self, mem: &[usize; 100]) {
println!("{mem:?}");
}
}
impl<T> Supertrait<T> for () {}

trait Trait<T, U>: Supertrait<T> + Supertrait<U> {
fn say_hello(&self, _: &usize) {
println!("Hello!");
}
}
impl<T, U> Trait<T, U> for () {}

(&() as &'static dyn for<'a> Trait<&'static (), &'a ()>
as &'static dyn Trait<&'static (), &'static ()>)
.say_hello(&0);
}

// Test for <https://github.com/rust-lang/rust/issues/135315>.
fn modulo_assoc() {
trait Supertrait<T> {
fn _print_numbers(&self, mem: &[usize; 100]) {
println!("{mem:?}");
}
}
impl<T> Supertrait<T> for () {}

trait Identity {
type Selff;
}
impl<Selff> Identity for Selff {
type Selff = Selff;
}

trait Middle<T>: Supertrait<()> + Supertrait<T> {
fn say_hello(&self, _: &usize) {
println!("Hello!");
}
}
impl<T> Middle<T> for () {}

trait Trait: Middle<<() as Identity>::Selff> {}
impl Trait for () {}

(&() as &dyn Trait as &dyn Middle<()>).say_hello(&0);
}
2 changes: 2 additions & 0 deletions tests/pass/dyn-upcast.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ before
goodbye
before
goodbye
Hello!
Hello!
33 changes: 18 additions & 15 deletions tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,25 @@ fn miri_config(
config.comment_defaults.base().add_custom("edition", Edition("2021".into()));

if let Some(WithDependencies { bless }) = with_dependencies {
config.comment_defaults.base().set_custom("dependencies", DependencyBuilder {
program: CommandBuilder {
// Set the `cargo-miri` binary, which we expect to be in the same folder as the `miri` binary.
// (It's a separate crate, so we don't get an env var from cargo.)
program: miri_path()
.with_file_name(format!("cargo-miri{}", env::consts::EXE_SUFFIX)),
// There is no `cargo miri build` so we just use `cargo miri run`.
args: ["miri", "run"].into_iter().map(Into::into).collect(),
// Reset `RUSTFLAGS` to work around <https://github.com/rust-lang/rust/pull/119574#issuecomment-1876878344>.
envs: vec![("RUSTFLAGS".into(), None)],
..CommandBuilder::cargo()
config.comment_defaults.base().set_custom(
"dependencies",
DependencyBuilder {
program: CommandBuilder {
// Set the `cargo-miri` binary, which we expect to be in the same folder as the `miri` binary.
// (It's a separate crate, so we don't get an env var from cargo.)
program: miri_path()
.with_file_name(format!("cargo-miri{}", env::consts::EXE_SUFFIX)),
// There is no `cargo miri build` so we just use `cargo miri run`.
args: ["miri", "run"].into_iter().map(Into::into).collect(),
// Reset `RUSTFLAGS` to work around <https://github.com/rust-lang/rust/pull/119574#issuecomment-1876878344>.
envs: vec![("RUSTFLAGS".into(), None)],
..CommandBuilder::cargo()
},
crate_manifest_path: Path::new("test_dependencies").join("Cargo.toml"),
build_std: None,
bless_lockfile: bless,
},
crate_manifest_path: Path::new("test_dependencies").join("Cargo.toml"),
build_std: None,
bless_lockfile: bless,
});
);
}
config
}
Expand Down

0 comments on commit 44e9863

Please sign in to comment.