Skip to content

Commit 13db844

Browse files
committed
Auto merge of #88686 - rylev:rollup-m1tf9ir, r=m-ou-se
Rollup of 6 pull requests Successful merges: - #88602 (Add tests for some const generics issues) - #88647 (Document when to use Windows' `symlink_dir` vs. `symlink_file`) - #88659 (Remove SmallVector mention) - #88661 (Correct typo) - #88673 (Fix typo: needede -> needed) - #88685 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1c858ba + 3c4b461 commit 13db844

File tree

15 files changed

+227
-6
lines changed

15 files changed

+227
-6
lines changed

compiler/rustc_data_structures/src/thin_vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::stable_hasher::{HashStable, StableHasher};
22

33
use std::iter::FromIterator;
44

5-
/// A vector type optimized for cases where this size is usually 0 (cf. `SmallVector`).
5+
/// A vector type optimized for cases where this size is usually 0 (cf. `SmallVec`).
66
/// The `Option<Box<..>>` wrapping allows us to represent a zero sized vector with `None`,
77
/// which uses only a single (null) pointer.
88
#[derive(Clone, Encodable, Decodable, Debug)]

library/alloc/src/collections/btree/node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,7 @@ pub mod marker {
16631663
const PERMITS_TRAVERSAL: bool = true;
16641664
}
16651665
impl BorrowType for Owned {
1666-
// Traversal isn't needede, it happens using the result of `borrow_mut`.
1666+
// Traversal isn't needed, it happens using the result of `borrow_mut`.
16671667
// By disabling traversal, and only creating new references to roots,
16681668
// we know that every reference of the `Owned` type is to a root node.
16691669
const PERMITS_TRAVERSAL: bool = false;

library/std/src/os/windows/fs.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,20 @@ impl FileTypeExt for fs::FileType {
517517
}
518518
}
519519

520-
/// Creates a new file symbolic link on the filesystem.
520+
/// Creates a new symlink to a non-directory file on the filesystem.
521521
///
522522
/// The `link` path will be a file symbolic link pointing to the `original`
523523
/// path.
524524
///
525+
/// The `original` path should not be a directory or a symlink to a directory,
526+
/// otherwise the symlink will be broken. Use [`symlink_dir`] for directories.
527+
///
528+
/// This function currently corresponds to [`CreateSymbolicLinkW`][CreateSymbolicLinkW].
529+
/// Note that this [may change in the future][changes].
530+
///
531+
/// [CreateSymbolicLinkW]: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinkw
532+
/// [changes]: io#platform-specific-behavior
533+
///
525534
/// # Examples
526535
///
527536
/// ```no_run
@@ -537,11 +546,20 @@ pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io:
537546
sys::fs::symlink_inner(original.as_ref(), link.as_ref(), false)
538547
}
539548

