Commit graph

79 commits

Author SHA1 Message Date
LeSeulArtichaut
3bd46f1aec Update UI test expectations 2019-12-12 20:56:14 +01:00
Nadrieril
1c1bec2f6d Remove top-level or-pattern hack 2019-12-02 16:03:03 +00:00
Nadrieril
a476af22e8 Correct error on partially unreachable or-pat in if let 2019-12-02 16:03:03 +00:00
Nadrieril
00ccadf43f Add some tests 2019-12-02 16:00:24 +00:00
bors
f453d1127d Auto merge of #66603 - Nadrieril:fix-65413, r=varkor
Fix #65413

#65413 was due to an oversight in `pat_constructor` that didn't check if a particular const value was maybe a slice/array const.
2019-11-28 14:22:47 +00:00
bors
53712f8637 Auto merge of #66389 - estebank:type-err-labels, r=petrochenkov
Specific labels when referring to "expected" and "found" types
2019-11-21 17:53:19 +00:00
Mazdak Farrokhzad
8f6197f39f Remove #![feature(never_type)] from tests.
Also remove `never_type` the feature-gate test.
2019-11-21 14:55:32 +01:00
Nadrieril
5510f5589e Use appropriate constructor for const slices 2019-11-21 11:20:46 +00:00
Nadrieril
fa4a4d3eda Add some tests 2019-11-21 11:20:46 +00:00
Esteban Küber
6f8f70624b Surround types with backticks in type errors 2019-11-18 11:03:04 -08:00
Esteban Küber
94c6425464 Remove E0308 note when primary label has all info 2019-11-18 11:03:03 -08:00
Esteban Küber
b2e6aef073 review comments: tweak prefix strings 2019-11-18 11:02:44 -08:00
Esteban Küber
83ffda5216 Specific labels when referring to "expected" and "found" types 2019-11-18 11:02:22 -08:00
Nadrieril Feneanar
2079ae3a52
Update src/test/ui/pattern/issue-53820-slice-pattern-large-array.rs
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-11-18 15:40:49 +00:00
Nadrieril
daa117eab7 Small improvement to exhaustiveness diagnostics 2019-11-17 17:59:37 +00:00
Nadrieril
5b420a9dc4 Add regression test for issue 53820 2019-11-16 16:43:55 +00:00
Nadrieril
d93c1b320c Introduce new FixedLenSlice constructor
It is used in the case where a variable-length slice pattern is used to
match on an array of known size. This allows considering only those
entries in the array that are captured by one of the patterns.
As a side-effect, diagnostics improve a bit for those cases.
2019-11-16 16:43:20 +00:00
Nadrieril
c00ecfa8d2 Add some tests 2019-11-16 16:18:46 +00:00
Nadrieril
cde9808eaa Add regression test 2019-11-15 16:55:38 +00:00
Nadrieril Feneanar
9165dd056b Apply suggestions from code review
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-11-15 16:55:37 +00:00
Nadrieril
c38aad4f4b Add test for failing try_eval_bits 2019-11-15 16:55:37 +00:00
Yuki Okushi
302cf6db74 Tweak non-char/numeric in range pattern diagnostic 2019-11-13 08:27:53 +09:00
Nadrieril
098974dadd Split slice-patterns test as suggested by Centril 2019-11-06 15:27:21 +00:00
Nadrieril
9531787ae5 Move a few more tests to the usefulness/ folder 2019-11-05 18:40:55 +00:00
Nadrieril
f774eb69fd Use VarLenSlice consistently when splitting constructors
The previous behaviour ignored slice lengths above a certain length
because it could not do otherwise. We now have VarLenSlice however, that
can represent the ignored lengths to make the algorithm more consistent.
This does not change the correctness of the algorithm, but makes it
easier to reason about.
As a nice side-effect, exhaustiveness errors have improved: they now
capture all missing lengths instead of only the shortest.
2019-11-05 18:32:26 +00:00
Nadrieril
58de9d9a13 Add some test cases 2019-11-05 17:59:01 +00:00
Nadrieril
65bc67e8d9 Make exhaustiveness error message more consistent for slice patterns
This improves error messages by indicating when slices above a certain
lengths have not been matched. Previously, we would only report examples
of such lengths, but of course never all of them.
2019-11-05 17:59:01 +00:00
Nadrieril
b66973043e Don't use max_slice_length when subtracting from VarLenSlice
This alters error messages slightly, but that'll be improved later
2019-11-05 17:59:01 +00:00
Nadrieril
4dc5697bd2 Add some slice-pattern exhaustiveness tests 2019-11-05 11:36:22 +00:00
bors
b43a682259 Auto merge of #65759 - tmiasko:ui, r=petrochenkov
Validate error patterns and error annotation in ui tests when present

