From 631cd5845e8de329d0e227aaa707d7ea228b8f8f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:20:29 +0200 Subject: Merging upstream version 1.70.0+dfsg1. Signed-off-by: Daniel Baumann --- .../cross_crate_predicate.stderr | 8 ++-- .../generic_const_exprs/issue-94287.stderr | 2 +- .../mismatched-gat-subst-kind.rs | 11 +++++ .../mismatched-gat-subst-kind.stderr | 18 ++++++++ .../typeid-equality-by-subtyping.rs | 52 ++++++++++++++++++++++ 5 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.stderr create mode 100644 tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs (limited to 'tests/ui/const-generics/generic_const_exprs') diff --git a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr index 7b4d46b82..6b3396a25 100644 --- a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr +++ b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr @@ -1,8 +1,8 @@ error: unconstrained generic constant - --> $DIR/cross_crate_predicate.rs:7:13 + --> $DIR/cross_crate_predicate.rs:7:44 | LL | let _ = const_evaluatable_lib::test1::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::() - 1]:` note: required by a bound in `test1` @@ -12,10 +12,10 @@ LL | [u8; std::mem::size_of::() - 1]: Sized, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` error: unconstrained generic constant - --> $DIR/cross_crate_predicate.rs:7:13 + --> $DIR/cross_crate_predicate.rs:7:44 | LL | let _ = const_evaluatable_lib::test1::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::() - 1]:` note: required by a bound in `test1` diff --git a/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr b/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr index 7390a0077..dc7d0c54f 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr @@ -8,7 +8,7 @@ LL | If<{ FRAC <= 32 }>: True, help: consider enabling this feature --> $DIR/issue-94287.rs:1:1 | -LL | #![feature(generic_const_exprs)] +LL + #![feature(generic_const_exprs)] | error: aborting due to previous error diff --git a/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.rs b/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.rs new file mode 100644 index 000000000..734a37862 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.rs @@ -0,0 +1,11 @@ +#![feature(generic_const_exprs)] +//~^ WARN the feature `generic_const_exprs` is incomplete + +trait B { + type U; +} + +fn f = ()>>() {} +//~^ ERROR constant provided when a type was expected + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.stderr b/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.stderr new file mode 100644 index 000000000..8b6eb5b75 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.stderr @@ -0,0 +1,18 @@ +warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/mismatched-gat-subst-kind.rs:1:12 + | +LL | #![feature(generic_const_exprs)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #76560 for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0747]: constant provided when a type was expected + --> $DIR/mismatched-gat-subst-kind.rs:8:13 + | +LL | fn f = ()>>() {} + | ^^^^ + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs new file mode 100644 index 000000000..85345d65c --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs @@ -0,0 +1,52 @@ +// check-pass +// known-bug: #97156 + +#![feature(const_type_id, generic_const_exprs)] +#![allow(incomplete_features)] + +use std::any::TypeId; +// `One` and `Two` are currently considered equal types, as both +// `One <: Two` and `One :> Two` holds. +type One = for<'a> fn(&'a (), &'a ()); +type Two = for<'a, 'b> fn(&'a (), &'b ()); +trait AssocCt { + const ASSOC: usize; +} +const fn to_usize() -> usize { + const WHAT_A_TYPE: TypeId = TypeId::of::(); + match TypeId::of::() { + WHAT_A_TYPE => 0, + _ => 1000, + } +} +impl AssocCt for T { + const ASSOC: usize = to_usize::(); +} + +trait WithAssoc { + type Assoc; +} +impl WithAssoc<()> for T where [(); ::ASSOC]: { + type Assoc = [u8; ::ASSOC]; +} + +fn generic(x: >::Assoc) -> >::Assoc +where + [(); ::ASSOC]:, + T: WithAssoc, +{ + x +} + + +fn unsound(x: >::Assoc) -> >::Assoc +where + One: WithAssoc, +{ + let x: >::Assoc = generic::(x); + x +} + +fn main() { + println!("{:?}", unsound::<()>([])); +} -- cgit v1.2.3