Skip to content

Rollup of 9 pull requests #143746

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

Merged
merged 25 commits into from
Jul 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8a195ef
Make it possible to attach opaque string metadata to `StepMetadata`
Kobzol Jul 7, 2025
8d0c55c
Remove test hack for std crates
Kobzol Jul 7, 2025
5880a31
Add `crates` metadata to `doc::Std` step
Kobzol Jul 7, 2025
d6bc881
Fix handling of std crates for no_std targets
Kobzol Jul 7, 2025
0455577
fix: correct parameter names in LLVMRustBuildMinNum and LLVMRustBuild…
dillona Jul 8, 2025
543c860
Constify `Fn*` traits
oli-obk Jul 3, 2025
29b75a6
Fix weird rustdoc output when single and glob reexport conflict on a …
GuillaumeGomez Jul 7, 2025
b1d45f6
Remove `const_eval_select` hack
oli-obk Jul 8, 2025
96cdbb9
Win: Use exceptions with empty data for SEH panic exception copies
Fulgen301 Jul 8, 2025
6fc5d4e
emit `.att_syntax` when global/naked asm use that option
folkertdev Jul 7, 2025
87e7539
Disable docs for `compiler-builtins` and `sysroot`
cuviper Jul 8, 2025
566dc98
Add `doc library` test for a no_std target
Kobzol Jul 9, 2025
6c38d38
Add doc cross-compilation test
Kobzol Jul 9, 2025
bf6d29d
use `--dynamic-list` for exporting executable symbols
usamoi Jul 4, 2025
27fb02c
Add rustdoc JSON tests for `#[doc(hidden)]` handling of items.
obi1kenobi Jul 9, 2025
086b13d
Add regression test for #143107
GuillaumeGomez Jul 7, 2025
b11e9e3
Rollup merge of #143446 - usamoi:export-executable-symbols, r=bjorn3,…
matthiaskrgr Jul 10, 2025
05c68f3
Rollup merge of #143590 - GuillaumeGomez:reexport-shadowing, r=lolbinary
matthiaskrgr Jul 10, 2025
9e6af56
Rollup merge of #143599 - folkertdev:x86-asm-syntax-global-naked-asm,…
matthiaskrgr Jul 10, 2025
55a57fc
Rollup merge of #143615 - Kobzol:doc-std, r=jieyouxu
matthiaskrgr Jul 10, 2025
95cbacd
Rollup merge of #143632 - dillona:ffi-param-names, r=jieyouxu
matthiaskrgr Jul 10, 2025
b4089bf
Rollup merge of #143640 - oli-obk:const-fn-traits, r=compiler-errors
matthiaskrgr Jul 10, 2025
92f9480
Rollup merge of #143651 - Fulgen301:seh-exception-ptr, r=ChrisDenton
matthiaskrgr Jul 10, 2025
6c4502d
Rollup merge of #143660 - cuviper:lib-doc-false, r=tgross35
matthiaskrgr Jul 10, 2025
b5d1b92
Rollup merge of #143665 - obi1kenobi:pg/doc-hidden-tests, r=aDotInThe…
matthiaskrgr Jul 10, 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
22 changes: 15 additions & 7 deletions compiler/rustc_codegen_llvm/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,19 @@ impl<'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
) {
let asm_arch = self.tcx.sess.asm_arch.unwrap();

// Default to Intel syntax on x86
let intel_syntax = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64)
&& !options.contains(InlineAsmOptions::ATT_SYNTAX);

// Build the template string
let mut template_str = String::new();
if intel_syntax {
template_str.push_str(".intel_syntax\n");

// On X86 platforms there are two assembly syntaxes. Rust uses intel by default,
// but AT&T can be specified explicitly.
if matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64) {
if options.contains(InlineAsmOptions::ATT_SYNTAX) {
template_str.push_str(".att_syntax\n")
} else {
template_str.push_str(".intel_syntax\n")
}
}

