Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #138873

Merged
merged 29 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a56b1d2
fix missing rustfmt and clippy for msi
heiseish Oct 7, 2024
a0abd61
fix missing rustfmt for apple darwin
heiseish Oct 7, 2024
43152ad
wix: allow to skip more components
klensy Nov 16, 2024
55239b5
adjust comment
heiseish Mar 17, 2025
0ee9456
fix download-llvm logic for subtree sync branches
RalfJung Mar 17, 2025
6362851
[bootstrap] Distribute split debuginfo if present
wesleywiser May 1, 2024
3bfb6af
Test windows file type equality
ChrisDenton Mar 18, 2025
6b2fa32
Windows: fix FileType PartialEq implementation
ChrisDenton Mar 18, 2025
b54ca0e
Add a MIR pre-codegen test for tuple comparisons
scottmcm Mar 6, 2025
35248c6
Add chaining versions of lt/le/gt/ge and use them in tuple PartialOrd
scottmcm Mar 6, 2025
521d0c4
Cache current_dll_path output
bjorn3 Mar 21, 2025
63cfd47
Don't attempt to export compiler-builtins symbols from rust dylibs
bjorn3 Feb 27, 2025
530ab61
Also check for compiler-builtins in linked_symbols
bjorn3 Mar 21, 2025
b46412f
rustdoc: be more strict about "Methods from Deref"
lolbinarycat Mar 16, 2025
575f129
Obligation::as_goal
compiler-errors Mar 22, 2025
d588bc2
Don't super fold const in Resolver
compiler-errors Mar 22, 2025
fad34c6
Explicitly don't fold coroutine obligations in writeback
compiler-errors Mar 23, 2025
7781346
Stop using specialization for this
scottmcm Mar 23, 2025
95181ae
Update `compiler-builtins` to 0.1.152
tgross35 Mar 20, 2025
95994f9
Rollup merge of #137593 - RalfJung:subtree-sync-download-llvm, r=Mark…
jhpratt Mar 24, 2025
9a243cf
Rollup merge of #137736 - bjorn3:compiler_builtins_export_fix, r=petr…
jhpratt Mar 24, 2025
1ba9b78
Rollup merge of #138135 - scottmcm:chaining-ord, r=Mark-Simulacrum
jhpratt Mar 24, 2025
66f2a19
Rollup merge of #138321 - wesleywiser:bootstrap_package_pdbs, r=onur-…
jhpratt Mar 24, 2025
abc6784
Rollup merge of #138574 - lolbinarycat:rustdoc-deref-24686-v2, r=Guil…
jhpratt Mar 24, 2025
0fc6279
Rollup merge of #138606 - heiseish:131365-extended, r=Mark-Simulacrum
jhpratt Mar 24, 2025
8e30df7
Rollup merge of #138671 - ChrisDenton:filetype, r=joshtriplett
jhpratt Mar 24, 2025
b406d9a
Rollup merge of #138728 - tgross35:update-builtins, r=tgross35
jhpratt Mar 24, 2025
ab138e6
Rollup merge of #138783 - bjorn3:cache_current_dll_path, r=lqd
jhpratt Mar 24, 2025
0e95f96
Rollup merge of #138846 - compiler-errors:stall-prereqs, r=lcnr
jhpratt Mar 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ index 7165c3e48af..968552ad435 100644

[dependencies]
core = { path = "../core", public = true }
-compiler_builtins = { version = "=0.1.151", features = ['rustc-dep-of-std'] }
+compiler_builtins = { version = "=0.1.151", features = ['rustc-dep-of-std', 'no-f16-f128'] }
-compiler_builtins = { version = "=0.1.152", features = ['rustc-dep-of-std'] }
+compiler_builtins = { version = "=0.1.152", features = ['rustc-dep-of-std', 'no-f16-f128'] }

