Skip to content

Commit 2a023bf

Browse files
committed
Auto merge of #143746 - matthiaskrgr:rollup-yaojj7t, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #143446 (use `--dynamic-list` for exporting executable symbols) - #143590 (Fix weird rustdoc output when single and glob reexport conflict on a name) - #143599 (emit `.att_syntax` when global/naked asm use that option) - #143615 (Fix handling of no_std targets in `doc::Std` step) - #143632 (fix: correct parameter names in LLVMRustBuildMinNum and LLVMRustBuildMaxNum FFI declarations) - #143640 (Constify `Fn*` traits) - #143651 (Win: Use exceptions with empty data for SEH panic exception copies instead of a new panic) - #143660 (Disable docs for `compiler-builtins` and `sysroot`) - #143665 ([rustdoc-json] Add tests for `#[doc(hidden)]` handling of items.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a9f2aad + b5d1b92 commit 2a023bf

Some content is hidden

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

47 files changed

+648
-767
lines changed

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,19 @@ impl<'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
384384
) {
385385
let asm_arch = self.tcx.sess.asm_arch.unwrap();
386386

387-
// Default to Intel syntax on x86
388-
let intel_syntax = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64)
389-
&& !options.contains(InlineAsmOptions::ATT_SYNTAX);
390-
391387
// Build the template string
392388
let mut template_str = String::new();
393-
if intel_syntax {
394-
template_str.push_str(".intel_syntax\n");
389+
390+
// On X86 platforms there are two assembly syntaxes. Rust uses intel by default,
391+
// but AT&T can be specified explicitly.
392+
if matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64) {
393+
if options.contains(InlineAsmOptions::ATT_SYNTAX) {
394+
template_str.push_str(".att_syntax\n")
395+
} else {
396+
template_str.push_str(".intel_syntax\n")
397+
}
395398
}
399+
396400
for piece in template {
397401
match *piece {
398402
InlineAsmTemplatePiece::String(ref s) => template_str.push_str(s),
@@ -431,7 +435,11 @@ impl<'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
431435
}
432436
}
433437
}
434-
if intel_syntax {
438+
439+
// Just to play it safe, if intel was used, reset the assembly syntax to att.
440+
if matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64)
441+
&& !options.contains(InlineAsmOptions::ATT_SYNTAX)
442+
{
435443
template_str.push_str("\n.att_syntax\n");
436444
}
437445

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,12 +1980,12 @@ unsafe extern "C" {
19801980
pub(crate) fn LLVMRustBuildMinNum<'a>(
19811981
B: &Builder<'a>,
19821982
LHS: &'a Value,
1983-
LHS: &'a Value,
1983+
RHS: &'a Value,
19841984
) -> &'a Value;
19851985
pub(crate) fn LLVMRustBuildMaxNum<'a>(
19861986
B: &Builder<'a>,
19871987
LHS: &'a Value,
1988-
LHS: &'a Value,
1988+
RHS: &'a Value,
19891989
) -> &'a Value;
19901990

19911991
// Atomic Operations

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,7 @@ impl<'a> Linker for GccLinker<'a> {
800800
return;
801801
}
802802

803-
let is_windows = self.sess.target.is_like_windows;
804-
let path = tmpdir.join(if is_windows { "list.def" } else { "list" });
805-
803+
let path = tmpdir.join(if self.sess.target.is_like_windows { "list.def" } else { "list" });
806804
debug!("EXPORTED SYMBOLS:");
807805

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

