Skip to content

Commit b7fb425

Browse files
committed
Auto merge of #124688 - compiler-errors:rollup-qhi9pyn, r=compiler-errors
Rollup of 8 pull requests Successful merges: - #124293 (Let miri and const eval execute intrinsics' fallback bodies) - #124418 (Use a proof tree visitor to refine the `Obligation` for error reporting in new solver) - #124480 (Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`) - #124648 (Trim crate graph) - #124656 (release notes 1.78: add link to interior-mut breaking change) - #124658 (Migrate `run-make/doctests-keep-binaries` to new rmake.rs format) - #124681 (zkvm: fix run_tests) - #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

-4
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

+4
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

-3
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

+2-2
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

+1-1
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

+24-7
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

+1-1
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

+4-1
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

+16-2
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

+1-2
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" }

compiler/rustc_errors/src/diagnostic_impls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol};
1313
use rustc_span::Span;
1414
use rustc_target::abi::TargetDataLayoutErrors;
1515
use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple};
16-
use rustc_type_ir as type_ir;
16+
use rustc_type_ir::{ClosureKind, FloatTy};
1717
use std::backtrace::Backtrace;
1818
use std::borrow::Cow;
1919
use std::fmt;
@@ -196,7 +196,7 @@ impl IntoDiagArg for ast::token::TokenKind {
196196
}
197197
}
198198

