From d3434b3181aa6dcdefe5c4b802b0650165209d18 Mon Sep 17 00:00:00 2001 From: Ellen Date: Thu, 2 Sep 2021 21:20:51 +0100 Subject: [PATCH 1/7] E-not-needs-test --- .../ui/const-generics/issues/issue-82956.rs | 33 +++++++++++++++++++ .../const-generics/issues/issue-82956.stderr | 21 ++++++++++++ .../ui/const-generics/issues/issue-84659.rs | 12 +++++++ .../const-generics/issues/issue-84659.stderr | 10 ++++++ .../ui/const-generics/issues/issue-86530.rs | 20 +++++++++++ .../const-generics/issues/issue-86530.stderr | 18 ++++++++++ .../ui/const-generics/issues/issue-86535-2.rs | 19 +++++++++++ .../ui/const-generics/issues/issue-86535.rs | 20 +++++++++++ .../sneaky-array-repeat-expr.rs | 32 ++++++++++++++++++ .../sneaky-array-repeat-expr.stderr | 18 ++++++++++ 10 files changed, 203 insertions(+) create mode 100644 src/test/ui/const-generics/issues/issue-82956.rs create mode 100644 src/test/ui/const-generics/issues/issue-82956.stderr create mode 100644 src/test/ui/const-generics/issues/issue-84659.rs create mode 100644 src/test/ui/const-generics/issues/issue-84659.stderr create mode 100644 src/test/ui/const-generics/issues/issue-86530.rs create mode 100644 src/test/ui/const-generics/issues/issue-86530.stderr create mode 100644 src/test/ui/const-generics/issues/issue-86535-2.rs create mode 100644 src/test/ui/const-generics/issues/issue-86535.rs create mode 100644 src/test/ui/const-generics/sneaky-array-repeat-expr.rs create mode 100644 src/test/ui/const-generics/sneaky-array-repeat-expr.stderr diff --git a/src/test/ui/const-generics/issues/issue-82956.rs b/src/test/ui/const-generics/issues/issue-82956.rs new file mode 100644 index 0000000000000..a3a0d8d06e87c --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-82956.rs @@ -0,0 +1,33 @@ +#![feature(generic_const_exprs, array_map)] +#![allow(incomplete_features)] + +pub struct ConstCheck; + +pub trait True {} +impl True for ConstCheck {} + +pub trait OrdesDec { + type Newlen; + type Output; + + fn pop(self) -> (Self::Newlen, Self::Output); +} + +impl OrdesDec for [T; N] +where + ConstCheck<{N > 1}>: True, + [T; N - 1]: Sized, +{ + type Newlen = [T; N - 1]; + type Output = T; + + fn pop(self) -> (Self::Newlen, Self::Output) { + let mut iter = IntoIter::new(self); + //~^ ERROR: failed to resolve: use of undeclared type `IntoIter` + let end = iter.next_back().unwrap(); + let new = [(); N - 1].map(move |()| iter.next().unwrap()); + (new, end) + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-82956.stderr b/src/test/ui/const-generics/issues/issue-82956.stderr new file mode 100644 index 0000000000000..c8b999da98104 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-82956.stderr @@ -0,0 +1,21 @@ +error[E0433]: failed to resolve: use of undeclared type `IntoIter` + --> $DIR/issue-82956.rs:25:24 + | +LL | let mut iter = IntoIter::new(self); + | ^^^^^^^^ not found in this scope + | +help: consider importing one of these items + | +LL | use std::array::IntoIter; + | +LL | use std::collections::binary_heap::IntoIter; + | +LL | use std::collections::btree_map::IntoIter; + | +LL | use std::collections::btree_set::IntoIter; + | + and 8 other candidates + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/const-generics/issues/issue-84659.rs b/src/test/ui/const-generics/issues/issue-84659.rs new file mode 100644 index 0000000000000..440ca740af2b0 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-84659.rs @@ -0,0 +1,12 @@ +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +trait Bar {} + +trait Foo<'a> { + const N: usize; + type Baz: Bar<{ Self::N }>; + //~^ ERROR: unconstrained generic constant +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-84659.stderr b/src/test/ui/const-generics/issues/issue-84659.stderr new file mode 100644 index 0000000000000..2dfc48a34e4b1 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-84659.stderr @@ -0,0 +1,10 @@ +error: unconstrained generic constant + --> $DIR/issue-84659.rs:8:15 + | +LL | type Baz: Bar<{ Self::N }>; + | ^^^^^^^^^^^^^^^^ + | + = help: try adding a `where` bound using this expression: `where [(); { Self::N }]:` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-86530.rs b/src/test/ui/const-generics/issues/issue-86530.rs new file mode 100644 index 0000000000000..919d3ca197f8f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-86530.rs @@ -0,0 +1,20 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait X { + const Y: usize; +} + +fn z(t: T) +where + T: X, + [(); T::Y]: , +{ +} + +fn unit_literals() { + z(" "); + //~^ ERROR: the trait bound `&str: X` is not satisfied +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-86530.stderr b/src/test/ui/const-generics/issues/issue-86530.stderr new file mode 100644 index 0000000000000..7cdfc9dfcdf5a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-86530.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `&str: X` is not satisfied + --> $DIR/issue-86530.rs:16:7 + | +LL | z(" "); + | ^^^ the trait `X` is not implemented for `&str` + | +note: required by a bound in `z` + --> $DIR/issue-86530.rs:10:8 + | +LL | fn z(t: T) + | - required by a bound in this +LL | where +LL | T: X, + | ^ required by this bound in `z` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/issues/issue-86535-2.rs b/src/test/ui/const-generics/issues/issue-86535-2.rs new file mode 100644 index 0000000000000..9a02b09b15502 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-86535-2.rs @@ -0,0 +1,19 @@ +// run-pass +#![feature(adt_const_params, generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait Foo { + const ASSOC_C: usize; + fn foo() where [(); Self::ASSOC_C]:; +} + +struct Bar; +impl Foo for Bar { + const ASSOC_C: usize = 3; + + fn foo() where [u8; Self::ASSOC_C]: { + let _: [u8; Self::ASSOC_C] = loop {}; + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-86535.rs b/src/test/ui/const-generics/issues/issue-86535.rs new file mode 100644 index 0000000000000..5289c4e99dd6f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-86535.rs @@ -0,0 +1,20 @@ +// run-pass +#![feature(adt_const_params, generic_const_exprs)] +#![allow(incomplete_features, unused_variables)] + +struct F; +impl X for F<{ S }> { + const W: usize = 3; + + fn d(r: &[u8; Self::W]) -> F<{ S }> { + let x: [u8; Self::W] = [0; Self::W]; + F + } +} + +pub trait X { + const W: usize; + fn d(r: &[u8; Self::W]) -> Self; +} + +fn main() {} diff --git a/src/test/ui/const-generics/sneaky-array-repeat-expr.rs b/src/test/ui/const-generics/sneaky-array-repeat-expr.rs new file mode 100644 index 0000000000000..b147c246bdac8 --- /dev/null +++ b/src/test/ui/const-generics/sneaky-array-repeat-expr.rs @@ -0,0 +1,32 @@ +trait Trait { + const Assoc: usize; +} + +impl Trait for () { + const Assoc: usize = 1; +} + + +pub const fn foo() where (): Trait { + let bar = [(); <()>::Assoc]; + //~^ error: constant expression depends on a generic parameter +} + +trait Trait2 { + const Assoc2: usize; +} + +impl Trait2 for () { + const Assoc2: usize = N - 1; +} + + +pub const fn foo2() where (): Trait2 { + let bar2 = [(); <()>::Assoc2]; + //~^ error: constant expression depends on a generic parameter +} + +fn main() { + foo::<0>(); + foo2::<0>(); +} diff --git a/src/test/ui/const-generics/sneaky-array-repeat-expr.stderr b/src/test/ui/const-generics/sneaky-array-repeat-expr.stderr new file mode 100644 index 0000000000000..5c77375d39934 --- /dev/null +++ b/src/test/ui/const-generics/sneaky-array-repeat-expr.stderr @@ -0,0 +1,18 @@ +error: constant expression depends on a generic parameter + --> $DIR/sneaky-array-repeat-expr.rs:11:20 + | +LL | let bar = [(); <()>::Assoc]; + | ^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: constant expression depends on a generic parameter + --> $DIR/sneaky-array-repeat-expr.rs:25:21 + | +LL | let bar2 = [(); <()>::Assoc2]; + | ^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: aborting due to 2 previous errors + From 89c6d4f9886b068f50b286eedbd503ff285f4b38 Mon Sep 17 00:00:00 2001 From: Ellen Date: Thu, 2 Sep 2021 21:30:13 +0100 Subject: [PATCH 2/7] tidy --- src/test/ui/const-generics/issues/issue-86530.rs | 2 +- src/test/ui/const-generics/issues/issue-86535-2.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/const-generics/issues/issue-86530.rs b/src/test/ui/const-generics/issues/issue-86530.rs index 919d3ca197f8f..b024decd4e11c 100644 --- a/src/test/ui/const-generics/issues/issue-86530.rs +++ b/src/test/ui/const-generics/issues/issue-86530.rs @@ -1,5 +1,5 @@ #![feature(generic_const_exprs)] -#![allow(incomplete_features)] +#![allow(incomplete_features)] pub trait X { const Y: usize; diff --git a/src/test/ui/const-generics/issues/issue-86535-2.rs b/src/test/ui/const-generics/issues/issue-86535-2.rs index 9a02b09b15502..0b535fd66498d 100644 --- a/src/test/ui/const-generics/issues/issue-86535-2.rs +++ b/src/test/ui/const-generics/issues/issue-86535-2.rs @@ -1,6 +1,6 @@ // run-pass #![feature(adt_const_params, generic_const_exprs)] -#![allow(incomplete_features)] +#![allow(incomplete_features)] pub trait Foo { const ASSOC_C: usize; From 2d95b5bce7119ae5549499083d24d143eae34d6b Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sat, 4 Sep 2021 19:22:34 +0100 Subject: [PATCH 3/7] Document when to use Windows' `symlink_dir` vs. `symlink_file` It was previously unclear which should be used when. --- library/std/src/os/windows/fs.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/library/std/src/os/windows/fs.rs b/library/std/src/os/windows/fs.rs index b20eafb4d53a5..71563a02dcbb9 100644 --- a/library/std/src/os/windows/fs.rs +++ b/library/std/src/os/windows/fs.rs @@ -517,11 +517,20 @@ impl FileTypeExt for fs::FileType { } } -/// Creates a new file symbolic link on the filesystem. +/// Creates a new symlink to a non-directory file on the filesystem. /// /// The `link` path will be a file symbolic link pointing to the `original` /// path. /// +/// The `original` path should not be a directory or a symlink to a directory, +/// otherwise the symlink will be broken. Use [`symlink_dir`] for directories. +/// +/// This function currently corresponds to [`CreateSymbolicLinkW`][CreateSymbolicLinkW]. +/// Note that this [may change in the future][changes]. +/// +/// [CreateSymbolicLinkW]: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinkw +/// [changes]: io#platform-specific-behavior +/// /// # Examples /// /// ```no_run @@ -537,11 +546,20 @@ pub fn symlink_file, Q: AsRef>(original: P, link: Q) -> io: sys::fs::symlink_inner(original.as_ref(), link.as_ref(), false) } -/// Creates a new directory symlink on the filesystem. +/// Creates a new symlink to a directory on the filesystem. /// /// The `link` path will be a directory symbolic link pointing to the `original` /// path. /// +/// The `original` path must be a directory or a symlink to a directory, +/// otherwise the symlink will be broken. Use [`symlink_file`] for other files. +/// +/// This function currently corresponds to [`CreateSymbolicLinkW`][CreateSymbolicLinkW]. +/// Note that this [may change in the future][changes]. +/// +/// [CreateSymbolicLinkW]: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinkw +/// [changes]: io#platform-specific-behavior +/// /// # Examples /// /// ```no_run From d84a39b35aaf161f9be228ddcc4b8b440c9c1adf Mon Sep 17 00:00:00 2001 From: est31 Date: Sun, 5 Sep 2021 06:08:34 +0200 Subject: [PATCH 4/7] Remove SmallVector mention SmallVector is long gone, as it's been first replaced by OneVector in commit e5e6375352636360add297c1f5a1f37ce71506e9, which then has been removed entirely in favour of SmallVec in commit 130a32fa7259d348dc3a684b38e688da398c30bb. --- compiler/rustc_data_structures/src/thin_vec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_data_structures/src/thin_vec.rs b/compiler/rustc_data_structures/src/thin_vec.rs index 00e304734983f..b5d2d24736cdc 100644 --- a/compiler/rustc_data_structures/src/thin_vec.rs +++ b/compiler/rustc_data_structures/src/thin_vec.rs @@ -2,7 +2,7 @@ use crate::stable_hasher::{HashStable, StableHasher}; use std::iter::FromIterator; -/// A vector type optimized for cases where this size is usually 0 (cf. `SmallVector`). +/// A vector type optimized for cases where this size is usually 0 (cf. `SmallVec`). /// The `Option>` wrapping allows us to represent a zero sized vector with `None`, /// which uses only a single (null) pointer. #[derive(Clone, Encodable, Decodable, Debug)] From 80d3cbc4c972e0f10025ea30238ed1d79d6c26a9 Mon Sep 17 00:00:00 2001 From: est31 Date: Sun, 5 Sep 2021 08:04:20 +0200 Subject: [PATCH 5/7] Correct typo --- src/test/ui/moves/move-guard-same-consts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/moves/move-guard-same-consts.rs b/src/test/ui/moves/move-guard-same-consts.rs index a2beb368b6e60..da436b89f538e 100644 --- a/src/test/ui/moves/move-guard-same-consts.rs +++ b/src/test/ui/moves/move-guard-same-consts.rs @@ -2,7 +2,7 @@ // arms whose patterns were composed solely of constants to not have // them linked in the cfg. // -// THis was broken for various reasons. In particular, that hack was +// This was broken for various reasons. In particular, that hack was // originally authored under the assunption that other checks // elsewhere would ensure that the two patterns did not overlap. But // that assumption did not hold, at least not in the long run (namely, From 3a105cfceac42c6b691a1ba0fc948eb896eeff7d Mon Sep 17 00:00:00 2001 From: Yechan Bae Date: Sun, 5 Sep 2021 16:04:19 -0400 Subject: [PATCH 6/7] Fix typo: needede -> needed --- library/alloc/src/collections/btree/node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index 8f6a2ec9ebd1f..a73f00a083af3 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -1663,7 +1663,7 @@ pub mod marker { const PERMITS_TRAVERSAL: bool = true; } impl BorrowType for Owned { - // Traversal isn't needede, it happens using the result of `borrow_mut`. + // Traversal isn't needed, it happens using the result of `borrow_mut`. // By disabling traversal, and only creating new references to roots, // we know that every reference of the `Owned` type is to a root node. const PERMITS_TRAVERSAL: bool = false; From a48ddcd93e9c4f4715b20c16ea06a5537080d2fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 6 Sep 2021 11:05:05 +0300 Subject: [PATCH 7/7] :arrow_up: rust-analyzer --- src/tools/rust-analyzer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer index 996300f4a061e..b73b321478d3b 160000 --- a/src/tools/rust-analyzer +++ b/src/tools/rust-analyzer @@ -1 +1 @@ -Subproject commit 996300f4a061e895a339a909fddce94f68ce7d19 +Subproject commit b73b321478d3b2a98d380eb79de717e01620c4e9