@@ -835,6 +834,21 @@ impl<'a> Linker for GccLinker<'a> {
835834
if let Err(error) = res {
836835
self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error });
837836
}
837+
self.link_arg(path);
838+
} else if crate_type == CrateType::Executable && !self.sess.target.is_like_solaris {
839+
let res: io::Result<()> = try {
840+
let mut f = File::create_buffered(&path)?;
841+
writeln!(f, "{{")?;
842+
for (sym, _) in symbols {
843+
debug!(sym);
844+
writeln!(f, " {sym};")?;
845+
}
846+
writeln!(f, "}};")?;
847+
};
848+
if let Err(error) = res {
849+
self.sess.dcx().emit_fatal(errors::VersionScriptWriteFailure { error });
850+
}
851+
self.link_arg("--dynamic-list").link_arg(path);
838852
} else {
839853
// Write an LD version script
840854
let res: io::Result<()> = try {
@@ -852,18 +866,13 @@ impl<'a> Linker for GccLinker<'a> {
852866
if let Err(error) = res {
853867
self.sess.dcx().emit_fatal(errors::VersionScriptWriteFailure { error });
854868
}
855-
}
856-
857-
if self.sess.target.is_like_darwin {
858-
self.link_arg("-exported_symbols_list").link_arg(path);
859-
} else if self.sess.target.is_like_solaris {
860-
self.link_arg("-M").link_arg(path);
861-
} else if is_windows {
862-
self.link_arg(path);
863-
} else {
864-
let mut arg = OsString::from("--version-script=");
865-
arg.push(path);
866-
self.link_arg(arg).link_arg("--no-undefined-version");
869+
if self.sess.target.is_like_solaris {
870+
self.link_arg("-M").link_arg(path);
871+
} else {
872+
let mut arg = OsString::from("--version-script=");
873+
arg.push(path);
874+
self.link_arg(arg).link_arg("--no-undefined-version");
875+
}
867876
}
868877
}
869878

compiler/rustc_hir_typeck/messages.ftl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,6 @@ hir_typeck_cast_unknown_pointer = cannot cast {$to ->
8282
hir_typeck_const_continue_bad_label =
8383
`#[const_continue]` must break to a labeled block that participates in a `#[loop_match]`
8484
85-
hir_typeck_const_select_must_be_const = this argument must be a `const fn`
86-
.help = consult the documentation on `const_eval_select` for more information
87-
88-
hir_typeck_const_select_must_be_fn = this argument must be a function item
89-
.note = expected a function item, found {$ty}
90-
.help = consult the documentation on `const_eval_select` for more information
91-
9285
hir_typeck_continue_labeled_block =
9386
`continue` pointing to a labeled block
9487
.label = labeled blocks cannot be `continue`'d

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -578,29 +578,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
578578
}
579579
}
580580

581-
if let Some(def_id) = def_id
582-
&& self.tcx.def_kind(def_id) == hir::def::DefKind::Fn
583-
&& self.tcx.is_intrinsic(def_id, sym::const_eval_select)
584-
{
585-
let fn_sig = self.resolve_vars_if_possible(fn_sig);
586-
for idx in 0..=1 {
587-
let arg_ty = fn_sig.inputs()[idx + 1];
588-
let span = arg_exprs.get(idx + 1).map_or(call_expr.span, |arg| arg.span);
589-
// Check that second and third argument of `const_eval_select` must be `FnDef`, and additionally that
590-
// the second argument must be `const fn`. The first argument must be a tuple, but this is already expressed
591-
// in the function signature (`F: FnOnce<ARG>`), so I did not bother to add another check here.
592-
//
593-
// This check is here because there is currently no way to express a trait bound for `FnDef` types only.
594-
if let ty::FnDef(def_id, _args) = *arg_ty.kind() {
595-
if idx == 0 && !self.tcx.is_const_fn(def_id) {
596-
self.dcx().emit_err(errors::ConstSelectMustBeConst { span });
597-
}
598-
} else {
599-
self.dcx().emit_err(errors::ConstSelectMustBeFn { span, ty: arg_ty });
600-
}
601-
}
602-
}
603-
604581
fn_sig.output()
605582
}
606583

compiler/rustc_hir_typeck/src/errors.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -605,24 +605,6 @@ impl Subdiagnostic for RemoveSemiForCoerce {
605605
}
606606
}
607607

608-
#[derive(Diagnostic)]
609-
#[diag(hir_typeck_const_select_must_be_const)]
610-
#[help]
611-
pub(crate) struct ConstSelectMustBeConst {
612-
#[primary_span]
613-
pub span: Span,
614-
}
615-
616-
#[derive(Diagnostic)]
617-
#[diag(hir_typeck_const_select_must_be_fn)]
618-
#[note]
619-
#[help]
620-
pub(crate) struct ConstSelectMustBeFn<'a> {
621-
#[primary_span]
622-
pub span: Span,
623-
pub ty: Ty<'a>,
624-
}
625-
626608
#[derive(Diagnostic)]
627609
#[diag(hir_typeck_union_pat_multiple_fields)]
628610
pub(crate) struct UnionPatMultipleFields {

compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
529529
// process any deferred resolutions.
530530
let deferred_call_resolutions = self.remove_deferred_call_resolutions(closure_def_id);
531531
for deferred_call_resolution in deferred_call_resolutions {
532-
deferred_call_resolution.resolve(self);
532+
deferred_call_resolution.resolve(&mut FnCtxt::new(
533+
self,
534+
self.param_env,
535+
closure_def_id,
536+
));
533537
}
534538
}
535539

