Auto merge of #123004 - matthiaskrgr:rollup-s3v4p50, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #122737 (conditionally ignore fatal diagnostic in the SilentEmitter)
 - #122757 (Fixed the `private-dependency` bug)
 - #122886 (add test for #90192)
 - #122937 (Unbox and unwrap the contents of `StatementKind::Coverage`)
 - #122949 (Add a regression test for #117310)
 - #122962 (Track run-make-support lib in common inputs stamp)
 - #122977 (Rename `Arguments::as_const_str` to `as_statically_known_str`)
 - #122983 (Fix build failure on ARM/AArch64/PowerPC/RISC-V FreeBSD/NetBSD)
 - #122984 (panic-in-panic-hook: formatting a message that's just a string is risk-free)
 - #122992 (std:🧵 refine available_parallelism for solaris/illumos.)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-03-24 16:09:51 +00:00
commit d36bdd19f2
33 changed files with 176 additions and 96 deletions

View File

@ -1,11 +1,11 @@
use rustc_codegen_ssa::traits::CoverageInfoBuilderMethods;
use rustc_middle::mir::Coverage;
use rustc_middle::mir::coverage::CoverageKind;
use rustc_middle::ty::Instance;
use crate::builder::Builder;
impl<'a, 'gcc, 'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
fn add_coverage(&mut self, _instance: Instance<'tcx>, _coverage: &Coverage) {
fn add_coverage(&mut self, _instance: Instance<'tcx>, _kind: &CoverageKind) {
// TODO(antoyo)
}
}

View File

