Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
124bfc9
Remove parent def lookup hack that is no longer needed
camelid Oct 13, 2025
258d553
Prepare for merging from rust-lang/rust
Oct 16, 2025
0784632
Merge ref '402ce0ef07d5' from rust-lang/rust
Oct 16, 2025
936dda5
Merge pull request #4637 from rust-lang/rustup-2025-10-16
RalfJung Oct 16, 2025
379a057
Fix lowering of CStr constants to valtrees
camelid Oct 13, 2025
cff6452
Ignore test-dashboard related files
samueltardieu Oct 17, 2025
736a276
Prepare for merging from rust-lang/rust
RalfJung Oct 22, 2025
4dff7b8
Merge ref '96fe3c31c2ec' from rust-lang/rust
RalfJung Oct 22, 2025
1d00266
make genmc tests less dependent on std internals
RalfJung Oct 22, 2025
86bb8eb
Merge pull request #4640 from RalfJung/rustup
RalfJung Oct 22, 2025
70aa534
Avoid panicking when `Cargo.toml` is not present
FranciscoTGouveia Oct 22, 2025
424f7bf
native_call: we only support thin pointers as return type
RalfJung Oct 22, 2025
23e3645
Merge pull request #4644 from RalfJung/native-call-return-ptr
RalfJung Oct 22, 2025
d521a79
Prepare for merging from rust-lang/rust
Oct 23, 2025
d60d4a5
Merge ref '6244effd0372' from rust-lang/rust
Oct 23, 2025
c13da7b
Merge pull request #4645 from rust-lang/rustup-2025-10-23
oli-obk Oct 23, 2025
ce35d4c
SB wildcard handling: extend comments
RalfJung Oct 23, 2025
c8c2e17
Merge pull request #4646 from RalfJung/sb-wildcard-comments
RalfJung Oct 23, 2025
b6c7138
Merge pull request #4643 from FranciscoTGouveia/avoid-panic-cargo-toml
RalfJung Oct 23, 2025
420096d
Prepare for merging from rust-lang/rust
Oct 24, 2025
77e7651
Merge ref '27050c0d15af' from rust-lang/rust
Oct 24, 2025
3c92cf1
Merge pull request #4649 from rust-lang/rustup-2025-10-24
oli-obk Oct 24, 2025
0c7ff00
add -Zmiri-user-relevant-crates
RalfJung Oct 27, 2025
80bd9cf
Merge pull request #4651 from RalfJung/user-relevant-crates
RalfJung Oct 27, 2025
8f70d2d
add miri magic function to configure allocation tracking at runtime
RalfJung Oct 27, 2025
9d60a23
Merge pull request #4652 from RalfJung/track-alloc-runtime
RalfJung Oct 27, 2025
20e0014
Support f32/f64 in native function calls
FranciscoTGouveia Oct 23, 2025
8fef16e
Merge pull request #4650 from FranciscoTGouveia/f32/64-native-func-calls
RalfJung Oct 28, 2025
48f8f23
Remove a special case for rust_eh_personality from reachable_non_gene…
bjorn3 Oct 29, 2025
1b78417
Remove special case for the panic runtime from reachable_non_generics
bjorn3 Oct 29, 2025
651076a
Prepare for merging from rust-lang/rust
Oct 30, 2025
c351d06
Merge ref '292be5c7c051' from rust-lang/rust
Oct 30, 2025
7e0783f
alloc access tracking: print accessed range
RalfJung Oct 30, 2025
8c678cc
update comment regarding disabled jobs
RalfJung Oct 30, 2025
3048ef2
unconditionally use Duration::from_nanos_u128
RalfJung Oct 30, 2025
9cb215a
Merge pull request #4656 from rust-lang/rustup-2025-10-30
RalfJung Oct 30, 2025
04eacd0
document -Zmiri-backtrace; dont print backtrace when there's only one…
RalfJung Oct 30, 2025
250ebfa
Merge pull request #4657 from RalfJung/tracking-and-backtrace
RalfJung Oct 30, 2025
20bddb1
weak memory: fix non-atomic read clearing store buffer
RalfJung Oct 30, 2025
851b10f
add store buffer initialization sanity check that would have caught t…
RalfJung Oct 30, 2025
0efeec5
Mention crate being analysized in query description
estebank Sep 28, 2025
63a18d4
Merge pull request #4658 from RalfJung/weak-mem-na-reads
RalfJung Nov 1, 2025
0bd6a03
dangling ptr lint cleanup
hkBst Oct 31, 2025
f39fb70
Update tests after fixing ICEs
camelid Nov 1, 2025
4a30664
Rollup merge of #147137 - estebank:issue-74380, r=nnethercote
Zalathar Nov 2, 2025
1d64a4b
Rollup merge of #147642 - camelid:misc-const-fixes, r=BoxyUwU
Zalathar Nov 2, 2025
07b4d40
Rollup merge of #147806 - samueltardieu:chores/gitignore-test-dashboa…
Zalathar Nov 2, 2025
ee1a756
Rollup merge of #148247 - bjorn3:minor_symbol_export_cleanup, r=Waffl…
Zalathar Nov 2, 2025
7813ee9
Rollup merge of #148348 - hkBst:dangling-ptr-lint-1, r=Urgau
Zalathar Nov 2, 2025
642e09c
Rollup merge of #148374 - RalfJung:miri, r=RalfJung
Zalathar Nov 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ node_modules
## Rustdoc GUI tests
tests/rustdoc-gui/src/**.lock

## Test dashboard
.citool-cache/
test-dashboard/

## direnv
/.envrc
/.direnv/
Expand Down
24 changes: 8 additions & 16 deletions compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
return Default::default();
}

// Check to see if this crate is a "special runtime crate". These
// crates, implementation details of the standard library, typically
// have a bunch of `pub extern` and `#[no_mangle]` functions as the
// ABI between them. We don't want their symbols to have a `C`
// export level, however, as they're just implementation details.
// Down below we'll hardwire all of the symbols to the `Rust` export
// level instead.
let special_runtime_crate =
tcx.is_panic_runtime(LOCAL_CRATE) || tcx.is_compiler_builtins(LOCAL_CRATE);
let is_compiler_builtins = tcx.is_compiler_builtins(LOCAL_CRATE);

let mut reachable_non_generics: DefIdMap<_> = tcx
.reachable_set(())
Expand Down Expand Up @@ -104,11 +96,12 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
if tcx.cross_crate_inlinable(def_id) { None } else { Some(def_id) }
})
.map(|def_id| {
// We won't link right if this symbol is stripped during LTO.
let name = tcx.symbol_name(Instance::mono(tcx, def_id.to_def_id())).name;
let used = name == "rust_eh_personality";

let export_level = if special_runtime_crate {
let export_level = if is_compiler_builtins {
// We don't want to export compiler-builtins symbols from any
// dylibs, even rust dylibs. Unlike all other crates it gets
// duplicated in every linker invocation and it may otherwise
// unintentionally override definitions of these symbols by
// libgcc or compiler-rt for C code.
SymbolExportLevel::Rust
} else {
symbol_export_level(tcx, def_id.to_def_id())
Expand All @@ -131,8 +124,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
SymbolExportKind::Text
},
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
|| used,
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER),
rustc_std_internal_symbol: codegen_attrs
.flags
.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL),
Expand Down
14 changes: 0 additions & 14 deletions compiler/rustc_hir_analysis/src/collect/generics_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
// stable enough and does not need a feature gate anymore.
Node::AnonConst(_) => {
let parent_did = tcx.parent(def_id.to_def_id());

// We don't do this unconditionally because the `DefId` parent of an anon const
// might be an implicitly created closure during `async fn` desugaring. This would
// have the wrong generics.
//
// i.e. `async fn foo<'a>() { let a = [(); { 1 + 2 }]; bar().await() }`
// would implicitly have a closure in its body that would be the parent of
// the `{ 1 + 2 }` anon const. This closure's generics is simply a witness
// instead of `['a]`.
let parent_did = if let DefKind::AnonConst = tcx.def_kind(parent_did) {
parent_did
} else {
tcx.hir_get_parent_item(hir_id).to_def_id()
};
debug!(?parent_did);

let mut in_param_ty = false;
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ lint_confusable_identifier_pair = found both `{$existing_sym}` and `{$sym}` as i
.current_use = this identifier can be confused with `{$existing_sym}`
.other_use = other identifier used here

lint_dangling_pointers_from_locals = a dangling pointer will be produced because the local variable `{$local_var_name}` will be dropped
.ret_ty = return type of the {$fn_kind} is `{$ret_ty}`
.local_var = `{$local_var_name}` is part the {$fn_kind} and will be dropped at the end of the {$fn_kind}
lint_dangling_pointers_from_locals = {$fn_kind} returns a dangling pointer to dropped local variable `{$local_var_name}`
.ret_ty = return type is `{$ret_ty}`
.local_var = local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}
.created_at = dangling pointer created here
.note = pointers do not have a lifetime; after returning, the `{$local_var_ty}` will be deallocated at the end of the {$fn_kind} because nothing is referencing it as far as the type system is concerned
.note = a dangling pointer is safe, but dereferencing one is undefined behavior

lint_dangling_pointers_from_temporaries = a dangling pointer will be produced because the temporary `{$ty}` will be dropped
.label_ptr = this pointer will immediately be invalid
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,10 @@ rustc_queries! {
/// The root query triggering all analysis passes like typeck or borrowck.
query analysis(key: ()) {
eval_always
desc { "running analysis passes on this crate" }
desc { |tcx|
"running analysis passes on crate `{}`",
tcx.crate_name(LOCAL_CRATE),
}
}

/// This query checks the fulfillment of collected lint expectations.
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_mir_build/src/thir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ pub(crate) fn lit_to_const<'tcx>(
(ast::LitKind::Byte(n), ty::Uint(ty::UintTy::U8)) => {
ty::ValTree::from_scalar_int(tcx, n.into())
}
(ast::LitKind::CStr(byte_sym, _), ty::Ref(_, inner_ty, _)) if matches!(inner_ty.kind(), ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::CStr)) => {
ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str())
(ast::LitKind::CStr(byte_sym, _), ty::Ref(_, inner_ty, _)) if matches!(inner_ty.kind(), ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::CStr)) =>
{
// A CStr is a newtype around a byte slice, so we create the inner slice here.
// We need a branch for each "level" of the data structure.
let bytes = ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str());
ty::ValTree::from_branches(tcx, [bytes])
}
(ast::LitKind::Int(n, _), ty::Uint(ui)) if !neg => {
let scalar_int = trunc(n.get(), *ui);
Expand Down
5 changes: 3 additions & 2 deletions src/tools/miri/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:
os: ubuntu-24.04-arm
multiarch: armhf
gcc_cross: arm-linux-gnueabihf
# Disabled due to Ubuntu repo trouble
# Ubuntu mirrors are not reliable enough for these architectures
# (see <https://bugs.launchpad.net/ubuntu/+bug/2130309>).
# - host_target: riscv64gc-unknown-linux-gnu
# os: ubuntu-latest
# multiarch: riscv64
Expand Down Expand Up @@ -68,7 +69,7 @@ jobs:
- name: install multiarch
if: ${{ matrix.multiarch != '' }}
run: |
# s390x, ppc64el, riscv64 need Ubuntu Ports to be in the mirror list
# armhf, s390x, ppc64el, riscv64 need Ubuntu Ports to be in the mirror list
sudo bash -c "echo 'https://ports.ubuntu.com/ priority:4' >> /etc/apt/apt-mirrors.txt"
# Add architecture
sudo dpkg --add-architecture ${{ matrix.multiarch }}
Expand Down
12 changes: 11 additions & 1 deletion src/tools/miri/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ Try running `cargo miri clean`.
Miri adds its own set of `-Z` flags, which are usually set via the `MIRIFLAGS`
environment variable. We first document the most relevant and most commonly used flags:

* `-Zmiri-backtrace=<0|1|full>` configures how Miri prints backtraces: `1` is the default,
where backtraces are printed in pruned form; `full` prints backtraces without pruning, and `0`
disables backtraces entirely.
* `-Zmiri-deterministic-concurrency` makes Miri's concurrency-related behavior fully deterministic.
Strictly speaking, Miri is always fully deterministic when isolation is enabled (the default
mode), but this determinism is achieved by using an RNG with a fixed seed. Seemingly harmless
Expand Down Expand Up @@ -373,6 +376,12 @@ environment variable. We first document the most relevant and most commonly used
ensure alignment. (The standard library `align_to` method works fine in both modes; under
symbolic alignment it only fills the middle slice when the allocation guarantees sufficient
alignment.)
* `-Zmiri-user-relevant-crates=<crate>,<crate>,...` extends the list of crates that Miri considers
"user-relevant". This affects the rendering of backtraces (for user-relevant crates, Miri shows
not just the function name but the actual code) and it affects the spans collected for data races
and aliasing violations (where Miri will show the span of the topmost non-`#[track_caller]` frame
in a user-relevant crate). When using `cargo miri`, the crates in the local workspace are always
considered user-relevant.

The remaining flags are for advanced use only, and more likely to change or be removed.
Some of these are **unsound**, which means they can lead
Expand Down Expand Up @@ -474,7 +483,8 @@ to Miri failing to detect cases of undefined behavior in a program.
* `-Zmiri-track-alloc-id=<id1>,<id2>,...` shows a backtrace when the given allocations are
being allocated or freed. This helps in debugging memory leaks and
use after free bugs. Specifying this argument multiple times does not overwrite the previous
values, instead it appends its values to the list. Listing an id multiple times has no effect.
values, instead it appends its values to the list. Listing an ID multiple times has no effect.
You can also add IDs at runtime using `miri_track_alloc`.
* `-Zmiri-track-pointer-tag=<tag1>,<tag2>,...` shows a backtrace when a given pointer tag
is created and when (if ever) it is popped from a borrow stack (which is where the tag becomes invalid
and any future use of it will error). This helps you in finding out why UB is
Expand Down
6 changes: 5 additions & 1 deletion src/tools/miri/cargo-miri/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ fn cargo_extra_flags() -> Vec<String> {

pub fn get_cargo_metadata() -> Metadata {
// This will honor the `CARGO` env var the same way our `cargo()` does.
MetadataCommand::new().no_deps().other_options(cargo_extra_flags()).exec().unwrap()
MetadataCommand::new()
.no_deps()
.other_options(cargo_extra_flags())
.exec()
.unwrap_or_else(|err| show_error!("{}", err))
}

/// Pulls all the crates in this workspace from the cargo metadata.
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 @@
28d0a4a205f9e511ad2f51ee79a4aa19a704a455
292be5c7c05138d753bbd4b30db7a3f1a5c914f7
2 changes: 2 additions & 0 deletions src/tools/miri/src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,8 @@ fn main() {
fatal_error!("-Zmiri-force-page-size requires a power of 2: {page_size}");
};
miri_config.page_size = Some(page_size);
} else if let Some(param) = arg.strip_prefix("-Zmiri-user-relevant-crates=") {
miri_config.user_relevant_crates.extend(param.split(',').map(|s| s.to_owned()));
} else {
// Forward to rustc.
rustc_args.push(arg);
Expand Down
14 changes: 10 additions & 4 deletions src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,16 +675,22 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
if let Ok((alloc_id, base_offset, orig_tag)) = this.ptr_try_get_alloc_id(place.ptr(), 0)
{
log_creation(this, Some((alloc_id, base_offset, orig_tag)))?;
// Still give it the new provenance, it got retagged after all.
// Still give it the new provenance, it got retagged after all. If this was a
// wildcard pointer, this will fix the AllocId and make future accesses with this
// reference to other allocations UB, but that's fine: due to subobject provenance,
// *all* future accesses with this reference should be UB!
return interp_ok(Some(Provenance::Concrete { alloc_id, tag: new_tag }));
} else {
// This pointer doesn't come with an AllocId. :shrug:
log_creation(this, None)?;
// Provenance unchanged.
// Provenance unchanged. Ideally we'd make this pointer UB to use like above,
// but there's no easy way to do that.
return interp_ok(place.ptr().provenance);
}
}

// The pointer *must* have a valid AllocId to continue, so we want to resolve this to
// a concrete ID even for wildcard pointers.
let (alloc_id, base_offset, orig_tag) = this.ptr_get_alloc_id(place.ptr(), 0)?;
log_creation(this, Some((alloc_id, base_offset, orig_tag)))?;

Expand Down Expand Up @@ -743,7 +749,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
// Make sure the data race model also knows about this.
// FIXME(genmc): Ensure this is still done in GenMC mode. Check for other places where GenMC may need to be informed.
if let Some(data_race) = alloc_extra.data_race.as_vclocks_mut() {
data_race.write(
data_race.write_non_atomic(
alloc_id,
range,
NaWriteType::Retag,
Expand Down Expand Up @@ -792,7 +798,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
assert_eq!(access, AccessKind::Read);
// Make sure the data race model also knows about this.
if let Some(data_race) = alloc_extra.data_race.as_vclocks_ref() {
data_race.read(
data_race.read_non_atomic(
alloc_id,
range,
NaReadType::Retag,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
// Also inform the data race model (but only if any bytes are actually affected).
if range_in_alloc.size.bytes() > 0 {
if let Some(data_race) = alloc_extra.data_race.as_vclocks_ref() {
data_race.read(
data_race.read_non_atomic(
alloc_id,
range_in_alloc,
NaReadType::Retag,
Expand Down
16 changes: 1 addition & 15 deletions src/tools/miri/src/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,7 @@ impl Instant {
InstantKind::Virtual { nanoseconds: earlier },
) => {
let duration = nanoseconds.saturating_sub(earlier);
cfg_select! {
bootstrap => {
// `Duration` does not provide a nice constructor from a `u128` of nanoseconds,
// so we have to implement this ourselves.
// It is possible for second to overflow because u64::MAX < (u128::MAX / 1e9).
// It will be saturated to u64::MAX seconds if the value after division exceeds u64::MAX.
let seconds = u64::try_from(duration / 1_000_000_000).unwrap_or(u64::MAX);
// It is impossible for nanosecond to overflow because u32::MAX > 1e9.
let nanosecond = u32::try_from(duration.wrapping_rem(1_000_000_000)).unwrap();
Duration::new(seconds, nanosecond)
}
_ => {
Duration::from_nanos_u128(duration)
}
}
Duration::from_nanos_u128(duration)
}
_ => panic!("all `Instant` must be of the same kind"),
}
Expand Down
Loading
Loading