aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-11-02 13:08:53 +0000
committerGitHub <[email protected]>2020-11-02 13:08:53 +0000
commit731b38fa3c1694648e6c8e60f61820f9783343eb (patch)
treeb3f4e94e8eac9bb24296aacafacb100930bee59e /crates/syntax
parent6507877e7039d4517682a4fc232356662f509d81 (diff)
parentb6101184537b1165cfdd5fc473e04ad4c5b7bffa (diff)
Merge #6438
6438: Deny unreachable-pub r=matklad a=matklad It's very useful when `pub` is equivalent to "this is crate's public API", let's enforce this! Ideally, we should enforce it for local `cargo test`, and only during CI, but that needs https://github.com/rust-lang/cargo/issues/5034. Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/syntax')
-rw-r--r--crates/syntax/src/ast.rs2
-rw-r--r--crates/syntax/src/ast/generated.rs6
-rw-r--r--crates/syntax/src/lib.rs11
-rw-r--r--crates/syntax/src/parsing.rs4
-rw-r--r--crates/syntax/src/parsing/text_token_source.rs2
-rw-r--r--crates/syntax/src/syntax_node.rs6
6 files changed, 15 insertions, 16 deletions
diff --git a/crates/syntax/src/ast.rs b/crates/syntax/src/ast.rs
index d536bb1e7..8a0e3d27b 100644
--- a/crates/syntax/src/ast.rs
+++ b/crates/syntax/src/ast.rs
@@ -17,7 +17,7 @@ use crate::{
17 17
18pub use self::{ 18pub use self::{
19 expr_ext::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp}, 19 expr_ext::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp},
20 generated::*, 20 generated::{nodes::*, tokens::*},
21 node_ext::{ 21 node_ext::{
22 AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents, 22 AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents,
23 StructKind, TypeBoundKind, VisibilityKind, 23 StructKind, TypeBoundKind, VisibilityKind,
diff --git a/crates/syntax/src/ast/generated.rs b/crates/syntax/src/ast/generated.rs
index 4a6f41ee7..843b43cf0 100644
--- a/crates/syntax/src/ast/generated.rs
+++ b/crates/syntax/src/ast/generated.rs
@@ -1,8 +1,8 @@
1//! This file is actually hand-written, but the submodules are indeed generated. 1//! This file is actually hand-written, but the submodules are indeed generated.
2#[rustfmt::skip] 2#[rustfmt::skip]
3mod nodes; 3pub(crate) mod nodes;
4#[rustfmt::skip] 4#[rustfmt::skip]
5mod tokens; 5pub(crate) mod tokens;
6 6
7use crate::{ 7use crate::{
8 AstNode, 8 AstNode,
@@ -10,7 +10,7 @@ use crate::{
10 SyntaxNode, 10 SyntaxNode,
11}; 11};
12 12
13pub use {nodes::*, tokens::*}; 13pub(crate) use nodes::*;
14 14
15// Stmt is the only nested enum, so it's easier to just hand-write it 15// Stmt is the only nested enum, so it's easier to just hand-write it
16impl AstNode for Stmt { 16impl AstNode for Stmt {
diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs
index 849a1cdd6..e753b11bb 100644
--- a/crates/syntax/src/lib.rs
+++ b/crates/syntax/src/lib.rs
@@ -46,16 +46,19 @@ use text_edit::Indel;
46pub use crate::{ 46pub use crate::{
47 algo::InsertPosition, 47 algo::InsertPosition,
48 ast::{AstNode, AstToken}, 48 ast::{AstNode, AstToken},
49 parsing::{lex_single_syntax_kind, lex_single_valid_syntax_kind, tokenize, Token}, 49 parsing::lexer::{lex_single_syntax_kind, lex_single_valid_syntax_kind, tokenize, Token},
50 ptr::{AstPtr, SyntaxNodePtr}, 50 ptr::{AstPtr, SyntaxNodePtr},
51 syntax_error::SyntaxError, 51 syntax_error::SyntaxError,
52 syntax_node::{ 52 syntax_node::{
53 Direction, GreenNode, NodeOrToken, SyntaxElement, SyntaxElementChildren, SyntaxNode, 53 SyntaxElement, SyntaxElementChildren, SyntaxNode, SyntaxNodeChildren, SyntaxToken,
54 SyntaxNodeChildren, SyntaxToken, SyntaxTreeBuilder, 54 SyntaxTreeBuilder,
55 }, 55 },
56}; 56};
57pub use parser::{SyntaxKind, T}; 57pub use parser::{SyntaxKind, T};
58pub use rowan::{SmolStr, SyntaxText, TextRange, TextSize, TokenAtOffset, WalkEvent}; 58pub use rowan::{
59 Direction, GreenNode, NodeOrToken, SmolStr, SyntaxText, TextRange, TextSize, TokenAtOffset,
60 WalkEvent,
61};
59 62
60/// `Parse` is the result of the parsing: a syntax tree and a collection of 63/// `Parse` is the result of the parsing: a syntax tree and a collection of
61/// errors. 64/// errors.
diff --git a/crates/syntax/src/parsing.rs b/crates/syntax/src/parsing.rs
index 68a39eb21..333bde54a 100644
--- a/crates/syntax/src/parsing.rs
+++ b/crates/syntax/src/parsing.rs
@@ -1,7 +1,7 @@
1//! Lexing, bridging to parser (which does the actual parsing) and 1//! Lexing, bridging to parser (which does the actual parsing) and
2//! incremental reparsing. 2//! incremental reparsing.
3 3
4mod lexer; 4pub(crate) mod lexer;
5mod text_token_source; 5mod text_token_source;
6mod text_tree_sink; 6mod text_tree_sink;
7mod reparsing; 7mod reparsing;
@@ -10,7 +10,7 @@ use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode};
10use text_token_source::TextTokenSource; 10use text_token_source::TextTokenSource;
11use text_tree_sink::TextTreeSink; 11use text_tree_sink::TextTreeSink;
12 12
13pub use lexer::*; 13pub(crate) use lexer::*;
14 14
15pub(crate) use self::reparsing::incremental_reparse; 15pub(crate) use self::reparsing::incremental_reparse;
16use parser::SyntaxKind; 16use parser::SyntaxKind;
diff --git a/crates/syntax/src/parsing/text_token_source.rs b/crates/syntax/src/parsing/text_token_source.rs
index df866dc2b..0614194a5 100644
--- a/crates/syntax/src/parsing/text_token_source.rs
+++ b/crates/syntax/src/parsing/text_token_source.rs
@@ -65,7 +65,7 @@ fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> parser::Tok
65 65
66impl<'t> TextTokenSource<'t> { 66impl<'t> TextTokenSource<'t> {
67 /// Generate input from tokens(expect comment and whitespace). 67 /// Generate input from tokens(expect comment and whitespace).
68 pub fn new(text: &'t str, raw_tokens: &'t [Token]) -> TextTokenSource<'t> { 68 pub(crate) fn new(text: &'t str, raw_tokens: &'t [Token]) -> TextTokenSource<'t> {
69 let token_offset_pairs: Vec<_> = raw_tokens 69 let token_offset_pairs: Vec<_> = raw_tokens
70 .iter() 70 .iter()
71 .filter_map({ 71 .filter_map({
diff --git a/crates/syntax/src/syntax_node.rs b/crates/syntax/src/syntax_node.rs
index b2abcbfbb..cc30138fa 100644
--- a/crates/syntax/src/syntax_node.rs
+++ b/crates/syntax/src/syntax_node.rs
@@ -10,9 +10,7 @@ use rowan::{GreenNodeBuilder, Language};
10 10
11use crate::{Parse, SmolStr, SyntaxError, SyntaxKind, TextSize}; 11use crate::{Parse, SmolStr, SyntaxError, SyntaxKind, TextSize};
12 12
13pub use rowan::GreenNode; 13pub(crate) use rowan::{GreenNode, GreenToken, NodeOrToken};
14
15pub(crate) use rowan::GreenToken;
16 14
17#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 15#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
18pub enum RustLanguage {} 16pub enum RustLanguage {}
@@ -34,8 +32,6 @@ pub type SyntaxElement = rowan::SyntaxElement<RustLanguage>;
34pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<RustLanguage>; 32pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<RustLanguage>;
35pub type SyntaxElementChildren = rowan::SyntaxElementChildren<RustLanguage>; 33pub type SyntaxElementChildren = rowan::SyntaxElementChildren<RustLanguage>;
36 34
37pub use rowan::{Direction, NodeOrToken};
38
39#[derive(Default)] 35#[derive(Default)]
40pub struct SyntaxTreeBuilder { 36pub struct SyntaxTreeBuilder {
41 errors: Vec<SyntaxError>, 37 errors: Vec<SyntaxError>,