Auto merge of #141824 - matthiaskrgr:rollup-7nffwd0, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#140787 (Note expr being cast when encounter NonScalar cast error)
 - rust-lang/rust#141112 (std: note that `std::str::from_utf8*` functions are aliases to `<str>::from_utf8*` methods)
 - rust-lang/rust#141646 (Document what `distcheck` is intended to exercise)
 - rust-lang/rust#141740 (Hir item kind field order)
 - rust-lang/rust#141793 (`tests/ui`: A New Order [1/N])
 - rust-lang/rust#141805 (Update `compiler-builtins` to 0.1.160)
 - rust-lang/rust#141815 (Enable non-leaf Frame Pointers for mingw-w64 Arm64 Windows)
 - rust-lang/rust#141819 (Fixes for building windows-gnullvm hosts)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-05-31 18:16:35 +00:00
commit 4d08223c05
66 changed files with 323 additions and 242 deletions

View file

@ -164,7 +164,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
fn visit_item(&mut self, i: &'hir Item<'hir>) {
debug_assert_eq!(i.owner_id, self.owner);
self.with_parent(i.hir_id(), |this| {
if let ItemKind::Struct(_, struct_def, _) = &i.kind {
if let ItemKind::Struct(_, _, struct_def) = &i.kind {
// If this is a tuple or unit-like struct, register the constructor.
if let Some(ctor_hir_id) = struct_def.ctor_hir_id() {
this.insert(i.span, ctor_hir_id, Node::Ctor(struct_def));

View file

@ -180,7 +180,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let (ty, body_id) =
self.lower_const_item(t, span, e.as_deref(), ImplTraitPosition::StaticTy);
self.lower_define_opaque(hir_id, define_opaque);
hir::ItemKind::Static(ident, ty, *m, body_id)
hir::ItemKind::Static(*m, ident, ty, body_id)
}
ItemKind::Const(box ast::ConstItem {
ident,
@ -200,7 +200,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
},
);
self.lower_define_opaque(hir_id, &define_opaque);
hir::ItemKind::Const(ident, ty, generics, body_id)
hir::ItemKind::Const(ident, generics, ty, body_id)
}
ItemKind::Fn(box Fn {
sig: FnSig { decl, header, span: fn_sig_span },
@ -304,7 +304,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
),
},
);
hir::ItemKind::TyAlias(ident, ty, generics)
hir::ItemKind::TyAlias(ident, generics, ty)
}
ItemKind::Enum(ident, generics, enum_definition) => {
let ident = self.lower_ident(*ident);
@ -318,7 +318,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
)
},
);
hir::ItemKind::Enum(ident, hir::EnumDef { variants }, generics)
hir::ItemKind::Enum(ident, generics, hir::EnumDef { variants })
}
ItemKind::Struct(ident, generics, struct_def) => {
let ident = self.lower_ident(*ident);
@ -328,7 +328,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|this| this.lower_variant_data(hir_id, struct_def),
);
hir::ItemKind::Struct(ident, struct_def, generics)
hir::ItemKind::Struct(ident, generics, struct_def)
}
ItemKind::Union(ident, generics, vdata) => {
let ident = self.lower_ident(*ident);
@ -338,7 +338,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|this| this.lower_variant_data(hir_id, vdata),
);
hir::ItemKind::Union(ident, vdata, generics)
hir::ItemKind::Union(ident, generics, vdata)
}
ItemKind::Impl(box Impl {
safety,
@ -467,8 +467,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
ItemKind::Delegation(box delegation) => {
let delegation_results = self.lower_delegation(delegation, id, false);
hir::ItemKind::Fn {
ident: delegation_results.ident,
sig: delegation_results.sig,
ident: delegation_results.ident,
generics: delegation_results.generics,
body: delegation_results.body_id,
has_body: true,

View file

@ -4106,11 +4106,11 @@ impl<'hir> Item<'hir> {
expect_use, (&'hir UsePath<'hir>, UseKind), ItemKind::Use(p, uk), (p, *uk);
expect_static, (Ident, &'hir Ty<'hir>, Mutability, BodyId),
ItemKind::Static(ident, ty, mutbl, body), (*ident, ty, *mutbl, *body);
expect_static, (Mutability, Ident, &'hir Ty<'hir>, BodyId),
ItemKind::Static(mutbl, ident, ty, body), (*mutbl, *ident, ty, *body);
expect_const, (Ident, &'hir Ty<'hir>, &'hir Generics<'hir>, BodyId),
ItemKind::Const(ident, ty, generics, body), (*ident, ty, generics, *body);
expect_const, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, BodyId),
ItemKind::Const(ident, generics, ty, body), (*ident, generics, ty, *body);
expect_fn, (Ident, &FnSig<'hir>, &'hir Generics<'hir>, BodyId),
ItemKind::Fn { ident, sig, generics, body, .. }, (*ident, sig, generics, *body);
@ -4125,17 +4125,17 @@ impl<'hir> Item<'hir> {
expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm { asm, .. }, asm;
expect_ty_alias, (Ident, &'hir Ty<'hir>, &'hir Generics<'hir>),
ItemKind::TyAlias(ident, ty, generics), (*ident, ty, generics);
expect_ty_alias, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
ItemKind::TyAlias(ident, generics, ty), (*ident, generics, ty);
expect_enum, (Ident, &EnumDef<'hir>, &'hir Generics<'hir>),
ItemKind::Enum(ident, def, generics), (*ident, def, generics);
expect_enum, (Ident, &'hir Generics<'hir>, &EnumDef<'hir>),
ItemKind::Enum(ident, generics, def), (*ident, generics, def);
expect_struct, (Ident, &VariantData<'hir>, &'hir Generics<'hir>),
ItemKind::Struct(ident, data, generics), (*ident, data, generics);
expect_struct, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
ItemKind::Struct(ident, generics, data), (*ident, generics, data);
expect_union, (Ident, &VariantData<'hir>, &'hir Generics<'hir>),
ItemKind::Union(ident, data, generics), (*ident, data, generics);
expect_union, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
ItemKind::Union(ident, generics, data), (*ident, generics, data);
expect_trait,
(
@ -4278,13 +4278,13 @@ pub enum ItemKind<'hir> {
Use(&'hir UsePath<'hir>, UseKind),
/// A `static` item.
Static(Ident, &'hir Ty<'hir>, Mutability, BodyId),
Static(Mutability, Ident, &'hir Ty<'hir>, BodyId),
/// A `const` item.
Const(Ident, &'hir Ty<'hir>, &'hir Generics<'hir>, BodyId),
Const(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, BodyId),
/// A function declaration.
Fn {
ident: Ident,
sig: FnSig<'hir>,
ident: Ident,
generics: &'hir Generics<'hir>,
body: BodyId,
/// Whether this function actually has a body.
@ -4309,13 +4309,13 @@ pub enum ItemKind<'hir> {
fake_body: BodyId,
},
/// A type alias, e.g., `type Foo = Bar<u8>`.
TyAlias(Ident, &'hir Ty<'hir>, &'hir Generics<'hir>),
TyAlias(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
/// An enum definition, e.g., `enum Foo<A, B> { C<A>, D<B> }`.
Enum(Ident, EnumDef<'hir>, &'hir Generics<'hir>),
Enum(Ident, &'hir Generics<'hir>, EnumDef<'hir>),
/// A struct definition, e.g., `struct Foo<A> {x: A}`.
Struct(Ident, VariantData<'hir>, &'hir Generics<'hir>),
Struct(Ident, &'hir Generics<'hir>, VariantData<'hir>),
/// A union definition, e.g., `union Foo<A, B> {x: A, y: B}`.
Union(Ident, VariantData<'hir>, &'hir Generics<'hir>),
Union(Ident, &'hir Generics<'hir>, VariantData<'hir>),
/// A trait definition.
Trait(IsAuto, Safety, Ident, &'hir Generics<'hir>, GenericBounds<'hir>, &'hir [TraitItemRef]),
/// A trait alias.
@ -4352,7 +4352,7 @@ impl ItemKind<'_> {
match *self {
ItemKind::ExternCrate(_, ident)
| ItemKind::Use(_, UseKind::Single(ident))
| ItemKind::Static(ident, ..)
| ItemKind::Static(_, ident, ..)
| ItemKind::Const(ident, ..)
| ItemKind::Fn { ident, .. }
| ItemKind::Macro(ident, ..)
@ -4374,11 +4374,11 @@ impl ItemKind<'_> {
pub fn generics(&self) -> Option<&Generics<'_>> {
Some(match self {
ItemKind::Fn { generics, .. }
| ItemKind::TyAlias(_, _, generics)
| ItemKind::Const(_, _, generics, _)
| ItemKind::Enum(_, _, generics)
| ItemKind::Struct(_, _, generics)
| ItemKind::Union(_, _, generics)
| ItemKind::TyAlias(_, generics, _)
| ItemKind::Const(_, generics, _, _)
| ItemKind::Enum(_, generics, _)
| ItemKind::Struct(_, generics, _)
| ItemKind::Union(_, generics, _)
| ItemKind::Trait(_, _, _, generics, _, _)
| ItemKind::TraitAlias(_, generics, _)
| ItemKind::Impl(Impl { generics, .. }) => generics,
@ -4802,9 +4802,9 @@ impl<'hir> Node<'hir> {
pub fn ty(self) -> Option<&'hir Ty<'hir>> {
match self {
Node::Item(it) => match it.kind {
ItemKind::TyAlias(_, ty, _)
| ItemKind::Static(_, ty, _, _)
| ItemKind::Const(_, ty, _, _) => Some(ty),
ItemKind::TyAlias(_, _, ty)
| ItemKind::Static(_, _, ty, _)
| ItemKind::Const(_, _, ty, _) => Some(ty),
ItemKind::Impl(impl_item) => Some(&impl_item.self_ty),
_ => None,
},
@ -4824,7 +4824,7 @@ impl<'hir> Node<'hir> {
pub fn alias_ty(self) -> Option<&'hir Ty<'hir>> {
match self {
Node::Item(Item { kind: ItemKind::TyAlias(_, ty, _), .. }) => Some(ty),
Node::Item(Item { kind: ItemKind::TyAlias(_, _, ty), .. }) => Some(ty),
_ => None,
}
}

View file

@ -545,15 +545,15 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
UseKind::Glob | UseKind::ListStem => {}
}
}
ItemKind::Static(ident, ref typ, _, body) => {
ItemKind::Static(_, ident, ref typ, body) => {
try_visit!(visitor.visit_ident(ident));
try_visit!(visitor.visit_ty_unambig(typ));
try_visit!(visitor.visit_nested_body(body));
}
ItemKind::Const(ident, ref typ, ref generics, body) => {
ItemKind::Const(ident, ref generics, ref typ, body) => {
try_visit!(visitor.visit_ident(ident));
try_visit!(visitor.visit_ty_unambig(typ));
try_visit!(visitor.visit_generics(generics));
try_visit!(visitor.visit_ty_unambig(typ));
try_visit!(visitor.visit_nested_body(body));
}
ItemKind::Fn { ident, sig, generics, body: body_id, .. } => {
@ -583,12 +583,12 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
// typeck results set correctly.
try_visit!(visitor.visit_nested_body(fake_body));
}
ItemKind::TyAlias(ident, ref ty, ref generics) => {
ItemKind::TyAlias(ident, ref generics, ref ty) => {
try_visit!(visitor.visit_ident(ident));
try_visit!(visitor.visit_ty_unambig(ty));
try_visit!(visitor.visit_generics(generics));
try_visit!(visitor.visit_ty_unambig(ty));
}
ItemKind::Enum(ident, ref enum_definition, ref generics) => {
ItemKind::Enum(ident, ref generics, ref enum_definition) => {
try_visit!(visitor.visit_ident(ident));
try_visit!(visitor.visit_generics(generics));
try_visit!(visitor.visit_enum_def(enum_definition));
@ -609,8 +609,8 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
try_visit!(visitor.visit_ty_unambig(self_ty));
walk_list!(visitor, visit_impl_item_ref, *items);
}
ItemKind::Struct(ident, ref struct_definition, ref generics)
| ItemKind::Union(ident, ref struct_definition, ref generics) => {
ItemKind::Struct(ident, ref generics, ref struct_definition)
| ItemKind::Union(ident, ref generics, ref struct_definition) => {
try_visit!(visitor.visit_ident(ident));
try_visit!(visitor.visit_generics(generics));
try_visit!(visitor.visit_variant_data(struct_definition));

View file

@ -297,32 +297,30 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
hir::ItemKind::Fn { ident, sig, .. } => {
check_item_fn(tcx, def_id, ident, item.span, sig.decl)
}
hir::ItemKind::Static(_, ty, ..) => {
hir::ItemKind::Static(_, _, ty, _) => {
check_static_item(tcx, def_id, ty.span, UnsizedHandling::Forbid)
}
hir::ItemKind::Const(_, ty, ..) => check_const_item(tcx, def_id, ty.span, item.span),
hir::ItemKind::Struct(_, _, hir_generics) => {
hir::ItemKind::Const(_, _, ty, _) => check_const_item(tcx, def_id, ty.span, item.span),
hir::ItemKind::Struct(_, generics, _) => {
let res = check_type_defn(tcx, item, false);
check_variances_for_type_defn(tcx, item, hir_generics);
check_variances_for_type_defn(tcx, item, generics);
res
}
hir::ItemKind::Union(_, _, hir_generics) => {
hir::ItemKind::Union(_, generics, _) => {
let res = check_type_defn(tcx, item, true);
check_variances_for_type_defn(tcx, item, hir_generics);
check_variances_for_type_defn(tcx, item, generics);
res
}
hir::ItemKind::Enum(_, _, hir_generics) => {
hir::ItemKind::Enum(_, generics, _) => {
let res = check_type_defn(tcx, item, true);
check_variances_for_type_defn(tcx, item, hir_generics);
check_variances_for_type_defn(tcx, item, generics);
res
}
hir::ItemKind::Trait(..) => check_trait(tcx, item),
hir::ItemKind::TraitAlias(..) => check_trait(tcx, item),
// `ForeignItem`s are handled separately.
hir::ItemKind::ForeignMod { .. } => Ok(()),
hir::ItemKind::TyAlias(_, hir_ty, hir_generics)
if tcx.type_alias_is_lazy(item.owner_id) =>
{
hir::ItemKind::TyAlias(_, generics, hir_ty) if tcx.type_alias_is_lazy(item.owner_id) => {
let res = enter_wf_checking_ctxt(tcx, item.span, def_id, |wfcx| {
let ty = tcx.type_of(def_id).instantiate_identity();
let item_ty =
@ -335,7 +333,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
check_where_clauses(wfcx, item.span, def_id);
Ok(())
});
check_variances_for_type_defn(tcx, item, hir_generics);
check_variances_for_type_defn(tcx, item, generics);
res
}
_ => Ok(()),

View file

@ -248,13 +248,13 @@ fn reject_placeholder_type_signatures_in_item<'tcx>(
item: &'tcx hir::Item<'tcx>,
) {
let (generics, suggest) = match &item.kind {
hir::ItemKind::Union(_, _, generics)
| hir::ItemKind::Enum(_, _, generics)
hir::ItemKind::Union(_, generics, _)
| hir::ItemKind::Enum(_, generics, _)
| hir::ItemKind::TraitAlias(_, generics, _)
| hir::ItemKind::Trait(_, _, _, generics, ..)
| hir::ItemKind::Impl(hir::Impl { generics, .. })
| hir::ItemKind::Struct(_, _, generics) => (generics, true),
hir::ItemKind::TyAlias(_, _, generics) => (generics, false),
| hir::ItemKind::Struct(_, generics, _) => (generics, true),
hir::ItemKind::TyAlias(_, generics, _) => (generics, false),
// `static`, `fn` and `const` are handled elsewhere to suggest appropriate type.
_ => return,
};
@ -470,9 +470,9 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
.tcx
.hir_expect_item(self.tcx.hir_get_parent_item(self.hir_id()).def_id);
match &item.kind {
hir::ItemKind::Enum(_, _, generics)
| hir::ItemKind::Struct(_, _, generics)
| hir::ItemKind::Union(_, _, generics) => {
hir::ItemKind::Enum(_, generics, _)
| hir::ItemKind::Struct(_, generics, _)
| hir::ItemKind::Union(_, generics, _) => {
let lt_name = get_new_lifetime_name(self.tcx, poly_trait_ref, generics);
let (lt_sp, sugg) = match generics.params {
[] => (generics.span, format!("<{lt_name}>")),
@ -740,7 +740,7 @@ fn lower_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
tcx.at(it.span).explicit_super_predicates_of(def_id);
tcx.ensure_ok().predicates_of(def_id);
}
hir::ItemKind::Struct(_, struct_def, _) | hir::ItemKind::Union(_, struct_def, _) => {
hir::ItemKind::Struct(_, _, struct_def) | hir::ItemKind::Union(_, _, struct_def) => {
tcx.ensure_ok().generics_of(def_id);
tcx.ensure_ok().type_of(def_id);
tcx.ensure_ok().predicates_of(def_id);
@ -762,7 +762,7 @@ fn lower_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
tcx.ensure_ok().predicates_of(def_id);
}
hir::ItemKind::Static(_, ty, ..) | hir::ItemKind::Const(_, ty, ..) => {
hir::ItemKind::Static(_, _, ty, _) | hir::ItemKind::Const(_, _, ty, _) => {
tcx.ensure_ok().generics_of(def_id);
tcx.ensure_ok().type_of(def_id);
tcx.ensure_ok().predicates_of(def_id);
@ -1093,7 +1093,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
let repr = tcx.repr_options_of_def(def_id);
let (kind, variants) = match &item.kind {
ItemKind::Enum(_, def, _) => {
ItemKind::Enum(_, _, def) => {
let mut distance_from_explicit = 0;
let variants = def
.variants
@ -1121,7 +1121,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
(AdtKind::Enum, variants)
}
ItemKind::Struct(ident, def, _) | ItemKind::Union(ident, def, _) => {
ItemKind::Struct(ident, _, def) | ItemKind::Union(ident, _, def) => {
let adt_kind = match item.kind {
ItemKind::Struct(..) => AdtKind::Struct,
_ => AdtKind::Union,

View file

@ -634,11 +634,11 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
// These sorts of items have no lifetime parameters at all.
intravisit::walk_item(self, item);
}
hir::ItemKind::TyAlias(_, _, generics)
| hir::ItemKind::Const(_, _, generics, _)
| hir::ItemKind::Enum(_, _, generics)
| hir::ItemKind::Struct(_, _, generics)
| hir::ItemKind::Union(_, _, generics)
hir::ItemKind::TyAlias(_, generics, _)
| hir::ItemKind::Const(_, generics, _, _)
| hir::ItemKind::Enum(_, generics, _)
| hir::ItemKind::Struct(_, generics, _)
| hir::ItemKind::Union(_, generics, _)
| hir::ItemKind::Trait(_, _, _, generics, ..)
| hir::ItemKind::TraitAlias(_, generics, ..)
| hir::ItemKind::Impl(&hir::Impl { generics, .. }) => {

View file

@ -206,7 +206,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
},
Node::Item(item) => match item.kind {
ItemKind::Static(ident, ty, .., body_id) => {
ItemKind::Static(_, ident, ty, body_id) => {
if ty.is_suggestable_infer_ty() {
infer_placeholder_type(
icx.lowerer(),
@ -220,7 +220,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
icx.lower_ty(ty)
}
}
ItemKind::Const(ident, ty, _, body_id) => {
ItemKind::Const(ident, _, ty, body_id) => {
if ty.is_suggestable_infer_ty() {
infer_placeholder_type(
icx.lowerer(),
@ -234,7 +234,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
icx.lower_ty(ty)
}
}
ItemKind::TyAlias(_, self_ty, _) => icx.lower_ty(self_ty),
ItemKind::TyAlias(_, _, self_ty) => icx.lower_ty(self_ty),
ItemKind::Impl(hir::Impl { self_ty, .. }) => match self_ty.find_self_aliases() {
spans if spans.len() > 0 => {
let guar = tcx
@ -532,5 +532,5 @@ pub(crate) fn type_alias_is_lazy<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) ->
}
}
}
HasTait.visit_ty_unambig(tcx.hir_expect_item(def_id).expect_ty_alias().1).is_break()
HasTait.visit_ty_unambig(tcx.hir_expect_item(def_id).expect_ty_alias().2).is_break()
}

View file

@ -141,7 +141,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let generics = match tcx.hir_node_by_def_id(parent_item) {
hir::Node::Item(hir::Item {
kind: hir::ItemKind::Struct(_, variant, generics),
kind: hir::ItemKind::Struct(_, generics, variant),
..
}) => {
if !variant.fields().iter().any(|field| field.hir_id == parent_hir_id) {
@ -149,7 +149,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
generics
}
hir::Node::Item(hir::Item { kind: hir::ItemKind::Enum(_, def, generics), .. }) => {
hir::Node::Item(hir::Item { kind: hir::ItemKind::Enum(_, generics, def), .. }) => {
if !def
.variants
.iter()
@ -269,7 +269,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
hir::Node::Field(field) => {
// Enums can't have unsized fields, fields can only have an unsized tail field.
if let hir::Node::Item(hir::Item {
kind: hir::ItemKind::Struct(_, variant, _), ..
kind: hir::ItemKind::Struct(_, _, variant), ..
}) = tcx.parent_hir_node(field.hir_id)
&& variant
.fields()

View file

@ -145,9 +145,9 @@ fn diagnostic_hir_wf_check<'tcx>(
ref item => bug!("Unexpected TraitItem {:?}", item),
},
hir::Node::Item(item) => match item.kind {
hir::ItemKind::TyAlias(_, ty, _)
| hir::ItemKind::Static(_, ty, _, _)
| hir::ItemKind::Const(_, ty, _, _) => vec![ty],
hir::ItemKind::TyAlias(_, _, ty)
| hir::ItemKind::Static(_, _, ty, _)
| hir::ItemKind::Const(_, _, ty, _) => vec![ty],
hir::ItemKind::Impl(impl_) => match &impl_.of_trait {
Some(t) => t
.path

View file

@ -477,10 +477,10 @@ impl<'a> State<'a> {
hir::ForeignItemKind::Fn(sig, arg_idents, generics) => {
let (cb, ib) = self.head("");
self.print_fn(
sig.decl,
sig.header,
Some(item.ident.name),
generics,
sig.decl,
arg_idents,
None,
);
@ -593,7 +593,7 @@ impl<'a> State<'a> {
self.end(ib);
self.end(cb);
}
hir::ItemKind::Static(ident, ty, m, expr) => {
hir::ItemKind::Static(m, ident, ty, expr) => {
let (cb, ib) = self.head("static");
if m.is_mut() {
self.word_space("mut");
@ -609,7 +609,7 @@ impl<'a> State<'a> {
self.word(";");
self.end(cb);
}
hir::ItemKind::Const(ident, ty, generics, expr) => {
hir::ItemKind::Const(ident, generics, ty, expr) => {
let (cb, ib) = self.head("const");
self.print_ident(ident);
self.print_generic_params(generics.params);
@ -626,7 +626,7 @@ impl<'a> State<'a> {
}
hir::ItemKind::Fn { ident, sig, generics, body, .. } => {
let (cb, ib) = self.head("");
self.print_fn(sig.decl, sig.header, Some(ident.name), generics, &[], Some(body));
self.print_fn(sig.header, Some(ident.name), generics, sig.decl, &[], Some(body));
self.word(" ");
self.end(ib);
self.end(cb);
@ -660,7 +660,7 @@ impl<'a> State<'a> {
self.end(cb);
self.end(ib);
}
hir::ItemKind::TyAlias(ident, ty, generics) => {
hir::ItemKind::TyAlias(ident, generics, ty) => {
let (cb, ib) = self.head("type");
self.print_ident(ident);
self.print_generic_params(generics.params);
@ -673,16 +673,16 @@ impl<'a> State<'a> {
self.word(";");
self.end(cb);
}
hir::ItemKind::Enum(ident, ref enum_definition, params) => {
self.print_enum_def(enum_definition, params, ident.name, item.span);
hir::ItemKind::Enum(ident, generics, ref enum_def) => {
self.print_enum_def(ident.name, generics, enum_def, item.span);
}
hir::ItemKind::Struct(ident, ref struct_def, generics) => {
hir::ItemKind::Struct(ident, generics, ref struct_def) => {
let (cb, ib) = self.head("struct");
self.print_struct(struct_def, generics, ident.name, item.span, true, cb, ib);
self.print_struct(ident.name, generics, struct_def, item.span, true, cb, ib);
}
hir::ItemKind::Union(ident, ref struct_def, generics) => {
hir::ItemKind::Union(ident, generics, ref struct_def) => {
let (cb, ib) = self.head("union");
self.print_struct(struct_def, generics, ident.name, item.span, true, cb, ib);
self.print_struct(ident.name, generics, struct_def, item.span, true, cb, ib);
}
hir::ItemKind::Impl(&hir::Impl {
constness,
@ -791,9 +791,9 @@ impl<'a> State<'a> {
fn print_enum_def(
&mut self,
enum_definition: &hir::EnumDef<'_>,
generics: &hir::Generics<'_>,
name: Symbol,
generics: &hir::Generics<'_>,
enum_def: &hir::EnumDef<'_>,
span: rustc_span::Span,
) {
let (cb, ib) = self.head("enum");
@ -801,7 +801,7 @@ impl<'a> State<'a> {
self.print_generic_params(generics.params);
self.print_where_clause(generics);
self.space();
self.print_variants(enum_definition.variants, span, cb, ib);
self.print_variants(enum_def.variants, span, cb, ib);
}
fn print_variants(
@ -834,9 +834,9 @@ impl<'a> State<'a> {
fn print_struct(
&mut self,
struct_def: &hir::VariantData<'_>,
generics: &hir::Generics<'_>,
name: Symbol,
generics: &hir::Generics<'_>,
struct_def: &hir::VariantData<'_>,
span: rustc_span::Span,
print_finalizer: bool,
cb: BoxMarker,
@ -886,7 +886,7 @@ impl<'a> State<'a> {
pub fn print_variant(&mut self, v: &hir::Variant<'_>) {
let (cb, ib) = self.head("");
let generics = hir::Generics::empty();
self.print_struct(&v.data, generics, v.ident.name, v.span, false, cb, ib);
self.print_struct(v.ident.name, generics, &v.data, v.span, false, cb, ib);
if let Some(ref d) = v.disr_expr {
self.space();
self.word_space("=");
@ -902,7 +902,7 @@ impl<'a> State<'a> {
arg_idents: &[Option<Ident>],
body_id: Option<hir::BodyId>,
) {
self.print_fn(m.decl, m.header, Some(ident.name), generics, arg_idents, body_id);
self.print_fn(m.header, Some(ident.name), generics, m.decl, arg_idents, body_id);
}
fn print_trait_item(&mut self, ti: &hir::TraitItem<'_>) {
@ -2141,10 +2141,10 @@ impl<'a> State<'a> {
fn print_fn(
&mut self,
decl: &hir::FnDecl<'_>,
header: hir::FnHeader,
name: Option<Symbol>,
generics: &hir::Generics<'_>,
decl: &hir::FnDecl<'_>,
arg_idents: &[Option<Ident>],
body_id: Option<hir::BodyId>,
) {
@ -2483,7 +2483,6 @@ impl<'a> State<'a> {
self.print_formal_generic_params(generic_params);
let generics = hir::Generics::empty();
self.print_fn(
decl,
hir::FnHeader {
safety: safety.into(),
abi,
@ -2492,6 +2491,7 @@ impl<'a> State<'a> {
},
name,
generics,
decl,
arg_idents,
None,
);

View file

@ -408,6 +408,16 @@ impl<'a, 'tcx> CastCheck<'tcx> {
self.expr_ty,
fcx.ty_to_string(self.cast_ty)
);
if let Ok(snippet) = fcx.tcx.sess.source_map().span_to_snippet(self.expr_span)
&& matches!(self.expr.kind, ExprKind::AddrOf(..))
{
err.note(format!(
"casting reference expression `{}` because `&` binds tighter than `as`",
snippet
));
}
let mut sugg = None;
let mut sugg_mutref = false;
if let ty::Ref(reg, cast_ty, mutbl) = *self.cast_ty.kind() {

View file

@ -722,8 +722,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
)) => {
if let Some(hir::Node::Item(hir::Item {
kind:
hir::ItemKind::Static(ident, ty, ..)
| hir::ItemKind::Const(ident, ty, ..),
hir::ItemKind::Static(_, ident, ty, _)
| hir::ItemKind::Const(ident, _, ty, _),
..
})) = self.tcx.hir_get_if_local(*def_id)
{

View file

@ -545,22 +545,22 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
return;
}
let (def, ty) = match item.kind {
hir::ItemKind::Struct(_, _, ast_generics) => {
if !ast_generics.params.is_empty() {
hir::ItemKind::Struct(_, generics, _) => {
if !generics.params.is_empty() {
return;
}
let def = cx.tcx.adt_def(item.owner_id);
(def, Ty::new_adt(cx.tcx, def, ty::List::empty()))
}
hir::ItemKind::Union(_, _, ast_generics) => {
if !ast_generics.params.is_empty() {
hir::ItemKind::Union(_, generics, _) => {
if !generics.params.is_empty() {
return;
}
let def = cx.tcx.adt_def(item.owner_id);
(def, Ty::new_adt(cx.tcx, def, ty::List::empty()))
}
hir::ItemKind::Enum(_, _, ast_generics) => {
if !ast_generics.params.is_empty() {
hir::ItemKind::Enum(_, generics, _) => {
if !generics.params.is_empty() {
return;
}
let def = cx.tcx.adt_def(item.owner_id);
@ -1422,7 +1422,7 @@ impl TypeAliasBounds {
impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
let hir::ItemKind::TyAlias(_, hir_ty, generics) = item.kind else { return };
let hir::ItemKind::TyAlias(_, generics, hir_ty) = item.kind else { return };
// There must not be a where clause.
if generics.predicates.is_empty() {
@ -2125,9 +2125,9 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
let def_id = item.owner_id.def_id;
if let hir::ItemKind::Struct(_, _, hir_generics)
| hir::ItemKind::Enum(_, _, hir_generics)
| hir::ItemKind::Union(_, _, hir_generics) = item.kind
if let hir::ItemKind::Struct(_, generics, _)
| hir::ItemKind::Enum(_, generics, _)
| hir::ItemKind::Union(_, generics, _) = item.kind
{
let inferred_outlives = cx.tcx.inferred_outlives_of(def_id);
if inferred_outlives.is_empty() {
@ -2135,7 +2135,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
}
let ty_generics = cx.tcx.generics_of(def_id);
let num_where_predicates = hir_generics
let num_where_predicates = generics
.predicates
.iter()
.filter(|predicate| predicate.kind.in_where_clause())
@ -2145,7 +2145,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
let mut lint_spans = Vec::new();
let mut where_lint_spans = Vec::new();
let mut dropped_where_predicate_count = 0;
for (i, where_predicate) in hir_generics.predicates.iter().enumerate() {
for (i, where_predicate) in generics.predicates.iter().enumerate() {
let (relevant_lifetimes, bounds, predicate_span, in_where_clause) =
match where_predicate.kind {
hir::WherePredicateKind::RegionPredicate(predicate) => {
@ -2228,7 +2228,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
} else if i + 1 < num_where_predicates {
// If all the bounds on a predicate were inferable and there are
// further predicates, we want to eat the trailing comma.
let next_predicate_span = hir_generics.predicates[i + 1].span;
let next_predicate_span = generics.predicates[i + 1].span;
if next_predicate_span.from_expansion() {
where_lint_spans.push(predicate_span);
} else {
@ -2237,7 +2237,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
}
} else {
// Eat the optional trailing comma after the last predicate.
let where_span = hir_generics.where_clause_span;
let where_span = generics.where_clause_span;
if where_span.from_expansion() {
where_lint_spans.push(predicate_span);
} else {
@ -2255,18 +2255,18 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
// If all predicates in where clause are inferable, drop the entire clause
// (including the `where`)
if hir_generics.has_where_clause_predicates
if generics.has_where_clause_predicates
&& dropped_where_predicate_count == num_where_predicates
{
let where_span = hir_generics.where_clause_span;
let where_span = generics.where_clause_span;
// Extend the where clause back to the closing `>` of the
// generics, except for tuple struct, which have the `where`
// after the fields of the struct.
let full_where_span =
if let hir::ItemKind::Struct(_, hir::VariantData::Tuple(..), _) = item.kind {
if let hir::ItemKind::Struct(_, _, hir::VariantData::Tuple(..)) = item.kind {
where_span
} else {
hir_generics.span.shrink_to_hi().to(where_span)
generics.span.shrink_to_hi().to(where_span)
};
// Due to macro expansions, the `full_where_span` might not actually contain all

View file

@ -95,8 +95,8 @@ impl<'tcx> LateLintPass<'tcx> for DefaultCouldBeDerived {
kind:
hir::ItemKind::Struct(
_,
hir::VariantData::Struct { fields, recovered: _ },
_generics,
hir::VariantData::Struct { fields, recovered: _ },
),
..
})) => fields.iter().map(|f| (f.ident.name, f)).collect::<FxHashMap<_, _>>(),

View file

@ -183,7 +183,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
&& parent_opt_item_name != Some(kw::Underscore)
&& let Some(parent) = parent.as_local()
&& let Node::Item(item) = cx.tcx.hir_node_by_def_id(parent)
&& let ItemKind::Const(ident, ty, _, _) = item.kind
&& let ItemKind::Const(ident, _, ty, _) = item.kind
&& let TyKind::Tup(&[]) = ty.kind
{
Some(ident.span)

View file

@ -513,7 +513,7 @@ impl<'tcx> LateLintPass<'tcx> for NonUpperCaseGlobals {
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
let attrs = cx.tcx.hir_attrs(it.hir_id());
match it.kind {
hir::ItemKind::Static(ident, ..)
hir::ItemKind::Static(_, ident, ..)
if !ast::attr::contains_name(attrs, sym::no_mangle) =>
{
NonUpperCaseGlobals::check_upper_case(cx, "static variable", &ident);

View file

@ -1710,7 +1710,7 @@ impl ImproperCTypesDefinitions {
&& cx.tcx.sess.target.os == "aix"
&& !adt_def.all_fields().next().is_none()
{
let struct_variant_data = item.expect_struct().1;
let struct_variant_data = item.expect_struct().2;
for field_def in struct_variant_data.fields().iter().skip(1) {
// Struct fields (after the first field) are checked for the
// power alignment rule, as fields after the first are likely
@ -1735,9 +1735,9 @@ impl ImproperCTypesDefinitions {
impl<'tcx> LateLintPass<'tcx> for ImproperCTypesDefinitions {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
match item.kind {
hir::ItemKind::Static(_, ty, ..)
| hir::ItemKind::Const(_, ty, ..)
| hir::ItemKind::TyAlias(_, ty, ..) => {
hir::ItemKind::Static(_, _, ty, _)
| hir::ItemKind::Const(_, _, ty, _)
| hir::ItemKind::TyAlias(_, _, ty) => {
self.check_ty_maybe_containing_foreign_fnptr(
cx,
ty,
@ -1804,7 +1804,7 @@ declare_lint_pass!(VariantSizeDifferences => [VARIANT_SIZE_DIFFERENCES]);
impl<'tcx> LateLintPass<'tcx> for VariantSizeDifferences {
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
if let hir::ItemKind::Enum(_, ref enum_definition, _) = it.kind {
if let hir::ItemKind::Enum(_, _, ref enum_definition) = it.kind {
let t = cx.tcx.type_of(it.owner_id).instantiate_identity();
let ty = cx.tcx.erase_regions(t);
let Ok(layout) = cx.layout_of(ty) else { return };

View file

@ -920,7 +920,7 @@ impl<'tcx> TyCtxt<'tcx> {
}) => until_within(*outer_span, generics.where_clause_span),
// Constants and Statics.
Node::Item(Item {
kind: ItemKind::Const(_, ty, ..) | ItemKind::Static(_, ty, ..),
kind: ItemKind::Const(_, _, ty, _) | ItemKind::Static(_, _, ty, _),
span: outer_span,
..
})

View file

@ -558,7 +558,7 @@ fn construct_const<'a, 'tcx>(
// Figure out what primary body this item has.
let (span, const_ty_span) = match tcx.hir_node(hir_id) {
Node::Item(hir::Item {
kind: hir::ItemKind::Static(_, ty, _, _) | hir::ItemKind::Const(_, ty, _, _),
kind: hir::ItemKind::Static(_, _, ty, _) | hir::ItemKind::Const(_, _, ty, _),
span,
..
})

View file

@ -802,7 +802,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
match target {
Target::Struct => {
if let Some(ItemLike::Item(hir::Item {
kind: hir::ItemKind::Struct(_, hir::VariantData::Struct { fields, .. }, _),
kind: hir::ItemKind::Struct(_, _, hir::VariantData::Struct { fields, .. }),
..
})) = item
&& !fields.is_empty()
@ -1130,12 +1130,12 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
return;
};
match item.kind {
ItemKind::Enum(_, _, generics) | ItemKind::Struct(_, _, generics)
ItemKind::Enum(_, generics, _) | ItemKind::Struct(_, generics, _)
if generics.params.len() != 0 => {}
ItemKind::Trait(_, _, _, generics, _, items)
if generics.params.len() != 0
|| items.iter().any(|item| matches!(item.kind, AssocItemKind::Type)) => {}
ItemKind::TyAlias(_, _, generics) if generics.params.len() != 0 => {}
ItemKind::TyAlias(_, generics, _) if generics.params.len() != 0 => {}
_ => {
self.dcx().emit_err(errors::DocSearchUnboxInvalid { span: meta.span() });
}
@ -2792,7 +2792,7 @@ impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> {
}
fn is_c_like_enum(item: &Item<'_>) -> bool {
if let ItemKind::Enum(_, ref def, _) = item.kind {
if let ItemKind::Enum(_, _, ref def) = item.kind {
for variant in def.variants {
match variant.data {
hir::VariantData::Unit(..) => { /* continue */ }

View file

@ -736,7 +736,7 @@ fn check_item<'tcx>(
match tcx.def_kind(id.owner_id) {
DefKind::Enum => {
let item = tcx.hir_item(id);
if let hir::ItemKind::Enum(_, ref enum_def, _) = item.kind {
if let hir::ItemKind::Enum(_, _, ref enum_def) = item.kind {
if let Some(comes_from_allow) = allow_dead_code {
worklist.extend(
enum_def.variants.iter().map(|variant| (variant.def_id, comes_from_allow)),
@ -783,7 +783,7 @@ fn check_item<'tcx>(
}
DefKind::Struct => {
let item = tcx.hir_item(id);
if let hir::ItemKind::Struct(_, ref variant_data, _) = item.kind
if let hir::ItemKind::Struct(_, _, ref variant_data) = item.kind
&& let Some(ctor_def_id) = variant_data.ctor_def_id()
{
struct_constructors.insert(ctor_def_id, item.owner_id.def_id);
@ -1055,7 +1055,7 @@ impl<'tcx> DeadVisitor<'tcx> {
let tuple_fields = if let Some(parent_id) = parent_item
&& let node = tcx.hir_node_by_def_id(parent_id)
&& let hir::Node::Item(hir::Item {
kind: hir::ItemKind::Struct(_, hir::VariantData::Tuple(fields, _, _), _),
kind: hir::ItemKind::Struct(_, _, hir::VariantData::Tuple(fields, _, _)),
..
}) = node
{

View file

@ -430,7 +430,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
kind = AnnotationKind::DeprecationProhibited;
const_stab_inherit = InheritConstStability::Yes;
}
hir::ItemKind::Struct(_, ref sd, _) => {
hir::ItemKind::Struct(_, _, ref sd) => {
if let Some(ctor_def_id) = sd.ctor_def_id() {
self.annotate(
ctor_def_id,

View file

@ -599,8 +599,8 @@ impl<'tcx> EmbargoVisitor<'tcx> {
DefKind::Struct | DefKind::Union => {
// While structs and unions have type privacy, their fields do not.
let item = self.tcx.hir_expect_item(def_id);
if let hir::ItemKind::Struct(_, ref struct_def, _)
| hir::ItemKind::Union(_, ref struct_def, _) = item.kind
if let hir::ItemKind::Struct(_, _, ref struct_def)
| hir::ItemKind::Union(_, _, ref struct_def) = item.kind
{
for field in struct_def.fields() {
let field_vis = self.tcx.local_visibility(field.def_id);
@ -725,7 +725,7 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
}
}
}
hir::ItemKind::Enum(_, ref def, _) => {
hir::ItemKind::Enum(_, _, ref def) => {
if let Some(item_ev) = item_ev {
self.reach(item.owner_id.def_id, item_ev).generics().predicates();
}
@ -763,8 +763,8 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
}
}
}
hir::ItemKind::Struct(_, ref struct_def, _)
| hir::ItemKind::Union(_, ref struct_def, _) => {
hir::ItemKind::Struct(_, _, ref struct_def)
| hir::ItemKind::Union(_, _, ref struct_def) => {
if let Some(item_ev) = item_ev {
self.reach(item.owner_id.def_id, item_ev).generics().predicates();
for field in struct_def.fields() {
@ -868,7 +868,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TestReachabilityVisitor<'a, 'tcx> {
self.effective_visibility_diagnostic(item.owner_id.def_id);
match item.kind {
hir::ItemKind::Enum(_, ref def, _) => {
hir::ItemKind::Enum(_, _, ref def) => {
for variant in def.variants.iter() {
self.effective_visibility_diagnostic(variant.def_id);
if let Some(ctor_def_id) = variant.data.ctor_def_id() {
@ -879,7 +879,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TestReachabilityVisitor<'a, 'tcx> {
}
}
}
hir::ItemKind::Struct(_, ref def, _) | hir::ItemKind::Union(_, ref def, _) => {
hir::ItemKind::Struct(_, _, ref def) | hir::ItemKind::Union(_, _, ref def) => {
if let Some(ctor_def_id) = def.ctor_def_id() {
self.effective_visibility_diagnostic(ctor_def_id);
}
@ -1651,7 +1651,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
}
DefKind::Enum => {
let item = tcx.hir_item(id);
if let hir::ItemKind::Enum(_, ref def, _) = item.kind {
if let hir::ItemKind::Enum(_, _, ref def) = item.kind {
self.check_unnameable(item.owner_id.def_id, effective_vis);
self.check(item.owner_id.def_id, item_visibility, effective_vis)
@ -1689,8 +1689,8 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
// Subitems of structs and unions have their own publicity.
DefKind::Struct | DefKind::Union => {
let item = tcx.hir_item(id);
if let hir::ItemKind::Struct(_, ref struct_def, _)
| hir::ItemKind::Union(_, ref struct_def, _) = item.kind
if let hir::ItemKind::Struct(_, _, ref struct_def)
| hir::ItemKind::Union(_, _, ref struct_def) = item.kind
{
self.check_unnameable(item.owner_id.def_id, effective_vis);
self.check(item.owner_id.def_id, item_visibility, effective_vis)

View file

@ -1,4 +1,4 @@
use crate::spec::{Target, TargetMetadata, base};
use crate::spec::{FramePointer, Target, TargetMetadata, base};
pub(crate) fn target() -> Target {
let mut base = base::windows_gnullvm::opts();
@ -6,6 +6,12 @@ pub(crate) fn target() -> Target {
base.features = "+v8a,+neon,+fp-armv8".into();
base.linker = Some("aarch64-w64-mingw32-clang".into());
// Microsoft recommends enabling frame pointers on Arm64 Windows.
// From https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers
// "The frame pointer (x29) is required for compatibility with fast stack walking used by ETW
// and other services. It must point to the previous {x29, x30} pair on the stack."
base.frame_pointer = FramePointer::NonLeaf;
Target {
llvm_target: "aarch64-pc-windows-gnu".into(),
metadata: TargetMetadata {

View file

@ -2026,7 +2026,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}
LetVisitor { span }.visit_body(body).break_value()
}
hir::Node::Item(hir::Item { kind: hir::ItemKind::Const(_, ty, _, _), .. }) => {
hir::Node::Item(hir::Item { kind: hir::ItemKind::Const(_, _, ty, _), .. }) => {
Some(&ty.peel_refs().kind)
}
_ => None,

View file

@ -351,14 +351,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
hir::Node::Item(hir::Item {
kind:
hir::ItemKind::Struct(_, _, generics)
| hir::ItemKind::Enum(_, _, generics)
| hir::ItemKind::Union(_, _, generics)
hir::ItemKind::Struct(_, generics, _)
| hir::ItemKind::Enum(_, generics, _)
| hir::ItemKind::Union(_, generics, _)
| hir::ItemKind::Trait(_, _, _, generics, ..)
| hir::ItemKind::Impl(hir::Impl { generics, .. })
| hir::ItemKind::Fn { generics, .. }
| hir::ItemKind::TyAlias(_, _, generics)
| hir::ItemKind::Const(_, _, generics, _)
| hir::ItemKind::TyAlias(_, generics, _)
| hir::ItemKind::Const(_, generics, _, _)
| hir::ItemKind::TraitAlias(_, generics, _),
..
})
@ -411,14 +411,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
hir::Node::Item(hir::Item {
kind:
hir::ItemKind::Struct(_, _, generics)
| hir::ItemKind::Enum(_, _, generics)
| hir::ItemKind::Union(_, _, generics)
hir::ItemKind::Struct(_, generics, _)
| hir::ItemKind::Enum(_, generics, _)
| hir::ItemKind::Union(_, generics, _)
| hir::ItemKind::Trait(_, _, _, generics, ..)
| hir::ItemKind::Impl(hir::Impl { generics, .. })
| hir::ItemKind::Fn { generics, .. }
| hir::ItemKind::TyAlias(_, _, generics)
| hir::ItemKind::Const(_, _, generics, _)
| hir::ItemKind::TyAlias(_, generics, _)
| hir::ItemKind::Const(_, generics, _, _)
| hir::ItemKind::TraitAlias(_, generics, _),
..
}) if !param_ty => {

View file

@ -61,9 +61,9 @@ dependencies = [
[[package]]
name = "compiler_builtins"
version = "0.1.159"
version = "0.1.160"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "448068da8f2326b2a0472353cb401dd8795a89c007ef30fff90f50706e862e72"
checksum = "6376049cfa92c0aa8b9ac95fae22184b981c658208d4ed8a1dc553cd83612895"
dependencies = [
"cc",
"rustc-std-workspace-core",

View file

@ -16,7 +16,7 @@ bench = false
[dependencies]
core = { path = "../core", public = true }
compiler_builtins = { version = "=0.1.159", features = ['rustc-dep-of-std'] }
compiler_builtins = { version = "=0.1.160", features = ['rustc-dep-of-std'] }
[features]
compiler-builtins-mem = ['compiler_builtins/mem']

View file

@ -6,6 +6,8 @@ use crate::{mem, ptr};
/// Converts a slice of bytes to a string slice.
///
/// This is an alias to [`str::from_utf8`].
///
/// A string slice ([`&str`]) is made of bytes ([`u8`]), and a byte slice
/// ([`&[u8]`][byteslice]) is made of bytes, so this function converts between
/// the two. Not all byte slices are valid string slices, however: [`&str`] requires
@ -97,6 +99,8 @@ pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
/// Converts a mutable slice of bytes to a mutable string slice.
///
/// This is an alias to [`str::from_utf8_mut`].
///
/// # Examples
///
/// Basic usage:
@ -142,6 +146,8 @@ pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
/// Converts a slice of bytes to a string slice without checking
/// that the string contains valid UTF-8.
///
/// This is an alias to [`str::from_utf8_unchecked`].
///
/// See the safe version, [`from_utf8`], for more information.
///
/// # Safety
@ -178,6 +184,8 @@ pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
/// Converts a slice of bytes to a string slice without checking
/// that the string contains valid UTF-8; mutable version.
///
/// This is an alias to [`str::from_utf8_unchecked_mut`].
///
/// See the immutable version, [`from_utf8_unchecked()`] for documentation and safety requirements.
///
/// # Examples

View file

@ -18,7 +18,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true }
compiler_builtins = { version = "=0.1.159" }
compiler_builtins = { version = "=0.1.160" }
unwind = { path = "../unwind" }
hashbrown = { version = "0.15", default-features = false, features = [
'rustc-dep-of-std',

View file

@ -1409,7 +1409,7 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
cargo.env("LLVM_LINKER_FLAGS", llvm_linker_flags);
}
// Building with a static libstdc++ is only supported on linux right now,
// Building with a static libstdc++ is only supported on Linux and windows-gnu* right now,
// not for MSVC or macOS
if builder.config.llvm_static_stdcpp
&& !target.contains("freebsd")
@ -1417,12 +1417,14 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
&& !target.contains("apple")
&& !target.contains("solaris")
{
let libstdcxx_name =
if target.contains("windows-gnullvm") { "libc++.a" } else { "libstdc++.a" };
let file = compiler_file(
builder,
&builder.cxx(target).unwrap(),
target,
CLang::Cxx,
"libstdc++.a",
libstdcxx_name,
);
cargo.env("LLVM_STATIC_STDCPP", file);
}

View file

@ -285,7 +285,8 @@ impl Step for Llvm {
LlvmBuildStatus::ShouldBuild(m) => m,
};
if builder.llvm_link_shared() && target.is_windows() {
if builder.llvm_link_shared() && target.is_windows() && !target.ends_with("windows-gnullvm")
{
panic!("shared linking to LLVM is not currently supported on {}", target.triple);
}

View file

@ -2964,7 +2964,14 @@ impl Step for Distcheck {
run.builder.ensure(Distcheck);
}
/// Runs "distcheck", a 'make check' from a tarball
/// Runs `distcheck`, which is a collection of smoke tests:
///
/// - Run `make check` from an unpacked dist tarball to make sure we can at the minimum run
/// check steps from those sources.
/// - Check that selected dist components (`rust-src` only at the moment) at least have expected
/// directory shape and crate manifests that cargo can generate a lockfile from.
///
/// FIXME(#136822): dist components are under-tested.
fn run(self, builder: &Builder<'_>) {
builder.info("Distcheck");
let dir = builder.tempdir().join("distcheck");

View file

@ -1,3 +1,15 @@
# Runs `distcheck`, which is a collection of smoke tests:
#
# - Run `make check` from an unpacked dist tarball to make sure we can at the
# minimum run check steps from those sources.
# - Check that selected dist components at least have expected directory shape
# and crate manifests that cargo can generate a lockfile from.
#
# Refer to `src/bootstrap/src/core/build_steps/test.rs` `Distcheck::run` for
# specifics.
#
# FIXME(#136822): dist components are generally under-tested.
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive

View file

@ -1749,7 +1749,7 @@ fn maybe_expand_private_type_alias<'tcx>(
} else {
return None;
};
let hir::ItemKind::TyAlias(_, ty, generics) = alias else { return None };
let hir::ItemKind::TyAlias(_, generics, ty) = alias else { return None };
let final_seg = &path.segments.last().expect("segments were empty");
let mut args = DefIdMap::default();
@ -2803,21 +2803,21 @@ fn clean_maybe_renamed_item<'tcx>(
let mut name = get_name(cx, item, renamed).unwrap();
let kind = match item.kind {
ItemKind::Static(_, ty, mutability, body_id) => StaticItem(Static {
ItemKind::Static(mutability, _, ty, body_id) => StaticItem(Static {
type_: Box::new(clean_ty(ty, cx)),
mutability,
expr: Some(body_id),
}),
ItemKind::Const(_, ty, generics, body_id) => ConstantItem(Box::new(Constant {
ItemKind::Const(_, generics, ty, body_id) => ConstantItem(Box::new(Constant {
generics: clean_generics(generics, cx),
type_: clean_ty(ty, cx),
kind: ConstantKind::Local { body: body_id, def_id },
})),
ItemKind::TyAlias(_, hir_ty, generics) => {
ItemKind::TyAlias(_, generics, ty) => {
*cx.current_type_aliases.entry(def_id).or_insert(0) += 1;
let rustdoc_ty = clean_ty(hir_ty, cx);
let rustdoc_ty = clean_ty(ty, cx);
let type_ =
clean_middle_ty(ty::Binder::dummy(lower_ty(cx.tcx, hir_ty)), cx, None, None);
clean_middle_ty(ty::Binder::dummy(lower_ty(cx.tcx, ty)), cx, None, None);
let generics = clean_generics(generics, cx);
if let Some(count) = cx.current_type_aliases.get_mut(&def_id) {
*count -= 1;
@ -2846,7 +2846,7 @@ fn clean_maybe_renamed_item<'tcx>(
));
return ret;
}
ItemKind::Enum(_, def, generics) => EnumItem(Enum {
ItemKind::Enum(_, generics, def) => EnumItem(Enum {
variants: def.variants.iter().map(|v| clean_variant(v, cx)).collect(),
generics: clean_generics(generics, cx),
}),
@ -2854,11 +2854,11 @@ fn clean_maybe_renamed_item<'tcx>(
generics: clean_generics(generics, cx),
bounds: bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(),
}),
ItemKind::Union(_, variant_data, generics) => UnionItem(Union {
ItemKind::Union(_, generics, variant_data) => UnionItem(Union {
generics: clean_generics(generics, cx),
fields: variant_data.fields().iter().map(|x| clean_field(x, cx)).collect(),
}),
ItemKind::Struct(_, variant_data, generics) => StructItem(Struct {
ItemKind::Struct(_, generics, variant_data) => StructItem(Struct {
ctor_kind: variant_data.ctor_kind(),
generics: clean_generics(generics, cx),
fields: variant_data.fields().iter().map(|x| clean_field(x, cx)).collect(),

View file

@ -241,7 +241,7 @@ impl DocVisitor<'_> for CoverageCalculator<'_, '_> {
data: hir::VariantData::Tuple(_, _, _),
..
}) | hir::Node::Item(hir::Item {
kind: hir::ItemKind::Struct(_, hir::VariantData::Tuple(_, _, _), _),
kind: hir::ItemKind::Struct(_, _, hir::VariantData::Tuple(_, _, _)),
..
})
)

View file

@ -272,7 +272,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
return;
}
match &item.kind {
ItemKind::Enum(_, enum_def, _generics) if self.enable_ordering_for_enum => {
ItemKind::Enum(_, _generics, enum_def) if self.enable_ordering_for_enum => {
let mut cur_v: Option<&Variant<'_>> = None;
for variant in enum_def.variants {
if variant.span.in_external_macro(cx.sess().source_map()) {
@ -288,7 +288,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
cur_v = Some(variant);
}
},
ItemKind::Struct(_, VariantData::Struct { fields, .. }, _generics) if self.enable_ordering_for_struct => {
ItemKind::Struct(_, _generics, VariantData::Struct { fields, .. }) if self.enable_ordering_for_struct => {
let mut cur_f: Option<&FieldDef<'_>> = None;
for field in *fields {
if field.span.in_external_macro(cx.sess().source_map()) {

View file

@ -92,7 +92,7 @@ impl_lint_pass!(EmptyWithBrackets => [EMPTY_STRUCTS_WITH_BRACKETS, EMPTY_ENUM_VA
impl LateLintPass<'_> for EmptyWithBrackets {
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
if let ItemKind::Struct(ident, var_data, _) = &item.kind
if let ItemKind::Struct(ident, _, var_data) = &item.kind
&& !item.span.from_expansion()
&& has_brackets(var_data)
&& let span_after_ident = item.span.with_lo(ident.span.hi())

View file

@ -38,7 +38,7 @@ impl<'tcx> LateLintPass<'tcx> for UnportableVariant {
if cx.tcx.data_layout.pointer_size.bits() != 64 {
return;
}
if let ItemKind::Enum(_, def, _) = &item.kind {
if let ItemKind::Enum(_, _, def) = &item.kind {
for var in def.variants {
if let Some(anon_const) = &var.disr_expr {
let def_id = cx.tcx.hir_body_owner_def_id(anon_const.body);

View file

@ -127,7 +127,7 @@ fn check_fn_decl(cx: &LateContext<'_>, decl: &FnDecl<'_>, sp: Span, max: u64) {
impl<'tcx> LateLintPass<'tcx> for ExcessiveBools {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
if let ItemKind::Struct(_, variant_data, _) = &item.kind
if let ItemKind::Struct(_, _, variant_data) = &item.kind
&& variant_data.fields().len() as u64 > self.max_struct_bools
&& has_n_bools(
variant_data.fields().iter().map(|field| field.ty),

View file

@ -76,7 +76,7 @@ impl LateLintPass<'_> for ExhaustiveItems {
"exported enums should not be exhaustive",
[].as_slice(),
),
ItemKind::Struct(_, v, ..) => (
ItemKind::Struct(_, _, v) => (
EXHAUSTIVE_STRUCTS,
"exported structs should not be exhaustive",
v.fields(),

View file

@ -103,7 +103,7 @@ fn check_result_large_err<'tcx>(cx: &LateContext<'tcx>, err_ty: Ty<'tcx>, hir_ty
.did()
.as_local()
&& let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id(local_def_id)
&& let hir::ItemKind::Enum(_, ref def, _) = item.kind
&& let hir::ItemKind::Enum(_, _, ref def) = item.kind
{
let variants_size = AdtVariantInfo::new(cx, *adt, subst);
if let Some((first_variant, variants)) = variants_size.split_first()

View file

@ -535,10 +535,10 @@ impl LateLintPass<'_> for ItemNameRepetitions {
if span_is_local(item.span) {
match item.kind {
ItemKind::Enum(_, def, _) => {
ItemKind::Enum(_, _, def) => {
self.check_variants(cx, item, &def);
},
ItemKind::Struct(_, VariantData::Struct { fields, .. }, _) => {
ItemKind::Struct(_, _, VariantData::Struct { fields, .. }) => {
self.check_fields(cx, item, fields);
},
_ => (),

View file

@ -48,7 +48,7 @@ impl_lint_pass!(LargeConstArrays => [LARGE_CONST_ARRAYS]);
impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
if let ItemKind::Const(ident, _, generics, _) = &item.kind
if let ItemKind::Const(ident, generics, _, _) = &item.kind
// Since static items may not have generics, skip generic const items.
// FIXME(generic_const_items): I don't think checking `generics.hwcp` suffices as it
// doesn't account for empty where-clauses that only consist of keyword `where` IINM.

View file

@ -73,7 +73,7 @@ impl_lint_pass!(LargeEnumVariant => [LARGE_ENUM_VARIANT]);
impl<'tcx> LateLintPass<'tcx> for LargeEnumVariant {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &Item<'tcx>) {
if let ItemKind::Enum(ident, ref def, _) = item.kind
if let ItemKind::Enum(ident, _, ref def) = item.kind
&& let ty = cx.tcx.type_of(item.owner_id).instantiate_identity()
&& let ty::Adt(adt, subst) = ty.kind()
&& adt.variants().len() > 1

View file

@ -87,7 +87,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
}
match item.kind {
ItemKind::Enum(_, def, _) if def.variants.len() > 1 => {
ItemKind::Enum(_, _, def) if def.variants.len() > 1 => {
let iter = def.variants.iter().filter_map(|v| {
(matches!(v.data, VariantData::Unit(_, _)) && is_doc_hidden(cx.tcx.hir_attrs(v.hir_id)))
.then_some((v.def_id, v.span))
@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
self.potential_enums.push((item.owner_id.def_id, id, item.span, span));
}
},
ItemKind::Struct(_, variant_data, _) => {
ItemKind::Struct(_, _, variant_data) => {
let fields = variant_data.fields();
let private_fields = fields
.iter()

View file

@ -225,7 +225,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingFieldsInDebug {
&& let typeck_results = cx.tcx.typeck_body(*body_id)
&& should_lint(cx, typeck_results, block)
// we intentionally only lint structs, see lint description
&& let ItemKind::Struct(_, data, _) = &self_item.kind
&& let ItemKind::Struct(_, _, data) = &self_item.kind
{
check_struct(cx, typeck_results, block, self_ty, item, data);
}

View file

@ -187,7 +187,7 @@ struct LazyInfo {
impl LazyInfo {
fn from_item(cx: &LateContext<'_>, item: &Item<'_>) -> Option<Self> {
// Check if item is a `once_cell:sync::Lazy` static.
if let ItemKind::Static(_, ty, _, body_id) = item.kind
if let ItemKind::Static(_, _, ty, body_id) = item.kind
&& let Some(path_def_id) = path_def_id(cx, ty)
&& let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = ty.kind
&& paths::ONCE_CELL_SYNC_LAZY.matches(cx, path_def_id)

View file

@ -58,7 +58,7 @@ impl PubUnderscoreFields {
impl<'tcx> LateLintPass<'tcx> for PubUnderscoreFields {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
// This lint only pertains to structs.
let ItemKind::Struct(_, variant_data, _) = &item.kind else {
let ItemKind::Struct(_, _, variant_data) = &item.kind else {
return;
};

View file

@ -57,7 +57,7 @@ impl<'tcx> LateLintPass<'tcx> for TrailingEmptyArray {
}
fn is_struct_with_trailing_zero_sized_array<'tcx>(cx: &LateContext<'tcx>, item: &Item<'tcx>) -> bool {
if let ItemKind::Struct(_, data, _) = &item.kind
if let ItemKind::Struct(_, _, data) = &item.kind
&& let Some(last_field) = data.fields().last()
&& let field_ty = cx.tcx.normalize_erasing_regions(
cx.typing_env(),

View file

@ -447,7 +447,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
let is_exported = cx.effective_visibilities.is_exported(item.owner_id.def_id);
match item.kind {
ItemKind::Static(_, ty, _, _) | ItemKind::Const(_, ty, _, _) => self.check_ty(
ItemKind::Static(_, _, ty, _) | ItemKind::Const(_, _, ty, _) => self.check_ty(
cx,
ty,
CheckTyContext {

View file

@ -134,7 +134,7 @@ impl LateLintPass<'_> for UpperCaseAcronyms {
ItemKind::TyAlias(ident, ..) | ItemKind::Struct(ident, ..) | ItemKind::Trait(_, _, ident, ..) => {
check_ident(cx, &ident, it.hir_id(), self.upper_case_acronyms_aggressive);
},
ItemKind::Enum(ident, ref enumdef, _) => {
ItemKind::Enum(ident, _, ref enumdef) => {
check_ident(cx, &ident, it.hir_id(), self.upper_case_acronyms_aggressive);
// check enum variants separately because again we only want to lint on private enums and
// the fn check_variant does not know about the vis of the enum of its variants

View file

@ -249,7 +249,7 @@ fn item_search_pat(item: &Item<'_>) -> (Pat, Pat) {
ItemKind::ForeignMod { .. } => (Pat::Str("extern"), Pat::Str("}")),
ItemKind::TyAlias(..) => (Pat::Str("type"), Pat::Str(";")),
ItemKind::Enum(..) => (Pat::Str("enum"), Pat::Str("}")),
ItemKind::Struct(_, VariantData::Struct { .. }, _) => (Pat::Str("struct"), Pat::Str("}")),
ItemKind::Struct(_, _, VariantData::Struct { .. }) => (Pat::Str("struct"), Pat::Str("}")),
ItemKind::Struct(..) => (Pat::Str("struct"), Pat::Str(";")),
ItemKind::Union(..) => (Pat::Str("union"), Pat::Str("}")),
ItemKind::Trait(_, Safety::Unsafe, ..)

View file

@ -2362,7 +2362,7 @@ fn with_test_item_names(tcx: TyCtxt<'_>, module: LocalModDefId, f: impl FnOnce(&
for id in tcx.hir_module_free_items(module) {
if matches!(tcx.def_kind(id.owner_id), DefKind::Const)
&& let item = tcx.hir_item(id)
&& let ItemKind::Const(ident, ty, _generics, _body) = item.kind
&& let ItemKind::Const(ident, _generics, ty, _body) = item.kind
&& let TyKind::Path(QPath::Resolved(_, path)) = ty.kind
// We could also check for the type name `test::TestDescAndFn`
&& let Res::Def(DefKind::Struct, _) = path.res

View file

@ -1,25 +0,0 @@
struct Clam {
x: Box<isize>,
y: Box<isize>,
}
struct Fish {
a: Box<isize>,
}
fn main() {
let a: Clam = Clam{ x: Box::new(1), y: Box::new(2) };
let b: Clam = Clam{ x: Box::new(10), y: Box::new(20) };
let z: isize = a.x + b.y;
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
println!("{}", z);
assert_eq!(z, 21);
let forty: Fish = Fish{ a: Box::new(40) };
let two: Fish = Fish{ a: Box::new(2) };
let answer: isize = forty.a + two.a;
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
println!("{}", answer);
assert_eq!(answer, 42);
}

View file

@ -0,0 +1,35 @@
//! Tests that auto-dereferencing does not allow addition of `Box<isize>` values.
//!
//! This test ensures that `Box<isize>` fields in structs (`Clam` and `Fish`) are not
//! automatically dereferenced to `isize` during addition operations, as `Box<isize>`
//! does not implement the `Add` trait.
struct Clam {
x: Box<isize>,
y: Box<isize>,
}
struct Fish {
a: Box<isize>,
}
fn main() {
let a: Clam = Clam {
x: Box::new(1),
y: Box::new(2),
};
let b: Clam = Clam {
x: Box::new(10),
y: Box::new(20),
};
let z: isize = a.x + b.y;
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
println!("{}", z);
assert_eq!(z, 21);
let forty: Fish = Fish { a: Box::new(40) };
let two: Fish = Fish { a: Box::new(2) };
let answer: isize = forty.a + two.a;
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
println!("{}", answer);
assert_eq!(answer, 42);
}

View file

@ -1,5 +1,5 @@
error[E0369]: cannot add `Box<isize>` to `Box<isize>`
--> $DIR/autoderef-full-lval.rs:15:24
--> $DIR/autoderef-box-no-add.rs:25:24
|
LL | let z: isize = a.x + b.y;
| --- ^ --- Box<isize>
@ -13,7 +13,7 @@ note: the foreign item type `Box<isize>` doesn't implement `Add`
= note: not implement `Add`
error[E0369]: cannot add `Box<isize>` to `Box<isize>`
--> $DIR/autoderef-full-lval.rs:21:33
--> $DIR/autoderef-box-no-add.rs:31:33
|
LL | let answer: isize = forty.a + two.a;
| ------- ^ ----- Box<isize>

View file

@ -0,0 +1,7 @@
fn my_fn(event: &Event<'_>) {}
struct Event<'a>(&'a ());
fn main() {
const ptr: &fn(&Event<'_>) = &my_fn as _; //~ ERROR non-primitive cast: `&for<'a, 'b> fn(&'a Event<'b>) {my_fn}` as `&for<'a, 'b> fn(&'a Event<'b>)` [E0605]
}

View file

@ -0,0 +1,11 @@
error[E0605]: non-primitive cast: `&for<'a, 'b> fn(&'a Event<'b>) {my_fn}` as `&for<'a, 'b> fn(&'a Event<'b>)`
--> $DIR/func-pointer-issue-140491.rs:6:34
|
LL | ..._>) = &my_fn as _;
| ^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
|
= note: casting reference expression `&my_fn` because `&` binds tighter than `as`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0605`.

View file

@ -3,6 +3,8 @@ error[E0605]: non-primitive cast: `&&[i32; 1]` as `&[_]`
|
LL | let _ = &&[0] as &[_];
| ^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
|
= note: casting reference expression `&&[0]` because `&` binds tighter than `as`
error[E0605]: non-primitive cast: `u32` as `Option<_>`
--> $DIR/issue-73886.rs:4:13

View file

@ -1,3 +1,7 @@
//! Tests that bare functions implement the `FnMut` trait.
//!
//! See <https://github.com/rust-lang/rust/issues/15448>.
//@ run-pass
fn call_f<F:FnMut()>(mut f: F) {

View file

@ -1,5 +1,7 @@
//! Test that valid large numeric literals do not trigger the `overflowing_literals` lint.
//@ run-pass
// Catch mistakes in the overflowing literals lint.
#![deny(overflowing_literals)]
pub fn main() {

View file

@ -1,8 +1,7 @@
//! Test that method resolution does not autoderef `Vec`
//! into a slice or perform additional autorefs.
fn main() {
// Testing that method lookup does not automatically borrow
// vectors to slices then automatically create a self reference.
let mut a = vec![0];
a.test_mut(); //~ ERROR no method named `test_mut` found
a.test(); //~ ERROR no method named `test` found

View file

@ -1,12 +1,12 @@
error[E0599]: no method named `test_mut` found for struct `Vec<{integer}>` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:7:7
--> $DIR/vec-autoderef-autoref.rs:6:7
|
LL | a.test_mut();
| ^^^^^^^^
|
= help: items from traits can only be used if the trait is implemented and in scope
note: `MyIter` defines an item `test_mut`, perhaps you need to implement it
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
--> $DIR/vec-autoderef-autoref.rs:13:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^
@ -14,40 +14,40 @@ help: there is a method `get_mut` with a similar name, but with different argume
--> $SRC_DIR/core/src/slice/mod.rs:LL:COL
error[E0599]: no method named `test` found for struct `Vec<{integer}>` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:8:7
--> $DIR/vec-autoderef-autoref.rs:7:7
|
LL | a.test();
| ^^^^ method not found in `Vec<{integer}>`
|
= help: items from traits can only be used if the trait is implemented and in scope
note: `MyIter` defines an item `test`, perhaps you need to implement it
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
--> $DIR/vec-autoderef-autoref.rs:13:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^
error[E0599]: no method named `test` found for array `[{integer}; 1]` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:10:11
--> $DIR/vec-autoderef-autoref.rs:9:11
|
LL | ([1]).test();
| ^^^^ method not found in `[{integer}; 1]`
|
= help: items from traits can only be used if the trait is implemented and in scope
note: `MyIter` defines an item `test`, perhaps you need to implement it
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
--> $DIR/vec-autoderef-autoref.rs:13:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^
error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:11:12
--> $DIR/vec-autoderef-autoref.rs:10:12
|
LL | (&[1]).test();
| ^^^^ method not found in `&[{integer}; 1]`
|
= help: items from traits can only be used if the trait is implemented and in scope
note: `MyIter` defines an item `test`, perhaps you need to implement it
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
--> $DIR/vec-autoderef-autoref.rs:13:1
|
LL | trait MyIter {
| ^^^^^^^^^^^^

View file

@ -1,3 +1,5 @@
//! Check that a bare string literal is typed as a `&'static str` and is usable.
//@ run-pass
pub fn main() {