Auto merge of #47799 - topecongiro:fix-span-of-visibility, r=petrochenkov

Fix span of visibility

This PR

1. adds a closing parenthesis to the span of `Visibility::Crate` (e.g. `pub(crate)`). The current span only covers `pub(crate`.
2. adds a `span` field to `Visibility::Restricted`. This span covers the entire visibility expression (e.g. `pub (in self)`). Currently all we can have is a span for `Path`.

This PR is motivated by the bug found in rustfmt (https://github.com/rust-lang-nursery/rustfmt/issues/2398).

The first change is a strict improvement IMHO. The second change may not be desirable, as it adds a field which is currently not used by the compiler.
This commit is contained in:
bors
2018-02-23 11:21:29 +00:00
26 changed files with 174 additions and 129 deletions

View File

@@ -1937,10 +1937,12 @@ pub enum CrateSugar {
JustCrate,
}
pub type Visibility = Spanned<VisibilityKind>;
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum Visibility {
pub enum VisibilityKind {
Public,
Crate(Span, CrateSugar),
Crate(CrateSugar),
Restricted { path: P<Path>, id: NodeId },
Inherited,
}