compiler/rustc_trait_selection/src/traits/effects.rs

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use rustc_hir::{self as hir, LangItem};
22
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes};
33
use rustc_infer::traits::{
4-
ImplDerivedHostCause, ImplSource, Obligation, ObligationCauseCode, PredicateObligation,
4+
ImplDerivedHostCause, ImplSource, Obligation, ObligationCause, ObligationCauseCode,
5+
PredicateObligation,
56
};
67
use rustc_middle::span_bug;
78
use rustc_middle::traits::query::NoSolution;
@@ -303,6 +304,9 @@ fn evaluate_host_effect_from_builtin_impls<'tcx>(
303304
) -> Result<ThinVec<PredicateObligation<'tcx>>, EvaluationFailure> {
304305
match selcx.tcx().as_lang_item(obligation.predicate.def_id()) {
305306
Some(LangItem::Destruct) => evaluate_host_effect_for_destruct_goal(selcx, obligation),
307+
Some(LangItem::Fn | LangItem::FnMut | LangItem::FnOnce) => {
308+
evaluate_host_effect_for_fn_goal(selcx, obligation)
309+
}
306310
_ => Err(EvaluationFailure::NoSolution),
307311
}
308312
}
@@ -398,6 +402,51 @@ fn evaluate_host_effect_for_destruct_goal<'tcx>(
398402
.collect())
399403
}
400404

405+
// NOTE: Keep this in sync with `extract_fn_def_from_const_callable` in the new solver.
406+
fn evaluate_host_effect_for_fn_goal<'tcx>(
407+
selcx: &mut SelectionContext<'_, 'tcx>,
408+
obligation: &HostEffectObligation<'tcx>,
409+
) -> Result<ThinVec<PredicateObligation<'tcx>>, EvaluationFailure> {
410+
let tcx = selcx.tcx();
411+
let self_ty = obligation.predicate.self_ty();
412+
413+
let (def, args) = match *self_ty.kind() {
414+
ty::FnDef(def, args) => (def, args),
415+
416+
// We may support function pointers at some point in the future
417+
ty::FnPtr(..) => return Err(EvaluationFailure::NoSolution),
418+
419+
// Closures could implement `[const] Fn`,
420+
// but they don't really need to right now.
421+
ty::Closure(..) | ty::CoroutineClosure(_, _) => {
422+
return Err(EvaluationFailure::NoSolution);
423+
}
424+
425+
// Everything else needs explicit impls or cannot have an impl
426+
_ => return Err(EvaluationFailure::NoSolution),
427+
};
428+
429+
match tcx.constness(def) {
430+
hir::Constness::Const => Ok(tcx
431+
.const_conditions(def)
432+
.instantiate(tcx, args)
433+
.into_iter()
434+
.map(|(c, span)| {
435+
let code = ObligationCauseCode::WhereClause(def, span);
436+
let cause =
437+
ObligationCause::new(obligation.cause.span, obligation.cause.body_id, code);
438+
Obligation::new(
439+
tcx,
440+
cause,
441+
obligation.param_env,
442+
c.to_host_effect_clause(tcx, obligation.predicate.constness),
443+
)
444+
})
445+
.collect()),
446+
hir::Constness::NotConst => Err(EvaluationFailure::NoSolution),
447+
}
448+
}
449+
401450
fn evaluate_host_effect_from_selection_candidate<'tcx>(
402451
selcx: &mut SelectionContext<'_, 'tcx>,
403452
obligation: &HostEffectObligation<'tcx>,

library/compiler-builtins/compiler-builtins/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ links = "compiler-rt"
1919
bench = false
2020
doctest = false
2121
test = false
22+
# make sure this crate isn't included in public standard library docs
23+
doc = false
2224

2325
[dependencies]
2426
core = { path = "../../core", optional = true }

library/core/src/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2279,7 +2279,7 @@ pub const fn const_eval_select<ARG: Tuple, F, G, RET>(
22792279
) -> RET
22802280
where
22812281
G: FnOnce<ARG, Output = RET>,
2282-
F: FnOnce<ARG, Output = RET>;
2282+
F: const FnOnce<ARG, Output = RET>;
22832283

22842284
/// A macro to make it easier to invoke const_eval_select. Use as follows:
22852285
/// ```rust,ignore (just a macro example)

0 commit comments

Comments
 (0)