a449bdb20e
Given a file like: ```rust enum Test { Variant, Variant2 {a: u32}, } fn main(){ let x = Test::Variant("Hello"); let y = Test::Variant2("World"); } ``` The errors now look this way: ```bash error[E0423]: `Test::Variant2` is the name of a struct or struct variant, but this expression uses it like a function name --> file3.rs:10:13 | 10 | let y = Test::Variant2("Hello"); | ^^^^^^^^^^^^^^ struct called like a function | = help: did you mean to write: `Test::Variant2 { /* fields */ }`? error: `Test::Variant` is being called, but it is not a function --> file3.rs:9:13 | 9 | let x = Test::Variant("World"); | ^^^^^^^^^^^^^^^^^^^^^^ | = help: did you mean to write: `Test::Variant`? note: defined here --> file3.rs:2:5 | 2 | Variant, | ^^^^^^^ error: aborting due to previous error ```
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
// 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.
|
|
|
|
// Can't use unit struct as constructor function
|
|
|
|
// aux-build:empty-struct.rs
|
|
|
|
extern crate empty_struct;
|
|
use empty_struct::*;
|
|
|
|
struct Empty2;
|
|
|
|
enum E {
|
|
Empty4
|
|
}
|
|
|
|
fn main() {
|
|
let e2 = Empty2(); //~ ERROR expected function, found `Empty2`
|
|
let e4 = E::Empty4();
|
|
//~^ ERROR `E::Empty4` is being called, but it is not a function
|
|
//~| HELP did you mean to write `E::Empty4`?
|
|
let xe2 = XEmpty2(); //~ ERROR expected function, found `empty_struct::XEmpty2`
|
|
let xe4 = XE::XEmpty4();
|
|
//~^ ERROR `XE::XEmpty4` is being called, but it is not a function
|
|
//~| HELP did you mean to write `XE::XEmpty4`?
|
|
}
|