diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/rustdoc-js/auxiliary/interner.rs | 245 | ||||
| -rw-r--r-- | tests/rustdoc-js/looks-like-rustc-interner.js | 9 | ||||
| -rw-r--r-- | tests/rustdoc-js/looks-like-rustc-interner.rs | 5 | ||||
| -rw-r--r-- | tests/ui/diagnostic_namespace/deny_malformed_attribute.rs | 7 | ||||
| -rw-r--r-- | tests/ui/diagnostic_namespace/deny_malformed_attribute.stderr | 14 | ||||
| -rw-r--r-- | tests/ui/simd/const-err-trumps-simd-err.rs | 24 | ||||
| -rw-r--r-- | tests/ui/simd/const-err-trumps-simd-err.stderr | 17 | ||||
| -rw-r--r-- | tests/ui/type-alias-impl-trait/in-where-clause.rs | 2 |
8 files changed, 322 insertions, 1 deletions
diff --git a/tests/rustdoc-js/auxiliary/interner.rs b/tests/rustdoc-js/auxiliary/interner.rs new file mode 100644 index 00000000000..c95029be9f0 --- /dev/null +++ b/tests/rustdoc-js/auxiliary/interner.rs @@ -0,0 +1,245 @@ +#![feature(associated_type_defaults)] + +use std::cmp::Ord; +use std::fmt::{Debug, Formatter}; +use std::hash::Hash; +use std::ops::ControlFlow; + +pub trait Interner: Sized { + type DefId: Copy + Debug + Hash + Ord; + type AdtDef: Copy + Debug + Hash + Ord; + type GenericArgs: Copy + + DebugWithInfcx<Self> + + Hash + + Ord + + IntoIterator<Item = Self::GenericArg>; + type GenericArg: Copy + DebugWithInfcx<Self> + Hash + Ord; + type Term: Copy + Debug + Hash + Ord; + type Binder<T: TypeVisitable<Self>>: BoundVars<Self> + TypeSuperVisitable<Self>; + type BoundVars: IntoIterator<Item = Self::BoundVar>; + type BoundVar; + type CanonicalVars: Copy + Debug + Hash + Eq + IntoIterator<Item = CanonicalVarInfo<Self>>; + type Ty: Copy + + DebugWithInfcx<Self> + + Hash + + Ord + + Into<Self::GenericArg> + + IntoKind<Kind = TyKind<Self>> + + TypeSuperVisitable<Self> + + Flags + + Ty<Self>; + type Tys: Copy + Debug + Hash + Ord + IntoIterator<Item = Self::Ty>; + type AliasTy: Copy + DebugWithInfcx<Self> + Hash + Ord; + type ParamTy: Copy + Debug + Hash + Ord; + type BoundTy: Copy + Debug + Hash + Ord; + type PlaceholderTy: Copy + Debug + Hash + Ord + PlaceholderLike; + type ErrorGuaranteed: Copy + Debug + Hash + Ord; + type BoundExistentialPredicates: Copy + DebugWithInfcx<Self> + Hash + Ord; + type PolyFnSig: Copy + DebugWithInfcx<Self> + Hash + Ord; + type AllocId: Copy + Debug + Hash + Ord; + type Const: Copy + + DebugWithInfcx<Self> + + Hash + + Ord + + Into<Self::GenericArg> + + IntoKind<Kind = ConstKind<Self>> + + ConstTy<Self> + + TypeSuperVisitable<Self> + + Flags + + Const<Self>; + type AliasConst: Copy + DebugWithInfcx<Self> + Hash + Ord; + type PlaceholderConst: Copy + Debug + Hash + Ord + PlaceholderLike; + type ParamConst: Copy + Debug + Hash + Ord; + type BoundConst: Copy + Debug + Hash + Ord; + type ValueConst: Copy + Debug + Hash + Ord; + type ExprConst: Copy + DebugWithInfcx<Self> + Hash + Ord; + type Region: Copy + + DebugWithInfcx<Self> + + Hash + + Ord + + Into<Self::GenericArg> + + IntoKind<Kind = RegionKind<Self>> + + Flags + + Region<Self>; + type EarlyParamRegion: Copy + Debug + Hash + Ord; + type LateParamRegion: Copy + Debug + Hash + Ord; + type BoundRegion: Copy + Debug + Hash + Ord; + type InferRegion: Copy + DebugWithInfcx<Self> + Hash + Ord; + type PlaceholderRegion: Copy + Debug + Hash + Ord + PlaceholderLike; + type Predicate: Copy + Debug + Hash + Eq + TypeSuperVisitable<Self> + Flags; + type TraitPredicate: Copy + Debug + Hash + Eq; + type RegionOutlivesPredicate: Copy + Debug + Hash + Eq; + type TypeOutlivesPredicate: Copy + Debug + Hash + Eq; + type ProjectionPredicate: Copy + Debug + Hash + Eq; + type NormalizesTo: Copy + Debug + Hash + Eq; + type SubtypePredicate: Copy + Debug + Hash + Eq; + type CoercePredicate: Copy + Debug + Hash + Eq; + type ClosureKind: Copy + Debug + Hash + Eq; + + // Required method + fn mk_canonical_var_infos( + self, + infos: &[CanonicalVarInfo<Self>] + ) -> Self::CanonicalVars; +} + +pub trait DebugWithInfcx<I: Interner>: Debug { + // Required method + fn fmt<Infcx: InferCtxtLike<Interner = I>>( + this: WithInfcx<'_, Infcx, &Self>, + f: &mut Formatter<'_> + ) -> std::fmt::Result; +} + +pub trait TypeVisitable<I: Interner>: Debug + Clone { + // Required method + fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result; +} + +pub trait BoundVars<I: Interner> { + // Required methods + fn bound_vars(&self) -> I::BoundVars; + fn has_no_bound_vars(&self) -> bool; +} + +pub trait TypeSuperVisitable<I: Interner>: TypeVisitable<I> { + // Required method + fn super_visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result; +} + +pub struct CanonicalVarInfo<I: Interner> { + pub kind: CanonicalVarKind<I>, +} + +pub struct CanonicalVarKind<I>(std::marker::PhantomData<I>); + +pub struct TyKind<I>(std::marker::PhantomData<I>); + +pub trait IntoKind { + type Kind; + + // Required method + fn kind(self) -> Self::Kind; +} +pub trait Flags { + // Required methods + fn flags(&self) -> TypeFlags; + fn outer_exclusive_binder(&self) -> DebruijnIndex; +} +pub struct TypeFlags; + +pub trait Ty<I: Interner<Ty = Self>> { + // Required method + fn new_anon_bound( + interner: I, + debruijn: DebruijnIndex, + var: BoundVar + ) -> Self; +} + +pub trait PlaceholderLike { + // Required methods + fn universe(self) -> UniverseIndex; + fn var(self) -> BoundVar; + fn with_updated_universe(self, ui: UniverseIndex) -> Self; + fn new(ui: UniverseIndex, var: BoundVar) -> Self; +} + +pub struct UniverseIndex; + +pub struct BoundVar; + +pub struct ConstKind<I>(std::marker::PhantomData<I>); +pub trait Const<I: Interner<Const = Self>> { + // Required method + fn new_anon_bound( + interner: I, + debruijn: DebruijnIndex, + var: BoundVar, + ty: I::Ty + ) -> Self; +} + +pub trait ConstTy<I: Interner> { + // Required method + fn ty(self) -> I::Ty; +} + +pub struct DebruijnIndex; + +pub struct RegionKind<I>(std::marker::PhantomData<I>); +pub trait Region<I: Interner<Region = Self>> { + // Required method + fn new_anon_bound( + interner: I, + debruijn: DebruijnIndex, + var: BoundVar + ) -> Self; +} + +pub trait TypeVisitor<I: Interner>: Sized { + type Result: VisitorResult = (); + + // Provided methods + fn visit_binder<T: TypeVisitable<I>>( + &mut self, + t: &I::Binder<T> + ) -> Self::Result { unimplemented!() } + fn visit_ty(&mut self, t: I::Ty) -> Self::Result { unimplemented!() } + fn visit_region(&mut self, _r: I::Region) -> Self::Result { unimplemented!() } + fn visit_const(&mut self, c: I::Const) -> Self::Result { unimplemented!() } + fn visit_predicate(&mut self, p: I::Predicate) -> Self::Result { unimplemented!() } +} + +pub trait VisitorResult { + type Residual; + + // Required methods + fn output() -> Self; + fn from_residual(residual: Self::Residual) -> Self; + fn from_branch(b: ControlFlow<Self::Residual>) -> Self; + fn branch(self) -> ControlFlow<Self::Residual>; +} + +impl VisitorResult for () { + type Residual = (); + fn output() -> Self {} + fn from_residual(_: Self::Residual) -> Self {} + fn from_branch(_: ControlFlow<Self::Residual>) -> Self {} + fn branch(self) -> ControlFlow<Self::Residual> { ControlFlow::Continue(()) } +} + +pub struct WithInfcx<'a, Infcx: InferCtxtLike, T> { + pub data: T, + pub infcx: &'a Infcx, +} + +pub trait InferCtxtLike { + type Interner: Interner; + + // Required methods + fn interner(&self) -> Self::Interner; + fn universe_of_ty(&self, ty: TyVid) -> Option<UniverseIndex>; + fn root_ty_var(&self, vid: TyVid) -> TyVid; + fn probe_ty_var( + &self, + vid: TyVid + ) -> Option<<Self::Interner as Interner>::Ty>; + fn universe_of_lt( + &self, + lt: <Self::Interner as Interner>::InferRegion + ) -> Option<UniverseIndex>; + fn opportunistic_resolve_lt_var( + &self, + vid: <Self::Interner as Interner>::InferRegion + ) -> Option<<Self::Interner as Interner>::Region>; + fn universe_of_ct(&self, ct: ConstVid) -> Option<UniverseIndex>; + fn root_ct_var(&self, vid: ConstVid) -> ConstVid; + fn probe_ct_var( + &self, + vid: ConstVid + ) -> Option<<Self::Interner as Interner>::Const>; +} + +pub struct TyVid; +pub struct ConstVid; diff --git a/tests/rustdoc-js/looks-like-rustc-interner.js b/tests/rustdoc-js/looks-like-rustc-interner.js new file mode 100644 index 00000000000..a4806d23499 --- /dev/null +++ b/tests/rustdoc-js/looks-like-rustc-interner.js @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/pull/122247 +// exact-check + +const EXPECTED = { + 'query': 'canonicalvarinfo, intoiterator -> intoiterator', + 'others': [ + { 'path': 'looks_like_rustc_interner::Interner', 'name': 'mk_canonical_var_infos' }, + ], +}; diff --git a/tests/rustdoc-js/looks-like-rustc-interner.rs b/tests/rustdoc-js/looks-like-rustc-interner.rs new file mode 100644 index 00000000000..f304e28d952 --- /dev/null +++ b/tests/rustdoc-js/looks-like-rustc-interner.rs @@ -0,0 +1,5 @@ +//@ aux-crate:interner=interner.rs +// https://github.com/rust-lang/rust/pull/122247 +extern crate interner; +#[doc(inline)] +pub use interner::*; diff --git a/tests/ui/diagnostic_namespace/deny_malformed_attribute.rs b/tests/ui/diagnostic_namespace/deny_malformed_attribute.rs new file mode 100644 index 00000000000..1d946a14aff --- /dev/null +++ b/tests/ui/diagnostic_namespace/deny_malformed_attribute.rs @@ -0,0 +1,7 @@ +#![deny(unknown_or_malformed_diagnostic_attributes)] + +#[diagnostic::unknown_attribute] +//~^ERROR unknown diagnostic attribute +struct Foo; + +fn main() {} diff --git a/tests/ui/diagnostic_namespace/deny_malformed_attribute.stderr b/tests/ui/diagnostic_namespace/deny_malformed_attribute.stderr new file mode 100644 index 00000000000..a646d3613de --- /dev/null +++ b/tests/ui/diagnostic_namespace/deny_malformed_attribute.stderr @@ -0,0 +1,14 @@ +error: unknown diagnostic attribute + --> $DIR/deny_malformed_attribute.rs:3:15 + | +LL | #[diagnostic::unknown_attribute] + | ^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/deny_malformed_attribute.rs:1:9 + | +LL | #![deny(unknown_or_malformed_diagnostic_attributes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/simd/const-err-trumps-simd-err.rs b/tests/ui/simd/const-err-trumps-simd-err.rs new file mode 100644 index 00000000000..06a747273ab --- /dev/null +++ b/tests/ui/simd/const-err-trumps-simd-err.rs @@ -0,0 +1,24 @@ +//@build-fail +//! Make sure that monomorphization-time const errors from `static_assert` take priority over the +//! error from simd_extract. Basically this checks that if a const fails to evaluate in some +//! function, we don't bother codegen'ing the function. +#![feature(generic_arg_infer)] +#![feature(core_intrinsics)] +#![feature(repr_simd)] +#![feature(inline_const)] +use std::intrinsics::simd::*; + +#[repr(simd)] +#[allow(non_camel_case_types)] +struct int8x4_t(u8,u8,u8,u8); + +fn get_elem<const LANE: u32>(a: int8x4_t) -> u8 { + const { assert!(LANE < 4); } // the error should be here... + //~^ ERROR failed + //~| assertion failed + unsafe { simd_extract(a, LANE) } // ...not here +} + +fn main() { + get_elem::<4>(int8x4_t(0,0,0,0)); +} diff --git a/tests/ui/simd/const-err-trumps-simd-err.stderr b/tests/ui/simd/const-err-trumps-simd-err.stderr new file mode 100644 index 00000000000..6e6aba8b6f1 --- /dev/null +++ b/tests/ui/simd/const-err-trumps-simd-err.stderr @@ -0,0 +1,17 @@ +error[E0080]: evaluation of `get_elem::<4>::{constant#0}` failed + --> $DIR/const-err-trumps-simd-err.rs:16:13 + | +LL | const { assert!(LANE < 4); } // the error should be here... + | ^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: LANE < 4', $DIR/const-err-trumps-simd-err.rs:16:13 + | + = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: the above error was encountered while instantiating `fn get_elem::<4>` + --> $DIR/const-err-trumps-simd-err.rs:23:5 + | +LL | get_elem::<4>(int8x4_t(0,0,0,0)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/type-alias-impl-trait/in-where-clause.rs b/tests/ui/type-alias-impl-trait/in-where-clause.rs index 0ad6e7a6f60..7c0de39c7c9 100644 --- a/tests/ui/type-alias-impl-trait/in-where-clause.rs +++ b/tests/ui/type-alias-impl-trait/in-where-clause.rs @@ -1,5 +1,5 @@ //! We evaluate `1 + 2` with `Reveal::All` during typeck, causing -//! us to to get the concrete type of `Bar` while computing it. +//! us to get the concrete type of `Bar` while computing it. //! This again requires type checking `foo`. #![feature(type_alias_impl_trait)] type Bar = impl Sized; |