540-
/// Creates a new directory symlink on the filesystem.
549+
/// Creates a new symlink to a directory on the filesystem.
541550
///
542551
/// The `link` path will be a directory symbolic link pointing to the `original`
543552
/// path.
544553
///
554+
/// The `original` path must be a directory or a symlink to a directory,
555+
/// otherwise the symlink will be broken. Use [`symlink_file`] for other files.
556+
///
557+
/// This function currently corresponds to [`CreateSymbolicLinkW`][CreateSymbolicLinkW].
558+
/// Note that this [may change in the future][changes].
559+
///
560+
/// [CreateSymbolicLinkW]: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinkw
561+
/// [changes]: io#platform-specific-behavior
562+
///
545563
/// # Examples
546564
///
547565
/// ```no_run
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#![feature(generic_const_exprs, array_map)]
2+
#![allow(incomplete_features)]
3+
4+
pub struct ConstCheck<const CHECK: bool>;
5+
6+
pub trait True {}
7+
impl True for ConstCheck<true> {}
8+
9+
pub trait OrdesDec {
10+
type Newlen;
11+
type Output;
12+
13+
fn pop(self) -> (Self::Newlen, Self::Output);
14+
}
15+
16+
impl<T, const N: usize> OrdesDec for [T; N]
17+
where
18+
ConstCheck<{N > 1}>: True,
19+
[T; N - 1]: Sized,
20+
{
21+
type Newlen = [T; N - 1];
22+
type Output = T;
23+
24+
fn pop(self) -> (Self::Newlen, Self::Output) {
25+
let mut iter = IntoIter::new(self);
26+
//~^ ERROR: failed to resolve: use of undeclared type `IntoIter`
27+
let end = iter.next_back().unwrap();
28+
let new = [(); N - 1].map(move |()| iter.next().unwrap());
29+
(new, end)
30+
}
31+
}
32+
33+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0433]: failed to resolve: use of undeclared type `IntoIter`
2+
--> $DIR/issue-82956.rs:25:24
3+
|
4+
LL | let mut iter = IntoIter::new(self);
5+
| ^^^^^^^^ not found in this scope
6+
|
7+
help: consider importing one of these items
8+
|
9+
LL | use std::array::IntoIter;
10+
|
11+
LL | use std::collections::binary_heap::IntoIter;
12+
|
13+
LL | use std::collections::btree_map::IntoIter;
14+
|
15+
LL | use std::collections::btree_set::IntoIter;
16+
|
17+
and 8 other candidates
18+
19+
error: aborting due to previous error
20+
21+
For more information about this error, try `rustc --explain E0433`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![allow(incomplete_features)]
2+
#![feature(generic_const_exprs)]
3+
4+
trait Bar<const N: usize> {}
5+
6+
trait Foo<'a> {
7+
const N: usize;
8+
type Baz: Bar<{ Self::N }>;
9+
//~^ ERROR: unconstrained generic constant
10+
}
11+
12+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: unconstrained generic constant
2+
--> $DIR/issue-84659.rs:8:15
3+
|
4+
LL | type Baz: Bar<{ Self::N }>;
5+
| ^^^^^^^^^^^^^^^^
6+
|
7+
= help: try adding a `where` bound using this expression: `where [(); { Self::N }]:`
8+
9+
error: aborting due to previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![feature(generic_const_exprs)]
2+
#![allow(incomplete_features)]
3+
4+
pub trait X {
5+
const Y: usize;
6+
}
7+
8+
fn z<T>(t: T)
9+
where
10+
T: X,
11+
[(); T::Y]: ,
12+
{
13+
}
14+
15+
fn unit_literals() {
16+
z(" ");
17+
//~^ ERROR: the trait bound `&str: X` is not satisfied
18+
}
19+
20+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0277]: the trait bound `&str: X` is not satisfied
2+
--> $DIR/issue-86530.rs:16:7
3+
|
4+
LL | z(" ");
5+
| ^^^ the trait `X` is not implemented for `&str`
6+
|
7+
note: required by a bound in `z`
8+
--> $DIR/issue-86530.rs:10:8
9+
|
10+
LL | fn z<T>(t: T)
11+
| - required by a bound in this
12+
LL | where
13+
LL | T: X,
14+
| ^ required by this bound in `z`
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// run-pass
2+
#![feature(adt_const_params, generic_const_exprs)]
3+
#![allow(incomplete_features)]
4+
5+
pub trait Foo {
6+
const ASSOC_C: usize;
7+
fn foo() where [(); Self::ASSOC_C]:;
8+
}
9+
10+
struct Bar<const N: &'static ()>;
11+
impl<const N: &'static ()> Foo for Bar<N> {
12+
const ASSOC_C: usize = 3;
13+
14+
fn foo() where [u8; Self::ASSOC_C]: {
15+
let _: [u8; Self::ASSOC_C] = loop {};
16+
}
17+
}
18+
19+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// run-pass
2+
#![feature(adt_const_params, generic_const_exprs)]
3+
#![allow(incomplete_features, unused_variables)]
4+
5+
struct F<const S: &'static str>;
6+
impl<const S: &'static str> X for F<{ S }> {
7+
const W: usize = 3;
8+
9+
fn d(r: &[u8; Self::W]) -> F<{ S }> {
10+
let x: [u8; Self::W] = [0; Self::W];
11+
F
12+
}
13+
}
14+
15+
pub trait X {
16+
const W: usize;
17+
fn d(r: &[u8; Self::W]) -> Self;
18+
}
19+
20+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
trait Trait<const N: usize> {
2+
const Assoc: usize;
3+
}
4+
5+
impl<const N: usize> Trait<N> for () {
6+
const Assoc: usize = 1;
7+
}
8+
9+
10+
pub const fn foo<const N: usize>() where (): Trait<N> {
11+
let bar = [(); <()>::Assoc];
12+
//~^ error: constant expression depends on a generic parameter
13+
}
14+
15+
trait Trait2<const N: usize> {
16+
const Assoc2: usize;
17+
}
18+
19+
impl<const N: usize> Trait2<N> for () {
20+
const Assoc2: usize = N - 1;
21+
}
22+
23+
24+
pub const fn foo2<const N: usize>() where (): Trait2<N> {
25+
let bar2 = [(); <()>::Assoc2];
26+
//~^ error: constant expression depends on a generic parameter
27+
}
28+
29+
fn main() {
30+
foo::<0>();
31+
foo2::<0>();
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error: constant expression depends on a generic parameter
2+
--> $DIR/sneaky-array-repeat-expr.rs:11:20
3+
|
4+
LL | let bar = [(); <()>::Assoc];
5+
| ^^^^^^^^^^^
6+
|
7+
= note: this may fail depending on what value the parameter takes
8+
9+
error: constant expression depends on a generic parameter
10+
--> $DIR/sneaky-array-repeat-expr.rs:25:21
11+
|
12+
LL | let bar2 = [(); <()>::Assoc2];
13+
| ^^^^^^^^^^^^
14+
|
15+
= note: this may fail depending on what value the parameter takes
16+
17+
error: aborting due to 2 previous errors
18+

src/test/ui/moves/move-guard-same-consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// arms whose patterns were composed solely of constants to not have
33
// them linked in the cfg.
44
//
5-
// THis was broken for various reasons. In particular, that hack was
5+
// This was broken for various reasons. In particular, that hack was
66
// originally authored under the assunption that other checks
77
// elsewhere would ensure that the two patterns did not overlap. But
88
// that assumption did not hold, at least not in the long run (namely,

src/tools/rust-analyzer

0 commit comments

Comments
 (0)