-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow const parameters in array sizes to be unified #60742
Conversation
This comment has been minimized.
This comment has been minimized.
This changes some test output, but it's in very rare cases, and the messages are not incorrect (they're just a little extraneous). |
☔ The latest upstream changes (presumably #60765) made this pull request unmergeable. Please resolve the merge conflicts. |
7e94d17
to
6ced4f5
Compare
@@ -11,7 +11,7 @@ error[E0308]: mismatched types | |||
--> $DIR/const-array-oob-arith.rs:8:44 | |||
| | |||
LL | const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99]; | |||
| ^^^^^^^ expected an array with a fixed size of 1 elements, found one with 2 elements | |||
| ^^^^^^^ expected `Const { ty: usize, val: Scalar(Bits { size: 8, bits: 1 }) }`, found `Const { ty: usize, val: Scalar(Bits { size: 8, bits: 2 }) }` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @oli-obk should we wait until printing this is fixed?
I believe this is waiting on #59276, correct? |
@yodaldevoid: that is correct. |
I've added some tests to confirm this also fixes #60923. |
This comment has been minimized.
This comment has been minimized.
83c32f5
to
eee346f
Compare
I've added back in the special cased message for arrays of different lengths and fixed a typo in related diagnostics. This is ready for re-review @eddyb. |
@@ -14,7 +14,7 @@ error[E0308]: mismatched types | |||
--> $DIR/cannot-infer-type-for-const-param.rs:10:22 | |||
| | |||
LL | let _ = Foo::<3>([1, 2, 3]); | |||
| ^^^^^^^^^ expected `Const { ty: usize, val: Unevaluated(DefId(0:18 ~ cannot_infer_type_for_const_param[317d]::main[0]::{{constant}}[0]), []) }`, found `Const { ty: usize, val: Scalar(0x0000000000000003) }` | |||
| ^^^^^^^^^ expected `3`, found `3usize` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This... is really weird? I assume the 3
is @oli-obk's printing of same-crate anon consts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because it can't infer the specific type, rather than an issue with printing. This is a bug, though, which should be fixed by #60839. (Which is ready to go as soon as this one is.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that the printing output is from Unevaluated
for the 3
in Foo::<3>
and not the value 3
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh, ok I did not envision user facing effects from that. So.... should I just do _
or {{unevaluated}}
or sth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to jump to something else here, but we should consider it carefully.
_
is clearly the conservative choice, as for "unevaluated" - I don't like that name too much, it just happened to be useful in ty::Const
(and we could/should pick another name).
5211145
to
6233d1f
Compare
@bors r=eddyb |
📌 Commit 6233d1f has been approved by |
…eddyb Allow const parameters in array sizes to be unified Fixes rust-lang#60632. Fixes rust-lang#60744. Fixes rust-lang#60923. (The last commit should probably be viewed in isolation, as it just renames things from `type` to `kind`.) r? @eddyb
…eddyb Allow const parameters in array sizes to be unified Fixes rust-lang#60632. Fixes rust-lang#60744. Fixes rust-lang#60923. (The last commit should probably be viewed in isolation, as it just renames things from `type` to `kind`.) r? @eddyb
Rollup of 9 pull requests Successful merges: - #60742 (Allow const parameters in array sizes to be unified) - #60756 (Add better tests for hidden lifetimes in impl trait) - #60928 (Changes the type `mir::Mir` into `mir::Body`) - #61024 (tests: Centralize proc macros commonly used for testing) - #61157 (BufReader: In Seek impl, remove extra discard_buffer call) - #61195 (Special-case `.llvm` in mangler) - #61202 (Print PermissionExt::mode() in octal in Documentation Examples) - #61259 (Mailmap fixes) - #61273 (mention that MaybeUninit is a bit like Option) Failed merges: r? @ghost
Fixes #60632.
Fixes #60744.
Fixes #60923.
(The last commit should probably be viewed in isolation, as it just renames things from
type
tokind
.)r? @eddyb