"type ... too big for the current architecture" error reported without span pointing to type

c9b7476
Opened by Oli Scherer at 2023-07-24 20:08:10

e053dfad23515f7020171ae18013b230531a6042 added checks for huge types. These checks are done in middle/trans, but the location of the type is not reported.

For anonymous array types there's no way to extract the span, as the ast-ID is lost.

An example:

fn main() {
    let _x = [0; 9223372036854775808];
}

the error message:

error: the type `[i32; 9223372036854775808]` is too big for the current architecture
  1. Triage: no change.

    Steve Klabnik at 2016-11-29 19:54:28

  2. Playground link

    Chris Gregory at 2019-06-01 17:38:23

  3. The diagnostic is actually wrong. It's not about the type, it's about values of that type. You can use any type no matter its size for trait resolution and such, you just can't create values of it.

    Additionally, we're still not emitting this error with spans. I think the only way to reasonably do this is to create a new well formedness bound that is automatically added to a function's where bounds for all types within that function that are used with values, but for which we can't prove well-formedness. This may be very expensive, since it spawns lots of new where bounds where there were none before. Not sure, but may be worth an experiment

    Oli Scherer at 2020-11-18 09:16:35

  4. Current output:

    error: values of the type `[i32; 9223372036854775808]` are too big for the current architecture
    

    Esteban Kuber at 2023-07-24 20:08:10