Skip to content

Commit

Permalink
Auto merge of rust-lang#132554 - matthiaskrgr:rollup-vwm71z1, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 16 pull requests

Successful merges:

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

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Nov 3, 2024
2 parents db034ce + 9c4884e commit d540225
Show file tree
Hide file tree
Showing 169 changed files with 949 additions and 524 deletions.
7 changes: 5 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3346,6 +3346,7 @@ dependencies = [
"either",
"itertools",
"polonius-engine",
"rustc_abi",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
Expand All @@ -3359,7 +3360,6 @@ dependencies = [
"rustc_mir_dataflow",
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_trait_selection",
"rustc_traits",
"smallvec",
Expand Down Expand Up @@ -3706,6 +3706,7 @@ name = "rustc_hir"
version = "0.0.0"
dependencies = [
"odht",
"rustc_abi",
"rustc_arena",
"rustc_ast",
"rustc_data_structures",
Expand Down Expand Up @@ -4131,6 +4132,7 @@ dependencies = [
name = "rustc_monomorphize"
version = "0.0.0"
dependencies = [
"rustc_abi",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -4467,6 +4470,7 @@ name = "rustc_trait_selection"
version = "0.0.0"
dependencies = [
"itertools",
"rustc_abi",
"rustc_ast",
"rustc_ast_ir",
"rustc_attr",
Expand All @@ -4483,7 +4487,6 @@ dependencies = [
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_transmute",
"rustc_type_ir",
"smallvec",
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -21,7 +22,6 @@ use rustc_span::def_id::LocalDefId;
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::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -16,7 +17,6 @@ use rustc_middle::mir::{
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;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
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(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::marker::PhantomData;
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;
Expand All @@ -45,7 +46,6 @@ use rustc_mir_dataflow::move_paths::{
};
use rustc_session::lint::builtin::UNUSED_MUT;
use rustc_span::{Span, Symbol};
use rustc_target::abi::FieldIdx;
use smallvec::SmallVec;
use tracing::{debug, instrument};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/path_utils.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::rc::Rc;
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;
Expand Down Expand Up @@ -40,7 +41,6 @@ use rustc_span::def_id::CRATE_DEF_ID;
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,
};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -19,7 +20,6 @@ use rustc_span::source_map::Spanned;
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;

Expand Down Expand Up @@ -2735,7 +2735,7 @@ impl PrimTy {
#[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],
Expand Down Expand Up @@ -3313,7 +3313,7 @@ impl<'hir> Item<'hir> {

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;
Expand Down Expand Up @@ -3386,7 +3386,7 @@ pub struct FnHeader {
pub safety: Safety,
pub constness: Constness,
pub asyncness: IsAsync,
pub abi: Abi,
pub abi: ExternAbi,
}

impl FnHeader {
Expand Down Expand Up @@ -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>`.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ hir_analysis_missing_trait_item_suggestion = implement the missing item: `{$snip
hir_analysis_missing_trait_item_unstable = not all trait items implemented, missing: `{$missing_item_name}`
.note = default implementation of `{$missing_item_name}` is unstable
.some_note = use of unstable library feature '{$feature}': {$reason}
.none_note = use of unstable library feature '{$feature}'
.some_note = use of unstable library feature `{$feature}`: {$reason}
.none_note = use of unstable library feature `{$feature}`
hir_analysis_missing_type_params =
the type {$parameterCount ->
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_hir_typeck/src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -680,7 +680,8 @@ impl<'tcx> Visitor<'tcx> for AnnotateUnitFallbackVisitor<'_, 'tcx> {
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
Expand All @@ -701,7 +702,7 @@ impl<'tcx> Visitor<'tcx> for AnnotateUnitFallbackVisitor<'_, 'tcx> {
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)
{
Expand Down
13 changes: 6 additions & 7 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,10 +777,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) {
Expand Down Expand Up @@ -932,8 +930,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);
Expand All @@ -942,7 +941,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);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ pub fn report_unstable(
soft_handler: impl FnOnce(&'static Lint, Span, String),
) {
let msg = match reason {
Some(r) => format!("use of unstable library feature '{feature}': {r}"),
None => format!("use of unstable library feature '{feature}'"),
Some(r) => format!("use of unstable library feature `{feature}`: {r}"),
None => format!("use of unstable library feature `{feature}`"),
};

if is_soft {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_monomorphize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ mod move_check;
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;
Expand All @@ -236,7 +237,6 @@ use rustc_session::config::EntryFnType;
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};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_sanitizers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,8 +19,6 @@ use rustc_middle::ty::{
};
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;
Expand Down Expand Up @@ -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);
}
_ => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_sanitizers/src/cfi/typeid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_sanitizers/src/kcfi/typeid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
Loading

0 comments on commit d540225

Please sign in to comment.