attr: parse rustc_scalable_vector(N)
Extend parsing of `ReprOptions` with `rustc_scalable_vector(N)` which optionally accepts a single literal integral value - the base multiple of lanes that are in a scalable vector. Can only be applied to structs. Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
This commit is contained in:
parent
6e7dd2cd99
commit
78b06057ef
16 changed files with 620 additions and 9 deletions
|
|
@ -96,9 +96,11 @@ bitflags! {
|
|||
/// If true, the type is always passed indirectly by non-Rustic ABIs.
|
||||
/// See [`TyAndLayout::pass_indirectly_in_non_rustic_abis`] for details.
|
||||
const PASS_INDIRECTLY_IN_NON_RUSTIC_ABIS = 1 << 5;
|
||||
/// Any of these flags being set prevent field reordering optimisation.
|
||||
const FIELD_ORDER_UNOPTIMIZABLE = ReprFlags::IS_C.bits()
|
||||
const IS_SCALABLE = 1 << 6;
|
||||
// Any of these flags being set prevent field reordering optimisation.
|
||||
const FIELD_ORDER_UNOPTIMIZABLE = ReprFlags::IS_C.bits()
|
||||
| ReprFlags::IS_SIMD.bits()
|
||||
| ReprFlags::IS_SCALABLE.bits()
|
||||
| ReprFlags::IS_LINEAR.bits();
|
||||
const ABI_UNOPTIMIZABLE = ReprFlags::IS_C.bits() | ReprFlags::IS_SIMD.bits();
|
||||
}
|
||||
|
|
@ -135,6 +137,19 @@ impl IntegerType {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
#[cfg_attr(
|
||||
feature = "nightly",
|
||||
derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
|
||||
)]
|
||||
pub enum ScalableElt {
|
||||
/// `N` in `rustc_scalable_vector(N)` - the element count of the scalable vector
|
||||
ElementCount(u16),
|
||||
/// `rustc_scalable_vector` w/out `N`, used for tuple types of scalable vectors that only
|
||||
/// contain other scalable vectors
|
||||
Container,
|
||||
}
|
||||
|
||||
/// Represents the repr options provided by the user.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
|
||||
#[cfg_attr(
|
||||
|
|
@ -146,6 +161,8 @@ pub struct ReprOptions {
|
|||
pub align: Option<Align>,
|
||||
pub pack: Option<Align>,
|
||||
pub flags: ReprFlags,
|
||||
/// `#[rustc_scalable_vector]`
|
||||
pub scalable: Option<ScalableElt>,
|
||||
/// The seed to be used for randomizing a type's layout
|
||||
///
|
||||
/// Note: This could technically be a `u128` which would
|
||||
|
|
@ -162,6 +179,11 @@ impl ReprOptions {
|
|||
self.flags.contains(ReprFlags::IS_SIMD)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scalable(&self) -> bool {
|
||||
self.flags.contains(ReprFlags::IS_SCALABLE)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn c(&self) -> bool {
|
||||
self.flags.contains(ReprFlags::IS_C)
|
||||
|
|
|
|||
|
|
@ -200,6 +200,9 @@ attr_parsing_rustc_allowed_unstable_pairing =
|
|||
attr_parsing_rustc_promotable_pairing =
|
||||
`rustc_promotable` attribute must be paired with either a `rustc_const_unstable` or a `rustc_const_stable` attribute
|
||||
|
||||
attr_parsing_rustc_scalable_vector_count_out_of_range = element count in `rustc_scalable_vector` is too large: `{$n}`
|
||||
.note = the value may not exceed `u16::MAX`
|
||||
|
||||
attr_parsing_soft_no_args =
|
||||
`soft` should not have any arguments
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use super::prelude::*;
|
||||
use super::util::parse_single_integer;
|
||||
use crate::session_diagnostics::RustcScalableVectorCountOutOfRange;
|
||||
|
||||
pub(crate) struct RustcMainParser;
|
||||
|
||||
|
|
@ -76,3 +77,29 @@ impl<S: Stage> SingleAttributeParser<S> for RustcSimdMonomorphizeLaneLimitParser
|
|||
Some(AttributeKind::RustcSimdMonomorphizeLaneLimit(cx.parse_limit_int(nv)?))
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct RustcScalableVectorParser;
|
||||
|
||||
impl<S: Stage> SingleAttributeParser<S> for RustcScalableVectorParser {
|
||||
const PATH: &[rustc_span::Symbol] = &[sym::rustc_scalable_vector];
|
||||
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
|
||||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]);
|
||||
const TEMPLATE: AttributeTemplate = template!(Word, List: &["count"]);
|
||||
|
||||
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
|
||||
if args.no_args().is_ok() {
|
||||
return Some(AttributeKind::RustcScalableVector {
|
||||
element_count: None,
|
||||
span: cx.attr_span,
|
||||
});
|
||||
}
|
||||
|
||||
let n = parse_single_integer(cx, args)?;
|
||||
let Ok(n) = n.try_into() else {
|
||||
cx.emit_err(RustcScalableVectorCountOutOfRange { span: cx.attr_span, n });
|
||||
return None;
|
||||
};
|
||||
Some(AttributeKind::RustcScalableVector { element_count: Some(n), span: cx.attr_span })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ use crate::attributes::prototype::CustomMirParser;
|
|||
use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser};
|
||||
use crate::attributes::rustc_internal::{
|
||||
RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, RustcMainParser,
|
||||
RustcObjectLifetimeDefaultParser, RustcSimdMonomorphizeLaneLimitParser,
|
||||
RustcObjectLifetimeDefaultParser, RustcScalableVectorParser,
|
||||
RustcSimdMonomorphizeLaneLimitParser,
|
||||
};
|
||||
use crate::attributes::semantics::MayDangleParser;
|
||||
use crate::attributes::stability::{
|
||||
|
|
@ -209,6 +210,7 @@ attribute_parsers!(
|
|||
Single<RustcLayoutScalarValidRangeEndParser>,
|
||||
Single<RustcLayoutScalarValidRangeStartParser>,
|
||||
Single<RustcObjectLifetimeDefaultParser>,
|
||||
Single<RustcScalableVectorParser>,
|
||||
Single<RustcSimdMonomorphizeLaneLimitParser>,
|
||||
Single<SanitizeParser>,
|
||||
Single<ShouldPanicParser>,
|
||||
|
|
|
|||
|
|
@ -501,6 +501,15 @@ pub(crate) struct LinkOrdinalOutOfRange {
|
|||
pub ordinal: u128,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(attr_parsing_rustc_scalable_vector_count_out_of_range)]
|
||||
#[note]
|
||||
pub(crate) struct RustcScalableVectorCountOutOfRange {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub n: u128,
|
||||
}
|
||||
|
||||
pub(crate) enum AttributeParseErrorReason<'a> {
|
||||
ExpectedNoArgs,
|
||||
ExpectedStringLiteral {
|
||||
|
|
|
|||
|
|
@ -1422,6 +1422,10 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
rustc_force_inline, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing, EncodeCrossCrate::Yes,
|
||||
"`#[rustc_force_inline]` forces a free function to be inlined"
|
||||
),
|
||||
rustc_attr!(
|
||||
rustc_scalable_vector, Normal, template!(List: &["count"]), WarnFollowing, EncodeCrossCrate::Yes,
|
||||
"`#[rustc_scalable_vector]` defines a scalable vector type"
|
||||
),
|
||||
|
||||
// ==========================================================================
|
||||
// Internal attributes, Testing:
|
||||
|
|
|
|||
|
|
@ -878,6 +878,14 @@ pub enum AttributeKind {
|
|||
/// Represents `#[rustc_pass_indirectly_in_non_rustic_abis]`
|
||||
RustcPassIndirectlyInNonRusticAbis(Span),
|
||||
|
||||
/// Represents `#[rustc_scalable_vector(N)]`
|
||||
RustcScalableVector {
|
||||
/// The base multiple of lanes that are in a scalable vector, if provided. `element_count`
|
||||
/// is not provided for representing tuple types.
|
||||
element_count: Option<u16>,
|
||||
span: Span,
|
||||
},
|
||||
|
||||
/// Represents `#[rustc_should_not_be_called_on_const_items]`
|
||||
RustcShouldNotBeCalledOnConstItems(Span),
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ impl AttributeKind {
|
|||
RustcMain => No,
|
||||
RustcObjectLifetimeDefault => No,
|
||||
RustcPassIndirectlyInNonRusticAbis(..) => No,
|
||||
RustcScalableVector { .. } => Yes,
|
||||
RustcShouldNotBeCalledOnConstItems(..) => Yes,
|
||||
RustcSimdMonomorphizeLaneLimit(..) => Yes, // Affects layout computation, which needs to work cross-crate
|
||||
Sanitize { .. } => No,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use std::num::NonZero;
|
||||
use std::ops::Deref;
|
||||
|
||||
use rustc_abi::Align;
|
||||
use rustc_ast::token::{CommentKind, DocFragmentKind};
|
||||
|
|
@ -37,6 +38,15 @@ impl<T: PrintAttribute> PrintAttribute for &T {
|
|||
T::print_attribute(self, p)
|
||||
}
|
||||
}
|
||||
impl<T: PrintAttribute> PrintAttribute for Box<T> {
|
||||
fn should_render(&self) -> bool {
|
||||
self.deref().should_render()
|
||||
}
|
||||
|
||||
fn print_attribute(&self, p: &mut Printer) {
|
||||
T::print_attribute(self.deref(), p)
|
||||
}
|
||||
}
|
||||
impl<T: PrintAttribute> PrintAttribute for Option<T> {
|
||||
fn should_render(&self) -> bool {
|
||||
self.as_ref().is_some_and(|x| x.should_render())
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ pub use assoc::*;
|
|||
pub use generic_args::{GenericArgKind, TermKind, *};
|
||||
pub use generics::*;
|
||||
pub use intrinsic::IntrinsicDef;
|
||||
use rustc_abi::{Align, FieldIdx, Integer, IntegerType, ReprFlags, ReprOptions, VariantIdx};
|
||||
use rustc_abi::{
|
||||
Align, FieldIdx, Integer, IntegerType, ReprFlags, ReprOptions, ScalableElt, VariantIdx,
|
||||
};
|
||||
use rustc_ast::AttrVec;
|
||||
use rustc_ast::expand::typetree::{FncTree, Kind, Type, TypeTree};
|
||||
use rustc_ast::node_id::NodeMap;
|
||||
|
|
@ -1515,6 +1517,17 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
let attributes = self.get_all_attrs(did);
|
||||
let elt = find_attr!(
|
||||
attributes,
|
||||
AttributeKind::RustcScalableVector { element_count, .. } => element_count
|
||||
)
|
||||
.map(|elt| match elt {
|
||||
Some(n) => ScalableElt::ElementCount(*n),
|
||||
None => ScalableElt::Container,
|
||||
});
|
||||
if elt.is_some() {
|
||||
flags.insert(ReprFlags::IS_SCALABLE);
|
||||
}
|
||||
if let Some(reprs) = find_attr!(attributes, AttributeKind::Repr { reprs, .. } => reprs) {
|
||||
for (r, _) in reprs {
|
||||
flags.insert(match *r {
|
||||
|
|
@ -1579,7 +1592,14 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
flags.insert(ReprFlags::PASS_INDIRECTLY_IN_NON_RUSTIC_ABIS);
|
||||
}
|
||||
|
||||
ReprOptions { int: size, align: max_align, pack: min_pack, flags, field_shuffle_seed }
|
||||
ReprOptions {
|
||||
int: size,
|
||||
align: max_align,
|
||||
pack: min_pack,
|
||||
flags,
|
||||
field_shuffle_seed,
|
||||
scalable: elt,
|
||||
}
|
||||
}
|
||||
|
||||
/// Look up the name of a definition across crates. This does not look at HIR.
|
||||
|
|
|
|||
|
|
@ -1253,6 +1253,14 @@ impl<'tcx> Ty<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_scalable_vector(self) -> bool {
|
||||
match self.kind() {
|
||||
Adt(def, _) => def.repr().scalable(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sequence_element_type(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
match self.kind() {
|
||||
Array(ty, _) | Slice(ty) => *ty,
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| AttributeKind::MacroEscape( .. )
|
||||
| AttributeKind::RustcLayoutScalarValidRangeStart(..)
|
||||
| AttributeKind::RustcLayoutScalarValidRangeEnd(..)
|
||||
| AttributeKind::RustcScalableVector { .. }
|
||||
| AttributeKind::RustcSimdMonomorphizeLaneLimit(..)
|
||||
| AttributeKind::RustcShouldNotBeCalledOnConstItems(..)
|
||||
| AttributeKind::ExportStable
|
||||
|
|
|
|||
|
|
@ -1998,6 +1998,7 @@ symbols! {
|
|||
rustc_reallocator,
|
||||
rustc_regions,
|
||||
rustc_reservation_impl,
|
||||
rustc_scalable_vector,
|
||||
rustc_serialize,
|
||||
rustc_should_not_be_called_on_const_items,
|
||||
rustc_simd_monomorphize_lane_limit,
|
||||
|
|
|
|||
162
tests/ui/scalable-vectors/invalid.rs
Normal file
162
tests/ui/scalable-vectors/invalid.rs
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
//@ edition: 2024
|
||||
#![allow(internal_features, unused_imports, unused_macros)]
|
||||
#![feature(extern_types)]
|
||||
#![feature(gen_blocks)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(trait_alias)]
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on extern crates
|
||||
extern crate std as other_std;
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on use statements
|
||||
use std::vec::Vec;
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on statics
|
||||
static _X: u32 = 0;
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on constants
|
||||
const _Y: u32 = 0;
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on modules
|
||||
mod bar {
|
||||
}
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on foreign modules
|
||||
unsafe extern "C" {
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on foreign statics
|
||||
static X: &'static u32;
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on foreign types
|
||||
type Y;
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on foreign functions
|
||||
fn foo();
|
||||
}
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on type aliases
|
||||
type Foo = u32;
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on enums
|
||||
enum Bar<#[rustc_scalable_vector(4)] T> {
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on function params
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on enum variants
|
||||
Baz(std::marker::PhantomData<T>),
|
||||
}
|
||||
|
||||
struct Qux {
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on struct fields
|
||||
field: u32,
|
||||
}
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on unions
|
||||
union FooBar {
|
||||
x: u32,
|
||||
y: u32,
|
||||
}
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on traits
|
||||
trait FooBaz {
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on associated types
|
||||
type Foo;
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on associated consts
|
||||
const Bar: i32;
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on provided trait methods
|
||||
fn foo() {}
|
||||
}
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on trait aliases
|
||||
trait FooQux = FooBaz;
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on inherent impl blocks
|
||||
impl<T> Bar<T> {
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on inherent methods
|
||||
fn foo() {}
|
||||
}
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on trait impl blocks
|
||||
impl<T> FooBaz for Bar<T> {
|
||||
type Foo = u32;
|
||||
const Bar: i32 = 3;
|
||||
}
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on macro defs
|
||||
macro_rules! barqux { ($foo:tt) => { $foo }; }
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on functions
|
||||
fn barqux(#[rustc_scalable_vector(4)] _x: u32) {}
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on function params
|
||||
//~^^ ERROR: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on functions
|
||||
async fn async_foo() {}
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on functions
|
||||
gen fn gen_foo() {}
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on functions
|
||||
async gen fn async_gen_foo() {}
|
||||
|
||||
fn main() {
|
||||
let _x = #[rustc_scalable_vector(4)] || { };
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on closures
|
||||
let _y = #[rustc_scalable_vector(4)] 3 + 4;
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on expressions
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on statements
|
||||
let _z = 3;
|
||||
|
||||
match _z {
|
||||
#[rustc_scalable_vector(4)]
|
||||
//~^ ERROR: `#[rustc_scalable_vector]` attribute cannot be used on match arms
|
||||
1 => (),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
#[rustc_scalable_vector("4")]
|
||||
//~^ ERROR: malformed `rustc_scalable_vector` attribute input
|
||||
struct ArgNotLit(f32);
|
||||
|
||||
#[rustc_scalable_vector(4, 2)]
|
||||
//~^ ERROR: malformed `rustc_scalable_vector` attribute input
|
||||
struct ArgMultipleLits(f32);
|
||||
|
||||
#[rustc_scalable_vector(count = "4")]
|
||||
//~^ ERROR: malformed `rustc_scalable_vector` attribute input
|
||||
struct ArgKind(f32);
|
||||
|
||||
#[rustc_scalable_vector(65536)]
|
||||
//~^ ERROR: element count in `rustc_scalable_vector` is too large: `65536`
|
||||
struct CountTooLarge(f32);
|
||||
|
||||
#[rustc_scalable_vector(4)]
|
||||
struct Okay(f32);
|
||||
|
||||
#[rustc_scalable_vector]
|
||||
struct OkayNoArg(f32);
|
||||
333
tests/ui/scalable-vectors/invalid.stderr
Normal file
333
tests/ui/scalable-vectors/invalid.stderr
Normal file
|
|
@ -0,0 +1,333 @@
|
|||
error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
|
||||
--> $DIR/invalid.rs:109:11
|
||||
|
|
||||
LL | fn barqux(#[rustc_scalable_vector(4)] _x: u32) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on extern crates
|
||||
--> $DIR/invalid.rs:9:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on use statements
|
||||
--> $DIR/invalid.rs:13:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on statics
|
||||
--> $DIR/invalid.rs:17:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on constants
|
||||
--> $DIR/invalid.rs:21:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on modules
|
||||
--> $DIR/invalid.rs:25:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on foreign modules
|
||||
--> $DIR/invalid.rs:30:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on foreign statics
|
||||
--> $DIR/invalid.rs:33:5
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on foreign types
|
||||
--> $DIR/invalid.rs:36:5
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on foreign functions
|
||||
--> $DIR/invalid.rs:39:5
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on type aliases
|
||||
--> $DIR/invalid.rs:44:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on enums
|
||||
--> $DIR/invalid.rs:48:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on function params
|
||||
--> $DIR/invalid.rs:50:10
|
||||
|
|
||||
LL | enum Bar<#[rustc_scalable_vector(4)] T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on enum variants
|
||||
--> $DIR/invalid.rs:52:5
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on struct fields
|
||||
--> $DIR/invalid.rs:58:5
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on unions
|
||||
--> $DIR/invalid.rs:63:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on traits
|
||||
--> $DIR/invalid.rs:70:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on associated types
|
||||
--> $DIR/invalid.rs:73:5
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on associated consts
|
||||
--> $DIR/invalid.rs:76:5
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on provided trait methods
|
||||
--> $DIR/invalid.rs:79:5
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on trait aliases
|
||||
--> $DIR/invalid.rs:84:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on inherent impl blocks
|
||||
--> $DIR/invalid.rs:88:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on inherent methods
|
||||
--> $DIR/invalid.rs:91:5
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on trait impl blocks
|
||||
--> $DIR/invalid.rs:96:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on macro defs
|
||||
--> $DIR/invalid.rs:103:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on functions
|
||||
--> $DIR/invalid.rs:107:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on function params
|
||||
--> $DIR/invalid.rs:109:11
|
||||
|
|
||||
LL | fn barqux(#[rustc_scalable_vector(4)] _x: u32) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on functions
|
||||
--> $DIR/invalid.rs:113:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on functions
|
||||
--> $DIR/invalid.rs:117:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on functions
|
||||
--> $DIR/invalid.rs:121:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on closures
|
||||
--> $DIR/invalid.rs:126:14
|
||||
|
|
||||
LL | let _x = #[rustc_scalable_vector(4)] || { };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on expressions
|
||||
--> $DIR/invalid.rs:128:14
|
||||
|
|
||||
LL | let _y = #[rustc_scalable_vector(4)] 3 + 4;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on statements
|
||||
--> $DIR/invalid.rs:130:5
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error: `#[rustc_scalable_vector]` attribute cannot be used on match arms
|
||||
--> $DIR/invalid.rs:135:9
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: `#[rustc_scalable_vector]` can only be applied to structs
|
||||
|
||||
error[E0539]: malformed `rustc_scalable_vector` attribute input
|
||||
--> $DIR/invalid.rs:142:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector("4")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^---^^
|
||||
| |
|
||||
| expected an integer literal here
|
||||
|
|
||||
help: try changing it to one of the following valid forms of the attribute
|
||||
|
|
||||
LL - #[rustc_scalable_vector("4")]
|
||||
LL + #[rustc_scalable_vector(count)]
|
||||
|
|
||||
LL - #[rustc_scalable_vector("4")]
|
||||
LL + #[rustc_scalable_vector]
|
||||
|
|
||||
|
||||
error[E0805]: malformed `rustc_scalable_vector` attribute input
|
||||
--> $DIR/invalid.rs:146:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(4, 2)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^------^
|
||||
| |
|
||||
| expected a single argument here
|
||||
|
|
||||
help: try changing it to one of the following valid forms of the attribute
|
||||
|
|
||||
LL - #[rustc_scalable_vector(4, 2)]
|
||||
LL + #[rustc_scalable_vector(count)]
|
||||
|
|
||||
LL - #[rustc_scalable_vector(4, 2)]
|
||||
LL + #[rustc_scalable_vector]
|
||||
|
|
||||
|
||||
error[E0539]: malformed `rustc_scalable_vector` attribute input
|
||||
--> $DIR/invalid.rs:150:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(count = "4")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^-----------^^
|
||||
| |
|
||||
| expected an integer literal here
|
||||
|
|
||||
help: try changing it to one of the following valid forms of the attribute
|
||||
|
|
||||
LL - #[rustc_scalable_vector(count = "4")]
|
||||
LL + #[rustc_scalable_vector(count)]
|
||||
|
|
||||
LL - #[rustc_scalable_vector(count = "4")]
|
||||
LL + #[rustc_scalable_vector]
|
||||
|
|
||||
|
||||
error: element count in `rustc_scalable_vector` is too large: `65536`
|
||||
--> $DIR/invalid.rs:154:1
|
||||
|
|
||||
LL | #[rustc_scalable_vector(65536)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the value may not exceed `u16::MAX`
|
||||
|
||||
error: aborting due to 38 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0539, E0805.
|
||||
For more information about an error, try `rustc --explain E0539`.
|
||||
|
|
@ -95,7 +95,7 @@ body:
|
|||
did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo)
|
||||
variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])), safety: Safe, value: None }], tainted: None, flags: }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], tainted: None, flags: }]
|
||||
flags: IS_ENUM
|
||||
repr: ReprOptions { int: None, align: None, pack: None, flags: , field_shuffle_seed: 13397682652773712997 }
|
||||
repr: ReprOptions { int: None, align: None, pack: None, flags: , scalable: None, field_shuffle_seed: 13397682652773712997 }
|
||||
args: []
|
||||
variant_index: 0
|
||||
subpatterns: [
|
||||
|
|
@ -109,7 +109,7 @@ body:
|
|||
did: DefId(0:3 ~ thir_tree_match[fcf8]::Bar)
|
||||
variants: [VariantDef { def_id: DefId(0:4 ~ thir_tree_match[fcf8]::Bar::First), ctor: Some((Const, DefId(0:5 ~ thir_tree_match[fcf8]::Bar::First::{constructor#0}))), name: "First", discr: Relative(0), fields: [], tainted: None, flags: }, VariantDef { def_id: DefId(0:6 ~ thir_tree_match[fcf8]::Bar::Second), ctor: Some((Const, DefId(0:7 ~ thir_tree_match[fcf8]::Bar::Second::{constructor#0}))), name: "Second", discr: Relative(1), fields: [], tainted: None, flags: }, VariantDef { def_id: DefId(0:8 ~ thir_tree_match[fcf8]::Bar::Third), ctor: Some((Const, DefId(0:9 ~ thir_tree_match[fcf8]::Bar::Third::{constructor#0}))), name: "Third", discr: Relative(2), fields: [], tainted: None, flags: }]
|
||||
flags: IS_ENUM
|
||||
repr: ReprOptions { int: None, align: None, pack: None, flags: , field_shuffle_seed: 7908585036048874241 }
|
||||
repr: ReprOptions { int: None, align: None, pack: None, flags: , scalable: None, field_shuffle_seed: 7908585036048874241 }
|
||||
args: []
|
||||
variant_index: 0
|
||||
subpatterns: []
|
||||
|
|
@ -157,7 +157,7 @@ body:
|
|||
did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo)
|
||||
variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])), safety: Safe, value: None }], tainted: None, flags: }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], tainted: None, flags: }]
|
||||
flags: IS_ENUM
|
||||
repr: ReprOptions { int: None, align: None, pack: None, flags: , field_shuffle_seed: 13397682652773712997 }
|
||||
repr: ReprOptions { int: None, align: None, pack: None, flags: , scalable: None, field_shuffle_seed: 13397682652773712997 }
|
||||
args: []
|
||||
variant_index: 0
|
||||
subpatterns: [
|
||||
|
|
@ -209,7 +209,7 @@ body:
|
|||
did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo)
|
||||
variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])), safety: Safe, value: None }], tainted: None, flags: }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], tainted: None, flags: }]
|
||||
flags: IS_ENUM
|
||||
repr: ReprOptions { int: None, align: None, pack: None, flags: , field_shuffle_seed: 13397682652773712997 }
|
||||
repr: ReprOptions { int: None, align: None, pack: None, flags: , scalable: None, field_shuffle_seed: 13397682652773712997 }
|
||||
args: []
|
||||
variant_index: 1
|
||||
subpatterns: []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue