From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../const-generics/hash-tyvid-regression-1.rs | 16 +++++++++ .../const-generics/hash-tyvid-regression-2.rs | 18 ++++++++++ .../const-generics/hash-tyvid-regression-3.rs | 26 ++++++++++++++ .../const-generics/hash-tyvid-regression-4.rs | 40 ++++++++++++++++++++++ src/test/incremental/const-generics/issue-61338.rs | 12 +++++++ src/test/incremental/const-generics/issue-61516.rs | 14 ++++++++ src/test/incremental/const-generics/issue-62536.rs | 9 +++++ src/test/incremental/const-generics/issue-64087.rs | 9 +++++ src/test/incremental/const-generics/issue-65623.rs | 12 +++++++ src/test/incremental/const-generics/issue-68477.rs | 25 ++++++++++++++ .../issue-77708-1.rs | 23 +++++++++++++ .../issue-77708-2.rs | 18 ++++++++++ .../issue-77708-3.rs | 22 ++++++++++++ .../issue-82034.rs | 34 ++++++++++++++++++ .../issue-85031-1.rs | 23 +++++++++++++ .../issue-85031-2.rs | 14 ++++++++ .../issue-85031-3.rs | 25 ++++++++++++++ .../issue-86953.rs | 16 +++++++++ .../issue-88022.rs | 28 +++++++++++++++ 19 files changed, 384 insertions(+) create mode 100644 src/test/incremental/const-generics/hash-tyvid-regression-1.rs create mode 100644 src/test/incremental/const-generics/hash-tyvid-regression-2.rs create mode 100644 src/test/incremental/const-generics/hash-tyvid-regression-3.rs create mode 100644 src/test/incremental/const-generics/hash-tyvid-regression-4.rs create mode 100644 src/test/incremental/const-generics/issue-61338.rs create mode 100644 src/test/incremental/const-generics/issue-61516.rs create mode 100644 src/test/incremental/const-generics/issue-62536.rs create mode 100644 src/test/incremental/const-generics/issue-64087.rs create mode 100644 src/test/incremental/const-generics/issue-65623.rs create mode 100644 src/test/incremental/const-generics/issue-68477.rs create mode 100644 src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-1.rs create mode 100644 src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-2.rs create mode 100644 src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs create mode 100644 src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-82034.rs create mode 100644 src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-1.rs create mode 100644 src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-2.rs create mode 100644 src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-3.rs create mode 100644 src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-86953.rs create mode 100644 src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-88022.rs (limited to 'src/test/incremental/const-generics') diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-1.rs b/src/test/incremental/const-generics/hash-tyvid-regression-1.rs new file mode 100644 index 000000000..5ff7b19d8 --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-1.rs @@ -0,0 +1,16 @@ +// revisions: cfail +#![feature(generic_const_exprs, adt_const_params)] +#![allow(incomplete_features)] +// regression test for #77650 +fn c() +where + [T; N.get()]: Sized, +{ + use std::convert::TryFrom; + <[T; N.get()]>::try_from(()) + //~^ error: the trait bound + //~| error: the trait bound + //~| error: mismatched types +} + +fn main() {} diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-2.rs b/src/test/incremental/const-generics/hash-tyvid-regression-2.rs new file mode 100644 index 000000000..5cdd43cd7 --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-2.rs @@ -0,0 +1,18 @@ +// revisions: cfail +#![feature(generic_const_exprs, adt_const_params)] +#![allow(incomplete_features)] +// regression test for #77650 +struct C([T; N.get()]) +where + [T; N.get()]: Sized; +impl<'a, const N: core::num::NonZeroUsize, A, B: PartialEq> PartialEq<&'a [A]> for C +where + [B; N.get()]: Sized, +{ + fn eq(&self, other: &&'a [A]) -> bool { + self.0 == other + //~^ error: can't compare + } +} + +fn main() {} diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-3.rs b/src/test/incremental/const-generics/hash-tyvid-regression-3.rs new file mode 100644 index 000000000..61f568f79 --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-3.rs @@ -0,0 +1,26 @@ +// revisions: cfail +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] +// regression test for #79251 +struct Node +where + SmallVec<{ D * 2 }>: , +{ + keys: SmallVec<{ D * 2 }>, +} + +impl Node +where + SmallVec<{ D * 2 }>: , +{ + fn new() -> Self { + let mut node = Node::new(); + node.keys.some_function(); + //~^ error: no method named + node + } +} + +struct SmallVec {} + +fn main() {} diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-4.rs b/src/test/incremental/const-generics/hash-tyvid-regression-4.rs new file mode 100644 index 000000000..12e8ac7ab --- /dev/null +++ b/src/test/incremental/const-generics/hash-tyvid-regression-4.rs @@ -0,0 +1,40 @@ +// revisions: cfail +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] +// regression test for #79251 +#[derive(Debug)] +struct Node +where + SmallVec: , +{ + keys: SmallVec, +} + +impl Node +where + SmallVec: , +{ + fn new() -> Self { + panic!() + } + + #[inline(never)] + fn split(&mut self, i: usize, k: K, right: bool) -> Node { + let mut node = Node::new(); + node.keys.push(k); + //~^ error: no method named + node + } +} + +#[derive(Debug)] +struct SmallVec { + data: [T; D], +} +impl SmallVec { + fn new() -> Self { + panic!() + } +} + +fn main() {} diff --git a/src/test/incremental/const-generics/issue-61338.rs b/src/test/incremental/const-generics/issue-61338.rs new file mode 100644 index 000000000..e9d67fee2 --- /dev/null +++ b/src/test/incremental/const-generics/issue-61338.rs @@ -0,0 +1,12 @@ +// revisions:rpass1 + +struct Struct(T); + +impl Struct<[T; N]> { + fn f() {} + fn g() { Self::f(); } +} + +fn main() { + Struct::<[u32; 3]>::g(); +} diff --git a/src/test/incremental/const-generics/issue-61516.rs b/src/test/incremental/const-generics/issue-61516.rs new file mode 100644 index 000000000..c781484d1 --- /dev/null +++ b/src/test/incremental/const-generics/issue-61516.rs @@ -0,0 +1,14 @@ +// revisions:rpass1 + +struct FakeArray(T); + +impl FakeArray { + fn len(&self) -> usize { + N + } +} + +fn main() { + let fa = FakeArray::(1); + assert_eq!(fa.len(), 32); +} diff --git a/src/test/incremental/const-generics/issue-62536.rs b/src/test/incremental/const-generics/issue-62536.rs new file mode 100644 index 000000000..93c1dbf44 --- /dev/null +++ b/src/test/incremental/const-generics/issue-62536.rs @@ -0,0 +1,9 @@ +// revisions:cfail1 +struct S([T; N]); + +fn f(x: T) -> S { panic!() } + +fn main() { + f(0u8); + //[cfail1]~^ ERROR type annotations needed +} diff --git a/src/test/incremental/const-generics/issue-64087.rs b/src/test/incremental/const-generics/issue-64087.rs new file mode 100644 index 000000000..81c813531 --- /dev/null +++ b/src/test/incremental/const-generics/issue-64087.rs @@ -0,0 +1,9 @@ +// revisions:cfail1 + +fn combinator() -> [T; S] {} +//[cfail1]~^ ERROR mismatched types + +fn main() { + combinator().into_iter(); + //[cfail1]~^ ERROR type annotations needed +} diff --git a/src/test/incremental/const-generics/issue-65623.rs b/src/test/incremental/const-generics/issue-65623.rs new file mode 100644 index 000000000..22bbcbcab --- /dev/null +++ b/src/test/incremental/const-generics/issue-65623.rs @@ -0,0 +1,12 @@ +// revisions:rpass1 +pub struct Foo([T; 0]); + +impl Foo { + pub fn new() -> Self { + Foo([]) + } +} + +fn main() { + let _: Foo = Foo::new(); +} diff --git a/src/test/incremental/const-generics/issue-68477.rs b/src/test/incremental/const-generics/issue-68477.rs new file mode 100644 index 000000000..9e35cf93d --- /dev/null +++ b/src/test/incremental/const-generics/issue-68477.rs @@ -0,0 +1,25 @@ +// edition:2018 +// revisions:rpass1 + +// Needed to supply generic arguments to the anon const in `[(); FOO]`. +#![feature(generic_const_exprs)] + +const FOO: usize = 1; + +struct Container { + val: std::marker::PhantomData, + blah: [(); FOO] +} + +async fn dummy() {} + +async fn foo() { + let a: Container<&'static ()>; + dummy().await; +} + +fn is_send(_: T) {} + +fn main() { + is_send(foo()); +} diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-1.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-1.rs new file mode 100644 index 000000000..8262a2a21 --- /dev/null +++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-1.rs @@ -0,0 +1,23 @@ +// revisions: cfail +#![feature(generic_const_exprs)] +#![allow(incomplete_features, unused_braces)] + +trait Delegates {} + +struct FileCap {} + +fn writes_to_path(cap: &C) +where + C: Delegates>, +{ + writes_to_specific_path(&cap); + //~^ error: the trait bound +} + +fn writes_to_specific_path(cap: &C) +where + C: Delegates>, +{ +} + +fn main() {} diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-2.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-2.rs new file mode 100644 index 000000000..92bbcba4b --- /dev/null +++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-2.rs @@ -0,0 +1,18 @@ +// revisions: rpass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +struct Z; +const fn one() -> usize { + 1 +} + +fn from_a_to_b(source: [u8; one()]) -> T { + todo!() +} + +fn not_main() { + let _: &Z = from_a_to_b([0; 1]); +} + +fn main() {} diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs new file mode 100644 index 000000000..fc114f224 --- /dev/null +++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs @@ -0,0 +1,22 @@ +// revisions: rpass +#![feature(generic_const_exprs, adt_const_params)] +#![allow(incomplete_features)] + +use std::{convert::TryFrom, num::NonZeroUsize}; + +struct A([u8; N.get()]) +where + [u8; N.get()]: Sized; + +impl<'a, const N: NonZeroUsize> TryFrom<&'a [u8]> for A +where + [u8; N.get()]: Sized, +{ + type Error = (); + fn try_from(slice: &'a [u8]) -> Result, ()> { + let _x = <&[u8; N.get()] as TryFrom<&[u8]>>::try_from(slice); + unimplemented!(); + } +} + +fn main() {} diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-82034.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-82034.rs new file mode 100644 index 000000000..c05d8355c --- /dev/null +++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-82034.rs @@ -0,0 +1,34 @@ +// revisions: rpass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] +pub trait IsTrue {} +pub trait IsFalse {} + +pub struct Assert {} + +impl IsTrue for Assert {} +impl IsFalse for Assert {} + +pub struct SliceConstWriter<'a, const N: usize> { + ptr: &'a mut [u8], +} +impl<'a, const N: usize> SliceConstWriter<'a, { N }> { + pub fn from_slice(vec: &'a mut [u8]) -> Self { + Self { ptr: vec } + } + + pub fn convert(mut self) -> SliceConstWriter<'a, { NN }> { + SliceConstWriter { ptr: self.ptr } + } +} + +impl<'a, const N: usize> SliceConstWriter<'a, { N }> +where + Assert<{ N >= 2 }>: IsTrue, +{ + pub fn write_u8(mut self) -> SliceConstWriter<'a, { N - 2 }> { + self.convert() + } +} + +fn main() {} diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-1.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-1.rs new file mode 100644 index 000000000..8886a556d --- /dev/null +++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-1.rs @@ -0,0 +1,23 @@ +// revisions: rpass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub struct Ref<'a, const NUM: usize>(&'a i32); + +impl<'a, const NUM: usize> Ref<'a, NUM> { + pub fn foo(r: Ref<'a, A>) -> Self + where + ([(); NUM - A], [(); A - NUM]): Sized, + { + Self::bar(r) + } + + pub fn bar(r: Ref<'a, A>) -> Self + where + ([(); NUM - A], [(); A - NUM]): Sized, + { + Self(r.0) + } +} + +fn main() {} diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-2.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-2.rs new file mode 100644 index 000000000..db1e2fc2a --- /dev/null +++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-2.rs @@ -0,0 +1,14 @@ +// revisions: cfail +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +pub struct Ref<'a>(&'a i32); + +impl<'a> Ref<'a> { + pub fn foo() -> [(); A - 0] { + Self::foo() + //~^ error: type annotations needed + } +} + +fn main() {} diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-3.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-3.rs new file mode 100644 index 000000000..5b2f5edc8 --- /dev/null +++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-3.rs @@ -0,0 +1,25 @@ +// revisions: rpass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +fn test() {} + +trait SomeTrait { + const SIZE: usize; +} + +struct A<'a, T> { + some_ref: &'a str, + _maker: core::marker::PhantomData, +} + +impl<'a, T: SomeTrait> A<'a, T> +where + [(); T::SIZE]: , +{ + fn call_test() { + test::<{ T::SIZE }>(); + } +} + +fn main() {} diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-86953.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-86953.rs new file mode 100644 index 000000000..d659c5676 --- /dev/null +++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-86953.rs @@ -0,0 +1,16 @@ +// revisions: rpass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +struct Foo; +impl<'a> std::ops::Add<&'a Foo> for Foo +where + [(); 0 + 0]: Sized, +{ + type Output = (); + fn add(self, _: &Foo) -> Self::Output { + loop {} + } +} + +fn main() {} diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-88022.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-88022.rs new file mode 100644 index 000000000..5f5435ba9 --- /dev/null +++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-88022.rs @@ -0,0 +1,28 @@ +// revisions: cfail +#![feature(generic_const_exprs)] +#![allow(incomplete_features, unused_braces)] + +struct Buffer +where + [(); { S * 2 }]: Default, +{ + data: [T; { S * 2 }], +} + +struct BufferIter<'a, T, const S: usize>(&'a Buffer) +where + [(); { S * 2 }]: Default; + +impl<'a, T, const S: usize> Iterator for BufferIter<'a, T, S> { + //~^ error: the trait bound + //~^^ error: unconstrained generic constant + type Item = &'a T; + + fn next(&mut self) -> Option { + //~^ error: the trait bound + //~^^ error: unconstrained generic constant + None + } +} + +fn main() {} -- cgit v1.2.3