Previously, when compilation succeeded, neither error patterns nor error
annotation would be validated. Additionally, when compilation failed,
only error patterns would be validated if both error patterns and error
annotation were present.

Now both error patterns and error annotation are validated when present,
regardless of compilation status. Furthermore, for test that should run,
the error patterns are matched against executable output, which is what
some of tests already expect to happen, and when #65506 is merged even
more ui tests will.

Fixes #56277
2019-11-03 15:14:09 +00:00
Tomasz Miąsko
dae4c6e722 Update error annotations in tests that successfully compile
Those annotation are silently ignored rather than begin validated
against compiler output. Update them before validation is enabled,
to avoid test failures.
2019-11-02 10:28:29 +01:00
Eduard-Mihai Burtescu
680089c2d9 Revert "pre-expansion gate box_patterns"
This reverts commit 2aff6b36d7.
2019-10-31 19:08:11 +02:00
bors
8d78bf6b27 Auto merge of #65421 - estebank:variants, r=petrochenkov
Point at local similarly named element and tweak references to variants

Partially address #65386.
2019-10-28 13:41:13 +00:00
Nadrieril
09f9947ebc Gather together usefulness tests
I took most tests that were testing only for match exhaustiveness,
pattern refutability or match arm reachability, and put them in
the same test folder.
2019-10-27 21:20:26 +00:00
Esteban Küber
b26ddb8af3 Point at local similarly named element and tweak references to variants
Point at the span for the definition of ADTs internal to the current
crate.

Look at the leading char of the ident to determine whether we're
expecting a likely fn or any of a fn, a tuple struct or a tuple variant.

Turn fn `add_typo_suggestion` into a `Resolver` method.
2019-10-27 11:50:43 -07:00
Mazdak Farrokhzad
2aff6b36d7 pre-expansion gate box_patterns 2019-10-24 00:32:03 +02:00
Mazdak Farrokhzad
6ec9b3a0b6 Adjust & --bless tests due to no longer downgrading NLL errors on 2015. 2019-09-26 06:44:57 +02:00
Esteban Küber
d9ab4ff9a3 Remove blanket silencing of "type annotation needed" errors
Remove blanket check for existence of other errors before emitting
"type annotation needed" errors, and add some eager checks to avoid
adding obligations when they refer to types that reference
`[type error]` in order to reduce unneded errors.
2019-09-24 11:31:14 -07:00
Esteban Küber
21e7e3f1e9 Point at variant on pattern field count mismatch 2019-09-04 19:04:44 -07:00
Mazdak Farrokhzad
6c7613b7fd Add semantic test for rest patterns. 2019-07-29 21:39:36 +02:00
Mazdak Farrokhzad
15bc63e8bf Add syntactic test for rest patterns. 2019-07-29 21:04:03 +02:00
bors
5748825cc8 Auto merge of #61682 - Centril:stabilize-type_alias_enum_variants, r=petrochenkov
Stabilize `type_alias_enum_variants` in Rust 1.37.0

Stabilize `#![feature(type_alias_enum_variants)]` which allows type-relative resolution with highest priority to `enum` variants in both expression and pattern contexts. For example, you may now write:

```rust
enum Option<T> {
    None,
    Some(T),
}

type OptAlias<T> = Option<T>;

fn work_on_alias(x: Option<u8>) -> u8 {
    match x {
        OptAlias::Some(y) => y + 1,
        OptAlias::None => 0,
    }
}
```

Closes https://github.com/rust-lang/rfcs/issues/2218
Closes https://github.com/rust-lang/rust/issues/52118

r? @petrochenkov
2019-07-01 03:11:19 +00:00
Eduard-Mihai Burtescu
2be847b2f9 test: normalize away the line/column info in ui/pattern/const-pat-ice. 2019-06-18 18:10:26 +03:00
Mazdak Farrokhzad
05dc864880 Move type_alias_enum_variants tests to a folder; Strip feature gates. 2019-06-15 19:18:09 +02:00
Eduard-Mihai Burtescu
fff08cb043 Run rustfmt --file-lines ... for changes from previous commits. 2019-06-12 13:38:28 +03:00
Alexander Regueiro
10b6daa6c8 Reblessed tests. 2019-06-05 21:09:27 +01:00
Oliver Scherer
dd327951eb Update ui tests 2019-05-25 10:07:02 +02:00
Oliver Scherer
fa17654f79 Make ConstValue::Slice solely take [u8] and str 2019-05-25 10:07:01 +02:00
Jethro Beekman
33fb1c501c Add FAQ for NLL migration 2019-05-21 09:52:05 -07:00
Matthew Jasper
ff71b80a85 Change compare mode to use -Zborrowck=mir 2019-05-12 18:46:43 +01:00