Skip to content

Commit 426bdb5

Browse files
authored
Unrolled build for rust-lang#127038
Rollup merge of rust-lang#127038 - BoxyUwU:reword_comment, r=camelid Update test comment r? `@camelid` Rewrote this comment since it mixed up a/b in one place and was generally a bit confusing
2 parents ef3d6fd + f79bf19 commit 426bdb5

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

tests/ui/const-generics/repeat_expr_hack_gives_right_generics.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
// Given an anon const `a`: `{ N }` and some anon const `b` which references the
2-
// first anon const: `{ [1; a] }`. `b` should not have any generics as it is not
3-
// a simple `N` argument nor is it a repeat expr count.
1+
// Given a const argument `a`: `{ N }` and some const argument `b` which references the
2+
// first anon const like so: `{ [1; a] }`. The `b` anon const should not be allowed to use
3+
// any generic parameters as:
4+
// - The anon const is not a simple bare parameter, e.g. `N`
5+
// - The anon const is not the *length* of an array repeat expression, e.g. the `N` in `[1; N]`.
46
//
5-
// On the other hand `b` *is* a repeat expr count and so it should inherit its
6-
// parents generics as part of the `const_evaluatable_unchecked` fcw (#76200).
7+
// On the other hand `a` *is* a const argument for the length of a repeat expression and
8+
// so it *should* inherit the generics declared on its parent definition. (This hack is
9+
// introduced for backwards compatibility and is tracked in #76200)
710
//
8-
// In this specific case however `b`'s parent should be `a` and so it should wind
9-
// up not having any generics after all. If `a` were to inherit its generics from
10-
// the enclosing item then the reference to `a` from `b` would contain generic
11-
// parameters not usable by `b` which would cause us to ICE.
11+
// In this specific case `a`'s parent should be `b` which does not have any generics.
12+
// This means that even though `a` inherits generics from `b`, it still winds up not having
13+
// access to any generic parameters. If `a` were to inherit its generics from the surrounding
14+
// function `foo` then the reference to `a` from `b` would contain generic parameters not usable
15+
// by `b` which would cause us to ICE.
1216

1317
fn bar<const N: usize>() {}
1418

tests/ui/const-generics/repeat_expr_hack_gives_right_generics.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: generic parameters may not be used in const operations
2-
--> $DIR/repeat_expr_hack_gives_right_generics.rs:16:17
2+
--> $DIR/repeat_expr_hack_gives_right_generics.rs:20:17
33
|
44
LL | bar::<{ [1; N] }>();
55
| ^ cannot perform const operation using `N`

0 commit comments

Comments
 (0)