Improve E0178 suggestion placement
This commit is contained in:
parent
3a5567bad4
commit
f4b1e2af68
7 changed files with 60 additions and 23 deletions
21
src/test/ui/did_you_mean/E0178.rs
Normal file
21
src/test/ui/did_you_mean/E0178.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
trait Foo {}
|
||||
|
||||
struct Bar<'a> {
|
||||
w: &'a Foo + Copy,
|
||||
x: &'a Foo + 'a,
|
||||
y: &'a mut Foo + 'a,
|
||||
z: fn() -> Foo + 'a,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
26
src/test/ui/did_you_mean/E0178.stderr
Normal file
26
src/test/ui/did_you_mean/E0178.stderr
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
error[E0178]: expected a path on the left-hand side of `+`, not `&'a Foo`
|
||||
--> $DIR/E0178.rs:14:8
|
||||
|
|
||||
14 | w: &'a Foo + Copy,
|
||||
| ^^^^^^^^^^^^^^ try adding parentheses: `&'a (Foo + Copy)`
|
||||
|
||||
error[E0178]: expected a path on the left-hand side of `+`, not `&'a Foo`
|
||||
--> $DIR/E0178.rs:15:8
|
||||
|
|
||||
15 | x: &'a Foo + 'a,
|
||||
| ^^^^^^^^^^^^ try adding parentheses: `&'a (Foo + 'a)`
|
||||
|
||||
error[E0178]: expected a path on the left-hand side of `+`, not `&'a mut Foo`
|
||||
--> $DIR/E0178.rs:16:8
|
||||
|
|
||||
16 | y: &'a mut Foo + 'a,
|
||||
| ^^^^^^^^^^^^^^^^ try adding parentheses: `&'a mut (Foo + 'a)`
|
||||
|
||||
error[E0178]: expected a path on the left-hand side of `+`, not `fn() -> Foo`
|
||||
--> $DIR/E0178.rs:17:8
|
||||
|
|
||||
17 | z: fn() -> Foo + 'a,
|
||||
| ^^^^^^^^^^^^^^^^ perhaps you forgot parentheses?
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// 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.
|
||||
|
||||
fn main() {
|
||||
let _: &Copy + 'static;
|
||||
let _: &'static Copy + 'static;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
error[E0178]: expected a path on the left-hand side of `+`, not `&Copy`
|
||||
--> $DIR/trait-object-reference-without-parens-suggestion.rs:12:12
|
||||
|
|
||||
12 | let _: &Copy + 'static;
|
||||
| ^^^^^^^^^^^^^^^ try adding parentheses: `&(Copy + 'static)`
|
||||
|
||||
error[E0178]: expected a path on the left-hand side of `+`, not `&'static Copy`
|
||||
--> $DIR/trait-object-reference-without-parens-suggestion.rs:13:12
|
||||
|
|
||||
13 | let _: &'static Copy + 'static;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ try adding parentheses: `&'static (Copy + 'static)`
|
||||
|
||||
error[E0038]: the trait `std::marker::Copy` cannot be made into an object
|
||||
--> $DIR/trait-object-reference-without-parens-suggestion.rs:12:12
|
||||
|
|
||||
12 | let _: &Copy + 'static;
|
||||
| ^^^^^ the trait `std::marker::Copy` cannot be made into an object
|
||||
|
|
||||
= note: the trait cannot require that `Self : Sized`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue