Do not emit E0277 on incorrect tuple destructured binding
This commit is contained in:
parent
7ee72070bd
commit
3d7099a968
4 changed files with 53 additions and 3 deletions
28
src/test/ui/elide-errors-on-mismatched-tuple.rs
Normal file
28
src/test/ui/elide-errors-on-mismatched-tuple.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Hide irrelevant E0277 errors (#50333)
|
||||
|
||||
trait T {}
|
||||
|
||||
struct A;
|
||||
impl T for A {}
|
||||
impl A {
|
||||
fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three
|
||||
//~^ ERROR mismatched types
|
||||
let ts: Vec<&T> = vec![&a, &b, &c];
|
||||
// There is no E0277 error above, as `a`, `b` and `c` are `TyErr`
|
||||
}
|
||||
12
src/test/ui/elide-errors-on-mismatched-tuple.stderr
Normal file
12
src/test/ui/elide-errors-on-mismatched-tuple.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/elide-errors-on-mismatched-tuple.rs:24:9
|
||||
|
|
||||
LL | let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three
|
||||
| ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
|
||||
|
|
||||
= note: expected type `(A, A)`
|
||||
found type `(_, _, _)`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue