about summary refs log tree commit diff
path: root/src/test/compile-fail/union
AgeCommit message (Collapse)AuthorLines
2018-08-14Moved compile-fail tests to ui tests.David Wood-400/+0
2018-07-11Rollup merge of #52207 - RalfJung:unsafety-errors, r=estebankMark Rousskov-6/+6
improve error message shown for unsafe operations Add a short explanation saying why undefined behavior could arise. In particular, the error many people got for "creating a pointer to a packed field requires unsafe block" was not worded great -- it lead to people just adding the unsafe block without considering if what they are doing follows the rules. I am not sure if a "note" is the right thing, but that was the easiest thing to add... Inspired by @gnzlbg at https://github.com/rust-lang/rust/issues/46043#issuecomment-381544673
2018-07-10Fix typo in error message E0277Rémy Rakic-2/+2
2018-07-10improve error message shown for unsafe operations: explain why undefined ↵Ralf Jung-6/+6
behavior could arise Inspired by @gnzlbg at https://github.com/rust-lang/rust/issues/46043#issuecomment-381544673
2018-06-19Update message for `!Sized` typesEsteban Küber-2/+3
2018-06-19Add message to `rustc_on_unimplemented` attributes in coreEsteban Küber-2/+4
2018-02-15[improper_ctypes] Overhaul primary labelRobin Kruppe-1/+1
- Always name the non-FFI-safe - Explain *why* the type is not FFI-safe - Stop vaguely gesturing at structs/enums/unions if the non-FFI-safe types occured in a field. The last part is arguably a regression, but it's minor now that the non-FFI-safe type is actually named. Removing it avoids some code duplication.
2017-12-14Move compile-fail tests with NOTE/HELP annotations to UIVadim Petrochenkov-120/+0
2017-12-11Merge remote-tracking branch 'origin/master' into miriOliver Schneider-37/+0
2017-12-07Migrate even more feature gate tests to uiest31-37/+0
We also rename some of the files to conform to the feature-gate-<feat_name>.rs pattern that is most common.
2017-12-06Update miri to rustc changesOliver Schneider-0/+2
2017-09-24move unsafety checking to MIRAriel Ben-Yehuda-2/+2
No functional changes intended.
2017-07-31limit and delimit available fields in noteZack M. Davis-1/+1
Also, don't show the note if no fields are available (usually due to privacy).
2017-07-23field does not exist error: note fields if Levenshtein suggestion failsZack M. Davis-0/+1
When trying to access or initialize a nonexistent field, if we can't infer what field was meant (by virtue of the purported field in the source being a small Levenshtein distance away from an actual field, suggestive of a typo), issue a note listing all the available fields. To reduce terminal clutter, we don't issue the note when we have a `find_best_match_for_name` Levenshtein suggestion: the suggestion is probably right. The third argument of the call to `find_best_match_for_name` is changed to `None`, accepting the default maximum Levenshtein distance of one-third of the identifier supplied for correction. The previous value of `Some(name.len())` was overzealous, inappropriately very Levenshtein-distant suggestions when the attempted field access could not plausibly be a mere typo. For example, if a struct has fields `mule` and `phone`, but I type `.donkey`, I'd rather the error have a note listing that the available fields are, in fact, `mule` and `phone` (which is the behavior induced by this patch) rather than the error asking "did you mean `phone`?" (which is the behavior on master). The "only find fits with at least one matching letter" comment was accurate when it was first introduced in 09d992471 (January 2015), but is a vicious lie in its present context before a call to `find_best_match_for_name` and must be destroyed (replacing every letter is a Levenshtein distance of name.len()). The present author claims that this suffices to resolve #42599.
2017-05-27Stabilize unions with `Copy` fields and no destructorVadim Petrochenkov-17/+21
2017-05-25Use parameter environment associated with field use, not field definitionVadim Petrochenkov-2/+1
2017-05-25Make assignments to `Copy` union fields safeVadim Petrochenkov-7/+39
2017-04-08Fix move checking for nested union fieldsVadim Petrochenkov-0/+57
2017-01-12Mark even more tests as gate testsest31-0/+2
Now, no feature outside of the whitelist is without a test marked as its gate test.
2016-10-02Improve error message and snippet for "did you mean `x`"Gavin Baker-2/+2
- Fixes #36164 - Part of #35233 - handles unknown fields - uses UI-style tests - update all related tests (cfail, ui, incremental)
2016-09-20Update E0560 to include labelaclarry-1/+3
2016-09-10Improve `Eq` derivingVadim Petrochenkov-1/+30
2016-09-10Improve shallow `Clone` derivingVadim Petrochenkov-3/+43
2016-09-06Auto merge of #36252 - joshtriplett:union-field-never-used, r=sanxiynbors-0/+26
Fix "field is never used" warning to take unions into account When compiling code containing a union with an unused field, rustc says "struct field is never used". Rather than saying "struct or union", or adding logic to determine the type of the item, just change the message to "field is never used", dropping the "struct". Update tests accordingly.
2016-09-05Add test for unused field in unionJosh Triplett-0/+26
2016-09-04Updated E0559 to new formatCobrand-2/+3
Refactored a method that printed one suggested field name, into a method that returns an `Option` of a suggestion Updated test cases accordingly
2016-09-03Address comments and add requested testsVadim Petrochenkov-0/+359