@ -14,7 +14,6 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_llvm::RustString;
use rustc_middle::bug;
use rustc_middle::mir::coverage::CoverageKind;
use rustc_middle::mir::Coverage;
use rustc_middle::ty::layout::HasTyCtxt;
use rustc_middle::ty::Instance;
@ -75,7 +74,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
#[instrument(level = "debug", skip(self))]
fn add_coverage(&mut self, instance: Instance<'tcx>, coverage: &Coverage) {
fn add_coverage(&mut self, instance: Instance<'tcx>, kind: &CoverageKind) {
// Our caller should have already taken care of inlining subtleties,
// so we can assume that counter/expression IDs in this coverage
// statement are meaningful for the given instance.
@ -98,7 +97,6 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
.entry(instance)
.or_insert_with(|| FunctionCoverageCollector::new(instance, function_coverage_info));
let Coverage { kind } = coverage;
match *kind {
CoverageKind::SpanMarker | CoverageKind::BlockMarker { .. } => unreachable!(
"marker statement {kind:?} should have been removed by CleanupPostBorrowck"

View File

@ -1,12 +1,12 @@
use crate::traits::*;
use rustc_middle::mir::Coverage;
use rustc_middle::mir::coverage::CoverageKind;
use rustc_middle::mir::SourceScope;
use super::FunctionCx;
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
pub fn codegen_coverage(&self, bx: &mut Bx, coverage: &Coverage, scope: SourceScope) {
pub fn codegen_coverage(&self, bx: &mut Bx, kind: &CoverageKind, scope: SourceScope) {
// Determine the instance that coverage data was originally generated for.
let instance = if let Some(inlined) = scope.inlined_instance(&self.mir.source_scopes) {
self.monomorphize(inlined)
@ -15,6 +15,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
};
// Handle the coverage info in a backend-specific way.
bx.add_coverage(instance, coverage);
bx.add_coverage(instance, kind);
}
}

View File

@ -64,8 +64,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
cg_indirect_place.storage_dead(bx);
}
}
mir::StatementKind::Coverage(box ref coverage) => {
self.codegen_coverage(bx, coverage, statement.source_info.scope);
mir::StatementKind::Coverage(ref kind) => {
self.codegen_coverage(bx, kind, statement.source_info.scope);
}
mir::StatementKind::Intrinsic(box NonDivergingIntrinsic::Assume(ref op)) => {
if !matches!(bx.tcx().sess.opts.optimize, OptLevel::No | OptLevel::Less) {

View File

@ -1,5 +1,5 @@
use super::BackendTypes;
use rustc_middle::mir::Coverage;
use rustc_middle::mir::coverage::CoverageKind;
use rustc_middle::ty::Instance;
pub trait CoverageInfoBuilderMethods<'tcx>: BackendTypes {
@ -7,5 +7,5 @@ pub trait CoverageInfoBuilderMethods<'tcx>: BackendTypes {
///
/// This can potentially be a no-op in backends that don't support
/// coverage instrumentation.
fn add_coverage(&mut self, instance: Instance<'tcx>, coverage: &Coverage);
fn add_coverage(&mut self, instance: Instance<'tcx>, kind: &CoverageKind);
}

View File

@ -346,8 +346,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
self.fail(location, format!("explicit `{kind:?}` is forbidden"));
}
}
StatementKind::Coverage(coverage) => {
let kind = &coverage.kind;
StatementKind::Coverage(kind) => {
if self.mir_phase >= MirPhase::Analysis(AnalysisPhase::PostCleanup)
&& let CoverageKind::BlockMarker { .. } | CoverageKind::SpanMarker { .. } = kind
{

View File

@ -541,6 +541,7 @@ pub struct SilentEmitter {
pub fallback_bundle: LazyFallbackBundle,
pub fatal_dcx: DiagCtxt,
pub fatal_note: Option<String>,
pub emit_fatal_diagnostic: bool,
}
impl Translate for SilentEmitter {
@ -561,7 +562,7 @@ impl Emitter for SilentEmitter {
}
fn emit_diagnostic(&mut self, mut diag: DiagInner) {
if diag.level == Level::Fatal {
if self.emit_fatal_diagnostic && diag.level == Level::Fatal {
if let Some(fatal_note) = &self.fatal_note {
diag.sub(Level::Note, fatal_note.clone(), MultiSpan::new());
}

View File

@ -612,12 +612,18 @@ impl DiagCtxt {
Self { inner: Lock::new(DiagCtxtInner::new(emitter)) }
}
pub fn make_silent(&mut self, fallback_bundle: LazyFallbackBundle, fatal_note: Option<String>) {
pub fn make_silent(
&mut self,
fallback_bundle: LazyFallbackBundle,
fatal_note: Option<String>,
emit_fatal_diagnostic: bool,
) {
self.wrap_emitter(|old_dcx| {
Box::new(emitter::SilentEmitter {
fallback_bundle,
fatal_dcx: DiagCtxt { inner: Lock::new(old_dcx) },
fatal_note,
emit_fatal_diagnostic,
})
});
}

View File

@ -48,6 +48,7 @@ pub(crate) fn parse_cfg(dcx: &DiagCtxt, cfgs: Vec<String>) -> Cfg {
let psess = ParseSess::with_silent_emitter(
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
format!("this error occurred on the command line: `--cfg={s}`"),
true,
);
let filename = FileName::cfg_spec_source_code(&s);
@ -111,6 +112,7 @@ pub(crate) fn parse_check_cfg(dcx: &DiagCtxt, specs: Vec<String>) -> CheckCfg {
let psess = ParseSess::with_silent_emitter(
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
format!("this error occurred on the command line: `--check-cfg={s}`"),
true,
);
let filename = FileName::cfg_spec_source_code(&s);

View File

@ -389,6 +389,15 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
None
}
// The `dependency` type is determined by the command line arguments(`--extern`) and
// `private_dep`. However, sometimes the directly dependent crate is not specified by
// `--extern`, in this case, `private-dep` is none during loading. This is equivalent to the
// scenario where the command parameter is set to `public-dependency`
fn is_private_dep(&self, name: &str, private_dep: Option<bool>) -> bool {
self.sess.opts.externs.get(name).map_or(private_dep.unwrap_or(false), |e| e.is_private_dep)
&& private_dep.unwrap_or(true)
}
fn register_crate(
&mut self,
host_lib: Option<Library>,
@ -404,14 +413,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
let Library { source, metadata } = lib;
let crate_root = metadata.get_root();
let host_hash = host_lib.as_ref().map(|lib| lib.metadata.get_root().hash());
let private_dep = self
.sess
.opts
.externs
.get(name.as_str())
.map_or(private_dep.unwrap_or(false), |e| e.is_private_dep)
&& private_dep.unwrap_or(true);
let private_dep = self.is_private_dep(name.as_str(), private_dep);
// Claim this crate number and cache it
let cnum = self.cstore.intern_stable_crate_id(&crate_root)?;
@ -601,14 +603,17 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
match result {
(LoadResult::Previous(cnum), None) => {
// When `private_dep` is none, it indicates the directly dependent crate. If it is
// not specified by `--extern` on command line parameters, it may be
// `private-dependency` when `register_crate` is called for the first time. Then it must be updated to
// `public-dependency` here.
let private_dep = self.is_private_dep(name.as_str(), private_dep);
let data = self.cstore.get_crate_data_mut(cnum);
if data.is_proc_macro_crate() {
dep_kind = CrateDepKind::MacrosOnly;
}
data.set_dep_kind(cmp::max(data.dep_kind(), dep_kind));
if let Some(private_dep) = private_dep {
data.update_and_private_dep(private_dep);
}
data.update_and_private_dep(private_dep);
Ok(cnum)
}
(LoadResult::Loaded(library), host_library) => {

View File

@ -13,7 +13,7 @@ use rustc_middle::mir::interpret::{
Provenance,
};
use rustc_middle::mir::visit::Visitor;
use rustc_middle::mir::{self, *};
use rustc_middle::mir::*;
use rustc_target::abi::Size;
const INDENT: &str = " ";
@ -711,7 +711,7 @@ impl Debug for Statement<'_> {
AscribeUserType(box (ref place, ref c_ty), ref variance) => {
write!(fmt, "AscribeUserType({place:?}, {variance:?}, {c_ty:?})")
}
Coverage(box mir::Coverage { ref kind }) => write!(fmt, "Coverage::{kind:?}"),
Coverage(ref kind) => write!(fmt, "Coverage::{kind:?}"),
Intrinsic(box ref intrinsic) => write!(fmt, "{intrinsic}"),
ConstEvalCounter => write!(fmt, "ConstEvalCounter"),
Nop => write!(fmt, "nop"),

View File

@ -373,7 +373,7 @@ pub enum StatementKind<'tcx> {
///
/// Interpreters and codegen backends that don't support coverage instrumentation
/// can usually treat this as a no-op.
Coverage(Box<Coverage>),
Coverage(CoverageKind),
/// Denotes a call to an intrinsic that does not require an unwind path and always returns.
/// This avoids adding a new block and a terminator for simple intrinsics.
@ -517,12 +517,6 @@ pub enum FakeReadCause {
ForIndex,
}
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct Coverage {
pub kind: CoverageKind,
}
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct CopyNonOverlapping<'tcx> {
@ -1458,5 +1452,6 @@ mod size_asserts {
static_assert_size!(Place<'_>, 16);
static_assert_size!(PlaceElem<'_>, 24);
static_assert_size!(Rvalue<'_>, 40);
static_assert_size!(StatementKind<'_>, 16);
// tidy-alphabetical-end
}

View File

@ -156,10 +156,10 @@ macro_rules! make_mir_visitor {
fn visit_coverage(
&mut self,
coverage: & $($mutability)? Coverage,
kind: & $($mutability)? coverage::CoverageKind,
location: Location,
) {
self.super_coverage(coverage, location);
self.super_coverage(kind, location);
}
fn visit_retag(
@ -803,7 +803,7 @@ macro_rules! make_mir_visitor {
}
fn super_coverage(&mut self,
_coverage: & $($mutability)? Coverage,
_kind: & $($mutability)? coverage::CoverageKind,
_location: Location) {
}

View File

@ -107,9 +107,7 @@ impl<'tcx> CFG<'tcx> {
/// This results in more accurate coverage reports for certain kinds of
/// syntax (e.g. `continue` or `if !`) that would otherwise not appear in MIR.
pub(crate) fn push_coverage_span_marker(&mut self, block: BasicBlock, source_info: SourceInfo) {
let kind = StatementKind::Coverage(Box::new(Coverage {
kind: coverage::CoverageKind::SpanMarker,
}));
let kind = StatementKind::Coverage(coverage::CoverageKind::SpanMarker);
let stmt = Statement { source_info, kind };
self.push(block, stmt);
}

View File

@ -127,9 +127,7 @@ impl Builder<'_, '_> {
let marker_statement = mir::Statement {
source_info,
kind: mir::StatementKind::Coverage(Box::new(mir::Coverage {
kind: CoverageKind::BlockMarker { id },
})),
kind: mir::StatementKind::Coverage(CoverageKind::BlockMarker { id }),
};
self.cfg.push(block, marker_statement);

View File

@ -18,7 +18,7 @@
use crate::MirPass;
use rustc_middle::mir::coverage::CoverageKind;
use rustc_middle::mir::{Body, BorrowKind, Coverage, Rvalue, StatementKind, TerminatorKind};
use rustc_middle::mir::{Body, BorrowKind, Rvalue, StatementKind, TerminatorKind};
use rustc_middle::ty::TyCtxt;
pub struct CleanupPostBorrowck;
@ -30,12 +30,11 @@ impl<'tcx> MirPass<'tcx> for CleanupPostBorrowck {
match statement.kind {
StatementKind::AscribeUserType(..)
| StatementKind::Assign(box (_, Rvalue::Ref(_, BorrowKind::Fake, _)))
| StatementKind::Coverage(box Coverage {
| StatementKind::Coverage(
// These kinds of coverage statements are markers inserted during
// MIR building, and are not needed after InstrumentCoverage.
kind: CoverageKind::BlockMarker { .. } | CoverageKind::SpanMarker { .. },
..
})
CoverageKind::BlockMarker { .. } | CoverageKind::SpanMarker { .. },
)
| StatementKind::FakeRead(..) => statement.make_nop(),
_ => (),
}

View File

@ -15,7 +15,7 @@ use crate::MirPass;
use rustc_middle::mir::coverage::*;
use rustc_middle::mir::{
self, BasicBlock, BasicBlockData, Coverage, SourceInfo, Statement, StatementKind, Terminator,
self, BasicBlock, BasicBlockData, SourceInfo, Statement, StatementKind, Terminator,
TerminatorKind,
};
use rustc_middle::ty::TyCtxt;
@ -230,10 +230,7 @@ fn inject_statement(mir_body: &mut mir::Body<'_>, counter_kind: CoverageKind, bb
debug!(" injecting statement {counter_kind:?} for {bb:?}");
let data = &mut mir_body[bb];
let source_info = data.terminator().source_info;
let statement = Statement {
source_info,
kind: StatementKind::Coverage(Box::new(Coverage { kind: counter_kind })),
};
let statement = Statement { source_info, kind: StatementKind::Coverage(counter_kind) };
data.statements.insert(0, statement);
}

View File

@ -1,7 +1,7 @@
use rustc_data_structures::captures::Captures;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir::coverage::{CounterId, CoverageKind};
use rustc_middle::mir::{Body, Coverage, CoverageIdsInfo, Statement, StatementKind};
use rustc_middle::mir::{Body, CoverageIdsInfo, Statement, StatementKind};
use rustc_middle::query::TyCtxtAt;
use rustc_middle::ty::{self, TyCtxt};
use rustc_middle::util::Providers;
@ -54,7 +54,7 @@ fn coverage_ids_info<'tcx>(
let mir_body = tcx.instance_mir(instance_def);
let max_counter_id = all_coverage_in_mir_body(mir_body)
.filter_map(|coverage| match coverage.kind {
.filter_map(|kind| match *kind {
CoverageKind::CounterIncrement { id } => Some(id),
_ => None,
})
@ -66,12 +66,10 @@ fn coverage_ids_info<'tcx>(
fn all_coverage_in_mir_body<'a, 'tcx>(
body: &'a Body<'tcx>,
) -> impl Iterator<Item = &'a Coverage> + Captures<'tcx> {
) -> impl Iterator<Item = &'a CoverageKind> + Captures<'tcx> {
body.basic_blocks.iter().flat_map(|bb_data| &bb_data.statements).filter_map(|statement| {
match statement.kind {
StatementKind::Coverage(box ref coverage) if !is_inlined(body, statement) => {
Some(coverage)
}
StatementKind::Coverage(ref kind) if !is_inlined(body, statement) => Some(kind),
_ => None,
}
})

View File

@ -187,9 +187,7 @@ fn filtered_statement_span(statement: &Statement<'_>) -> Option<Span> {
// for their parent `BasicBlock`.
StatementKind::StorageLive(_)
| StatementKind::StorageDead(_)
// Ignore `ConstEvalCounter`s
| StatementKind::ConstEvalCounter
// Ignore `Nop`s
| StatementKind::Nop => None,
// FIXME(#78546): MIR InstrumentCoverage - Can the source_info.span for `FakeRead`
@ -211,30 +209,28 @@ fn filtered_statement_span(statement: &Statement<'_>) -> Option<Span> {
StatementKind::FakeRead(box (FakeReadCause::ForGuardBinding, _)) => None,
// Retain spans from most other statements.
StatementKind::FakeRead(box (_, _)) // Not including `ForGuardBinding`
StatementKind::FakeRead(_)
| StatementKind::Intrinsic(..)
| StatementKind::Coverage(box mir::Coverage {
| StatementKind::Coverage(
// The purpose of `SpanMarker` is to be matched and accepted here.
kind: CoverageKind::SpanMarker
})
CoverageKind::SpanMarker,
)
| StatementKind::Assign(_)
| StatementKind::SetDiscriminant { .. }
| StatementKind::Deinit(..)
| StatementKind::Retag(_, _)
| StatementKind::PlaceMention(..)
| StatementKind::AscribeUserType(_, _) => {
Some(statement.source_info.span)
}
| StatementKind::AscribeUserType(_, _) => Some(statement.source_info.span),
StatementKind::Coverage(box mir::Coverage {
// Block markers are used for branch coverage, so ignore them here.
kind: CoverageKind::BlockMarker {..}
}) => None,
// Block markers are used for branch coverage, so ignore them here.
StatementKind::Coverage(CoverageKind::BlockMarker { .. }) => None,
StatementKind::Coverage(box mir::Coverage {
// These coverage statements should not exist prior to coverage instrumentation.
kind: CoverageKind::CounterIncrement { .. } | CoverageKind::ExpressionUsed { .. }
}) => bug!("Unexpected coverage statement found during coverage instrumentation: {statement:?}"),
// These coverage statements should not exist prior to coverage instrumentation.
StatementKind::Coverage(
CoverageKind::CounterIncrement { .. } | CoverageKind::ExpressionUsed { .. },
) => bug!(
"Unexpected coverage statement found during coverage instrumentation: {statement:?}"
),
}
}
@ -382,9 +378,7 @@ pub(super) fn extract_branch_mappings(
// Fill out the mapping from block marker IDs to their enclosing blocks.
for (bb, data) in mir_body.basic_blocks.iter_enumerated() {
for statement in &data.statements {
if let StatementKind::Coverage(coverage) = &statement.kind
&& let CoverageKind::BlockMarker { id } = coverage.kind
{
if let StatementKind::Coverage(CoverageKind::BlockMarker { id }) = statement.kind {
block_markers[id] = Some(bb);
}
}

View File

@ -269,7 +269,11 @@ impl ParseSess {
}
}
pub fn with_silent_emitter(locale_resources: Vec<&'static str>, fatal_note: String) -> Self {
pub fn with_silent_emitter(
locale_resources: Vec<&'static str>,
fatal_note: String,
emit_fatal_diagnostic: bool,
) -> Self {
let fallback_bundle = fallback_fluent_bundle(locale_resources, false);
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let emitter = Box::new(HumanEmitter::new(
@ -281,6 +285,7 @@ impl ParseSess {
fallback_bundle,
fatal_dcx,
fatal_note: Some(fatal_note),
emit_fatal_diagnostic,
}))
.disable_warnings();
ParseSess::with_dcx(dcx, sm)

View File

@ -201,7 +201,7 @@ pub trait Write {
impl<W: Write + ?Sized> SpecWriteFmt for &mut W {
#[inline]
default fn spec_write_fmt(mut self, args: Arguments<'_>) -> Result {
if let Some(s) = args.as_const_str() {
if let Some(s) = args.as_statically_known_str() {
self.write_str(s)
} else {
write(&mut self, args)
@ -212,7 +212,7 @@ pub trait Write {
impl<W: Write> SpecWriteFmt for &mut W {
#[inline]
fn spec_write_fmt(self, args: Arguments<'_>) -> Result {
if let Some(s) = args.as_const_str() {
if let Some(s) = args.as_statically_known_str() {
self.write_str(s)
} else {
write(self, args)
@ -442,7 +442,7 @@ impl<'a> Arguments<'a> {
/// Same as [`Arguments::as_str`], but will only return `Some(s)` if it can be determined at compile time.
#[must_use]
#[inline]
fn as_const_str(&self) -> Option<&'static str> {
fn as_statically_known_str(&self) -> Option<&'static str> {
let s = self.as_str();
if core::intrinsics::is_val_statically_known(s.is_some()) { s } else { None }
}
@ -1617,7 +1617,11 @@ impl<'a> Formatter<'a> {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result {
if let Some(s) = fmt.as_const_str() { self.buf.write_str(s) } else { write(self.buf, fmt) }
if let Some(s) = fmt.as_statically_known_str() {
self.buf.write_str(s)
} else {
write(self.buf, fmt)
}
}
/// Flags for formatting
@ -2308,7 +2312,7 @@ impl Write for Formatter<'_> {
#[inline]
fn write_fmt(&mut self, args: Arguments<'_>) -> Result {
if let Some(s) = args.as_const_str() {
if let Some(s) = args.as_statically_known_str() {
self.buf.write_str(s)
} else {
write(self.buf, args)

View File

@ -328,6 +328,7 @@
#![feature(float_gamma)]
#![feature(float_minimum_maximum)]
#![feature(float_next_up_down)]
#![feature(fmt_internals)]
#![feature(generic_nonzero)]
#![feature(hasher_prefixfree_extras)]
#![feature(hashmap_internals)]

View File

@ -391,6 +391,7 @@ pub mod panic_count {
pub fn increase(run_panic_hook: bool) -> Option<MustAbort> {
let global_count = GLOBAL_PANIC_COUNT.fetch_add(1, Ordering::Relaxed);
if global_count & ALWAYS_ABORT_FLAG != 0 {
// Do *not* access thread-local state, we might be after a `fork`.
return Some(MustAbort::AlwaysAbort);
}
@ -744,11 +745,14 @@ fn rust_panic_with_hook(
if let Some(must_abort) = must_abort {
match must_abort {
panic_count::MustAbort::PanicInHook => {
// Don't try to print the message in this case
// - perhaps that is causing the recursive panics.
// Don't try to format the message in this case, perhaps that is causing the
// recursive panics. However if the message is just a string, no user-defined
// code is involved in printing it, so that is risk-free.
let msg_str = message.and_then(|m| m.as_str()).map(|m| [m]);
let message = msg_str.as_ref().map(|m| fmt::Arguments::new_const(m));
let panicinfo = PanicInfo::internal_constructor(
None, // no message
location, // but we want to show the location!
message.as_ref(),
location,
can_unwind,
force_no_backtrace,
);
@ -756,7 +760,7 @@ fn rust_panic_with_hook(
}
panic_count::MustAbort::AlwaysAbort => {
// Unfortunately, this does not print a backtrace, because creating
// a `Backtrace` will allocate, which we must to avoid here.
// a `Backtrace` will allocate, which we must avoid here.
let panicinfo = PanicInfo::internal_constructor(
message,
location,

View File

@ -459,7 +459,7 @@ impl Socket {
const AF_NAME_MAX: usize = 16;
let mut buf = [0; AF_NAME_MAX];
for (src, dst) in name.to_bytes().iter().zip(&mut buf[..AF_NAME_MAX - 1]) {
*dst = *src as i8;
*dst = *src as libc::c_char;
}
let mut arg: libc::accept_filter_arg = unsafe { mem::zeroed() };
arg.af_name = buf;

View File

@ -355,8 +355,6 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
target_os = "tvos",
target_os = "linux",
target_os = "macos",
target_os = "solaris",
target_os = "illumos",
target_os = "aix",
))] {
#[allow(unused_assignments)]
@ -483,6 +481,12 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
.ok_or(io::const_io_error!(io::ErrorKind::NotFound, "The number of hardware threads is not known for the target platform"))
}
}
} else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] {
let mut cpus = 0u32;
if unsafe { libc::pset_info(libc::PS_MYID, core::ptr::null_mut(), &mut cpus, core::ptr::null_mut()) } != 0 {
return Err(io::const_io_error!(io::ErrorKind::NotFound, "The number of hardware threads is not known for the target platform"));
}
Ok(unsafe { NonZero::new_unchecked(cpus as usize) })
} else if #[cfg(target_os = "haiku")] {
// system_info cpu_count field gets the static data set at boot time with `smp_set_num_cpus`
// `get_system_info` calls then `smp_get_num_cpus`

View File

@ -609,6 +609,8 @@ fn common_inputs_stamp(config: &Config) -> Stamp {
stamp.add_path(&rust_src_dir.join("src/etc/htmldocck.py"));
}
stamp.add_dir(&rust_src_dir.join("src/tools/run-make-support"));
// Compiletest itself.
stamp.add_dir(&rust_src_dir.join("src/tools/compiletest/"));

View File

@ -121,6 +121,7 @@ fn default_dcx(
fallback_bundle,
fatal_dcx: DiagCtxt::new(emitter),
fatal_note: None,
emit_fatal_diagnostic: false,
})
} else {
emitter
@ -209,7 +210,7 @@ impl ParseSess {
rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
false,
);
self.raw_psess.dcx.make_silent(fallback_bundle, None);
self.raw_psess.dcx.make_silent(fallback_bundle, None, false);
}
pub(crate) fn span_to_filename(&self, span: Span) -> FileName {

View File

@ -1,2 +1,3 @@
panicked at $DIR/panic-in-message-fmt.rs:18:9:
not yet implemented
thread panicked while processing panic. aborting.

View File

@ -0,0 +1,20 @@
// issue: rust-lang/rust#90192
// ICE assertion failed: matches!(ty.kind(), ty :: Param(_))
//@ compile-flags:-Zpolymorphize=on -Zmir-opt-level=3
//@ build-pass
fn test<T>() {
std::mem::size_of::<T>();
}
pub fn foo<T>(_: T) -> &'static fn() {
&(test::<T> as fn())
}
fn outer<T>() {
foo(|| ());
}
fn main() {
outer::<u8>();
}

View File

@ -0,0 +1,6 @@
//@ aux-crate:priv:foo=foo.rs
//@ compile-flags: -Zunstable-options
#![crate_type = "rlib"]
extern crate foo;
pub struct Bar(pub i32);

View File

@ -0,0 +1,2 @@
#![crate_type = "rlib"]
pub struct Foo(pub i32);

View File

@ -0,0 +1,12 @@
//@ aux-build: bar.rs
//@ aux-build: foo.rs
//@ build-pass
#![deny(exported_private_dependencies)]
// Ensure the libbar.rlib is loaded first. If the command line parameter `--extern foo` does not
// exist, previus version would fail to compile
#![crate_type = "rlib"]
extern crate bar;
extern crate foo;
pub fn baz() -> (Option<foo::Foo>, Option<bar::Bar>) { (None, None) }

View File

@ -0,0 +1,28 @@
//@ check-pass
#![feature(type_alias_impl_trait)]
#![allow(dead_code)]
use std::ops::Deref;
trait Trait {}
impl<A, B> Trait for (A, B, u8) where A: Deref, B: Deref<Target = A::Target>, {}
impl<A, B> Trait for (A, B, i8) {}
type TaitSized = impl Sized;
fn def_tait1() -> TaitSized {}
type TaitCopy = impl Copy;
fn def_tait2() -> TaitCopy {}
fn impl_trait<T: Trait> () {}
fn test() {
impl_trait::<(&TaitSized, &TaitCopy, _)>();
impl_trait::<(&TaitCopy, &TaitSized, _)>();
impl_trait::<(&TaitCopy, &String, _)>();
impl_trait::<(&TaitSized, &String, _)>();
}
fn main() {}