diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-05-04 09:21:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-04 09:21:21 +0200 |
| commit | 6a86be9fca0b46ad098717fad7f75319e9708c5c (patch) | |
| tree | 601b5e6a4371736ee5dd15cd6ede31fec7f7abb7 /src/libsyntax/parse | |
| parent | e2326366935613816927e679d3b2dc04db44678c (diff) | |
| parent | a3aafea68fcb3a2e7026ab4a9e33e031f2b01821 (diff) | |
| download | rust-6a86be9fca0b46ad098717fad7f75319e9708c5c.tar.gz rust-6a86be9fca0b46ad098717fad7f75319e9708c5c.zip | |
Rollup merge of #60429 - estebank:pub-path, r=michaelwoerister
Account for paths in incorrect pub qualifier help Handle case where incorrect pub qualifier with a mod path is used and provide the same help given for all other incorrect qualifiers by making the `pub(crate)` parse check more specific.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c5173aa5569..d46feeab335 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -7149,7 +7149,9 @@ impl<'a> Parser<'a> { // `()` 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 // by the following tokens. - if self.look_ahead(1, |t| t.is_keyword(keywords::Crate)) { + if self.look_ahead(1, |t| t.is_keyword(keywords::Crate)) && + self.look_ahead(2, |t| t != &token::ModSep) // account for `pub(crate::foo)` + { // `pub(crate)` self.bump(); // `(` self.bump(); // `crate` @@ -7192,7 +7194,7 @@ impl<'a> Parser<'a> { `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path"##; let path = self.parse_path(PathStyle::Mod)?; - let sp = self.prev_span; + let sp = path.span; let help_msg = format!("make this visible only to module `{}` with `in`", path); self.expect(&token::CloseDelim(token::Paren))?; // `)` let mut err = struct_span_err!(self.sess.span_diagnostic, sp, E0704, "{}", msg); |