for piece in template {
match *piece {
InlineAsmTemplatePiece::String(ref s) => template_str.push_str(s),
Expand Down Expand Up @@ -431,7 +435,11 @@ impl<'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
}
}
}
if intel_syntax {

// Just to play it safe, if intel was used, reset the assembly syntax to att.
if matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64)
&& !options.contains(InlineAsmOptions::ATT_SYNTAX)
{
template_str.push_str("\n.att_syntax\n");
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1980,12 +1980,12 @@ unsafe extern "C" {
pub(crate) fn LLVMRustBuildMinNum<'a>(
B: &Builder<'a>,
LHS: &'a Value,
LHS: &'a Value,
RHS: &'a Value,
) -> &'a Value;
pub(crate) fn LLVMRustBuildMaxNum<'a>(
B: &Builder<'a>,
LHS: &'a Value,
LHS: &'a Value,
RHS: &'a Value,
) -> &'a Value;

// Atomic Operations
Expand Down
41 changes: 25 additions & 16 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,7 @@ impl<'a> Linker for GccLinker<'a> {
return;
}

let is_windows = self.sess.target.is_like_windows;
let path = tmpdir.join(if is_windows { "list.def" } else { "list" });

let path = tmpdir.join(if self.sess.target.is_like_windows { "list.def" } else { "list" });
debug!("EXPORTED SYMBOLS:");

if self.sess.target.is_like_darwin {
Expand All @@ -817,7 +815,8 @@ impl<'a> Linker for GccLinker<'a> {
if let Err(error) = res {
self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error });
}
} else if is_windows {
self.link_arg("-exported_symbols_list").link_arg(path);
} else if self.sess.target.is_like_windows {
let res: io::Result<()> = try {
let mut f = File::create_buffered(&path)?;

Expand All @@ -835,6 +834,21 @@ impl<'a> Linker for GccLinker<'a> {
if let Err(error) = res {
self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error });
}
self.link_arg(path);
} else if crate_type == CrateType::Executable && !self.sess.target.is_like_solaris {
let res: io::Result<()> = try {
let mut f = File::create_buffered(&path)?;
writeln!(f, "{{")?;
for (sym, _) in symbols {
debug!(sym);
writeln!(f, " {sym};")?;
}
writeln!(f, "}};")?;
};
if let Err(error) = res {
self.sess.dcx().emit_fatal(errors::VersionScriptWriteFailure { error });
}
self.link_arg("--dynamic-list").link_arg(path);
} else {
// Write an LD version script
let res: io::Result<()> = try {
Expand All @@ -852,18 +866,13 @@ impl<'a> Linker for GccLinker<'a> {
if let Err(error) = res {
self.sess.dcx().emit_fatal(errors::VersionScriptWriteFailure { error });
}
}

if self.sess.target.is_like_darwin {
self.link_arg("-exported_symbols_list").link_arg(path);
} else if self.sess.target.is_like_solaris {
self.link_arg("-M").link_arg(path);
} else if is_windows {
self.link_arg(path);
} else {
let mut arg = OsString::from("--version-script=");
arg.push(path);
self.link_arg(arg).link_arg("--no-undefined-version");
if self.sess.target.is_like_solaris {
self.link_arg("-M").link_arg(path);
} else {
let mut arg = OsString::from("--version-script=");
arg.push(path);
self.link_arg(arg).link_arg("--no-undefined-version");
}
}
}

Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_hir_typeck/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ hir_typeck_cast_unknown_pointer = cannot cast {$to ->
hir_typeck_const_continue_bad_label =
`#[const_continue]` must break to a labeled block that participates in a `#[loop_match]`
hir_typeck_const_select_must_be_const = this argument must be a `const fn`
.help = consult the documentation on `const_eval_select` for more information
hir_typeck_const_select_must_be_fn = this argument must be a function item
.note = expected a function item, found {$ty}
.help = consult the documentation on `const_eval_select` for more information
hir_typeck_continue_labeled_block =
`continue` pointing to a labeled block
.label = labeled blocks cannot be `continue`'d
Expand Down
23 changes: 0 additions & 23 deletions compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,29 +578,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

if let Some(def_id) = def_id
&& self.tcx.def_kind(def_id) == hir::def::DefKind::Fn
&& self.tcx.is_intrinsic(def_id, sym::const_eval_select)
{
let fn_sig = self.resolve_vars_if_possible(fn_sig);
for idx in 0..=1 {
let arg_ty = fn_sig.inputs()[idx + 1];
let span = arg_exprs.get(idx + 1).map_or(call_expr.span, |arg| arg.span);
// Check that second and third argument of `const_eval_select` must be `FnDef`, and additionally that
// the second argument must be `const fn`. The first argument must be a tuple, but this is already expressed
// in the function signature (`F: FnOnce<ARG>`), so I did not bother to add another check here.
//
// This check is here because there is currently no way to express a trait bound for `FnDef` types only.
if let ty::FnDef(def_id, _args) = *arg_ty.kind() {
if idx == 0 && !self.tcx.is_const_fn(def_id) {
self.dcx().emit_err(errors::ConstSelectMustBeConst { span });
}
} else {
self.dcx().emit_err(errors::ConstSelectMustBeFn { span, ty: arg_ty });
}
}
}

fn_sig.output()
}

Expand Down
18 changes: 0 additions & 18 deletions compiler/rustc_hir_typeck/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,24 +605,6 @@ impl Subdiagnostic for RemoveSemiForCoerce {
}
}