199-
impl IntoDiagArg for type_ir::FloatTy {
199+
impl IntoDiagArg for FloatTy {
200200
fn into_diag_arg(self) -> DiagArgValue {
201201
DiagArgValue::Str(Cow::Borrowed(self.name_str()))
202202
}
@@ -252,7 +252,7 @@ impl IntoDiagArg for Level {
252252
}
253253
}
254254

255-
impl IntoDiagArg for type_ir::ClosureKind {
255+
impl IntoDiagArg for ClosureKind {
256256
fn into_diag_arg(self) -> DiagArgValue {
257257
DiagArgValue::Str(self.as_str().into())
258258
}

compiler/rustc_feature/src/builtin_attrs.rs

-4
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
396396
),
397397

398398
// Entry point:
399-
gated!(
400-
unix_sigpipe, Normal, template!(NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing,
401-
EncodeCrossCrate::Yes, experimental!(unix_sigpipe)
402-
),
403399
ungated!(start, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No),
404400
ungated!(no_start, CrateLevel, template!(Word), WarnFollowing, EncodeCrossCrate::No),
405401
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing, EncodeCrossCrate::No),

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,6 @@ declare_features! (
619619
/// Allows creation of instances of a struct by moving fields that have
620620
/// not changed from prior instances of the same struct (RFC #2528)
621621
(unstable, type_changing_struct_update, "1.58.0", Some(86555)),
622-
/// Enables rustc to generate code that instructs libstd to NOT ignore SIGPIPE.
623-
(unstable, unix_sigpipe, "1.65.0", Some(97889)),
624622
/// Allows unnamed fields of struct and union type
625623
(incomplete, unnamed_fields, "1.74.0", Some(49804)),
626624
/// Allows unsized fn parameters.

compiler/rustc_hir_analysis/src/bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_span::Span;
2323
/// include the self type (e.g., `trait_bounds`) but in others we do not
2424
#[derive(Default, PartialEq, Eq, Clone, Debug)]
2525
pub struct Bounds<'tcx> {
26-
pub clauses: Vec<(ty::Clause<'tcx>, Span)>,
26+
clauses: Vec<(ty::Clause<'tcx>, Span)>,
2727
}
2828

2929
impl<'tcx> Bounds<'tcx> {

compiler/rustc_hir_typeck/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ rustc_attr = { path = "../rustc_attr" }
1212
rustc_data_structures = { path = "../rustc_data_structures" }
1313
rustc_errors = { path = "../rustc_errors" }
1414
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
15-
rustc_graphviz = { path = "../rustc_graphviz" }
1615
rustc_hir = { path = "../rustc_hir" }
1716
rustc_hir_analysis = { path = "../rustc_hir_analysis" }
1817
rustc_hir_pretty = { path = "../rustc_hir_pretty" }

compiler/rustc_hir_typeck/src/pat.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_hir::pat_util::EnumerateAndAdjustIterator;
1010
use rustc_hir::{self as hir, BindingMode, ByRef, HirId, Mutability, Pat, PatKind};
1111
use rustc_infer::infer;
1212
use rustc_infer::infer::type_variable::TypeVariableOrigin;
13-
use rustc_lint as lint;
1413
use rustc_middle::mir::interpret::ErrorHandled;
1514
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
1615
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
@@ -684,7 +683,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
684683
{
685684
// `mut x` resets the binding mode in edition <= 2021.
686685
self.tcx.emit_node_span_lint(
687-
lint::builtin::DEREFERENCING_MUT_BINDING,
686+
rustc_lint::builtin::DEREFERENCING_MUT_BINDING,
688687
pat.hir_id,
689688
pat.span,
690689
errors::DereferencingMutBinding { span: pat.span },

compiler/rustc_interface/src/passes.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::proc_macro_decls;
44
use crate::util;
55

66
use rustc_ast::{self as ast, visit};
7-
use rustc_borrowck as mir_borrowck;
87
use rustc_codegen_ssa::traits::CodegenBackend;
98
use rustc_data_structures::parallel;
109
use rustc_data_structures::steal::Steal;
@@ -20,7 +19,6 @@ use rustc_middle::arena::Arena;
2019
use rustc_middle::dep_graph::DepGraph;
2120
use rustc_middle::ty::{self, GlobalCtxt, RegisteredTools, TyCtxt};
2221
use rustc_middle::util::Providers;
23-
use rustc_mir_build as mir_build;
2422
use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str, validate_attr};
2523
use rustc_passes::{abi_test, hir_stats, layout_test};
2624
use rustc_resolve::Resolver;
@@ -616,8 +614,8 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
616614
proc_macro_decls::provide(providers);
617615
rustc_const_eval::provide(providers);
618616
rustc_middle::hir::provide(providers);
619-
mir_borrowck::provide(providers);
620-
mir_build::provide(providers);
617+
rustc_borrowck::provide(providers);
618+
rustc_mir_build::provide(providers);
621619
rustc_mir_transform::provide(providers);
622620
rustc_monomorphize::provide(providers);
623621
rustc_privacy::provide(providers);

compiler/rustc_interface/src/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_span::source_map::{RealFileLoader, SourceMapInputs};
2020
use rustc_span::symbol::sym;
2121
use rustc_span::{FileName, SourceFileHashAlgorithm};
2222
use rustc_target::spec::{
23-
CodeModel, LinkerFlavorCli, MergeFunctions, PanicStrategy, RelocModel, WasmCAbi,
23+
CodeModel, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, WasmCAbi,
2424
};
2525
use rustc_target::spec::{RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel};
2626
use std::collections::{BTreeMap, BTreeSet};
@@ -809,6 +809,7 @@ fn test_unstable_options_tracking_hash() {
809809
tracked!(no_profiler_runtime, true);
810810
tracked!(no_trait_vptr, true);
811811
tracked!(no_unique_section_names, true);
812+
tracked!(on_broken_pipe, OnBrokenPipe::Kill);
812813
tracked!(oom, OomStrategy::Panic);
813814
tracked!(osx_rpath_install_name, true);
814815
tracked!(packed_bundled_libs, true);

compiler/rustc_interface/src/util.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@ use rustc_data_structures::sync;
77
use rustc_metadata::{load_symbol_from_dylib, DylibError};
88
use rustc_middle::ty::CurrentGcx;
99
use rustc_parse::validate_attr;
10-
use rustc_session as session;
11-
use rustc_session::config::{Cfg, OutFileName, OutputFilenames, OutputTypes};
10+
use rustc_session::config::{host_triple, Cfg, OutFileName, OutputFilenames, OutputTypes};
1211
use rustc_session::filesearch::sysroot_candidates;
1312
use rustc_session::lint::{self, BuiltinLintDiag, LintBuffer};
14-
use rustc_session::{filesearch, Session};
13+
use rustc_session::output::{categorize_crate_type, CRATE_TYPES};
14+
use rustc_session::{filesearch, EarlyDiagCtxt, Session};
1515
use rustc_span::edit_distance::find_best_match_for_name;
1616
use rustc_span::edition::Edition;
1717
use rustc_span::source_map::SourceMapInputs;
1818
use rustc_span::symbol::sym;
1919
use rustc_target::spec::Target;
20-
use session::output::{categorize_crate_type, CRATE_TYPES};
21-
use session::EarlyDiagCtxt;
2220
use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
2321
use std::path::{Path, PathBuf};
2422
use std::sync::atomic::{AtomicBool, Ordering};
@@ -286,7 +284,7 @@ fn get_codegen_sysroot(
286284
"cannot load the default codegen backend twice"
287285
);
288286

289-
let target = session::config::host_triple();
287+
let target = host_triple();
290288
let sysroot_candidates = sysroot_candidates();
291289

292290
let sysroot = iter::once(sysroot)

compiler/rustc_middle/src/traits/solve.rs

+2
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ pub enum GoalSource {
273273
/// they are from an impl where-clause. This is necessary due to
274274
/// backwards compatability, cc trait-system-refactor-initiatitive#70.
275275
ImplWhereBound,
276+
/// Instantiating a higher-ranked goal and re-proving it.
277+
InstantiateHigherRanked,
276278
}
277279

278280
/// Possible ways the given goal can be proven.

compiler/rustc_middle/src/traits/solve/inspect/format.rs

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
127127
let source = match source {
128128
GoalSource::Misc => "misc",
129129
GoalSource::ImplWhereBound => "impl where-bound",
130+
GoalSource::InstantiateHigherRanked => "higher-ranked goal",
130131
};
131132
writeln!(this.f, "ADDED GOAL ({source}): {goal:?}")?
132133
}

compiler/rustc_passes/messages.ftl

-3
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,6 @@ passes_transparent_incompatible =
695695
passes_undefined_naked_function_abi =
696696
Rust ABI is unsupported in naked functions
697697
698-
passes_unix_sigpipe_values =
699-
valid values for `#[unix_sigpipe = "..."]` are `inherit`, `sig_ign`, or `sig_dfl`
700-
701698
passes_unknown_external_lang_item =
702699
unknown external lang item: `{$lang_item}`
703700

0 commit comments

Comments
 (0)