diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1baf0d1b54ce1..53656d8c6c210 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5122,7 +5122,6 @@ impl<'a> Parser<'a> { } if self.check(&token::OpenDelim(token::Paren)) { - let start_span = self.span; // We don't `self.bump()` the `(` yet because this might be a struct definition where // `()` or a tuple might be allowed. For example, `struct Struct(pub (), pub (usize));`. // Because of this, we only `bump` the `(` if we're assured it is appropriate to do so @@ -5165,8 +5164,7 @@ impl<'a> Parser<'a> { the path:", path); self.expect(&token::CloseDelim(token::Paren))?; // `)` - let sp = start_span.to(self.prev_span); - let mut err = self.span_fatal_help(sp, &msg, &suggestion); + let mut err = self.span_fatal_help(path_span, &msg, &suggestion); err.span_suggestion(path_span, &help_msg, format!("in {}", path)); err.emit(); // emit diagnostic, but continue with public visibility } diff --git a/src/test/compile-fail/issue-27842.rs b/src/test/compile-fail/issue-27842.rs index 28050a2ee9083..f7cd4e03c3b11 100644 --- a/src/test/compile-fail/issue-27842.rs +++ b/src/test/compile-fail/issue-27842.rs @@ -13,7 +13,7 @@ fn main() { // the case where we show a suggestion let _ = tup[0]; //~^ ERROR cannot index a value of type - //~| HELP to access tuple elements, use tuple indexing syntax as shown + //~| HELP to access tuple elements, use //~| SUGGESTION let _ = tup.0 // the case where we show just a general hint diff --git a/src/test/ui/pub/pub-restricted.rs b/src/test/ui/pub/pub-restricted.rs index 48e487f71a791..934ad24c16779 100644 --- a/src/test/ui/pub/pub-restricted.rs +++ b/src/test/ui/pub/pub-restricted.rs @@ -34,4 +34,8 @@ mod y { } } -fn main() {} \ No newline at end of file +fn main() {} + +// test multichar names +mod xyz {} +pub (xyz) fn xyz() {} diff --git a/src/test/ui/pub/pub-restricted.stderr b/src/test/ui/pub/pub-restricted.stderr index 5bc230e8da377..7bee1791eab40 100644 --- a/src/test/ui/pub/pub-restricted.stderr +++ b/src/test/ui/pub/pub-restricted.stderr @@ -1,41 +1,46 @@ error: incorrect visibility restriction - --> $DIR/pub-restricted.rs:15:5 + --> $DIR/pub-restricted.rs:15:6 | 15 | pub (a) fn afn() {} - | ^^^ + | ^ to make this visible only to module `a`, add `in` before the path: `in a` | = help: some possible visibility restrictions are: `pub(crate)`: visible only on the current crate `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path -help: to make this visible only to module `a`, add `in` before the path: - | pub (in a) fn afn() {} error: incorrect visibility restriction - --> $DIR/pub-restricted.rs:16:5 + --> $DIR/pub-restricted.rs:16:6 | 16 | pub (b) fn bfn() {} - | ^^^ + | ^ to make this visible only to module `b`, add `in` before the path: `in b` | = help: some possible visibility restrictions are: `pub(crate)`: visible only on the current crate `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path -help: to make this visible only to module `b`, add `in` before the path: - | pub (in b) fn bfn() {} error: incorrect visibility restriction - --> $DIR/pub-restricted.rs:32:13 + --> $DIR/pub-restricted.rs:32:14 | 32 | pub (a) invalid: usize, - | ^^^ + | ^ to make this visible only to module `a`, add `in` before the path: `in a` + | + = help: some possible visibility restrictions are: + `pub(crate)`: visible only on the current crate + `pub(super)`: visible only in the current module's parent + `pub(in path::to::module)`: visible only on the specified path + +error: incorrect visibility restriction + --> $DIR/pub-restricted.rs:41:6 + | +41 | pub (xyz) fn xyz() {} + | ^^^ to make this visible only to module `xyz`, add `in` before the path: `in xyz` | = help: some possible visibility restrictions are: `pub(crate)`: visible only on the current crate `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path -help: to make this visible only to module `a`, add `in` before the path: - | pub (in a) invalid: usize, error: visibilities can only be restricted to ancestor modules --> $DIR/pub-restricted.rs:33:17 @@ -43,5 +48,5 @@ error: visibilities can only be restricted to ancestor modules 33 | pub (in x) non_parent_invalid: usize, | ^ -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors diff --git a/src/test/ui/span/issue-39018.stderr b/src/test/ui/span/issue-39018.stderr index 9d6d4570c6ba6..46d39dac5aca7 100644 --- a/src/test/ui/span/issue-39018.stderr +++ b/src/test/ui/span/issue-39018.stderr @@ -2,11 +2,11 @@ error[E0369]: binary operation `+` cannot be applied to type `&'static str` --> $DIR/issue-39018.rs:12:13 | 12 | let x = "Hello " + "World!"; - | ^^^^^^^^ + | ^^^^^^^^----------- + | | + | to_owned() can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. `"Hello ".to_owned() + "World!"` | = note: `+` can't be used to concatenate two `&str` strings -help: to_owned() can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. - | let x = "Hello ".to_owned() + "World!"; error[E0369]: binary operation `+` cannot be applied to type `World` --> $DIR/issue-39018.rs:17:13 diff --git a/src/test/ui/span/suggestion-non-ascii.stderr b/src/test/ui/span/suggestion-non-ascii.stderr index 385c211f393c6..7e0cf030d766e 100644 --- a/src/test/ui/span/suggestion-non-ascii.stderr +++ b/src/test/ui/span/suggestion-non-ascii.stderr @@ -2,10 +2,7 @@ error: cannot index a value of type `({integer},)` --> $DIR/suggestion-non-ascii.rs:14:21 | 14 | println!("☃{}", tup[0]); - | ^^^^^^ - | -help: to access tuple elements, use tuple indexing syntax as shown - | println!("☃{}", tup.0); + | ^^^^^^ to access tuple elements, use `tup.0` error: aborting due to previous error