Skip to content

Conversation

TaKO8Ki
Copy link
Member

@TaKO8Ki TaKO8Ki commented Dec 7, 2022

Fixes #105257

@rustbot
Copy link
Collaborator

rustbot commented Dec 7, 2022

r? @petrochenkov

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 7, 2022
@BoxyUwU
Copy link
Member

BoxyUwU commented Dec 7, 2022

r? @BoxyUwU

Do you know why the test case doesn't ICE when you provide a valid default instead of ""?

@rustbot rustbot assigned BoxyUwU and unassigned petrochenkov Dec 7, 2022
@BoxyUwU
Copy link
Member

BoxyUwU commented Dec 7, 2022

oh it does if you provide { 10 + 1 } but 10 wouldnt be an anon const right.. I wonder why const N: u32 = "" is creating an anon const 🤔 (or i guess really I am surprised we arent special casing "" as a const arg like we do with N or 10)

r=me with a test that uses const N: usize = { std::mem::size_of::<T>() } so that we can be more sure we have a test that will continue having an anon const in the future

@BoxyUwU BoxyUwU added the A-const-generics Area: const generics (parameters and arguments) label Dec 7, 2022
@BoxyUwU
Copy link
Member

BoxyUwU commented Dec 8, 2022

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 8, 2022

📌 Commit 85d7d9b has been approved by BoxyUwU

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 8, 2022
@TaKO8Ki
Copy link
Member Author

TaKO8Ki commented Dec 8, 2022

@BoxyUwU

Do you know why the test case doesn't ICE when you provide a valid default instead of ""?

This is because of Const::try_eval_lit_or_param. If the default is "", it returns Some. If I use provide a valid default like 1, it returns None in the following lines. And this leads to the ICE that happens in generics_of.

match Self::try_eval_lit_or_param(tcx, ty, expr) {
Some(v) => v,
None => tcx.mk_const(
ty::UnevaluatedConst {
def: def.to_global(),
substs: InternalSubsts::identity_for_item(tcx, def.did.to_def_id()),
},
ty,
),
}

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 10, 2022
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#104460 (Migrate parts of `rustc_expand` to session diagnostics)
 - rust-lang#105192 (Point at LHS on binop type err if relevant)
 - rust-lang#105234 (Remove unneeded field from `SwitchTargets`)
 - rust-lang#105239 (Avoid heap allocation when truncating thread names)
 - rust-lang#105410 (Consider `parent_count` for const param defaults)
 - rust-lang#105482 (Fix invalid codegen during debuginfo lowering)

Failed merges:

 - rust-lang#105411 (Introduce `with_forced_trimmed_paths`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 62160cb into rust-lang:master Dec 10, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 10, 2022
@TaKO8Ki TaKO8Ki deleted the fix-105257 branch December 12, 2022 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: generic_const_exprs "range end index 2 out of range for slice of length 1"
5 participants