Commit Graph

455 Commits

Author SHA1 Message Date
varkor
87463c3962 Improve some comments 2018-08-20 23:16:15 +01:00
varkor
798b9ff9d5 Tweak comments 2018-08-19 23:10:18 +01:00
varkor
0383539ded Fix handling of floating-point ranges 2018-08-16 20:10:01 +01:00
varkor
1dbc78112f Handle equivalence classes of length-1 ranges 2018-08-16 20:10:01 +01:00
varkor
e9c8361cc6 Add equivalence class splitting for range constructors 2018-08-16 20:10:01 +01:00
varkor
9e9e023354 More formatting improvements 2018-08-16 20:09:05 +01:00
varkor
400cb1411e Add a summary of the algorithm to the file 2018-08-16 20:09:05 +01:00
varkor
99754adbbb Some reformatting 2018-08-16 20:09:05 +01:00
varkor
5959a358e4 Move logic from push_wild_constructor to apply_constructor 2018-08-16 20:09:05 +01:00
varkor
4aa929cf8b Move witnesses inside push_wild_constructor 2018-08-16 20:09:05 +01:00
varkor
bfc0807b28 Add some comments 2018-08-16 20:09:05 +01:00
varkor
af366b0eb8 Refactor condition 2018-08-16 20:09:05 +01:00
varkor
07064de9a7 No longer return value_constructors for all_constructors 2018-08-16 20:09:05 +01:00
varkor
d27c21c016 Refactor for less allocation 2018-08-16 20:09:05 +01:00
varkor
6c21a0322c Refactor after miri api changes 2018-08-16 20:09:05 +01:00
varkor
732d638483 Replace ... with ..= in suggestions
As ... is "(silently) deprecated". Presumably this means we should be giving correct, up-to-date suggestions, though.
2018-08-16 20:09:05 +01:00
varkor
1aa749469b Introduce signed_bias method
The epitome of simplicity!
2018-08-16 20:09:05 +01:00
varkor
72cc4bd33b Inline encode and decode methods 2018-08-16 20:09:05 +01:00
varkor
be12b242ce Fix print_miri_value for signed integers 2018-08-16 20:09:05 +01:00
varkor
97a032ebb4 Simplify bitwise operations 2018-08-16 20:09:05 +01:00
varkor
c388c11a60 Special-case (RangeEnd::Included, Ordering::Equal) in lower_pattern_unadjusted 2018-08-16 20:09:05 +01:00
varkor
effb3d05a0 Improve the comments 2018-08-16 20:09:05 +01:00
varkor
a9f2c5a7b2 Fix sign conversion arithmetic errors 2018-08-16 20:09:05 +01:00
varkor
f4af3b015f Refactor to remove explicit integer type matching 2018-08-16 20:09:05 +01:00
varkor
a553fa7244 Fix integer overflow 2018-08-16 20:09:05 +01:00
varkor
7695bd0be9 Use bit operators for min_max_ty 2018-08-16 20:09:04 +01:00
varkor
c00fd8f58c Refactor interval conditions 2018-08-16 20:09:04 +01:00
varkor
7f72030421 Fix range splitting 2018-08-16 20:09:04 +01:00
varkor
a20cb1084a Require just the Unicode Scalar Values to be matched for a char 2018-08-16 20:09:04 +01:00
varkor
9778a81e92 Improve macros with reduced repetition 2018-08-16 20:09:04 +01:00
varkor
121fa8d499 Fix handling of signed integers 2018-08-16 20:09:04 +01:00
varkor
ed5a4d5e60 Add feature gate and refactor 2018-08-16 20:09:04 +01:00
varkor
384db4f0cf Add support for all integer types 2018-08-16 20:09:04 +01:00
varkor
b3d2baff94 Give correct suggestions 2018-08-16 20:09:04 +01:00
varkor
e3357d9984 Implement interval checking 2018-08-16 20:09:04 +01:00
Oliver Schneider
37e18e7a30 Second field of ScalarPair can be undef in some cases 2018-08-02 13:16:53 +02:00
Oliver Schneider
c6c06854c0 Reintroduce Undef and properly check constant value sizes 2018-08-01 15:29:35 +02:00
Shotaro Yamada
3525368a56 Use str::repeat 2018-07-27 23:26:36 +09:00
Oliver Schneider
de511438cd Promoteds are statics and statics have a place, not just a value 2018-07-23 09:51:30 +02:00
csmoe
19730cc996 Fix tidy 2018-07-16 15:09:17 +02:00
csmoe
6a16b38198 ExprKind 2018-07-16 15:09:16 +02:00
csmoe
14893ba96b DeclKind 2018-07-16 15:09:16 +02:00
csmoe
114314c920 StmtKind 2018-07-16 15:09:16 +02:00
csmoe
fe8955bd58 BinOpKind 2018-07-16 15:09:16 +02:00
varkor
adf4ef7b98 Use LitToConstError rather than bool for errors 2018-07-02 19:44:27 +01:00
varkor
0195714836 Fix ICEs with match/return expressions inside array lengths 2018-07-02 19:44:27 +01:00
varkor
b00050f4cf Add more safeguards to "missing binding mode" errors 2018-07-02 19:44:27 +01:00
varkor
998141f8ef Fix another return-const ICE 2018-07-02 19:43:16 +01:00
bors
d94b804863 Auto merge of #51882 - varkor:check-type_dependent_defs, r=estebank
Always check type_dependent_defs

Directly indexing into `type_dependent_defs` has caused multiple ICEs in the past (https://github.com/rust-lang/rust/issues/46771, https://github.com/rust-lang/rust/issues/49241, etc.) and is almost certainly responsible for #51798 too. This PR ensures we always check `type_dependent_defs` first, which should prevent any more of these (or at least make them easier to track down).
2018-07-01 08:41:50 +00:00
bors
ab8a67c12a Auto merge of #51729 - matthewjasper:move-errors, r=nikomatsakis
[NLL] Better move errors

Make a number of changes to improve the quality of NLL cannot move errors.

* Group errors that occur in the same `match` with the same cause.
* Suggest `ref`, `&` or removing `*` to avoid the move.
* Show the place being matched on.

Differences from AST borrowck:

* `&` is suggested over `ref` when matching on a place that can't be moved from.
* Removing `*` is suggested instead of adding `&` when applicable.
* Sub-pattern spans aren't used, this would probably need Spans on Places.

Closes #45699
Closes #46627
Closes #51187
Closes #51189

r? @pnkfelix
2018-06-29 12:40:12 +00:00
Mark Rousskov
57aceeecc0
Rollup merge of #51636 - oli-obk:const_diagnostics, r=eddyb
Refactor error reporting of constants

cc @eddyb

This PR should not change any behaviour. It solely simplifies the internal handling of the errors
2018-06-28 16:07:10 -06:00
varkor
4071adfcb5 Always check type_dependent_defs 2018-06-28 22:52:44 +01:00
Oliver Schneider
4bb9648b27 Merge ConstVal and ConstValue 2018-06-28 11:04:25 +02:00
Oliver Schneider
05994779ea Move everything over from middle::const_val to mir::interpret 2018-06-28 11:02:31 +02:00
Vadim Petrochenkov
d7072b5bb4 Fix rebase 2018-06-28 11:04:51 +03:00
Vadim Petrochenkov
f0622dfe5d Use Idents for associated item definitions in HIR
Remove emulation of hygiene with gensyms
2018-06-28 11:04:50 +03:00
Vadim Petrochenkov
c6ca1e4abd Use Idents in a number of structures in HIR
Namely: labels, type parameters, bindings in patterns, parameter names in functions without body.
All of these do not need hygiene after lowering to HIR, only span locations.
2018-06-28 11:04:50 +03:00
Matthew Jasper
0193d1f736 Group move errors before reporting, add suggestions 2018-06-27 22:46:58 +01:00
Zack M. Davis
057715557b migrate codebase to ..= inclusive range patterns
These were stabilized in March 2018's #47813, and are the Preferred Way
to Do It going forward (q.v. #51043).
2018-06-26 07:53:30 -07:00
bors
764232cb2a Auto merge of #51805 - pietroalbini:rollup, r=pietroalbini
Rollup of 11 pull requests

Successful merges:

 - #51104 (add `dyn ` to display of dynamic (trait) types)
 - #51153 (Link panic and compile_error docs)
 - #51642 (Fix unknown windows build)
 - #51730 (New safe associated functions for PinMut)
 - #51731 (Fix ICEs when using continue as an array length inside closures (inside loop conditions))
 - #51747 (Add error for using null characters in #[export_name])
 - #51769 (Update broken rustc-guide links)
 - #51786 (Remove unnecessary stat64 pointer casts)
 - #51788 (Fix typo)
 - #51789 (Don't ICE when performing `lower_pattern_unadjusted` on a `TyError`)
 - #51791 (Minify css)

Failed merges:

r? @ghost
2018-06-26 11:20:18 +00:00
bors
309fd8a6fb Auto merge of #49469 - Nokel81:allow-irrefutable-let-patterns, r=nikomatsakis
Implementation of RFC 2086 - Allow Irrefutable Let patterns

This is the set of changes for RFC2086. Tracking issue #44495. Rendered [here](https://github.com/rust-lang/rfcs/pull/2086)
2018-06-26 09:20:33 +00:00
Esteban Küber
7aab3bf863 Don't ICE when performing lower_pattern_unadjusted on a TyError 2018-06-25 13:49:34 -07:00
bors
8acec1f9d0 Auto merge of #51750 - zackmdavis:superstructure, r=oli-obk
three diagnostics upgrades

 * reword `...` expression syntax error to not imply that you should use it in patterns either (#51043) and make it a structured suggestion
 * shorten the top-line message for the trivial-casts lint by tucking the advisory sentence into a help note
 * structured suggestion for pattern-named-the-same-as-variant warning

r? @oli-obk
2018-06-25 13:43:22 +00:00
bors
ecfe37056f Auto merge of #51733 - varkor:ice-match-slice, r=oli-obk
Fix an ICE when matching over const slices

Fixes #51655. I'm not super familiar with this code, so tell me if this is the wrong approach 😅

r? @oli-obk
2018-06-25 11:36:13 +00:00
Zack M. Davis
4650361fb6 use structured suggestion for pattern-named-the-same-as-variant warning 2018-06-23 22:57:37 -07:00
bors
4fe88c05cd Auto merge of #51727 - varkor:expragain-to-exprcontinue, r=petrochenkov
Rename hir::ExprAgain to hir::ExprContinue

The current name is confusing and historical.

I also used this PR to clean up the annoying indentation in `check/mod.rs`. If that's viewed as too tangential a change, I'll split it up, but it seemed reasonable to slip it in to reduce @bors's work. It's easy to compare for the two commits individually.

r? @petrochenkov
2018-06-23 14:33:10 +00:00
varkor
e14e48bfaa Fix an ICE when matching over const slices 2018-06-23 14:41:01 +01:00
varkor
7ba2952af6 Rename ExprAgain to ExprContinue 2018-06-23 10:51:01 +01:00
bors
2ea922a96d Auto merge of #51696 - estebank:fuzzy-ice-ice, r=oli-obk
Accept `TyError` in patterns to avoid ICE on bad input

Fix #50585.
2018-06-23 06:56:12 +00:00
Esteban Küber
fe5710a25e Accept TyError in patterns to avoid ICE on bad input 2018-06-21 18:18:39 -07:00
varkor
76c0d68745 Rename "parameter" to "arg" 2018-06-20 12:19:04 +01:00
Niko Matsakis
92d4ae2be2 rename irrefutable_let_pattern to irrefutable_let_patterns 2018-06-08 11:37:35 -04:00
Oliver Schneider
5c0d1355f2 Refactor the const eval diagnostic API 2018-06-05 20:49:46 +02:00
Sebastian Malton
4fe40635ef Implementation of RFC 2086 - Allow Irrefutable Let patterns 2018-06-05 10:19:21 -04:00
Felix S. Klock II
47bb3fd505 Debug flag to bypass restriction of mutation in match guards.
Now, if you pass `-Z disable-ast-check-for-mutation-in-guard`, then we
will just allow you to mutably-borrow and assign in guards of `match`
arms.

This is wildly unsound with AST-borrowck. It is also unsound with
MIR-borrowck without further adjustments, which come in later in the
commit series on this Pull Request.

See also rust-lang/rust#24535 and rust-lang/rfcs#1006.
2018-05-29 23:01:36 +02:00
Zack M. Davis
1329605a3d operate on HirId in hir::Pat::each_binding, and consequences of that
Changing the `each_binding` utility method to take the `HirId` of a
binding pattern rather than its `NodeId` seems like a modest first step
in support of the `HirId`ification initiative #50928. (The inspiration
for choosing this in particular came from the present author's previous
work on diagnostics issued during liveness analysis, which is the most
greatly affected module in this change.)
2018-05-28 09:20:14 -07:00
Vadim Petrochenkov
189c0a1297 Use Idents for fields in HIR 2018-05-26 14:41:58 +03:00
Oliver Schneider
85de4efdd8 Rename amt variables to shift 2018-05-24 20:49:38 +02:00
Oliver Schneider
80a1488601 Prefer to_value_with_len over manual expanison of it 2018-05-24 20:49:38 +02:00
Oliver Schneider
bdd23bf215 tcx.lift_to_global > tcx.global_tcx().lift 2018-05-24 20:49:38 +02:00
Oliver Schneider
569ae80a0a Wrongly named a closure clamp when it was doing truncation 2018-05-24 20:49:38 +02:00
Oliver Schneider
cfd5fb5102 Reuse to_bits instead of badly reinventing it 2018-05-24 20:49:38 +02:00
Oliver Schneider
50628b7373 Only defined bits are relevant 2018-05-24 20:49:38 +02:00
Oliver Schneider
c6d25dc224 Don't ICE on horrible transmutes in pattern constants 2018-05-24 20:49:38 +02:00
Oliver Schneider
1a2964a541 Simplify a ScalarPair creation 2018-05-24 20:49:38 +02:00
Oliver Schneider
cc60a22b10 Get rid of scalar_size 2018-05-24 20:49:37 +02:00
Oliver Schneider
ea8f544964 Rebase fallout 2018-05-24 20:49:37 +02:00
Oliver Schneider
64a75ecc80 change Value::Bytes to Value::Bits 2018-05-24 20:49:37 +02:00
Oliver Schneider
3bbf2fd715 Remove Pointer::zero in favor of Pointer::from 2018-05-24 20:48:54 +02:00
Oliver Schneider
d7324631ae Rename MemoryPointer to Pointer 2018-05-24 20:48:54 +02:00
Oliver Schneider
03a92b61ec Eliminate the Pointer wrapper type 2018-05-24 20:48:13 +02:00
Oliver Schneider
ef2177cffc Rename ByVal(Pair) to Scalar(Pair) 2018-05-24 20:47:35 +02:00
Oliver Schneider
1606e137e7 Rename PrimVal to Scalar 2018-05-24 20:47:35 +02:00
Oliver Schneider
9cc5d927c9 Add constant for Size::from_bytes(0) 2018-05-24 20:46:07 +02:00
John Kåre Alsaker
ddc54188fb Introduce AllocType which indicates what AllocIds point to 2018-05-22 04:15:29 +02:00
John Kåre Alsaker
aace842a08 Get rid of literal_alloc_cache 2018-05-22 04:15:28 +02:00
Eduard-Mihai Burtescu
e3df729c25 rustc: make mk_substs_trait take &[Kind] instead of &[Ty]. 2018-05-21 12:13:17 +03:00
bors
538fea5757 Auto merge of #50851 - eddyb:the-only-constant, r=nikomatsakis
rustc: introduce {ast,hir}::AnonConst to consolidate so-called "embedded constants".

Previously, constants in array lengths and enum variant discriminants were "merely an expression", and had no separate ID for, e.g. type-checking or const-eval, instead reusing the expression's.

That complicated code working with bodies, because such constants were the only special case where the "owner" of the body wasn't the HIR parent, but rather the same node as the body itself.
Also, if the body happened to be a closure, we had no way to allocate a `DefId` for both the constant *and* the closure, leading to *several* bugs (mostly ICEs where type errors were expected).

This PR rectifies the situation by adding another (`{ast,hir}::AnonConst`) node around every such constant. Also, const generics are expected to rely on the new `AnonConst` nodes, as well (cc @varkor).
* fixes #48838
* fixes #50600
* fixes #50688
* fixes #50689
* obsoletes #50623

r? @nikomatsakis
2018-05-20 22:37:06 +00:00
Eduard-Mihai Burtescu
26aad25487 rustc: introduce {ast,hir}::AnonConst to consolidate so-called "embedded constants". 2018-05-19 20:34:42 +03:00
Oliver Schneider
7c25aa79c5 Use Size instead of u64 in mir interpretation 2018-05-19 16:38:49 +02:00