Auto merge of #132555 - matthiaskrgr:rollup-2d79661, r=matthiaskrgr

Rollup of 15 pull requests

Successful merges:

 - #129329 (Implement `From<&mut {slice}>` for `Box/Rc/Arc<{slice}>`)
 - #131377 (Add LowerExp and UpperExp implementations to NonZero)
 - #132393 (Docs: added brief colon explanation)
 - #132437 (coverage: Regression test for inlining into an uninstrumented crate)
 - #132499 (unicode_data.rs: show command for generating file)
 - #132503 (better test for const HashMap; remove const_hash leftovers)
 - #132511 (stabilize const_arguments_as_str)
 - #132520 (NFC add known bug nr to test)
 - #132522 (make codegen help output more consistent)
 - #132523 (Added regression test for generics index out of bounds)
 - #132528 (Use `*_opt` typeck results fns to not ICE in fallback suggestion)
 - #132537 (PassWrapper: adapt for llvm/llvm-project@5445edb5d)
 - #132540 (Do not format generic consts)
 - #132543 (add and update some crashtests)
 - #132550 (compiler: Continue introducing rustc_abi to the compiler)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-11-03 13:46:47 +00:00
commit 7028d9318f
56 changed files with 525 additions and 100 deletions

View File

@ -3346,6 +3346,7 @@ dependencies = [
"either",
"itertools",
"polonius-engine",
"rustc_abi",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
@ -3359,7 +3360,6 @@ dependencies = [
"rustc_mir_dataflow",
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_trait_selection",
"rustc_traits",
"smallvec",
@ -3706,6 +3706,7 @@ name = "rustc_hir"
version = "0.0.0"
dependencies = [
"odht",
"rustc_abi",
"rustc_arena",
"rustc_ast",
"rustc_data_structures",
@ -4131,6 +4132,7 @@ dependencies = [
name = "rustc_monomorphize"
version = "0.0.0"
dependencies = [
"rustc_abi",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
@ -4335,6 +4337,7 @@ name = "rustc_sanitizers"
version = "0.0.0"
dependencies = [
"bitflags 2.6.0",
"rustc_abi",
"rustc_data_structures",
"rustc_hir",
"rustc_middle",
@ -4467,6 +4470,7 @@ name = "rustc_trait_selection"
version = "0.0.0"
dependencies = [
"itertools",
"rustc_abi",
"rustc_ast",
"rustc_ast_ir",
"rustc_attr",
@ -4483,7 +4487,6 @@ dependencies = [
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_transmute",
"rustc_type_ir",
"smallvec",

View File

@ -414,6 +414,12 @@ pub struct WhereClause {
pub span: Span,
}
impl WhereClause {
pub fn is_empty(&self) -> bool {
!self.has_where_token && self.predicates.is_empty()
}
}
impl Default for WhereClause {
fn default() -> WhereClause {
WhereClause { has_where_token: false, predicates: ThinVec::new(), span: DUMMY_SP }

View File

@ -8,6 +8,7 @@ edition = "2021"
either = "1.5.0"
itertools = "0.12"
polonius-engine = "0.13.0"
rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
@ -21,7 +22,6 @@ rustc_middle = { path = "../rustc_middle" }
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_traits = { path = "../rustc_traits" }
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }

View File

@ -1,5 +1,6 @@
//! Borrow checker diagnostics.
use rustc_abi::{FieldIdx, VariantIdx};
use rustc_errors::{Applicability, Diag, MultiSpan};
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::{self as hir, CoroutineKind, LangItem};
@ -21,7 +22,6 @@
use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym;
use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_target::abi::{FieldIdx, VariantIdx};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{

View File

@ -4,6 +4,7 @@
use core::ops::ControlFlow;
use hir::{ExprKind, Param};
use rustc_abi::FieldIdx;
use rustc_errors::{Applicability, Diag};
use rustc_hir::intravisit::Visitor;
use rustc_hir::{self as hir, BindingMode, ByRef, Node};
@ -16,7 +17,6 @@
use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, Upcast};
use rustc_span::symbol::{Symbol, kw};
use rustc_span::{BytePos, DesugaringKind, Span, sym};
use rustc_target::abi::FieldIdx;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits;

View File

@ -1103,7 +1103,7 @@ fn suggest_deref_closure_return(&self, diag: &mut Diag<'_>) {
peeled_ty,
liberated_sig.c_variadic,
hir::Safety::Safe,
rustc_target::spec::abi::Abi::Rust,
rustc_abi::ExternAbi::Rust,
)),
);
let closure_ty = Ty::new_closure(

View File

@ -21,6 +21,7 @@
use std::ops::Deref;
use consumers::{BodyWithBorrowckFacts, ConsumerOptions};
use rustc_abi::FieldIdx;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::graph::dominators::Dominators;
use rustc_errors::Diag;
@ -45,7 +46,6 @@
};
use rustc_session::lint::builtin::UNUSED_MUT;
use rustc_span::{Span, Symbol};
use rustc_target::abi::FieldIdx;
use smallvec::SmallVec;
use tracing::{debug, instrument};

View File

@ -1,7 +1,7 @@
use rustc_abi::FieldIdx;
use rustc_data_structures::graph::dominators::Dominators;
use rustc_middle::mir::{BasicBlock, Body, BorrowKind, Location, Place, PlaceRef, ProjectionElem};
use rustc_middle::ty::TyCtxt;
use rustc_target::abi::FieldIdx;
use tracing::debug;
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};

View File

@ -4,6 +4,7 @@
use std::{fmt, iter, mem};
use either::Either;
use rustc_abi::{FIRST_VARIANT, FieldIdx};
use rustc_data_structures::frozen::Frozen;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_errors::ErrorGuaranteed;
@ -40,7 +41,6 @@
use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym;
use rustc_span::{DUMMY_SP, Span};
use rustc_target::abi::{FIRST_VARIANT, FieldIdx};
use rustc_trait_selection::traits::query::type_op::custom::{
CustomTypeOp, scrape_region_constraints,
};

View File

@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
# tidy-alphabetical-start
odht = { version = "0.3.1", features = ["nightly"] }
rustc_abi = { path = "../rustc_abi" }
rustc_arena = { path = "../rustc_arena" }
rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" }

View File

@ -1,5 +1,6 @@
use std::fmt;
use rustc_abi::ExternAbi;
use rustc_ast::util::parser::ExprPrecedence;
use rustc_ast::{
self as ast, Attribute, FloatTy, InlineAsmOptions, InlineAsmTemplatePiece, IntTy, Label,
@ -19,7 +20,6 @@
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, ErrorGuaranteed, Span};
use rustc_target::asm::InlineAsmRegOrRegClass;
use rustc_target::spec::abi::Abi;
use smallvec::SmallVec;
use tracing::debug;
@ -2735,7 +2735,7 @@ pub fn from_name(name: Symbol) -> Option<Self> {
#[derive(Debug, Clone, Copy, HashStable_Generic)]
pub struct BareFnTy<'hir> {
pub safety: Safety,
pub abi: Abi,
pub abi: ExternAbi,
pub generic_params: &'hir [GenericParam<'hir>],
pub decl: &'hir FnDecl<'hir>,
pub param_names: &'hir [Ident],
@ -3313,7 +3313,7 @@ pub fn is_struct_or_union(&self) -> bool {
expect_mod, &'hir Mod<'hir>, ItemKind::Mod(m), m;
expect_foreign_mod, (Abi, &'hir [ForeignItemRef]),
expect_foreign_mod, (ExternAbi, &'hir [ForeignItemRef]),
ItemKind::ForeignMod { abi, items }, (*abi, items);
expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm(asm), asm;
@ -3386,7 +3386,7 @@ pub struct FnHeader {
pub safety: Safety,
pub constness: Constness,
pub asyncness: IsAsync,
pub abi: Abi,
pub abi: ExternAbi,
}
impl FnHeader {
@ -3428,7 +3428,7 @@ pub enum ItemKind<'hir> {
/// A module.
Mod(&'hir Mod<'hir>),
/// An external module, e.g. `extern { .. }`.
ForeignMod { abi: Abi, items: &'hir [ForeignItemRef] },
ForeignMod { abi: ExternAbi, items: &'hir [ForeignItemRef] },
/// Module-level inline assembly (from `global_asm!`).
GlobalAsm(&'hir InlineAsm<'hir>),
/// A type alias, e.g., `type Foo = Bar<u8>`.

View File

@ -643,7 +643,7 @@ impl<'tcx> Visitor<'tcx> for AnnotateUnitFallbackVisitor<'_, 'tcx> {
fn visit_ty(&mut self, hir_ty: &'tcx hir::Ty<'tcx>) -> Self::Result {
// Try to replace `_` with `()`.
if let hir::TyKind::Infer = hir_ty.kind
&& let ty = self.fcx.typeck_results.borrow().node_type(hir_ty.hir_id)
&& let Some(ty) = self.fcx.typeck_results.borrow().node_type_opt(hir_ty.hir_id)
&& let Some(vid) = self.fcx.root_vid(ty)
&& self.reachable_vids.contains(&vid)
{
@ -680,7 +680,8 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Self::Result {
if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = expr.kind
&& let Res::Def(DefKind::AssocFn, def_id) = path.res
&& self.fcx.tcx.trait_of_item(def_id).is_some()
&& let self_ty = self.fcx.typeck_results.borrow().node_args(expr.hir_id).type_at(0)
&& let Some(args) = self.fcx.typeck_results.borrow().node_args_opt(expr.hir_id)
&& let self_ty = args.type_at(0)
&& let Some(vid) = self.fcx.root_vid(self_ty)
&& self.reachable_vids.contains(&vid)
&& let [.., trait_segment, _method_segment] = path.segments
@ -701,7 +702,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Self::Result {
fn visit_local(&mut self, local: &'tcx hir::LetStmt<'tcx>) -> Self::Result {
// For a local, try suggest annotating the type if it's missing.
if let None = local.ty
&& let ty = self.fcx.typeck_results.borrow().node_type(local.hir_id)
&& let Some(ty) = self.fcx.typeck_results.borrow().node_type_opt(local.hir_id)
&& let Some(vid) = self.fcx.root_vid(ty)
&& self.reachable_vids.contains(&vid)
{

View File

@ -745,10 +745,8 @@ extern "C" LLVMRustResult LLVMRustOptimize(
CGSCCAnalysisManager CGAM;
ModuleAnalysisManager MAM;
// FIXME: We may want to expose this as an option.
bool DebugPassManager = false;
StandardInstrumentations SI(TheModule->getContext(), DebugPassManager);
StandardInstrumentations SI(TheModule->getContext(),
/*DebugLogging=*/false);
SI.registerCallbacks(PIC, &MAM);
if (LLVMPluginsLen) {
@ -900,8 +898,9 @@ extern "C" LLVMRustResult LLVMRustOptimize(
for (const auto &C : OptimizerLastEPCallbacks)
PB.registerOptimizerLastEPCallback(C);
// Pass false as we manually schedule ThinLTOBufferPasses below.
MPM = PB.buildO0DefaultPipeline(OptLevel, /* PreLinkLTO */ false);
// We manually schedule ThinLTOBufferPasses below, so don't pass the value
// to enable it here.
MPM = PB.buildO0DefaultPipeline(OptLevel);
} else {
for (const auto &C : PipelineStartEPCallbacks)
PB.registerPipelineStartEPCallback(C);
@ -910,7 +909,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
switch (OptStage) {
case LLVMRustOptStage::PreLinkNoLTO:
MPM = PB.buildPerModuleDefaultPipeline(OptLevel, DebugPassManager);
MPM = PB.buildPerModuleDefaultPipeline(OptLevel);
break;
case LLVMRustOptStage::PreLinkThinLTO:
MPM = PB.buildThinLTOPreLinkDefaultPipeline(OptLevel);

View File

@ -5,6 +5,7 @@ edition = "2021"
[dependencies]
# tidy-alphabetical-start
rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }

View File

@ -210,6 +210,7 @@
use std::path::PathBuf;
use move_check::MoveCheckState;
use rustc_abi::Size;
use rustc_data_structures::sync::{LRef, MTLock, par_for_each_in};
use rustc_data_structures::unord::{UnordMap, UnordSet};
use rustc_hir as hir;
@ -236,7 +237,6 @@
use rustc_span::source_map::{Spanned, dummy_spanned, respan};
use rustc_span::symbol::{Ident, sym};
use rustc_span::{DUMMY_SP, Span};
use rustc_target::abi::Size;
use tracing::{debug, instrument, trace};
use crate::errors::{self, EncounteredErrorWhileInstantiating, NoOptimizedMir, RecursionLimit};

View File

@ -7,6 +7,7 @@ edition = "2021"
bitflags = "2.5.0"
tracing = "0.1"
twox-hash = "1.6.3"
rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_hir = { path = "../rustc_hir" }
rustc_middle = { path = "../rustc_middle" }

View File

@ -7,6 +7,7 @@
use std::fmt::Write as _;
use rustc_abi::{ExternAbi, Integer};
use rustc_data_structures::base_n::{ALPHANUMERIC_ONLY, CASE_INSENSITIVE, ToBaseN};
use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
@ -18,8 +19,6 @@
};
use rustc_span::def_id::DefId;
use rustc_span::sym;
use rustc_target::abi::Integer;
use rustc_target::spec::abi::Abi;
use tracing::instrument;
use crate::cfi::typeid::TypeIdOptions;
@ -185,7 +184,7 @@ fn encode_fnsig<'tcx>(
let mut encode_ty_options = EncodeTyOptions::from_bits(options.bits())
.unwrap_or_else(|| bug!("encode_fnsig: invalid option(s) `{:?}`", options.bits()));
match fn_sig.abi {
Abi::C { .. } => {
ExternAbi::C { .. } => {
encode_ty_options.insert(EncodeTyOptions::GENERALIZE_REPR_C);
}
_ => {

View File

@ -7,7 +7,7 @@
use rustc_data_structures::fx::FxHashMap;
use rustc_middle::bug;
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
use rustc_target::abi::call::{Conv, FnAbi, PassMode};
use rustc_target::callconv::{Conv, FnAbi, PassMode};
use tracing::instrument;
mod encode;

View File

@ -6,7 +6,7 @@
use bitflags::bitflags;
use rustc_middle::ty::{Instance, Ty, TyCtxt};
use rustc_target::abi::call::FnAbi;
use rustc_target::callconv::FnAbi;
bitflags! {
/// Options for typeid_for_fnabi.

View File

@ -7,7 +7,7 @@
use std::hash::Hasher;
use rustc_middle::ty::{Instance, InstanceKind, ReifyReason, Ty, TyCtxt};
use rustc_target::abi::call::FnAbi;
use rustc_target::callconv::FnAbi;
use twox_hash::XxHash64;
pub use crate::cfi::typeid::{TypeIdOptions, itanium_cxx_abi};

View File

@ -1585,7 +1585,7 @@ pub(crate) fn parse_mir_include_spans(slot: &mut MirIncludeSpans, v: Option<&str
link_dead_code: Option<bool> = (None, parse_opt_bool, [TRACKED],
"keep dead code at link time (useful for code coverage) (default: no)"),
link_self_contained: LinkSelfContained = (LinkSelfContained::default(), parse_link_self_contained, [UNTRACKED],
"control whether to link Rust provided C objects/libraries or rely
"control whether to link Rust provided C objects/libraries or rely \
on a C toolchain or linker installed in the system"),
linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
"system linker to link outputs with"),

View File

@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
# tidy-alphabetical-start
itertools = "0.12"
rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" }
rustc_ast_ir = { path = "../rustc_ast_ir" }
rustc_attr = { path = "../rustc_attr" }
@ -22,7 +23,6 @@ rustc_query_system = { path = "../rustc_query_system" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
rustc_transmute = { path = "../rustc_transmute", features = ["rustc"] }
rustc_type_ir = { path = "../rustc_type_ir" }
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }

View File

@ -50,6 +50,7 @@
use std::path::PathBuf;
use std::{cmp, fmt, iter};
use rustc_abi::ExternAbi;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_errors::{Applicability, Diag, DiagStyledString, IntoDiagArg, StringPart, pluralize};
use rustc_hir::def::DefKind;
@ -67,7 +68,6 @@
TypeVisitableExt,
};
use rustc_span::{BytePos, DesugaringKind, Pos, Span, sym};
use rustc_target::spec::abi;
use tracing::{debug, instrument};
use crate::error_reporting::TypeErrCtxt;
@ -686,10 +686,10 @@ fn cmp_fn_sig(
// unsafe extern "C" for<'a> fn(&'a T) -> &'a T
// ^^^^^^^^^^
if sig1.abi != abi::Abi::Rust {
if sig1.abi != ExternAbi::Rust {
values.0.push(format!("extern {} ", sig1.abi), sig1.abi != sig2.abi);
}
if sig2.abi != abi::Abi::Rust {
if sig2.abi != ExternAbi::Rust {
values.1.push(format!("extern {} ", sig2.abi), sig1.abi != sig2.abi);
}

View File

@ -6,6 +6,7 @@
use std::path::PathBuf;
use itertools::{EitherOrBoth, Itertools};
use rustc_abi::ExternAbi;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::codes::*;
@ -38,7 +39,6 @@
use rustc_span::def_id::LocalDefId;
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, ExpnKind, MacroKind, Span};
use rustc_target::spec::abi;
use tracing::{debug, instrument};
use super::{
@ -1916,7 +1916,7 @@ pub(crate) fn build_fn_sig_ty<'tcx>(
infcx.next_ty_var(DUMMY_SP),
false,
hir::Safety::Safe,
abi::Abi::Rust,
ExternAbi::Rust,
)
}
_ => infcx.tcx.mk_fn_sig(
@ -1924,7 +1924,7 @@ pub(crate) fn build_fn_sig_ty<'tcx>(
infcx.next_ty_var(DUMMY_SP),
false,
hir::Safety::Safe,
abi::Abi::Rust,
ExternAbi::Rust,
),
};
@ -3996,7 +3996,7 @@ fn suggest_option_method_if_applicable<G: EmissionGuarantee>(
&& let [self_ty, found_ty] = trait_ref.args.as_slice()
&& let Some(fn_ty) = self_ty.as_type().filter(|ty| ty.is_fn())
&& let fn_sig @ ty::FnSig {
abi: abi::Abi::Rust,
abi: ExternAbi::Rust,
c_variadic: false,
safety: hir::Safety::Safe,
..

View File

@ -7,6 +7,7 @@
use std::iter;
use std::ops::ControlFlow;
use rustc_abi::BackendRepr;
use rustc_errors::FatalError;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
@ -18,7 +19,6 @@
};
use rustc_span::Span;
use rustc_span::symbol::Symbol;
use rustc_target::abi::BackendRepr;
use smallvec::SmallVec;
use tracing::{debug, instrument};

View File

@ -109,6 +109,29 @@ fn from(slice: &[T]) -> Box<[T]> {
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "box_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl<T: Clone> From<&mut [T]> for Box<[T]> {
/// Converts a `&mut [T]` into a `Box<[T]>`
///
/// This conversion allocates on the heap
/// and performs a copy of `slice` and its contents.
///
/// # Examples
/// ```rust
/// // create a &mut [u8] which will be used to create a Box<[u8]>
/// let mut array = [104, 101, 108, 108, 111];
/// let slice: &mut [u8] = &mut array;
/// let boxed_slice: Box<[u8]> = Box::from(slice);
///
/// println!("{boxed_slice:?}");
/// ```
#[inline]
fn from(slice: &mut [T]) -> Box<[T]> {
Self::from(&*slice)
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "box_from_cow", since = "1.45.0")]
impl<T: Clone> From<Cow<'_, [T]>> for Box<[T]> {
@ -147,6 +170,28 @@ fn from(s: &str) -> Box<str> {
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "box_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut str> for Box<str> {
/// Converts a `&mut str` into a `Box<str>`
///
/// This conversion allocates on the heap
/// and performs a copy of `s`.
///
/// # Examples
///
/// ```rust
/// let mut original = String::from("hello");
/// let original: &mut str = &mut original;
/// let boxed: Box<str> = Box::from(original);
/// println!("{boxed}");
/// ```
#[inline]
fn from(s: &mut str) -> Box<str> {
Self::from(&*s)
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "box_from_cow", since = "1.45.0")]
impl From<Cow<'_, str>> for Box<str> {

View File

@ -772,6 +772,16 @@ fn from(s: &CStr) -> Box<CStr> {
}
}
#[cfg(not(test))]
#[stable(feature = "box_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut CStr> for Box<CStr> {
/// Converts a `&mut CStr` into a `Box<CStr>`,
/// by copying the contents into a newly allocated [`Box`].
fn from(s: &mut CStr) -> Box<CStr> {
Self::from(&*s)
}
}
#[stable(feature = "box_from_cow", since = "1.45.0")]
impl From<Cow<'_, CStr>> for Box<CStr> {
/// Converts a `Cow<'a, CStr>` into a `Box<CStr>`,
@ -910,6 +920,17 @@ fn from(s: &CStr) -> Arc<CStr> {
}
}
#[cfg(target_has_atomic = "ptr")]
#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut CStr> for Arc<CStr> {
/// Converts a `&mut CStr` into a `Arc<CStr>`,
/// by copying the contents into a newly allocated [`Arc`].
#[inline]
fn from(s: &mut CStr) -> Arc<CStr> {
Arc::from(&*s)
}
}
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
impl From<CString> for Rc<CStr> {
/// Converts a [`CString`] into an <code>[Rc]<[CStr]></code> by moving the [`CString`]
@ -932,6 +953,16 @@ fn from(s: &CStr) -> Rc<CStr> {
}
}
#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut CStr> for Rc<CStr> {
/// Converts a `&mut CStr` into a `Rc<CStr>`,
/// by copying the contents into a newly allocated [`Rc`].
#[inline]
fn from(s: &mut CStr) -> Rc<CStr> {
Rc::from(&*s)
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "more_rc_default_impls", since = "1.80.0")]
impl Default for Rc<CStr> {

View File

@ -109,6 +109,16 @@
//! parameters (corresponding to `format_spec` in [the syntax](#syntax)). These
//! parameters affect the string representation of what's being formatted.
//!
//! The colon `:` in format syntax divides indentifier of the input data and
//! the formatting options, the colon itself does not change anything, only
//! introduces the options.
//!
//! ```
//! let a = 5;
//! let b = &a;
//! println!("{a:e} {b:p}"); // => 5e0 0x7ffe37b7273c
//! ```
//!
//! ## Width
//!
//! ```

View File

@ -2657,6 +2657,26 @@ fn from(v: &[T]) -> Rc<[T]> {
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl<T: Clone> From<&mut [T]> for Rc<[T]> {
/// Allocates a reference-counted slice and fills it by cloning `v`'s items.
///
/// # Example
///
/// ```
/// # use std::rc::Rc;
/// let mut original = [1, 2, 3];
/// let original: &mut [i32] = &mut original;
/// let shared: Rc<[i32]> = Rc::from(original);
/// assert_eq!(&[1, 2, 3], &shared[..]);
/// ```
#[inline]
fn from(v: &mut [T]) -> Rc<[T]> {
Rc::from(&*v)
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "shared_from_slice", since = "1.21.0")]
impl From<&str> for Rc<str> {
@ -2676,6 +2696,26 @@ fn from(v: &str) -> Rc<str> {
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut str> for Rc<str> {
/// Allocates a reference-counted string slice and copies `v` into it.
///
/// # Example
///
/// ```
/// # use std::rc::Rc;
/// let mut original = String::from("statue");
/// let original: &mut str = &mut original;
/// let shared: Rc<str> = Rc::from(original);
/// assert_eq!("statue", &shared[..]);
/// ```
#[inline]
fn from(v: &mut str) -> Rc<str> {
Rc::from(&*v)
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "shared_from_slice", since = "1.21.0")]
impl From<String> for Rc<str> {

View File

@ -3614,6 +3614,26 @@ fn from(v: &[T]) -> Arc<[T]> {
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl<T: Clone> From<&mut [T]> for Arc<[T]> {
/// Allocates a reference-counted slice and fills it by cloning `v`'s items.
///
/// # Example
///
/// ```
/// # use std::sync::Arc;
/// let mut original = [1, 2, 3];
/// let original: &mut [i32] = &mut original;
/// let shared: Arc<[i32]> = Arc::from(original);
/// assert_eq!(&[1, 2, 3], &shared[..]);
/// ```
#[inline]
fn from(v: &mut [T]) -> Arc<[T]> {
Arc::from(&*v)
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "shared_from_slice", since = "1.21.0")]
impl From<&str> for Arc<str> {
@ -3633,6 +3653,26 @@ fn from(v: &str) -> Arc<str> {
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut str> for Arc<str> {
/// Allocates a reference-counted `str` and copies `v` into it.
///
/// # Example
///
/// ```
/// # use std::sync::Arc;
/// let mut original = String::from("eggplant");
/// let original: &mut str = &mut original;
/// let shared: Arc<str> = Arc::from(original);
/// assert_eq!("eggplant", &shared[..]);
/// ```
#[inline]
fn from(v: &mut str) -> Arc<str> {
Arc::from(&*v)
}
}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "shared_from_slice", since = "1.21.0")]
impl From<String> for Arc<str> {

View File

@ -438,10 +438,9 @@ impl<'a> Arguments<'a> {
/// assert_eq!(format_args!("{:?}", std::env::current_dir()).as_str(), None);
/// ```
#[stable(feature = "fmt_as_str", since = "1.52.0")]
#[rustc_const_unstable(feature = "const_arguments_as_str", issue = "103900")]
#[rustc_const_stable(feature = "const_arguments_as_str", since = "CURRENT_RUSTC_VERSION")]
#[must_use]
#[inline]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
pub const fn as_str(&self) -> Option<&'static str> {
match (self.pieces, self.args) {
([], []) => Some(""),

View File

@ -147,9 +147,8 @@ impl SipHasher {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[deprecated(since = "1.13.0", note = "use `std::hash::DefaultHasher` instead")]
#[rustc_const_unstable(feature = "const_hash", issue = "104061")]
#[must_use]
pub const fn new() -> SipHasher {
pub fn new() -> SipHasher {
SipHasher::new_with_keys(0, 0)
}
@ -157,9 +156,8 @@ pub const fn new() -> SipHasher {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[deprecated(since = "1.13.0", note = "use `std::hash::DefaultHasher` instead")]
#[rustc_const_unstable(feature = "const_hash", issue = "104061")]
#[must_use]
pub const fn new_with_keys(key0: u64, key1: u64) -> SipHasher {
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher {
SipHasher(SipHasher24 { hasher: Hasher::new_with_keys(key0, key1) })
}
}
@ -169,8 +167,7 @@ impl SipHasher13 {
#[inline]
#[unstable(feature = "hashmap_internals", issue = "none")]
#[deprecated(since = "1.13.0", note = "use `std::hash::DefaultHasher` instead")]
#[rustc_const_unstable(feature = "const_hash", issue = "104061")]
pub const fn new() -> SipHasher13 {
pub fn new() -> SipHasher13 {
SipHasher13::new_with_keys(0, 0)
}
@ -178,8 +175,7 @@ pub const fn new() -> SipHasher13 {
#[inline]
#[unstable(feature = "hashmap_internals", issue = "none")]
#[deprecated(since = "1.13.0", note = "use `std::hash::DefaultHasher` instead")]
#[rustc_const_unstable(feature = "const_hash", issue = "104061")]
pub const fn new_with_keys(key0: u64, key1: u64) -> SipHasher13 {
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher13 {
SipHasher13 { hasher: Hasher::new_with_keys(key0, key1) }
}
}

View File

@ -114,13 +114,11 @@
#![feature(const_align_of_val_raw)]
#![feature(const_align_offset)]
#![feature(const_alloc_layout)]
#![feature(const_arguments_as_str)]
#![feature(const_black_box)]
#![feature(const_char_encode_utf16)]
#![feature(const_eval_select)]
#![feature(const_exact_div)]
#![feature(const_float_methods)]
#![feature(const_hash)]
#![feature(const_heap)]
#![feature(const_nonnull_new)]
#![feature(const_option_ext)]

View File

@ -110,26 +110,40 @@ unsafe impl ZeroablePrimitive for $primitive {
pub struct NonZero<T: ZeroablePrimitive>(T::NonZeroInner);
macro_rules! impl_nonzero_fmt {
($Trait:ident) => {
#[stable(feature = "nonzero", since = "1.28.0")]
impl<T> fmt::$Trait for NonZero<T>
where
T: ZeroablePrimitive + fmt::$Trait,
{
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.get().fmt(f)
($(#[$Attribute:meta] $Trait:ident)*) => {
$(
#[$Attribute]
impl<T> fmt::$Trait for NonZero<T>
where
T: ZeroablePrimitive + fmt::$Trait,
{
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.get().fmt(f)
}
}
}
)*
};
}
impl_nonzero_fmt!(Debug);
impl_nonzero_fmt!(Display);
impl_nonzero_fmt!(Binary);
impl_nonzero_fmt!(Octal);
impl_nonzero_fmt!(LowerHex);
impl_nonzero_fmt!(UpperHex);
impl_nonzero_fmt! {
#[stable(feature = "nonzero", since = "1.28.0")]
Debug
#[stable(feature = "nonzero", since = "1.28.0")]
Display
#[stable(feature = "nonzero", since = "1.28.0")]
Binary
#[stable(feature = "nonzero", since = "1.28.0")]
Octal
#[stable(feature = "nonzero", since = "1.28.0")]
LowerHex
#[stable(feature = "nonzero", since = "1.28.0")]
UpperHex
#[stable(feature = "nonzero_fmt_exp", since = "CURRENT_RUSTC_VERSION")]
LowerExp
#[stable(feature = "nonzero_fmt_exp", since = "CURRENT_RUSTC_VERSION")]
UpperExp
}
macro_rules! impl_nonzero_auto_trait {
(unsafe $Trait:ident) => {

View File

@ -165,10 +165,9 @@ impl<'a> PanicMessage<'a> {
///
/// See [`fmt::Arguments::as_str`] for details.
#[stable(feature = "panic_info_message", since = "1.81.0")]
#[rustc_const_unstable(feature = "const_arguments_as_str", issue = "103900")]
#[rustc_const_stable(feature = "const_arguments_as_str", since = "CURRENT_RUSTC_VERSION")]
#[must_use]
#[inline]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
pub const fn as_str(&self) -> Option<&'static str> {
self.message.as_str()
}

View File

@ -1,4 +1,4 @@
///! This file is generated by src/tools/unicode-table-generator; do not edit manually!
///! This file is generated by `./x run src/tools/unicode-table-generator`; do not edit manually!
#[inline(always)]
const fn bitset_search<

View File

@ -19,7 +19,6 @@
#![feature(const_align_offset)]
#![feature(const_black_box)]
#![feature(const_eval_select)]
#![feature(const_hash)]
#![feature(const_heap)]
#![feature(const_nonnull_new)]
#![feature(const_option_ext)]

View File

@ -354,3 +354,14 @@ fn test_signed_nonzero_neg() {
assert_eq!((-NonZero::<i128>::new(1).unwrap()).get(), -1);
assert_eq!((-NonZero::<i128>::new(-1).unwrap()).get(), 1);
}
#[test]
fn test_nonzero_fmt() {
let i = format!("{0}, {0:?}, {0:x}, {0:X}, {0:#x}, {0:#X}, {0:o}, {0:b}, {0:e}, {0:E}", 42);
let nz = format!(
"{0}, {0:?}, {0:x}, {0:X}, {0:#x}, {0:#X}, {0:o}, {0:b}, {0:e}, {0:E}",
NonZero::new(42).unwrap()
);
assert_eq!(i, nz);
}

View File

@ -5,7 +5,7 @@
use super::HashMap;
use crate::assert_matches::assert_matches;
use crate::cell::RefCell;
use crate::hash::RandomState;
use crate::hash::{BuildHasher, BuildHasherDefault, DefaultHasher, RandomState};
use crate::test_helpers::test_rng;
// https://github.com/rust-lang/rust/issues/62301
@ -1124,6 +1124,26 @@ fn from_array() {
#[test]
fn const_with_hasher() {
const X: HashMap<(), (), ()> = HashMap::with_hasher(());
assert_eq!(X.len(), 0);
const X: HashMap<(), (), BuildHasherDefault<DefaultHasher>> =
HashMap::with_hasher(BuildHasherDefault::new());
let mut x = X;
assert_eq!(x.len(), 0);
x.insert((), ());
assert_eq!(x.len(), 1);
// It *is* possible to do this without using the `BuildHasherDefault` type.
struct MyBuildDefaultHasher;
impl BuildHasher for MyBuildDefaultHasher {
type Hasher = DefaultHasher;
fn build_hasher(&self) -> Self::Hasher {
DefaultHasher::new()
}
}
const Y: HashMap<(), (), MyBuildDefaultHasher> = HashMap::with_hasher(MyBuildDefaultHasher);
let mut y = Y;
assert_eq!(y.len(), 0);
y.insert((), ());
assert_eq!(y.len(), 1);
}

View File

@ -1225,6 +1225,15 @@ fn from(s: &OsStr) -> Box<OsStr> {
}
}
#[stable(feature = "box_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut OsStr> for Box<OsStr> {
/// Copies the string into a newly allocated <code>[Box]&lt;[OsStr]&gt;</code>.
#[inline]
fn from(s: &mut OsStr) -> Box<OsStr> {
Self::from(&*s)
}
}
#[stable(feature = "box_from_cow", since = "1.45.0")]
impl From<Cow<'_, OsStr>> for Box<OsStr> {
/// Converts a `Cow<'a, OsStr>` into a <code>[Box]&lt;[OsStr]&gt;</code>,
@ -1296,6 +1305,15 @@ fn from(s: &OsStr) -> Arc<OsStr> {
}
}
#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut OsStr> for Arc<OsStr> {
/// Copies the string into a newly allocated <code>[Arc]&lt;[OsStr]&gt;</code>.
#[inline]
fn from(s: &mut OsStr) -> Arc<OsStr> {
Arc::from(&*s)
}
}
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
impl From<OsString> for Rc<OsStr> {
/// Converts an [`OsString`] into an <code>[Rc]<[OsStr]></code> by moving the [`OsString`]
@ -1317,6 +1335,15 @@ fn from(s: &OsStr) -> Rc<OsStr> {
}
}
#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut OsStr> for Rc<OsStr> {
/// Copies the string into a newly allocated <code>[Rc]&lt;[OsStr]&gt;</code>.
#[inline]
fn from(s: &mut OsStr) -> Rc<OsStr> {
Rc::from(&*s)
}
}
#[stable(feature = "cow_from_osstr", since = "1.28.0")]
impl<'a> From<OsString> for Cow<'a, OsStr> {
/// Moves the string into a [`Cow::Owned`].

View File

@ -105,9 +105,8 @@ impl DefaultHasher {
#[stable(feature = "hashmap_default_hasher", since = "1.13.0")]
#[inline]
#[allow(deprecated)]
#[rustc_const_unstable(feature = "const_hash", issue = "104061")]
#[must_use]
pub const fn new() -> DefaultHasher {
pub fn new() -> DefaultHasher {
DefaultHasher(SipHasher13::new_with_keys(0, 0))
}
}

View File

@ -328,6 +328,7 @@
// Library features (core):
// tidy-alphabetical-start
#![feature(array_chunks)]
#![feature(build_hasher_default_const_new)]
#![feature(c_str_module)]
#![feature(char_internals)]
#![feature(clone_to_uninit)]
@ -415,7 +416,6 @@
// Only for const-ness:
// tidy-alphabetical-start
#![feature(const_collections_with_hasher)]
#![feature(const_hash)]
#![feature(thread_local_internals)]
// tidy-alphabetical-end
//

View File

@ -1762,6 +1762,16 @@ fn from(path: &Path) -> Box<Path> {
}
}
#[stable(feature = "box_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut Path> for Box<Path> {
/// Creates a boxed [`Path`] from a reference.
///
/// This will allocate and clone `path` to it.
fn from(path: &mut Path) -> Box<Path> {
Self::from(&*path)
}
}
#[stable(feature = "box_from_cow", since = "1.45.0")]
impl From<Cow<'_, Path>> for Box<Path> {
/// Creates a boxed [`Path`] from a clone-on-write pointer.
@ -1990,6 +2000,15 @@ fn from(s: &Path) -> Arc<Path> {
}
}
#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut Path> for Arc<Path> {
/// Converts a [`Path`] into an [`Arc`] by copying the [`Path`] data into a new [`Arc`] buffer.
#[inline]
fn from(s: &mut Path) -> Arc<Path> {
Arc::from(&*s)
}
}
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
impl From<PathBuf> for Rc<Path> {
/// Converts a [`PathBuf`] into an <code>[Rc]<[Path]></code> by moving the [`PathBuf`] data into
@ -2011,6 +2030,15 @@ fn from(s: &Path) -> Rc<Path> {
}
}
#[stable(feature = "shared_from_mut_slice", since = "CURRENT_RUSTC_VERSION")]
impl From<&mut Path> for Rc<Path> {
/// Converts a [`Path`] into an [`Rc`] by copying the [`Path`] data into a new [`Rc`] buffer.
#[inline]
fn from(s: &mut Path) -> Rc<Path> {
Rc::from(&*s)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl ToOwned for Path {
type Owned = PathBuf;

View File

@ -2009,6 +2009,7 @@ pub(crate) struct StaticParts<'a> {
safety: ast::Safety,
vis: &'a ast::Visibility,
ident: symbol::Ident,
generics: Option<&'a ast::Generics>,
ty: &'a ast::Ty,
mutability: ast::Mutability,
expr_opt: Option<&'a ptr::P<ast::Expr>>,
@ -2018,8 +2019,10 @@ pub(crate) struct StaticParts<'a> {
impl<'a> StaticParts<'a> {
pub(crate) fn from_item(item: &'a ast::Item) -> Self {
let (defaultness, prefix, safety, ty, mutability, expr) = match &item.kind {
ast::ItemKind::Static(s) => (None, "static", s.safety, &s.ty, s.mutability, &s.expr),
let (defaultness, prefix, safety, ty, mutability, expr, generics) = match &item.kind {
ast::ItemKind::Static(s) => {
(None, "static", s.safety, &s.ty, s.mutability, &s.expr, None)
}
ast::ItemKind::Const(c) => (
Some(c.defaultness),
"const",
@ -2027,6 +2030,7 @@ pub(crate) fn from_item(item: &'a ast::Item) -> Self {
&c.ty,
ast::Mutability::Not,
&c.expr,
Some(&c.generics),
),
_ => unreachable!(),
};
@ -2035,6 +2039,7 @@ pub(crate) fn from_item(item: &'a ast::Item) -> Self {
safety,
vis: &item.vis,
ident: item.ident,
generics,
ty,
mutability,
expr_opt: expr.as_ref(),
@ -2044,8 +2049,8 @@ pub(crate) fn from_item(item: &'a ast::Item) -> Self {
}
pub(crate) fn from_trait_item(ti: &'a ast::AssocItem) -> Self {
let (defaultness, ty, expr_opt) = match &ti.kind {
ast::AssocItemKind::Const(c) => (c.defaultness, &c.ty, &c.expr),
let (defaultness, ty, expr_opt, generics) = match &ti.kind {
ast::AssocItemKind::Const(c) => (c.defaultness, &c.ty, &c.expr, Some(&c.generics)),
_ => unreachable!(),
};
StaticParts {
@ -2053,6 +2058,7 @@ pub(crate) fn from_trait_item(ti: &'a ast::AssocItem) -> Self {
safety: ast::Safety::Default,
vis: &ti.vis,
ident: ti.ident,
generics,
ty,
mutability: ast::Mutability::Not,
expr_opt: expr_opt.as_ref(),
@ -2062,8 +2068,8 @@ pub(crate) fn from_trait_item(ti: &'a ast::AssocItem) -> Self {
}
pub(crate) fn from_impl_item(ii: &'a ast::AssocItem) -> Self {
let (defaultness, ty, expr) = match &ii.kind {
ast::AssocItemKind::Const(c) => (c.defaultness, &c.ty, &c.expr),
let (defaultness, ty, expr, generics) = match &ii.kind {
ast::AssocItemKind::Const(c) => (c.defaultness, &c.ty, &c.expr, Some(&c.generics)),
_ => unreachable!(),
};
StaticParts {
@ -2071,6 +2077,7 @@ pub(crate) fn from_impl_item(ii: &'a ast::AssocItem) -> Self {
safety: ast::Safety::Default,
vis: &ii.vis,
ident: ii.ident,
generics,
ty,
mutability: ast::Mutability::Not,
expr_opt: expr.as_ref(),
@ -2085,6 +2092,14 @@ fn rewrite_static(
static_parts: &StaticParts<'_>,
offset: Indent,
) -> Option<String> {
// For now, if this static (or const) has generics, then bail.
if static_parts
.generics
.is_some_and(|g| !g.params.is_empty() || !g.where_clause.is_empty())
{
return None;
}
let colon = colon_spaces(context.config);
let mut prefix = format!(
"{}{}{}{} {}{}{}",

View File

@ -0,0 +1,25 @@
// Make sure we don't mess up the formatting of generic consts
#![feature(generic_const_items)]
const GENERIC<N, const M: usize>: i32 = 0;
const WHERECLAUSE: i32 = 0
where
i32:;
trait Foo {
const GENERIC<N, const M: usize>: i32;
const WHERECLAUSE: i32
where
i32:;
}
impl Foo for () {
const GENERIC<N, const M: usize>: i32 = 0;
const WHERECLAUSE: i32 = 0
where
i32:;
}

View File

@ -268,7 +268,7 @@ fn main() {
let mut table_file = String::new();
table_file.push_str(
"///! This file is generated by src/tools/unicode-table-generator; do not edit manually!\n",
"///! This file is generated by `./x run src/tools/unicode-table-generator`; do not edit manually!\n",
);
// Include the range search function

View File

@ -0,0 +1,13 @@
//@ edition: 2021
//@ compile-flags: -Cinstrument-coverage=on
#[inline]
pub fn inline_me() {}
#[inline(never)]
pub fn no_inlining_please() {}
pub fn generic<T>() {}
// FIXME(#132436): Even though this doesn't ICE, it still produces coverage
// reports that undercount the affected code.

View File

@ -0,0 +1,19 @@
//@ edition: 2021
//@ compile-flags: -Cinstrument-coverage=off
//@ ignore-coverage-run
//@ aux-crate: inline_mixed_helper=inline_mixed_helper.rs
// Regression test for <https://github.com/rust-lang/rust/pull/132395>.
// Various forms of cross-crate inlining can cause coverage statements to be
// inlined into crates that are being built without coverage instrumentation.
// At the very least, we need to not ICE when that happens.
fn main() {
inline_mixed_helper::inline_me();
inline_mixed_helper::no_inlining_please();
inline_mixed_helper::generic::<u32>();
}
// FIXME(#132437): We currently don't test this in coverage-run mode, because
// whether or not it produces a `.profraw` file appears to differ between
// platforms.

18
tests/crashes/126268.rs Normal file
View File

@ -0,0 +1,18 @@
//@ known-bug: #126268
#![feature(min_specialization)]
trait Trait {}
impl<T> Trait for T {}
trait Data {
type Elem;
}
struct DatasetIter<'a, R: Data> {
data: &'a R::Elem,
}
pub struct ArrayBase {}
impl<'a> Trait for DatasetIter<'a, ArrayBase> {}

View File

@ -1,25 +1,21 @@
//@ known-bug: #131050
//@ compile-flags: --edition=2021
fn query_as<D>() {}
use std::future::Future;
async fn create_user() {
query_as();
fn invalid_future() -> impl Future {}
fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
async { &|| async { invalid_future().await } }
}
async fn post_user_filter() -> impl Filter {
AndThen(&(), || async { create_user().await })
fn coerce_impl_trait() -> impl Future<Output = impl Send> {
create_complex_future()
}
async fn get_app() -> impl Send {
post_user_filter().await
}
trait ReturnsSend {}
trait Filter {}
struct AndThen<T, F>(T, F);
impl<T, F, R> Filter for AndThen<T, F>
impl<F, R> ReturnsSend for F
where
F: Fn() -> R,
R: Send,

2
tests/crashes/132126.rs Normal file
View File

@ -0,0 +1,2 @@
//@ known-bug: #132126
trait UnsafeCopy where Self: use<Self> {}

View File

@ -0,0 +1,4 @@
fn main() {
x::<_>(|_| panic!())
//~^ ERROR cannot find function `x` in this scope
}

View File

@ -0,0 +1,9 @@
error[E0425]: cannot find function `x` in this scope
--> $DIR/suggestion-ice-132517.rs:2:5
|
LL | x::<_>(|_| panic!())
| ^ not found in this scope
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0425`.

View File

@ -2,7 +2,7 @@
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@[next] check-pass
//@[current] known-bug: unknown
//@[current] known-bug: #132519
//@[current] failure-status: 101
//@[current] dont-check-compiler-stderr

View File

@ -0,0 +1,24 @@
//@ check-fail
//
// Regression for https://github.com/rust-lang/rust/issues/117446
pub struct Repeated<T>(Vec<T>);
trait Foo<'a> {
fn outer<D>() -> Option<()>;
}
impl<'a, T> Foo<'a> for Repeated<T> {
fn outer() -> Option<()> {
//~^ ERROR associated function `outer` has 0 type parameters but its trait declaration has 1 type parameter [E0049]
//~^^ ERROR mismatched types [E0308]
fn inner<Q>(value: Option<()>) -> Repeated<Q> {
match value {
_ => Self(unimplemented!()),
//~^ ERROR can't reference `Self` constructor from outer item [E0401]
}
}
}
}
fn main() {}

View File

@ -0,0 +1,33 @@
error[E0049]: associated function `outer` has 0 type parameters but its trait declaration has 1 type parameter
--> $DIR/ice-index-out-of-bounds-issue-117446.rs:12:13
|
LL | fn outer<D>() -> Option<()>;
| - expected 1 type parameter
...
LL | fn outer() -> Option<()> {
| ^ found 0 type parameters
error[E0308]: mismatched types
--> $DIR/ice-index-out-of-bounds-issue-117446.rs:12:19
|
LL | fn outer() -> Option<()> {
| ----- ^^^^^^^^^^ expected `Option<()>`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected enum `Option<()>`
found unit type `()`
error[E0401]: can't reference `Self` constructor from outer item
--> $DIR/ice-index-out-of-bounds-issue-117446.rs:17:22
|
LL | impl<'a, T> Foo<'a> for Repeated<T> {
| ----------------------------------- the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference
...
LL | _ => Self(unimplemented!()),
| ^^^^ help: replace `Self` with the actual type: `Repeated`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0049, E0308, E0401.
For more information about an error, try `rustc --explain E0049`.