diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-11-02 13:08:53 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-02 13:08:53 +0000 |
commit | 731b38fa3c1694648e6c8e60f61820f9783343eb (patch) | |
tree | b3f4e94e8eac9bb24296aacafacb100930bee59e /crates/syntax | |
parent | 6507877e7039d4517682a4fc232356662f509d81 (diff) | |
parent | b6101184537b1165cfdd5fc473e04ad4c5b7bffa (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.rs | 2 | ||||
-rw-r--r-- | crates/syntax/src/ast/generated.rs | 6 | ||||
-rw-r--r-- | crates/syntax/src/lib.rs | 11 | ||||
-rw-r--r-- | crates/syntax/src/parsing.rs | 4 | ||||
-rw-r--r-- | crates/syntax/src/parsing/text_token_source.rs | 2 | ||||
-rw-r--r-- | crates/syntax/src/syntax_node.rs | 6 |
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 | ||
18 | pub use self::{ | 18 | pub 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] |
3 | mod nodes; | 3 | pub(crate) mod nodes; |
4 | #[rustfmt::skip] | 4 | #[rustfmt::skip] |
5 | mod tokens; | 5 | pub(crate) mod tokens; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | AstNode, | 8 | AstNode, |
@@ -10,7 +10,7 @@ use crate::{ | |||
10 | SyntaxNode, | 10 | SyntaxNode, |
11 | }; | 11 | }; |
12 | 12 | ||
13 | pub use {nodes::*, tokens::*}; | 13 | pub(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 |
16 | impl AstNode for Stmt { | 16 | impl 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; | |||
46 | pub use crate::{ | 46 | pub 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 | }; |
57 | pub use parser::{SyntaxKind, T}; | 57 | pub use parser::{SyntaxKind, T}; |
58 | pub use rowan::{SmolStr, SyntaxText, TextRange, TextSize, TokenAtOffset, WalkEvent}; | 58 | pub 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 | ||
4 | mod lexer; | 4 | pub(crate) mod lexer; |
5 | mod text_token_source; | 5 | mod text_token_source; |
6 | mod text_tree_sink; | 6 | mod text_tree_sink; |
7 | mod reparsing; | 7 | mod reparsing; |
@@ -10,7 +10,7 @@ use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode}; | |||
10 | use text_token_source::TextTokenSource; | 10 | use text_token_source::TextTokenSource; |
11 | use text_tree_sink::TextTreeSink; | 11 | use text_tree_sink::TextTreeSink; |
12 | 12 | ||
13 | pub use lexer::*; | 13 | pub(crate) use lexer::*; |
14 | 14 | ||
15 | pub(crate) use self::reparsing::incremental_reparse; | 15 | pub(crate) use self::reparsing::incremental_reparse; |
16 | use parser::SyntaxKind; | 16 | use 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 | ||
66 | impl<'t> TextTokenSource<'t> { | 66 | impl<'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 | ||
11 | use crate::{Parse, SmolStr, SyntaxError, SyntaxKind, TextSize}; | 11 | use crate::{Parse, SmolStr, SyntaxError, SyntaxKind, TextSize}; |
12 | 12 | ||
13 | pub use rowan::GreenNode; | 13 | pub(crate) use rowan::{GreenNode, GreenToken, NodeOrToken}; |
14 | |||
15 | pub(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)] |
18 | pub enum RustLanguage {} | 16 | pub enum RustLanguage {} |
@@ -34,8 +32,6 @@ pub type SyntaxElement = rowan::SyntaxElement<RustLanguage>; | |||
34 | pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<RustLanguage>; | 32 | pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<RustLanguage>; |
35 | pub type SyntaxElementChildren = rowan::SyntaxElementChildren<RustLanguage>; | 33 | pub type SyntaxElementChildren = rowan::SyntaxElementChildren<RustLanguage>; |
36 | 34 | ||
37 | pub use rowan::{Direction, NodeOrToken}; | ||
38 | |||
39 | #[derive(Default)] | 35 | #[derive(Default)] |
40 | pub struct SyntaxTreeBuilder { | 36 | pub struct SyntaxTreeBuilder { |
41 | errors: Vec<SyntaxError>, | 37 | errors: Vec<SyntaxError>, |