about summary refs log tree commit diff
path: root/src/libsyntax/ast.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-02-23 11:21:29 +0000
committerbors <bors@rust-lang.org>2018-02-23 11:21:29 +0000
commit063deba92e44809125a433ca6e6c1ad0993313bf (patch)
tree95ff2922a9ae38b3059361343514e920f2931a4d /src/libsyntax/ast.rs
parent928435305ad1d778d7c4d2c2ff989c6a87be0223 (diff)
parent8e9fa57055a083ebc2378d855514166e3ec7a566 (diff)
downloadrust-063deba92e44809125a433ca6e6c1ad0993313bf.tar.gz
rust-063deba92e44809125a433ca6e6c1ad0993313bf.zip
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.
Diffstat (limited to 'src/libsyntax/ast.rs')
-rw-r--r--src/libsyntax/ast.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 8c1e5cf7586..c7ce7fffaa2 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -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,
 }