Auto merge of #45997 - estebank:pub-ident, r=nikomatsakis
Account for missing keyword in fn/struct definition Fix #38911.
This commit is contained in:
commit
d1364a65c0
24 changed files with 268 additions and 22 deletions
|
|
@ -17,7 +17,8 @@ extern crate derive_bad;
|
|||
#[derive(
|
||||
A
|
||||
)]
|
||||
//~^^ ERROR: proc-macro derive produced unparseable tokens
|
||||
//~^^ ERROR proc-macro derive produced unparseable tokens
|
||||
//~| ERROR expected `:`, found `}`
|
||||
struct A;
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,20 @@
|
|||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Z continue-parse-after-error
|
||||
|
||||
struct X {
|
||||
a: u8 /** document a */,
|
||||
//~^ ERROR found a documentation comment that doesn't document anything
|
||||
//~| HELP maybe a comment was intended
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let y = X {a = 1};
|
||||
struct Y {
|
||||
a: u8 /// document a
|
||||
//~^ ERROR found a documentation comment that doesn't document anything
|
||||
//~| HELP maybe a comment was intended
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = X { a: 1 };
|
||||
let y = Y { a: 1 };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,5 +17,5 @@ struct X {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let y = X {a = 1};
|
||||
let y = X {a: 1};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,5 +16,5 @@ struct X {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let y = X {a = 1};
|
||||
let y = X {a: 1};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ fn main() {
|
|||
println!("Y {}",x);
|
||||
return x;
|
||||
};
|
||||
//~^ ERROR expected item, found `;`
|
||||
|
||||
caller(bar_handler);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
macro_rules! failed {
|
||||
() => {{
|
||||
let x = 5 ""; //~ ERROR found `""`
|
||||
}} //~ ERROR macro expansion ignores token `}`
|
||||
}}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -15,4 +15,5 @@
|
|||
pub fn main() {
|
||||
struct Foo { x: isize }
|
||||
let mut Foo { x: x } = Foo { x: 3 }; //~ ERROR: expected one of `:`, `;`, `=`, or `@`, found `{`
|
||||
//~^ ERROR expected item, found `=`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let v[0] = v[1]; //~ error: expected one of `:`, `;`, `=`, or `@`, found `[`
|
||||
let v[0] = v[1]; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@ struct Foo {
|
|||
pub(crate) () foo: usize, //~ ERROR expected identifier
|
||||
}
|
||||
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
16
src/test/ui/suggestions/pub-ident-fn-2.rs
Normal file
16
src/test/ui/suggestions/pub-ident-fn-2.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
pub foo(s: usize) { bar() }
|
||||
//~^ ERROR missing `fn` for method definition
|
||||
|
||||
fn main() {
|
||||
foo(2);
|
||||
}
|
||||
12
src/test/ui/suggestions/pub-ident-fn-2.stderr
Normal file
12
src/test/ui/suggestions/pub-ident-fn-2.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error: missing `fn` for method definition
|
||||
--> $DIR/pub-ident-fn-2.rs:11:4
|
||||
|
|
||||
11 | pub foo(s: usize) { bar() }
|
||||
| ^
|
||||
help: add `fn` here to parse `foo` as a public method
|
||||
|
|
||||
11 | pub fn foo(s: usize) { bar() }
|
||||
| ^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
14
src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs
Normal file
14
src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
pub S();
|
||||
//~^ ERROR missing `fn` or `struct` for method or struct definition
|
||||
|
||||
fn main() {}
|
||||
8
src/test/ui/suggestions/pub-ident-fn-or-struct-2.stderr
Normal file
8
src/test/ui/suggestions/pub-ident-fn-or-struct-2.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error: missing `fn` or `struct` for method or struct definition
|
||||
--> $DIR/pub-ident-fn-or-struct-2.rs:11:4
|
||||
|
|
||||
11 | pub S();
|
||||
| ---^- help: if you meant to call a macro, write instead: `S!`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
14
src/test/ui/suggestions/pub-ident-fn-or-struct.rs
Normal file
14
src/test/ui/suggestions/pub-ident-fn-or-struct.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
pub S (foo) bar
|
||||
//~^ ERROR missing `fn` or `struct` for method or struct definition
|
||||
|
||||
fn main() {}
|
||||
8
src/test/ui/suggestions/pub-ident-fn-or-struct.stderr
Normal file
8
src/test/ui/suggestions/pub-ident-fn-or-struct.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error: missing `fn` or `struct` for method or struct definition
|
||||
--> $DIR/pub-ident-fn-or-struct.rs:11:4
|
||||
|
|
||||
11 | pub S (foo) bar
|
||||
| ---^- help: if you meant to call a macro, write instead: `S!`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
16
src/test/ui/suggestions/pub-ident-fn.rs
Normal file
16
src/test/ui/suggestions/pub-ident-fn.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
pub foo(s: usize) -> bool { true }
|
||||
//~^ ERROR missing `fn` for method definition
|
||||
|
||||
fn main() {
|
||||
foo(2);
|
||||
}
|
||||
12
src/test/ui/suggestions/pub-ident-fn.stderr
Normal file
12
src/test/ui/suggestions/pub-ident-fn.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error: missing `fn` for method definition
|
||||
--> $DIR/pub-ident-fn.rs:11:4
|
||||
|
|
||||
11 | pub foo(s: usize) -> bool { true }
|
||||
| ^^^
|
||||
help: add `fn` here to parse `foo` as a public method
|
||||
|
|
||||
11 | pub fn foo(s: usize) -> bool { true }
|
||||
| ^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
14
src/test/ui/suggestions/pub-ident-struct.rs
Normal file
14
src/test/ui/suggestions/pub-ident-struct.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
pub S {
|
||||
//~^ ERROR missing `struct` for struct definition
|
||||
}
|
||||
fn main() {}
|
||||
12
src/test/ui/suggestions/pub-ident-struct.stderr
Normal file
12
src/test/ui/suggestions/pub-ident-struct.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error: missing `struct` for struct definition
|
||||
--> $DIR/pub-ident-struct.rs:11:4
|
||||
|
|
||||
11 | pub S {
|
||||
| ^
|
||||
help: add `struct` here to parse `S` as a public struct
|
||||
|
|
||||
11 | pub struct S {
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue