Zack M. Davis
1f04597c3c
in which parentheses are suggested for should-have-been-tuple-patterns
...
Programmers used to working in some other languages (such as Python or
Go) might expect to be able to destructure values with comma-separated
identifiers but no parentheses on the left side of an assignment.
Previously, the first name in such code would get parsed as a
single-indentifier pattern—recognizing, for example, the
`let a` in `let a, b = (1, 2);`—whereupon we would have a fatal syntax
error on seeing an unexpected comma rather than the expected semicolon
(all the way nearer to the end of `parse_full_stmt`).
Instead, let's look for that comma when parsing the pattern, and if we
see it, momentarily make-believe that we're parsing the remaining
elements in a tuple pattern, so that we can suggest wrapping it all in
parentheses. We need to do this in a separate wrapper method called on
the top-level pattern (or `|`-patterns) in a `let` statement, `for`
loop, `if`- or `while let` expression, or match arm rather than within
`parse_pat` itself, because `parse_pat` gets called recursively to parse
the sub-patterns within a tuple pattern.
Resolves #48492 .
2018-03-08 11:30:34 -08:00
Oliver Schneider
52dec0e1c9
Don't derive traits on packed structs
2018-03-08 08:35:39 +01:00
Oliver Schneider
47e0bb59db
Clean up the binary hex lint
2018-03-08 08:35:39 +01:00
Oliver Schneider
c0fc6a8b6b
simplify constant value pair field access
2018-03-08 08:35:39 +01:00
Oliver Schneider
b5ace9a906
Unify the const folding errors
...
before they differed depending on whether optimizations were on or not
2018-03-08 08:35:39 +01:00
Oliver Schneider
edc5f73433
Correct the shift overflow check in miri
2018-03-08 08:35:39 +01:00
Oliver Schneider
aedd4c61ea
Regenerate tests
2018-03-08 08:35:38 +01:00
Oliver Schneider
6cfda078bf
Use clearer name for integer bit width helper function
2018-03-08 08:35:38 +01:00
Oliver Schneider
eb18d39a04
Reuse Integer::from_attr
2018-03-08 08:35:38 +01:00
Oliver Schneider
273025675d
Remove unused error code
2018-03-08 08:35:38 +01:00
Oliver Schneider
3dc7e93db6
Generator assertions are unconditionally triggered
2018-03-08 08:35:38 +01:00
Oliver Schneider
47913ee8f4
Address review comments
2018-03-08 08:35:38 +01:00
Oliver Schneider
208d764833
Adjust test which differs between 32 bit and 64 bit
...
The differences are not part of what the test is testing, so they were simply removed.
2018-03-08 08:35:38 +01:00
Oliver Schneider
e8d357f070
Decide signdedness on the layout instead of the type
2018-03-08 08:35:37 +01:00
Oliver Schneider
889a4ebfa9
Deduplicate some code
2018-03-08 08:34:18 +01:00
Oliver Schneider
df283df887
Don't use the undefined bytes of PrimVal::Bytes
2018-03-08 08:34:18 +01:00
Oliver Schneider
7218836500
Fix mozjs crater failure
2018-03-08 08:34:18 +01:00
Oliver Schneider
134c2910ec
Const eval will oom together with rustc now
2018-03-08 08:34:18 +01:00
Oliver Schneider
0ca4b45a0c
Step limit is now terminator limit
2018-03-08 08:34:17 +01:00
Oliver Schneider
b63c6bbfee
Add regression test
2018-03-08 08:34:17 +01:00
Oliver Schneider
d98a2b90b2
Rebase fallout
2018-03-08 08:34:17 +01:00
Oliver Schneider
2f0e077300
Report tcx errors with the span of the currently evaluating statement
2018-03-08 08:34:17 +01:00
Oliver Schneider
1e653aa96b
Report a best guess span if no stack is available anymore
2018-03-08 08:34:17 +01:00
Oliver Schneider
f363e08c9d
Update compile-fail tests
2018-03-08 08:34:17 +01:00
Oliver Schneider
f68dc0190a
Add a test for transmuting via unions in constants
2018-03-08 08:34:17 +01:00
Oliver Schneider
0a1278aea8
Typo
2018-03-08 08:34:17 +01:00
Oliver Schneider
5b698a1040
Unregress error spans in constant errors
2018-03-08 08:34:17 +01:00
Oliver Schneider
421622d8f7
Stage 2 doesn't see suggestion_approximate
2018-03-08 08:34:16 +01:00
Oliver Schneider
f5cc5ca8c7
Remove dead code
2018-03-08 08:34:16 +01:00
Oliver Schneider
1f9d846a58
Add some documentation to pattern/const conversions
2018-03-08 08:34:16 +01:00
Oliver Schneider
b985399831
Reduce code duplication
2018-03-08 08:34:16 +01:00
Oliver Schneider
3c663d0607
Tidy fix
2018-03-08 08:34:16 +01:00
Oliver Schneider
8500c2fab2
Const eval error refactoring
2018-03-08 08:34:16 +01:00
Oliver Schneider
bd03371f71
Add stack traces to miri errors
2018-03-08 08:34:16 +01:00
Oliver Schneider
8c53d54b98
Update tests
2018-03-08 08:34:16 +01:00
Oliver Schneider
d2f363ba89
Report all errors other than those about insufficient type information
2018-03-08 08:34:15 +01:00
Oliver Schneider
64fbf5d5ad
Compute the ParamEnv only once and use it to call tcx.const_eval
2018-03-08 08:34:15 +01:00
Oliver Schneider
a678044c77
Add regression test for const prop
2018-03-08 08:34:15 +01:00
Oliver Schneider
dde68dcfe5
Can only const prop temporaries
...
Variables might error in branches that are not reachable due to the variable value.
2018-03-08 08:34:15 +01:00
Oliver Schneider
05a03d7537
Update tests
2018-03-08 08:34:15 +01:00
Oliver Schneider
1561b4ad50
Simplify const propagator by removing unused code paths
2018-03-08 08:34:15 +01:00
Oliver Schneider
411fcf58fd
Rename OptimizationFinder and don't propagate any borrows
2018-03-08 08:34:15 +01:00
Oliver Schneider
57ae890265
Simplify const prop checks through PlaceContext
2018-03-08 08:34:15 +01:00
Oliver Schneider
65ed591197
Move the resource limits to the session in preparation for attributes configuring them
2018-03-08 08:34:15 +01:00
Oliver Schneider
0462d092d2
Figure out const propgatable locals in a single pass
2018-03-08 08:34:14 +01:00
Oliver Schneider
16d560fd99
Remove unused error E0020
2018-03-08 08:34:14 +01:00
Oliver Schneider
ceb634a732
Update tests
2018-03-08 08:34:14 +01:00
Oliver Schneider
45abb1ba84
Stabilize const_indexing feature
2018-03-08 08:34:14 +01:00
Oliver Schneider
600fcc7159
Report const eval errors at the correct span
2018-03-08 08:34:14 +01:00
Oliver Schneider
13c0dc56df
Only report bitshift lints on bitshift ops
2018-03-08 08:34:14 +01:00