be more robust to bogus items in struct patterns/constructors

Fixes #27815
This commit is contained in:
Ariel Ben-Yehuda 2015-08-14 16:14:09 +03:00
parent 7b7fc67dd4
commit b87c292627
6 changed files with 99 additions and 115 deletions

View file

@ -15,6 +15,6 @@ pub use use_from_trait_xc::Trait;
fn main() {
match () {
Trait { x: 42 } => () //~ ERROR use of trait `Trait` in a struct pattern
Trait { x: 42 } => () //~ ERROR `Trait` does not name a struct
}
}

View file

@ -0,0 +1,20 @@
// Copyright 2015 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.
mod A {}
fn main() {
let u = A { x: 1 }; //~ ERROR `A` does not name a structure
let v = u32 { x: 1 }; //~ ERROR `u32` does not name a structure
match () {
A { x: 1 } => {} //~ ERROR `A` does not name a struct
u32 { x: 1 } => {} //~ ERROR `u32` does not name a struct
}
}

View file

@ -12,5 +12,5 @@ trait TraitNotAStruct {}
fn main() {
TraitNotAStruct{ value: 0 };
//~^ ERROR: use of trait `TraitNotAStruct` as a struct constructor [E0159]
//~^ ERROR: `TraitNotAStruct` does not name a structure [E0071]
}