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
58 changes: 30 additions & 28 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,6 @@ dependencies = [
"allocator-api2",
"equivalent",
"foldhash 0.1.5",
"serde",
]

[[package]]
Expand All @@ -1675,6 +1674,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [
"foldhash 0.2.0",
"serde",
"serde_core",
]

[[package]]
Expand Down Expand Up @@ -1898,9 +1899,9 @@ dependencies = [

[[package]]
name = "id-arena"
version = "2.2.1"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"

[[package]]
name = "ident_case"
Expand Down Expand Up @@ -6152,9 +6153,9 @@ dependencies = [

[[package]]
name = "wasm-component-ld"
version = "0.5.20"
version = "0.5.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "846d20ed66ae37b7a237e36dfcd2fdc979eae82a46cdb0586f9bba80782fd789"
checksum = "59dcd765f510df84d1677a502c49057761486597a95950b4c92153e5707af091"
dependencies = [
"anyhow",
"clap",
Expand All @@ -6163,7 +6164,7 @@ dependencies = [
"libc",
"tempfile",
"wasi-preview1-component-adapter-provider",
"wasmparser 0.243.0",
"wasmparser 0.245.1",
"wat",
"windows-sys 0.61.2",
"winsplit",
Expand All @@ -6190,24 +6191,24 @@ dependencies = [

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

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

[[package]]
Expand All @@ -6232,35 +6233,35 @@ dependencies = [

[[package]]
name = "wasmparser"
version = "0.243.0"
version = "0.245.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6d8db401b0528ec316dfbe579e6ab4152d61739cfe076706d2009127970159d"
checksum = "4f08c9adee0428b7bddf3890fc27e015ac4b761cc608c822667102b8bfd6995e"
dependencies = [
"bitflags",
"hashbrown 0.15.5",
"hashbrown 0.16.1",
"indexmap",
"semver",
"serde",
]

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

[[package]]
name = "wat"
version = "1.243.0"
version = "1.245.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "226a9a91cd80a50449312fef0c75c23478fcecfcc4092bdebe1dc8e760ef521b"
checksum = "cd48d1679b6858988cb96b154dda0ec5bbb09275b71db46057be37332d5477be"
dependencies = [
"wast",
]
Expand Down Expand Up @@ -6707,9 +6708,9 @@ dependencies = [

[[package]]
name = "wit-component"
version = "0.243.0"
version = "0.245.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36f9fc53513e461ce51dcf17a3e331752cb829f1d187069e54af5608fc998fe4"
checksum = "4894f10d2d5cbc17c77e91f86a1e48e191a788da4425293b55c98b44ba3fcac9"
dependencies = [
"anyhow",
"bitflags",
Expand All @@ -6718,19 +6719,20 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"wasm-encoder 0.243.0",
"wasm-encoder 0.245.1",
"wasm-metadata",
"wasmparser 0.243.0",
"wasmparser 0.245.1",
"wit-parser",
]

[[package]]
name = "wit-parser"
version = "0.243.0"
version = "0.245.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df983a8608e513d8997f435bb74207bf0933d0e49ca97aa9d8a6157164b9b7fc"
checksum = "330698718e82983499419494dd1e3d7811a457a9bf9f69734e8c5f07a2547929"
dependencies = [
"anyhow",
"hashbrown 0.16.1",
"id-arena",
"indexmap",
"log",
Expand All @@ -6739,7 +6741,7 @@ dependencies = [
"serde_derive",
"serde_json",
"unicode-xid",
"wasmparser 0.243.0",
"wasmparser 0.245.1",
]

[[package]]
Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,19 @@ impl Align {
// LLVM has a maximal supported alignment of 2^29, we inherit that.
pub const MAX: Align = Align { pow2: 29 };

/// Either `1 << (pointer_bits - 1)` or [`Align::MAX`], whichever is smaller.
#[inline]
pub fn max_for_target(tdl: &TargetDataLayout) -> Align {
let pointer_bits = tdl.pointer_size().bits();
if let Ok(pointer_bits) = u8::try_from(pointer_bits)
&& pointer_bits <= Align::MAX.pow2
{
Align { pow2: pointer_bits - 1 }
} else {
Align::MAX
}
}

#[inline]
pub fn from_bits(bits: u64) -> Result<Align, AlignFromBytesError> {
Align::from_bytes(Size::from_bits(bits).bytes())
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let predicates = match parent.kind {
hir::ExprKind::Call(callee, _) => {
let ty = typeck_result.node_type_opt(callee.hir_id)?;
let ty::FnDef(fn_def_id, args) = ty.kind() else { return None };
let ty::FnDef(fn_def_id, args) = *ty.kind() else { return None };
tcx.predicates_of(fn_def_id).instantiate(tcx, args)
}
hir::ExprKind::MethodCall(..) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
}
_ => {
let local = &self.body.local_decls[local];
match local.local_info() {
match *local.local_info() {
LocalInfo::StaticRef { def_id, .. } => {
let span = self.infcx.tcx.def_span(def_id);
err.span_label(span, format!("this `static` cannot be {acted_on}"));
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let tcx = self.infcx.tcx;

let ConstraintCategory::CallArgument(Some(func_ty)) = category else { return };
let ty::FnDef(fn_did, args) = func_ty.kind() else { return };
let ty::FnDef(fn_did, args) = *func_ty.kind() else { return };
debug!(?fn_did, ?args);

// Only suggest this on function calls, not closures
Expand All @@ -938,7 +938,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let Ok(Some(instance)) = ty::Instance::try_resolve(
tcx,
self.infcx.typing_env(self.infcx.param_env),
*fn_did,
fn_did,
self.infcx.resolve_vars_if_possible(args),
) else {
return;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,12 +1013,12 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
let is_implicit_coercion = coercion_source == CoercionSource::Implicit;
let src_ty = op.ty(self.body, tcx);
let mut src_sig = src_ty.fn_sig(tcx);
if let ty::FnDef(def_id, _) = src_ty.kind()
if let ty::FnDef(def_id, _) = *src_ty.kind()
&& let ty::FnPtr(_, target_hdr) = *ty.kind()
&& tcx.codegen_fn_attrs(def_id).safe_target_features
&& target_hdr.safety.is_safe()
&& let Some(safe_sig) = tcx.adjust_target_feature_sig(
*def_id,
def_id,
src_sig,
self.body.source.def_id(),
)
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_abi::WrappingRange;
use rustc_abi::{Align, WrappingRange};
use rustc_middle::mir::SourceInfo;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::{bug, span_bug};
Expand Down Expand Up @@ -179,9 +179,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let size_bound = bx.data_layout().ptr_sized_integer().signed_max() as u128;
bx.range_metadata(value, WrappingRange { start: 0, end: size_bound });
}
// Alignment is always nonzero.
// Alignment is always a power of two, thus 1..=0x800…000,
// but also bounded by the maximum we support in type layout.
sym::vtable_align => {
bx.range_metadata(value, WrappingRange { start: 1, end: !0 })
let align_bound = Align::max_for_target(bx.data_layout()).bytes().into();
bx.range_metadata(value, WrappingRange { start: 1, end: align_bound })
}
_ => {}
}
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_codegen_ssa/src/size_of_val.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Computing the size and alignment of a value.
use rustc_abi::WrappingRange;
use rustc_abi::{Align, WrappingRange};
use rustc_hir::LangItem;
use rustc_middle::bug;
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
Expand Down Expand Up @@ -36,8 +36,10 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// Size is always <= isize::MAX.
let size_bound = bx.data_layout().ptr_sized_integer().signed_max() as u128;
bx.range_metadata(size, WrappingRange { start: 0, end: size_bound });
// Alignment is always nonzero.
bx.range_metadata(align, WrappingRange { start: 1, end: !0 });
// Alignment is always a power of two, thus 1..=0x800…000,
// but also bounded by the maximum we support in type layout.
let align_bound = Align::max_for_target(bx.data_layout()).bytes().into();
bx.range_metadata(align, WrappingRange { start: 1, end: align_bound });

(size, align)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {

Rvalue::Aggregate(kind, ..) => {
if let AggregateKind::Coroutine(def_id, ..) = kind.as_ref()
&& let Some(coroutine_kind) = self.tcx.coroutine_kind(def_id)
&& let Some(coroutine_kind) = self.tcx.coroutine_kind(*def_id)
{
self.check_op(ops::Coroutine(coroutine_kind));
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ fn check_impl_items_against_trait<'tcx>(
match impl_trait_header.polarity {
ty::ImplPolarity::Reservation | ty::ImplPolarity::Positive => {}
ty::ImplPolarity::Negative => {
if let [first_item_ref, ..] = impl_item_refs {
if let [first_item_ref, ..] = *impl_item_refs {
let first_item_span = tcx.def_span(first_item_ref);
struct_span_code_err!(
tcx.dcx(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ fn check_region_late_boundedness<'tcx>(
.iter()
.map(|param| {
let (LateEarlyMismatch::EarlyInImpl(impl_param_def_id, ..)
| LateEarlyMismatch::LateInImpl(impl_param_def_id, ..)) = param;
| LateEarlyMismatch::LateInImpl(impl_param_def_id, ..)) = *param;
tcx.def_span(impl_param_def_id)
})
.collect();
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2445,12 +2445,12 @@ fn is_late_bound_map(
)) => {
// See comments on `ConstrainedCollectorPostHirTyLowering` for why this arm does not
// just consider args to be unconstrained.
let generics = self.tcx.generics_of(alias_def);
let generics = self.tcx.generics_of(*alias_def);
let mut walker = ConstrainedCollectorPostHirTyLowering {
arg_is_constrained: vec![false; generics.own_params.len()]
.into_boxed_slice(),
};
walker.visit_ty(self.tcx.type_of(alias_def).instantiate_identity());
walker.visit_ty(self.tcx.type_of(*alias_def).instantiate_identity());

match segments.last() {
Some(hir::PathSegment { args: Some(args), .. }) => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
if let [best_trait] = visible_traits
.iter()
.copied()
.filter(|trait_def_id| {
.filter(|&trait_def_id| {
tcx.associated_items(trait_def_id)
.filter_by_name_unhygienic(suggested_name)
.any(|item| item.tag() == assoc_tag)
Expand Down Expand Up @@ -1234,7 +1234,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&& let name = Symbol::intern(&format!("{ident2}_{ident3}"))
&& let Some(item) = inherent_impls
.iter()
.flat_map(|inherent_impl| {
.flat_map(|&inherent_impl| {
tcx.associated_items(inherent_impl).filter_by_name_unhygienic(name)
})
.next()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/impl_wf_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained(
let lifetimes_in_associated_types: FxHashSet<_> = tcx
.associated_item_def_ids(impl_def_id)
.iter()
.flat_map(|def_id| {
.flat_map(|&def_id| {
let item = tcx.associated_item(def_id);
match item.kind {
ty::AssocKind::Type { .. } => {
Expand Down
24 changes: 23 additions & 1 deletion compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
result = self.try_overloaded_call_step(call_expr, callee_expr, arg_exprs, &autoderef);
}

match autoderef.final_ty().kind() {
match *autoderef.final_ty().kind() {
ty::FnDef(def_id, _) => {
let abi = self.tcx.fn_sig(def_id).skip_binder().skip_binder().abi;
self.check_call_abi(abi, call_expr.span);
Expand All @@ -98,6 +98,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => { /* cannot have a non-rust abi */ }
}

if self.is_scalable_vector_ctor(autoderef.final_ty()) {
let mut err = self.dcx().create_err(errors::ScalableVectorCtor {
span: callee_expr.span,
ty: autoderef.final_ty(),
});
err.span_label(callee_expr.span, "you can create scalable vectors using intrinsics");
Ty::new_error(self.tcx, err.emit());
}

self.register_predicates(autoderef.into_obligations());

let output = match result {
Expand Down Expand Up @@ -420,6 +429,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
None
}

fn is_scalable_vector_ctor(&self, callee_ty: Ty<'_>) -> bool {
if let ty::FnDef(def_id, _) = callee_ty.kind()
&& let def::DefKind::Ctor(def::CtorOf::Struct, _) = self.tcx.def_kind(def_id)
{
self.tcx
.opt_parent(*def_id)
.and_then(|id| self.tcx.adt_def(id).repr().scalable)
.is_some()
} else {
false
}
}

/// Give appropriate suggestion when encountering `||{/* not callable */}()`, where the
/// likely intention is to call the closure, suggest `(||{})()`. (#55851)
fn identify_bad_closure_def_and_call(
Expand Down
Loading
Loading