Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b7fb425

Browse files
committed
Auto merge of rust-lang#124688 - compiler-errors:rollup-qhi9pyn, r=compiler-errors
Rollup of 8 pull requests Successful merges: - rust-lang#124293 (Let miri and const eval execute intrinsics' fallback bodies) - rust-lang#124418 (Use a proof tree visitor to refine the `Obligation` for error reporting in new solver) - rust-lang#124480 (Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`) - rust-lang#124648 (Trim crate graph) - rust-lang#124656 (release notes 1.78: add link to interior-mut breaking change) - rust-lang#124658 (Migrate `run-make/doctests-keep-binaries` to new rmake.rs format) - rust-lang#124681 (zkvm: fix run_tests) - rust-lang#124687 (Make `Bounds.clauses` private) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 09cd00f + d67586e commit b7fb425

File tree

133 files changed

+886
-582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+886
-582
lines changed

Cargo.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3824,7 +3824,6 @@ dependencies = [
38243824
"rustc_session",
38253825
"rustc_smir",
38263826
"rustc_span",
3827-
"rustc_symbol_mangling",
38283827
"rustc_target",
38293828
"rustc_trait_selection",
38303829
"rustc_ty_utils",
@@ -4008,7 +4007,6 @@ dependencies = [
40084007
"rustc_data_structures",
40094008
"rustc_errors",
40104009
"rustc_fluent_macro",
4011-
"rustc_graphviz",
40124010
"rustc_hir",
40134011
"rustc_hir_analysis",
40144012
"rustc_hir_pretty",
@@ -4468,7 +4466,6 @@ dependencies = [
44684466
"rustc_errors",
44694467
"rustc_fluent_macro",
44704468
"rustc_hir",
4471-
"rustc_hir_analysis",
44724469
"rustc_macros",
44734470
"rustc_middle",
44744471
"rustc_session",
@@ -4515,7 +4512,6 @@ dependencies = [
45154512
"rustc_session",
45164513
"rustc_span",
45174514
"rustc_target",
4518-
"rustc_type_ir",
45194515
"smallvec",
45204516
"thin-vec",
45214517
"tracing",

RELEASES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ Compatibility Notes
102102
- [Change equality of higher ranked types to not rely on subtyping](https://github.com/rust-lang/rust/pull/118247)
103103
- [When called, additionally check bounds on normalized function return type](https://github.com/rust-lang/rust/pull/118882)
104104
- [Expand coverage for `arithmetic_overflow` lint](https://github.com/rust-lang/rust/pull/119432/)
105+
- [Fix detection of potential interior mutability in `const` initializers](https://github.com/rust-lang/rust/issues/121250)
106+
This code was accidentally accepted. The fix can break generic code that borrows a value of unknown type,
107+
as there is currently no way to declare "this type has no interior mutability". In the future, stabilizing
108+
the [`Freeze` trait](https://github.com/rust-lang/rust/issues/121675) will allow proper support for such code.
105109

106110
<a id="1.78.0-Internal-Changes"></a>
107111

compiler/rustc/src/main.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(unix_sigpipe)]
2-
31
// A note about jemalloc: rustc uses jemalloc when built for CI and
42
// distribution. The obvious way to do this is with the `#[global_allocator]`
53
// mechanism. However, for complicated reasons (see
@@ -34,7 +32,6 @@
3432
// https://github.com/rust-lang/rust/commit/b90cfc887c31c3e7a9e6d462e2464db1fe506175#diff-43914724af6e464c1da2171e4a9b6c7e607d5bc1203fa95c0ab85be4122605ef
3533
// for an example of how to do so.
3634

37-
#[unix_sigpipe = "sig_dfl"]
3835
fn main() {
3936
// See the comment at the top of this file for an explanation of this.
4037
#[cfg(feature = "jemalloc-sys")]

compiler/rustc_builtin_macros/src/format.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ fn make_format_args(
307307
return ExpandResult::Ready(Err(guar));
308308
}
309309

310-
let to_span = |inner_span: rustc_parse_format::InnerSpan| {
310+
let to_span = |inner_span: parse::InnerSpan| {
311311
is_source_literal.then(|| {
312312
fmt_span.from_inner(InnerSpan { start: inner_span.start, end: inner_span.end })
313313
})
@@ -577,7 +577,7 @@ fn make_format_args(
577577
fn invalid_placeholder_type_error(
578578
ecx: &ExtCtxt<'_>,
579579
ty: &str,
580-
ty_span: Option<rustc_parse_format::InnerSpan>,
580+
ty_span: Option<parse::InnerSpan>,
581581
fmt_span: Span,
582582
) {
583583
let sp = ty_span.map(|sp| fmt_span.from_inner(InnerSpan::new(sp.start, sp.end)));

compiler/rustc_const_eval/src/const_eval/dummy_machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for DummyMachine {
105105
_destination: &interpret::MPlaceTy<'tcx, Self::Provenance>,
106106
_target: Option<BasicBlock>,
107107
_unwind: UnwindAction,
108-
) -> interpret::InterpResult<'tcx> {
108+
) -> interpret::InterpResult<'tcx, Option<ty::Instance<'tcx>>> {
109109
unimplemented!()
110110
}
111111

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -459,16 +459,26 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
459459
dest: &MPlaceTy<'tcx, Self::Provenance>,
460460
target: Option<mir::BasicBlock>,
461461
_unwind: mir::UnwindAction,
462-
) -> InterpResult<'tcx> {
462+
) -> InterpResult<'tcx, Option<ty::Instance<'tcx>>> {
463463
// Shared intrinsics.
464464
if ecx.emulate_intrinsic(instance, args, dest, target)? {
465-
return Ok(());
465+
return Ok(None);
466466
}
467467
let intrinsic_name = ecx.tcx.item_name(instance.def_id());
468468

469469
// CTFE-specific intrinsics.
470470
let Some(ret) = target else {
471-
throw_unsup_format!("intrinsic `{intrinsic_name}` is not supported at compile-time");
471+
// Handle diverging intrinsics. We can't handle any of them (that are not already
472+
// handled above), but check if there is a fallback body.
473+
if ecx.tcx.intrinsic(instance.def_id()).unwrap().must_be_overridden {
474+
throw_unsup_format!(
475+
"intrinsic `{intrinsic_name}` is not supported at compile-time"
476+
);
477+
}
478+
return Ok(Some(ty::Instance {
479+
def: ty::InstanceDef::Item(instance.def_id()),
480+
args: instance.args,
481+
}));
472482
};
473483
match intrinsic_name {
474484
sym::ptr_guaranteed_cmp => {
@@ -536,14 +546,21 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
536546
// not the optimization stage.)
537547
sym::is_val_statically_known => ecx.write_scalar(Scalar::from_bool(false), dest)?,
538548
_ => {
539-
throw_unsup_format!(
540-
"intrinsic `{intrinsic_name}` is not supported at compile-time"
541-
);
549+
// We haven't handled the intrinsic, let's see if we can use a fallback body.
550+
if ecx.tcx.intrinsic(instance.def_id()).unwrap().must_be_overridden {
551+
throw_unsup_format!(
552+
"intrinsic `{intrinsic_name}` is not supported at compile-time"
553+
);
554+
}
555+
return Ok(Some(ty::Instance {
556+
def: ty::InstanceDef::Item(instance.def_id()),
557+
args: instance.args,
558+
}));
542559
}
543560
}
544561

545562
ecx.go_to_block(ret);
546-
Ok(())
563+
Ok(None)
547564
}
548565

549566
fn assert_panic(

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
414414
}
415415
self.copy_op(&self.project_index(&input, index)?, dest)?;
416416
}
417-
sym::likely | sym::unlikely | sym::black_box => {
417+
sym::black_box => {
418418
// These just return their argument
419419
self.copy_op(&args[0], dest)?;
420420
}

compiler/rustc_const_eval/src/interpret/machine.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,17 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
216216

217217
/// Directly process an intrinsic without pushing a stack frame. It is the hook's
218218
/// responsibility to advance the instruction pointer as appropriate.
219+
///
220+
/// Returns `None` if the intrinsic was fully handled.
221+
/// Otherwise, returns an `Instance` of the function that implements the intrinsic.
219222
fn call_intrinsic(
220223
ecx: &mut InterpCx<'mir, 'tcx, Self>,
221224
instance: ty::Instance<'tcx>,
222225
args: &[OpTy<'tcx, Self::Provenance>],
223226
destination: &MPlaceTy<'tcx, Self::Provenance>,
224227
target: Option<mir::BasicBlock>,
225228
unwind: mir::UnwindAction,
226-
) -> InterpResult<'tcx>;
229+
) -> InterpResult<'tcx, Option<ty::Instance<'tcx>>>;
227230

228231
/// Called to evaluate `Assert` MIR terminators that trigger a panic.
229232
fn assert_panic(

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,14 +539,28 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
539539
ty::InstanceDef::Intrinsic(def_id) => {
540540
assert!(self.tcx.intrinsic(def_id).is_some());
541541
// FIXME: Should `InPlace` arguments be reset to uninit?
542-
M::call_intrinsic(
542+
if let Some(fallback) = M::call_intrinsic(
543543
self,
544544
instance,
545545
&self.copy_fn_args(args),
546546
destination,
547547
target,
548548
unwind,
549-
)
549+
)? {
550+
assert!(!self.tcx.intrinsic(fallback.def_id()).unwrap().must_be_overridden);
551+
assert!(matches!(fallback.def, ty::InstanceDef::Item(_)));
552+
return self.eval_fn_call(
553+
FnVal::Instance(fallback),
554+
(caller_abi, caller_fn_abi),
555+
args,
556+
with_caller_location,
557+
destination,
558+
target,
559+
unwind,
560+
);
561+
} else {
562+
Ok(())
563+
}
550564
}
551565
ty::InstanceDef::VTableShim(..)
552566
| ty::InstanceDef::ReifyShim(..)

compiler/rustc_driver_impl/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ rustc_privacy = { path = "../rustc_privacy" }
4242
rustc_query_system = { path = "../rustc_query_system" }
4343
rustc_resolve = { path = "../rustc_resolve" }
4444
rustc_session = { path = "../rustc_session" }
45-
rustc_smir ={ path = "../rustc_smir" }
45+
rustc_smir = { path = "../rustc_smir" }
4646
rustc_span = { path = "../rustc_span" }
47-
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }
4847
rustc_target = { path = "../rustc_target" }
4948
rustc_trait_selection = { path = "../rustc_trait_selection" }
5049
rustc_ty_utils = { path = "../rustc_ty_utils" }

0 commit comments

Comments
 (0)