Commit Graph

31 Commits

Author SHA1 Message Date
Ralf Jung
5e7eec2eaa
Rollup merge of #72497 - RalfJung:tag-term, r=oli-obk
tag/niche terminology cleanup

The term "discriminant" was used in two ways throughout the compiler:
* every enum variant has a corresponding discriminant, that can be given explicitly with `Variant = N`.
* that discriminant is then encoded in memory to store which variant is active -- but this encoded form of the discriminant was also often called "discriminant", even though it is conceptually quite different (e.g., it can be smaller in size, or even use niche-filling).

After discussion with @eddyb, this renames the second term to "tag". The way the tag is encoded can be either `TagEncoding::Direct` (formerly `DiscriminantKind::Tag`) or `TagEncoding::Niche` (formerly `DiscrimianntKind::Niche`).

This finally resolves some long-standing confusion I had about the handling of variant indices and discriminants, which surfaced in https://github.com/rust-lang/rust/pull/72419.

(There is also a `DiscriminantKind` type in libcore, it remains unaffected. I think this corresponds to the discriminant, not the tag, so that seems all right.)

r? @eddyb
2020-06-19 08:56:02 +02:00
Ralf Jung
7a6d03c269 miri errors: rename InvalidDiscriminant -> InvalidTag 2020-05-30 14:37:15 +02:00
Ralf Jung
f8d3805733 miri validation: clarify valid values of 'char' 2020-05-30 09:33:05 +02:00
Ralf Jung
3fccdb3ded Pointer printing: do not print 0 offset 2020-05-12 13:30:50 +02:00
Ralf Jung
b12faeb027 keep 'pointer' terminology around 2020-04-27 17:54:17 +02:00
Ralf Jung
96cfb20be9 organize Debug/Display impls a bit more; avoid sign-ignorant decimal display 2020-04-26 18:59:20 +02:00
Ralf Jung
a95f00fe1b fix type size mismatch on 32bit 2020-03-08 12:41:59 +01:00
Ralf Jung
f0586f9aea please tidy 2020-03-06 22:41:49 +01:00
Ralf Jung
f481547622 test some more kinds of enums with uninhabited variants 2020-03-06 22:41:49 +01:00
Ralf Jung
aa1435b0ae const validation ub tests: use transmute instead of unions 2020-03-06 22:41:49 +01:00
Ralf Jung
12054dce9a miri: validity visitor comments and path printing improvements 2020-02-26 13:34:02 +01:00
Ralf Jung
f8999fbdcf miri value visitor: fix some wrong assumptions about layout; improve error messages 2020-02-18 09:50:11 +01:00
Alexander Regueiro
022d9c8eb5 Fixed grammar/style in error messages and reblessed tests. 2019-09-06 03:46:08 +01:00
Ralf Jung
6d86163ffb const-eval tests: make all unions repr(C) 2019-08-30 09:35:33 +02:00
Ralf Jung
ceb496cf59 improve validity error range printing for singleton ranges 2019-07-04 10:47:23 +02:00
Ralf Jung
d9d6b3bb28 turns out that dangling pointer branch is dead code; remove it and improve the error that actually gets shown a bit 2019-07-04 10:47:23 +02:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Ralf Jung
c462e44c13 we now do proper validation on scalars 2018-11-19 23:02:28 +01:00
Ralf Jung
a3770c2547 do not accept out-of-bounds pointers in enum discriminants, they might be NULL 2018-11-15 10:59:39 +01:00
Ralf Jung
ffb6ba0828 validation: better error when the enum discriminant is Undef 2018-11-15 09:58:09 +01:00
Oliver Scherer
b174b0b955 miri-engine value visitor update to VariantIdx 2018-11-12 14:24:45 +01:00
Ralf Jung
b42b9b34d5 pretty-print scalar range that only has an upper bound 2018-11-07 13:58:43 +01:00
Ralf Jung
9dba743a6a do not print wrapping ranges like normal ranges in diagnostics 2018-11-07 13:46:49 +01:00
Ralf Jung
77c283465c Also test for undef in enum discriminant
The error message is sub-par, but fixing that requries moving ScalarMaybeUndef
to librustc which would conflict badly with another PR that is in flight.
2018-11-05 09:17:48 +01:00
Ralf Jung
fa01e04fbb fix validation error on non-integer enum discriminants 2018-11-05 09:17:48 +01:00
Oliver Schneider
7fdf06cdde Report const eval error inside the query 2018-10-25 16:46:19 +02:00
Ralf Jung
69a320f40d also validate everything that has a Scalar layout, to catch NonNull 2018-10-09 13:08:00 +02:00
Ralf Jung
f65d3b5491 switch validation of scalars to be type-driven
This does not actually regress anything.  It would regress NonNull, but we
didn't handle that correctly previously either.
2018-10-09 13:08:00 +02:00
Ralf Jung
f96208ca5b address nits 2018-08-28 19:57:05 +02:00
Ralf Jung
89cfd08b47 validate enum discriminant whenever it is read 2018-08-27 18:12:49 +02:00
Ralf Jung
49999e9b1d optimize sanity check path printing
During the sanity check, we keep track of the path we are below in a `Vec`.  We
avoid cloning that `Vec` unless we hit a pointer indirection.  The `String`
representation is only computed when validation actually fails.
2018-08-22 13:08:39 +02:00