[features]
compiler-builtins-mem = ['compiler_builtins/mem']
Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,10 @@ fn exported_symbols_for_non_proc_macro(tcx: TyCtxt<'_>, crate_type: CrateType) -
let mut symbols = Vec::new();
let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| {
if info.level.is_below_threshold(export_threshold) {
// Do not export mangled symbols from cdylibs and don't attempt to export compiler-builtins
// from any cdylib. The latter doesn't work anyway as we use hidden visibility for
// compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning.
if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum) {
symbols.push(symbol_export::exporting_symbol_name_for_instance_in_crate(
tcx, symbol, cnum,
));
Expand Down Expand Up @@ -1821,7 +1824,9 @@ pub(crate) fn linked_symbols(

let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| {
if info.level.is_below_threshold(export_threshold) || info.used {
if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum)
|| info.used
{
symbols.push((
symbol_export::linking_symbol_name_for_instance_in_crate(tcx, symbol, cnum),
info.kind,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! A utility module to inspect currently ambiguous obligations in the current context.

use rustc_infer::traits::{self, ObligationCause, PredicateObligations};
use rustc_middle::traits::solve::{Goal, GoalSource};
use rustc_middle::traits::solve::GoalSource;
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
use rustc_span::Span;
use rustc_trait_selection::solve::inspect::{
Expand Down Expand Up @@ -85,7 +85,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
root_cause: &obligation.cause,
};

let goal = Goal::new(self.tcx, obligation.param_env, obligation.predicate);
let goal = obligation.as_goal();
self.visit_proof_tree(goal, &mut visitor);
}

Expand Down
50 changes: 32 additions & 18 deletions compiler/rustc_hir_typeck/src/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
let fcx_typeck_results = self.fcx.typeck_results.borrow();
assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
for (predicate, cause) in &fcx_typeck_results.coroutine_stalled_predicates {
let (predicate, cause) = self.resolve((*predicate, cause.clone()), &cause.span);
let (predicate, cause) =
self.resolve_coroutine_predicate((*predicate, cause.clone()), &cause.span);
self.typeck_results.coroutine_stalled_predicates.insert((predicate, cause));
}
}
Expand Down Expand Up @@ -730,7 +731,25 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
T: TypeFoldable<TyCtxt<'tcx>>,
{
let value = self.fcx.resolve_vars_if_possible(value);
let value = value.fold_with(&mut Resolver::new(self.fcx, span, self.body));
let value = value.fold_with(&mut Resolver::new(self.fcx, span, self.body, true));
assert!(!value.has_infer());

// We may have introduced e.g. `ty::Error`, if inference failed, make sure
// to mark the `TypeckResults` as tainted in that case, so that downstream
// users of the typeck results don't produce extra errors, or worse, ICEs.
if let Err(guar) = value.error_reported() {
self.typeck_results.tainted_by_errors = Some(guar);
}

value
}

fn resolve_coroutine_predicate<T>(&mut self, value: T, span: &dyn Locatable) -> T
where
T: TypeFoldable<TyCtxt<'tcx>>,
{
let value = self.fcx.resolve_vars_if_possible(value);
let value = value.fold_with(&mut Resolver::new(self.fcx, span, self.body, false));
assert!(!value.has_infer());

// We may have introduced e.g. `ty::Error`, if inference failed, make sure
Expand Down Expand Up @@ -774,8 +793,9 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
fcx: &'cx FnCtxt<'cx, 'tcx>,
span: &'cx dyn Locatable,
body: &'tcx hir::Body<'tcx>,
should_normalize: bool,
) -> Resolver<'cx, 'tcx> {
Resolver { fcx, span, body, should_normalize: fcx.next_trait_solver() }
Resolver { fcx, span, body, should_normalize }
}

fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) -> ErrorGuaranteed {
Expand Down Expand Up @@ -805,10 +825,9 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
T: Into<ty::GenericArg<'tcx>> + TypeSuperFoldable<TyCtxt<'tcx>> + Copy,
{
let tcx = self.fcx.tcx;
// We must deeply normalize in the new solver, since later lints
// expect that types that show up in the typeck are fully
// normalized.
let mut value = if self.should_normalize {
// We must deeply normalize in the new solver, since later lints expect
// that types that show up in the typeck are fully normalized.
let mut value = if self.should_normalize && self.fcx.next_trait_solver() {
let body_id = tcx.hir_body_owner_def_id(self.body.id());
let cause = ObligationCause::misc(self.span.to_span(tcx), body_id);
let at = self.fcx.at(&cause, self.fcx.param_env);
Expand Down Expand Up @@ -864,20 +883,15 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
}

fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
self.handle_term(ct, ty::Const::outer_exclusive_binder, |tcx, guar| {
ty::Const::new_error(tcx, guar)
})
.super_fold_with(self)
self.handle_term(ct, ty::Const::outer_exclusive_binder, ty::Const::new_error)
}

fn fold_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ty::Predicate<'tcx> {
// Do not normalize predicates in the new solver. The new solver is
// supposed to handle unnormalized predicates and incorrectly normalizing
// them can be unsound, e.g. for `WellFormed` predicates.
let prev = mem::replace(&mut self.should_normalize, false);
let predicate = predicate.super_fold_with(self);
self.should_normalize = prev;
predicate
assert!(
!self.should_normalize,
"normalizing predicates in writeback is not generally sound"
);
predicate.super_fold_with(self)
}
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_infer/src/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ impl<'tcx> InferCtxt<'tcx> {
.eq(DefineOpaqueTypes::Yes, prev, hidden_ty)?
.obligations
.into_iter()
// FIXME: Shuttling between obligations and goals is awkward.
.map(Goal::from),
.map(|obligation| obligation.as_goal()),
);
}
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_infer/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ pub struct Obligation<'tcx, T> {
pub recursion_depth: usize,
}

impl<'tcx, T: Copy> Obligation<'tcx, T> {
pub fn as_goal(&self) -> solve::Goal<'tcx, T> {
solve::Goal { param_env: self.param_env, predicate: self.predicate }
}
}

impl<'tcx, T: PartialEq> PartialEq<Obligation<'tcx, T>> for Obligation<'tcx, T> {
#[inline]
fn eq(&self, other: &Obligation<'tcx, T>) -> bool {
Expand All @@ -75,12 +81,6 @@ impl<T: Hash> Hash for Obligation<'_, T> {
}
}

impl<'tcx, P> From<Obligation<'tcx, P>> for solve::Goal<'tcx, P> {
fn from(value: Obligation<'tcx, P>) -> Self {
solve::Goal { param_env: value.param_env, predicate: value.predicate }
}
}

pub type PredicateObligation<'tcx> = Obligation<'tcx, ty::Predicate<'tcx>>;
pub type TraitObligation<'tcx> = Obligation<'tcx, ty::TraitPredicate<'tcx>>;
pub type PolyTraitObligation<'tcx> = Obligation<'tcx, ty::PolyTraitPredicate<'tcx>>;
Expand Down
122 changes: 66 additions & 56 deletions compiler/rustc_session/src/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,66 +60,76 @@ pub fn make_target_bin_path(sysroot: &Path, target_triple: &str) -> PathBuf {

#[cfg(unix)]
fn current_dll_path() -> Result<PathBuf, String> {
use std::ffi::{CStr, OsStr};
use std::os::unix::prelude::*;

#[cfg(not(target_os = "aix"))]
unsafe {
let addr = current_dll_path as usize as *mut _;
let mut info = std::mem::zeroed();
if libc::dladdr(addr, &mut info) == 0 {
return Err("dladdr failed".into());
}
if info.dli_fname.is_null() {
return Err("dladdr returned null pointer".into());
}
let bytes = CStr::from_ptr(info.dli_fname).to_bytes();
let os = OsStr::from_bytes(bytes);
Ok(PathBuf::from(os))
}

#[cfg(target_os = "aix")]
unsafe {
// On AIX, the symbol `current_dll_path` references a function descriptor.
// A function descriptor is consisted of (See https://reviews.llvm.org/D62532)
// * The address of the entry point of the function.
// * The TOC base address for the function.
// * The environment pointer.
// The function descriptor is in the data section.
let addr = current_dll_path as u64;
let mut buffer = vec![std::mem::zeroed::<libc::ld_info>(); 64];
loop {
if libc::loadquery(
libc::L_GETINFO,
buffer.as_mut_ptr() as *mut u8,
(size_of::<libc::ld_info>() * buffer.len()) as u32,
) >= 0
{
break;
} else {
if std::io::Error::last_os_error().raw_os_error().unwrap() != libc::ENOMEM {
return Err("loadquery failed".into());
use std::sync::OnceLock;

// This is somewhat expensive relative to other work when compiling `fn main() {}` as `dladdr`
// needs to iterate over the symbol table of librustc_driver.so until it finds a match.
// As such cache this to avoid recomputing if we try to get the sysroot in multiple places.
static CURRENT_DLL_PATH: OnceLock<Result<PathBuf, String>> = OnceLock::new();
CURRENT_DLL_PATH
.get_or_init(|| {
use std::ffi::{CStr, OsStr};
use std::os::unix::prelude::*;

#[cfg(not(target_os = "aix"))]
unsafe {
let addr = current_dll_path as usize as *mut _;
let mut info = std::mem::zeroed();
if libc::dladdr(addr, &mut info) == 0 {
return Err("dladdr failed".into());
}
buffer.resize(buffer.len() * 2, std::mem::zeroed::<libc::ld_info>());
}
}
let mut current = buffer.as_mut_ptr() as *mut libc::ld_info;
loop {
let data_base = (*current).ldinfo_dataorg as u64;
let data_end = data_base + (*current).ldinfo_datasize;
if (data_base..data_end).contains(&addr) {
let bytes = CStr::from_ptr(&(*current).ldinfo_filename[0]).to_bytes();
if info.dli_fname.is_null() {
return Err("dladdr returned null pointer".into());
}
let bytes = CStr::from_ptr(info.dli_fname).to_bytes();
let os = OsStr::from_bytes(bytes);
return Ok(PathBuf::from(os));
Ok(PathBuf::from(os))
}
if (*current).ldinfo_next == 0 {
break;

#[cfg(target_os = "aix")]
unsafe {
// On AIX, the symbol `current_dll_path` references a function descriptor.
// A function descriptor is consisted of (See https://reviews.llvm.org/D62532)
// * The address of the entry point of the function.
// * The TOC base address for the function.
// * The environment pointer.
// The function descriptor is in the data section.
let addr = current_dll_path as u64;
let mut buffer = vec![std::mem::zeroed::<libc::ld_info>(); 64];
loop {
if libc::loadquery(
libc::L_GETINFO,
buffer.as_mut_ptr() as *mut u8,
(size_of::<libc::ld_info>() * buffer.len()) as u32,
) >= 0
{
break;
} else {
if std::io::Error::last_os_error().raw_os_error().unwrap() != libc::ENOMEM {
return Err("loadquery failed".into());
}
buffer.resize(buffer.len() * 2, std::mem::zeroed::<libc::ld_info>());
}
}
let mut current = buffer.as_mut_ptr() as *mut libc::ld_info;
loop {
let data_base = (*current).ldinfo_dataorg as u64;
let data_end = data_base + (*current).ldinfo_datasize;
if (data_base..data_end).contains(&addr) {
let bytes = CStr::from_ptr(&(*current).ldinfo_filename[0]).to_bytes();
let os = OsStr::from_bytes(bytes);
return Ok(PathBuf::from(os));
}
if (*current).ldinfo_next == 0 {
break;
}
current = (current as *mut i8).offset((*current).ldinfo_next as isize)
as *mut libc::ld_info;
}
return Err(format!("current dll's address {} is not in the load map", addr));
}
current =
(current as *mut i8).offset((*current).ldinfo_next as isize) as *mut libc::ld_info;
}
return Err(format!("current dll's address {} is not in the load map", addr));
}
})
.clone()
}

#[cfg(windows)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/solve/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
) -> Option<Vec<Goal<'tcx, ty::Predicate<'tcx>>>> {
crate::traits::wf::unnormalized_obligations(&self.0, param_env, arg, DUMMY_SP, CRATE_DEF_ID)
.map(|obligations| {
obligations.into_iter().map(|obligation| obligation.into()).collect()
obligations.into_iter().map(|obligation| obligation.as_goal()).collect()
})
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/solve/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<'tcx> ObligationStorage<'tcx> {
// change.
// FIXME: <https://github.com/Gankra/thin-vec/pull/66> is merged, this can be removed.
self.overflowed.extend(ExtractIf::new(&mut self.pending, |o| {
let goal = o.clone().into();
let goal = o.as_goal();
let result = <&SolverDelegate<'tcx>>::from(infcx)
.evaluate_root_goal(goal, GenerateProofTree::No, o.cause.span)
.0;
Expand Down Expand Up @@ -161,7 +161,7 @@ where

let mut has_changed = false;
for obligation in self.obligations.unstalled_for_select() {
let goal = obligation.clone().into();
let goal = obligation.as_goal();
let result = <&SolverDelegate<'tcx>>::from(infcx)
.evaluate_root_goal(goal, GenerateProofTree::No, obligation.cause.span)
.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::{bug, span_bug};
use rustc_next_trait_solver::solve::{GenerateProofTree, SolverDelegateEvalExt as _};
use rustc_type_ir::solve::{Goal, NoSolution};
use rustc_type_ir::solve::NoSolution;
use tracing::{instrument, trace};

use crate::solve::Certainty;
Expand Down Expand Up @@ -89,7 +89,7 @@ pub(super) fn fulfillment_error_for_stalled<'tcx>(
let (code, refine_obligation) = infcx.probe(|_| {
match <&SolverDelegate<'tcx>>::from(infcx)
.evaluate_root_goal(
root_obligation.clone().into(),
root_obligation.as_goal(),
GenerateProofTree::No,
root_obligation.cause.span,
)
Expand Down Expand Up @@ -155,7 +155,7 @@ fn find_best_leaf_obligation<'tcx>(
.fudge_inference_if_ok(|| {
infcx
.visit_proof_tree(
obligation.clone().into(),
obligation.as_goal(),
&mut BestObligation { obligation: obligation.clone(), consider_ambiguities },
)
.break_value()
Expand Down Expand Up @@ -245,7 +245,7 @@ impl<'tcx> BestObligation<'tcx> {
{
let nested_goal = candidate.instantiate_proof_tree_for_nested_goal(
GoalSource::Misc,
Goal::new(infcx.tcx, obligation.param_env, obligation.predicate),
obligation.as_goal(),
self.span(),
);
// Skip nested goals that aren't the *reason* for our goal's failure.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ fn compute_intercrate_ambiguity_causes<'tcx>(
let mut causes: FxIndexSet<IntercrateAmbiguityCause<'tcx>> = Default::default();

for obligation in obligations {
search_ambiguity_causes(infcx, obligation.clone().into(), &mut causes);
search_ambiguity_causes(infcx, obligation.as_goal(), &mut causes);
}

causes
Expand Down
4 changes: 2 additions & 2 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.151"
version = "0.1.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abc30f1766d387c35f2405e586d3e7a88230dc728ff78cd1d0bc59ae0b63154b"
checksum = "2153cf213eb259361567720ce55f6446f17acd0ccca87fb6dc05360578228a58"
dependencies = [
"cc",
"rustc-std-workspace-core",
Expand Down
Loading
Loading