#[derive(Diagnostic)]
#[diag(hir_typeck_const_select_must_be_const)]
#[help]
pub(crate) struct ConstSelectMustBeConst {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(hir_typeck_const_select_must_be_fn)]
#[note]
#[help]
pub(crate) struct ConstSelectMustBeFn<'a> {
#[primary_span]
pub span: Span,
pub ty: Ty<'a>,
}

#[derive(Diagnostic)]
#[diag(hir_typeck_union_pat_multiple_fields)]
pub(crate) struct UnionPatMultipleFields {
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_hir_typeck/src/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// process any deferred resolutions.
let deferred_call_resolutions = self.remove_deferred_call_resolutions(closure_def_id);
for deferred_call_resolution in deferred_call_resolutions {
deferred_call_resolution.resolve(self);
deferred_call_resolution.resolve(&mut FnCtxt::new(
self,
self.param_env,
closure_def_id,
));
}
}

Expand Down
51 changes: 50 additions & 1 deletion compiler/rustc_trait_selection/src/traits/effects.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use rustc_hir::{self as hir, LangItem};
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes};
use rustc_infer::traits::{
ImplDerivedHostCause, ImplSource, Obligation, ObligationCauseCode, PredicateObligation,
ImplDerivedHostCause, ImplSource, Obligation, ObligationCause, ObligationCauseCode,
PredicateObligation,
};
use rustc_middle::span_bug;
use rustc_middle::traits::query::NoSolution;
Expand Down Expand Up @@ -303,6 +304,9 @@ fn evaluate_host_effect_from_builtin_impls<'tcx>(
) -> Result<ThinVec<PredicateObligation<'tcx>>, EvaluationFailure> {
match selcx.tcx().as_lang_item(obligation.predicate.def_id()) {
Some(LangItem::Destruct) => evaluate_host_effect_for_destruct_goal(selcx, obligation),
Some(LangItem::Fn | LangItem::FnMut | LangItem::FnOnce) => {
evaluate_host_effect_for_fn_goal(selcx, obligation)
}
_ => Err(EvaluationFailure::NoSolution),
}
}
Expand Down Expand Up @@ -398,6 +402,51 @@ fn evaluate_host_effect_for_destruct_goal<'tcx>(
.collect())
}

// NOTE: Keep this in sync with `extract_fn_def_from_const_callable` in the new solver.
fn evaluate_host_effect_for_fn_goal<'tcx>(
selcx: &mut SelectionContext<'_, 'tcx>,
obligation: &HostEffectObligation<'tcx>,
) -> Result<ThinVec<PredicateObligation<'tcx>>, EvaluationFailure> {
let tcx = selcx.tcx();
let self_ty = obligation.predicate.self_ty();

let (def, args) = match *self_ty.kind() {
ty::FnDef(def, args) => (def, args),

// We may support function pointers at some point in the future
ty::FnPtr(..) => return Err(EvaluationFailure::NoSolution),

// Closures could implement `[const] Fn`,
// but they don't really need to right now.
ty::Closure(..) | ty::CoroutineClosure(_, _) => {
return Err(EvaluationFailure::NoSolution);
}

// Everything else needs explicit impls or cannot have an impl
_ => return Err(EvaluationFailure::NoSolution),
};

