Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6221,9 +6221,9 @@ dependencies = [

[[package]]
name = "wasi-preview1-component-adapter-provider"
version = "38.0.4"
version = "40.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ec3ef3783e18f2457796ed91b1e6c2adc46f2905f740d1527ab3053fe8e5682"
checksum = "bb5e2b9858989c3a257de4ca169977f4f79897b64e4f482f188f4fcf8ac557d1"

[[package]]
name = "wasm-bindgen"
Expand Down Expand Up @@ -6272,17 +6272,18 @@ dependencies = [

[[package]]
name = "wasm-component-ld"
version = "0.5.19"
version = "0.5.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bfc50dd0b883d841bc1dba5ff7020ca52fa7b2c3bb1266d8bf6a09dd032e115"
checksum = "846d20ed66ae37b7a237e36dfcd2fdc979eae82a46cdb0586f9bba80782fd789"
dependencies = [
"anyhow",
"clap",
"clap_lex",
"lexopt",
"libc",
"tempfile",
"wasi-preview1-component-adapter-provider",
"wasmparser 0.241.2",
"wasmparser 0.243.0",
"wat",
"windows-sys 0.61.2",
"winsplit",
Expand All @@ -6309,24 +6310,24 @@ dependencies = [

[[package]]
name = "wasm-encoder"
version = "0.241.2"
version = "0.243.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e01164c9dda68301e34fdae536c23ed6fe90ce6d97213ccc171eebbd3d02d6b8"
checksum = "c55db9c896d70bd9fa535ce83cd4e1f2ec3726b0edd2142079f594fc3be1cb35"
dependencies = [
"leb128fmt",
"wasmparser 0.241.2",
"wasmparser 0.243.0",
]

[[package]]
name = "wasm-metadata"
version = "0.241.2"
version = "0.243.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "876fe286f2fa416386deedebe8407e6f19e0b5aeaef3d03161e77a15fa80f167"
checksum = "eae05bf9579f45a62e8d0a4e3f52eaa8da518883ac5afa482ec8256c329ecd56"
dependencies = [
"anyhow",
"indexmap",
"wasm-encoder 0.241.2",
"wasmparser 0.241.2",
"wasm-encoder 0.243.0",
"wasmparser 0.243.0",
]

[[package]]
Expand All @@ -6351,9 +6352,9 @@ dependencies = [

[[package]]
name = "wasmparser"
version = "0.241.2"
version = "0.243.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46d90019b1afd4b808c263e428de644f3003691f243387d30d673211ee0cb8e8"
checksum = "f6d8db401b0528ec316dfbe579e6ab4152d61739cfe076706d2009127970159d"
dependencies = [
"bitflags",
"hashbrown 0.15.5",
Expand All @@ -6364,22 +6365,22 @@ dependencies = [

[[package]]
name = "wast"
version = "241.0.2"
version = "243.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63f66e07e2ddf531fef6344dbf94d112df7c2f23ed6ffb10962e711500b8d816"
checksum = "df21d01c2d91e46cb7a221d79e58a2d210ea02020d57c092e79255cc2999ca7f"
dependencies = [
"bumpalo",
"leb128fmt",
"memchr",
"unicode-width 0.2.2",
"wasm-encoder 0.241.2",
"wasm-encoder 0.243.0",
]

[[package]]
name = "wat"
version = "1.241.2"
version = "1.243.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45f923705c40830af909c5dec2352ec2821202e4a66008194585e1917458a26d"
checksum = "226a9a91cd80a50449312fef0c75c23478fcecfcc4092bdebe1dc8e760ef521b"
dependencies = [
"wast",
]
Expand Down Expand Up @@ -6775,9 +6776,9 @@ dependencies = [

[[package]]
name = "wit-component"
version = "0.241.2"
version = "0.243.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0c57df25e7ee612d946d3b7646c1ddb2310f8280aa2c17e543b66e0812241"
checksum = "36f9fc53513e461ce51dcf17a3e331752cb829f1d187069e54af5608fc998fe4"
dependencies = [
"anyhow",
"bitflags",
Expand All @@ -6786,17 +6787,17 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"wasm-encoder 0.241.2",
"wasm-encoder 0.243.0",
"wasm-metadata",
"wasmparser 0.241.2",
"wasmparser 0.243.0",
"wit-parser",
]

[[package]]
name = "wit-parser"
version = "0.241.2"
version = "0.243.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ef1c6ad67f35c831abd4039c02894de97034100899614d1c44e2268ad01c91"
checksum = "df983a8608e513d8997f435bb74207bf0933d0e49ca97aa9d8a6157164b9b7fc"
dependencies = [
"anyhow",
"id-arena",
Expand All @@ -6807,7 +6808,7 @@ dependencies = [
"serde_derive",
"serde_json",
"unicode-xid",
"wasmparser 0.241.2",
"wasmparser 0.243.0",
]

[[package]]
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ pub(crate) unsafe fn create_module<'ll>(
// LLVM 22 updated the NVPTX layout to indicate 256-bit vector load/store: https://github.com/llvm/llvm-project/pull/155198
target_data_layout = target_data_layout.replace("-i256:256", "");
}
if sess.target.arch == Arch::PowerPC64 {
// LLVM 22 updated the ABI alignment for double on AIX: https://github.com/llvm/llvm-project/pull/144673
target_data_layout = target_data_layout.replace("-f64:32:64", "");
}
}

// Ensure the data-layout values hardcoded remain the defaults.
Expand Down
36 changes: 30 additions & 6 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use rustc_ast_pretty::pprust::state::MacHeader;
use rustc_ast_pretty::pprust::{Comments, PrintState};
use rustc_hir::attrs::{AttributeKind, PrintAttribute};
use rustc_hir::{
BindingMode, ByRef, ConstArgKind, GenericArg, GenericBound, GenericParam, GenericParamKind,
HirId, ImplicitSelfKind, LifetimeParamKind, Node, PatKind, PreciseCapturingArg, RangeEnd, Term,
TyPatKind,
BindingMode, ByRef, ConstArg, ConstArgExprField, ConstArgKind, GenericArg, GenericBound,
GenericParam, GenericParamKind, HirId, ImplicitSelfKind, LifetimeParamKind, Node, PatKind,
PreciseCapturingArg, RangeEnd, Term, TyPatKind,
};
use rustc_span::source_map::SourceMap;
use rustc_span::{DUMMY_SP, FileName, Ident, Span, Symbol, kw, sym};
Expand Down Expand Up @@ -1141,16 +1141,40 @@ impl<'a> State<'a> {

fn print_const_arg(&mut self, const_arg: &hir::ConstArg<'_>) {
match &const_arg.kind {
// FIXME(mgca): proper printing for struct exprs
ConstArgKind::Struct(..) => self.word("/* STRUCT EXPR */"),
ConstArgKind::TupleCall(..) => self.word("/* TUPLE CALL */"),
ConstArgKind::Struct(qpath, fields) => self.print_const_struct(qpath, fields),
ConstArgKind::TupleCall(qpath, args) => self.print_const_ctor(qpath, args),
ConstArgKind::Path(qpath) => self.print_qpath(qpath, true),
ConstArgKind::Anon(anon) => self.print_anon_const(anon),
ConstArgKind::Error(_, _) => self.word("/*ERROR*/"),
ConstArgKind::Infer(..) => self.word("_"),
}
}

fn print_const_struct(&mut self, qpath: &hir::QPath<'_>, fields: &&[&ConstArgExprField<'_>]) {
self.print_qpath(qpath, true);
self.word(" ");
self.word("{");
if !fields.is_empty() {
self.nbsp();
}
self.commasep(Inconsistent, *fields, |s, field| {
s.word(field.field.as_str().to_string());
s.word(":");
s.nbsp();
s.print_const_arg(field.expr);
});
self.word("}");
}

fn print_const_ctor(&mut self, qpath: &hir::QPath<'_>, args: &&[&ConstArg<'_, ()>]) {
self.print_qpath(qpath, true);
self.word("(");
self.commasep(Inconsistent, *args, |s, arg| {
s.print_const_arg(arg);
});
self.word(")");
}

fn print_call_post(&mut self, args: &[hir::Expr<'_>]) {
self.popen();
self.commasep_exprs(Inconsistent, args);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ impl PickConstraintsForShadowed {
// An item never shadows itself
candidate.item.def_id != self.def_id
// and we're only concerned about inherent impls doing the shadowing.
// Shadowing can only occur if the shadowed is further along
// the Receiver dereferencing chain than the shadowed.
// Shadowing can only occur if the impl being shadowed is further along
// the Receiver dereferencing chain than the impl doing the shadowing.
&& match candidate.kind {
CandidateKind::InherentImplCandidate { receiver_steps, .. } => match self.receiver_steps {
Some(shadowed_receiver_steps) => receiver_steps > shadowed_receiver_steps,
Expand Down
24 changes: 1 addition & 23 deletions compiler/rustc_mir_build/src/thir/cx/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use rustc_hir as hir;
use rustc_index::Idx;
use rustc_middle::middle::region;
use rustc_middle::thir::*;
use rustc_middle::ty;
use rustc_middle::ty::CanonicalUserTypeAnnotation;
use tracing::debug;

use crate::thir::cx::ThirBuildCx;
Expand Down Expand Up @@ -73,29 +71,9 @@ impl<'tcx> ThirBuildCx<'tcx> {

let else_block = local.els.map(|els| self.mirror_block(els));

let mut pattern = self.pattern_from_hir(local.pat);
let pattern = self.pattern_from_hir_with_annotation(local.pat, local.ty);
debug!(?pattern);

if let Some(ty) = &local.ty
&& let Some(&user_ty) =
self.typeck_results.user_provided_types().get(ty.hir_id)
{
debug!("mirror_stmts: user_ty={:?}", user_ty);
let annotation = CanonicalUserTypeAnnotation {
user_ty: Box::new(user_ty),
span: ty.span,
inferred_ty: self.typeck_results.node_type(ty.hir_id),
};
pattern = Box::new(Pat {
ty: pattern.ty,
span: pattern.span,
kind: PatKind::AscribeUserType {
ascription: Ascription { annotation, variance: ty::Covariant },
subpattern: pattern,
},
});
}

let span = match local.init {
Some(init) => local.span.with_hi(init.span.hi()),
None => local.span,
Expand Down
22 changes: 16 additions & 6 deletions compiler/rustc_mir_build/src/thir/cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ use rustc_hir::{self as hir, HirId, find_attr};
use rustc_middle::bug;
use rustc_middle::thir::*;
use rustc_middle::ty::{self, TyCtxt};
use tracing::instrument;

use crate::thir::pattern::pat_from_hir;

/// Query implementation for [`TyCtxt::thir_body`].
pub(crate) fn thir_body(
Expand Down Expand Up @@ -111,9 +108,22 @@ impl<'tcx> ThirBuildCx<'tcx> {
}
}

#[instrument(level = "debug", skip(self))]
fn pattern_from_hir(&mut self, p: &'tcx hir::Pat<'tcx>) -> Box<Pat<'tcx>> {
pat_from_hir(self.tcx, self.typing_env, self.typeck_results, p)
fn pattern_from_hir(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Box<Pat<'tcx>> {
self.pattern_from_hir_with_annotation(pat, None)
}

fn pattern_from_hir_with_annotation(
&mut self,
pat: &'tcx hir::Pat<'tcx>,
let_stmt_type: Option<&hir::Ty<'tcx>>,
) -> Box<Pat<'tcx>> {
crate::thir::pattern::pat_from_hir(
self.tcx,
self.typing_env,
self.typeck_results,
pat,
let_stmt_type,
)
}

fn closure_env_param(&self, owner_def: LocalDefId, expr_id: HirId) -> Option<Param<'tcx>> {
Expand Down
32 changes: 29 additions & 3 deletions compiler/rustc_mir_build/src/thir/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ struct PatCtxt<'tcx> {
rust_2024_migration: Option<PatMigration<'tcx>>,
}

#[instrument(level = "debug", skip(tcx, typing_env, typeck_results), ret)]
pub(super) fn pat_from_hir<'tcx>(
tcx: TyCtxt<'tcx>,
typing_env: ty::TypingEnv<'tcx>,
typeck_results: &'tcx ty::TypeckResults<'tcx>,
pat: &'tcx hir::Pat<'tcx>,
// Present if `pat` came from a let statement with an explicit type annotation
let_stmt_type: Option<&hir::Ty<'tcx>>,
) -> Box<Pat<'tcx>> {
let mut pcx = PatCtxt {
tcx,
Expand All @@ -54,12 +57,35 @@ pub(super) fn pat_from_hir<'tcx>(
.get(pat.hir_id)
.map(PatMigration::new),
};
let result = pcx.lower_pattern(pat);
debug!("pat_from_hir({:?}) = {:?}", pat, result);

let mut thir_pat = pcx.lower_pattern(pat);

// If this pattern came from a let statement with an explicit type annotation
// (e.g. `let x: Foo = ...`), retain that user type information in the THIR pattern.
if let Some(let_stmt_type) = let_stmt_type
&& let Some(&user_ty) = typeck_results.user_provided_types().get(let_stmt_type.hir_id)
{
debug!(?user_ty);
let annotation = CanonicalUserTypeAnnotation {
user_ty: Box::new(user_ty),
span: let_stmt_type.span,
inferred_ty: typeck_results.node_type(let_stmt_type.hir_id),
};
thir_pat = Box::new(Pat {
ty: thir_pat.ty,
span: thir_pat.span,
kind: PatKind::AscribeUserType {
ascription: Ascription { annotation, variance: ty::Covariant },
subpattern: thir_pat,
},
});
}

if let Some(m) = pcx.rust_2024_migration {
m.emit(tcx, pat.hir_id);
}
result

thir_pat
}

impl<'tcx> PatCtxt<'tcx> {
Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,15 @@ fn maybe_record_as_seed<'tcx>(
match tcx.def_kind(parent) {
DefKind::Impl { of_trait: false } | DefKind::Trait => {}
DefKind::Impl { of_trait: true } => {
if let Some(trait_item_def_id) =
tcx.associated_item(owner_id.def_id).trait_item_def_id()
&& let Some(trait_item_local_def_id) = trait_item_def_id.as_local()
&& let Some(comes_from_allow) =
has_allow_dead_code_or_lang_attr(tcx, trait_item_local_def_id)
{
worklist.push((owner_id.def_id, comes_from_allow));
}

// We only care about associated items of traits,
// because they cannot be visited directly,
// so we later mark them as live if their corresponding traits
Expand All @@ -791,6 +800,14 @@ fn maybe_record_as_seed<'tcx>(
}
DefKind::Impl { of_trait: true } => {
if allow_dead_code.is_none() {
if let Some(trait_def_id) =
tcx.impl_trait_ref(owner_id.def_id).skip_binder().def_id.as_local()
&& let Some(comes_from_allow) =
has_allow_dead_code_or_lang_attr(tcx, trait_def_id)
{
worklist.push((owner_id.def_id, comes_from_allow));
}

unsolved_items.push(owner_id.def_id);
}
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pub(crate) fn target() -> Target {
std: None, // ?
},
pointer_width: 64,
data_layout: "E-m:a-Fi64-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "E-m:a-Fi64-i64:64-i128:128-n32:64-f64:32:64-S128-v256:256:256-v512:512:512"
.into(),
arch: Arch::PowerPC64,
options: base,
}
Expand Down
Loading
Loading