match tcx.constness(def) {
hir::Constness::Const => Ok(tcx
.const_conditions(def)
.instantiate(tcx, args)
.into_iter()
.map(|(c, span)| {
let code = ObligationCauseCode::WhereClause(def, span);
let cause =
ObligationCause::new(obligation.cause.span, obligation.cause.body_id, code);
Obligation::new(
tcx,
cause,
obligation.param_env,
c.to_host_effect_clause(tcx, obligation.predicate.constness),
)
})
.collect()),
hir::Constness::NotConst => Err(EvaluationFailure::NoSolution),
}
}

fn evaluate_host_effect_from_selection_candidate<'tcx>(
selcx: &mut SelectionContext<'_, 'tcx>,
obligation: &HostEffectObligation<'tcx>,
Expand Down
2 changes: 2 additions & 0 deletions library/compiler-builtins/compiler-builtins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ links = "compiler-rt"
bench = false
doctest = false
test = false
# make sure this crate isn't included in public standard library docs
doc = false

[dependencies]
core = { path = "../../core", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,7 @@ pub const fn const_eval_select<ARG: Tuple, F, G, RET>(
) -> RET
where
G: FnOnce<ARG, Output = RET>,
F: FnOnce<ARG, Output = RET>;
F: const FnOnce<ARG, Output = RET>;

/// A macro to make it easier to invoke const_eval_select. Use as follows:
/// ```rust,ignore (just a macro example)
Expand Down
34 changes: 21 additions & 13 deletions library/core/src/ops/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ use crate::marker::Tuple;
)]
#[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use = "closures are lazy and do nothing unless called"]
// FIXME(const_trait_impl) #[const_trait]
#[const_trait]
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
pub trait Fn<Args: Tuple>: FnMut<Args> {
/// Performs the call operation.
#[unstable(feature = "fn_traits", issue = "29625")]
Expand Down Expand Up @@ -159,7 +160,8 @@ pub trait Fn<Args: Tuple>: FnMut<Args> {
)]
#[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use = "closures are lazy and do nothing unless called"]
// FIXME(const_trait_impl) #[const_trait]
#[const_trait]
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
pub trait FnMut<Args: Tuple>: FnOnce<Args> {
/// Performs the call operation.
#[unstable(feature = "fn_traits", issue = "29625")]
Expand Down Expand Up @@ -238,7 +240,8 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> {
)]
#[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use = "closures are lazy and do nothing unless called"]
// FIXME(const_trait_impl) #[const_trait]
#[const_trait]
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
pub trait FnOnce<Args: Tuple> {
/// The returned type after the call operator is used.
#[lang = "fn_once_output"]
Expand All @@ -254,29 +257,32 @@ mod impls {
use crate::marker::Tuple;

#[stable(feature = "rust1", since = "1.0.0")]
impl<A: Tuple, F: ?Sized> Fn<A> for &F
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
impl<A: Tuple, F: ?Sized> const Fn<A> for &F
where
F: Fn<A>,
F: ~const Fn<A>,
{
extern "rust-call" fn call(&self, args: A) -> F::Output {
(**self).call(args)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<A: Tuple, F: ?Sized> FnMut<A> for &F
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
impl<A: Tuple, F: ?Sized> const FnMut<A> for &F
where
F: Fn<A>,
F: ~const Fn<A>,
{
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
(**self).call(args)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<A: Tuple, F: ?Sized> FnOnce<A> for &F
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
impl<A: Tuple, F: ?Sized> const FnOnce<A> for &F
where
F: Fn<A>,
F: ~const Fn<A>,
{
type Output = F::Output;

Expand All @@ -286,19 +292,21 @@ mod impls {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<A: Tuple, F: ?Sized> FnMut<A> for &mut F
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
impl<A: Tuple, F: ?Sized> const FnMut<A> for &mut F
where
F: FnMut<A>,
F: ~const FnMut<A>,
{
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
(*self).call_mut(args)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<A: Tuple, F: ?Sized> FnOnce<A> for &mut F
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
impl<A: Tuple, F: ?Sized> const FnOnce<A> for &mut F
where
F: FnMut<A>,
F: ~const FnMut<A>,
{
type Output = F::Output;
extern "rust-call" fn call_once(self, args: A) -> F::Output {
Expand Down
Loading