Skip to content

Commit af6ca1e

Browse files
authored
turn on clippy::wildcard_imports (#692)
cc @Xanewok for context: #680 (comment) This works well on `use foo::*` and allows automatic fixing/replacing. But it doesn't work on `pub use foo::*`. I looked into doing that manually, but realized that for public re-exports, it is actually much more work to do/maintain than the readability benefits it offers, especially when items have different visibility, and there are generated items. Taking `non_terminals/mod.rs`, I think the below list is a lot of noise, and requires manual work every time we add/remove something. I suggest allowing `pub use foo::*` for these reasons, and use it as appropriate. ```rust pub use enum_::{EnumItem, EnumVariant}; pub use field::{Field, FieldDelimiters, FieldKind, FieldsErrorRecovery}; pub use precedence::{PrecedenceExpression, PrecedenceItem, PrecedenceOperator, PrimaryExpression}; pub use repeated::RepeatedItem; pub use separated::SeparatedItem; pub use struct_::StructItem; pub(crate) use enum_::{SpannedEnumItem, SpannedEnumVariant}; pub(crate) use field::{ SpannedField, SpannedFieldDelimiters, SpannedFieldKind, SpannedFieldsErrorRecovery, }; pub(crate) use precedence::{ SpannedPrecedenceExpression, SpannedPrecedenceItem, SpannedPrecedenceOperator, SpannedPrimaryExpression, }; pub(crate) use repeated::SpannedRepeatedItem; pub(crate) use separated::SpannedSeparatedItem; pub(crate) use struct_::SpannedStructItem; ```
1 parent e37d4b5 commit af6ca1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+163
-93
lines changed

.cargo/config.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ lto = true
77

88
[build]
99
rustflags = [
10+
# rustc additional warnings:
1011
"--warn",
1112
"unused_crate_dependencies",
13+
# clippy additional warnings:
14+
"--warn",
15+
"clippy::wildcard_imports",
1216
# This is a list of allowed Clippy rules for the purposes of gradual migration.
1317
# See https://github.com/NomicFoundation/slang/pull/626
1418
"-A",

crates/codegen/grammar/src/grammar.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use std::collections::{BTreeSet, HashMap};
22

33
use semver::Version;
44

5-
use super::*;
5+
use super::{
6+
GrammarVisitor, ParserDefinitionRef, PrecedenceParserDefinitionRef, ScannerDefinitionRef,
7+
TriviaParserDefinitionRef, Visitable,
8+
};
69

710
pub struct Grammar {
811
pub name: String,

crates/codegen/grammar/src/parser_definition.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use std::fmt::Debug;
22
use std::rc::Rc;
33

4-
use super::*;
4+
use super::{
5+
GrammarVisitor, PrecedenceParserDefinitionRef, ScannerDefinitionRef, VersionQualityRange,
6+
Visitable,
7+
};
58

69
pub trait ParserDefinition: Debug {
710
fn name(&self) -> &'static str;

crates/codegen/grammar/src/precedence_parser_definition.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use std::fmt::Debug;
22
use std::rc::Rc;
33

4-
use super::*;
4+
use super::{
5+
GrammarVisitor, ParserDefinitionNode, ParserDefinitionRef, VersionQualityRange, Visitable,
6+
};
57

68
pub trait PrecedenceParserDefinition: Debug {
79
fn name(&self) -> &'static str;

crates/codegen/grammar/src/scanner_definition.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::Debug;
22
use std::rc::Rc;
33

4-
use super::*;
4+
use super::{GrammarVisitor, VersionQualityRange, Visitable};
55

66
pub trait ScannerDefinition: Debug {
77
fn name(&self) -> &'static str;

crates/codegen/grammar/src/visitor.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use super::*;
1+
use super::{
2+
Grammar, ParserDefinitionNode, ParserDefinitionRef, PrecedenceParserDefinitionNode,
3+
PrecedenceParserDefinitionRef, ScannerDefinitionNode, ScannerDefinitionRef,
4+
TriviaParserDefinitionRef,
5+
};
26

37
pub trait GrammarVisitor {
48
fn grammar_enter(&mut self, _grammar: &Grammar) {}

crates/codegen/parser/runtime/src/cst.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ use std::rc::Rc;
22

33
use serde::Serialize;
44

5-
use super::{cursor::Cursor, kinds::*, text_index::TextIndex};
5+
use super::{
6+
cursor::Cursor,
7+
kinds::{RuleKind, TokenKind},
8+
text_index::TextIndex,
9+
};
610

711
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
812
pub struct RuleNode {

crates/codegen/parser/runtime/src/cursor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::rc::Rc;
44

55
use super::{
66
cst::{Node, RuleNode},
7-
kinds::*,
7+
kinds::{RuleKind, TokenKind},
88
text_index::{TextIndex, TextRange},
99
};
1010

crates/codegen/parser/runtime/src/kinds.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#[cfg(feature = "slang_napi_interfaces")]
2-
use {napi::bindgen_prelude::*, napi_derive::napi};
2+
use {
3+
napi::bindgen_prelude::{FromNapiValue, ToNapiValue},
4+
napi_derive::napi,
5+
};
36

47
#[derive(
58
Debug,

crates/codegen/parser/runtime/src/napi/napi_cst.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
use std::rc::Rc;
22

33
use {
4-
napi::{bindgen_prelude::*, JsObject, NapiValue},
4+
napi::{
5+
bindgen_prelude::{Env, FromNapiValue, ToNapiValue},
6+
JsObject, NapiValue,
7+
},
58
napi_derive::napi,
69
};
710

8-
use super::*;
11+
use super::{
12+
napi_cursor, napi_text_index, RuleKind, RustNode, RustRuleNode, RustTextIndex, RustTokenNode,
13+
TokenKind,
14+
};
915
use napi_cursor::Cursor;
1016
use napi_text_index::TextIndex;
1117

crates/codegen/parser/runtime/src/napi/napi_cursor.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use {
2-
napi::{bindgen_prelude::*, JsObject},
2+
napi::{bindgen_prelude::Env, JsObject},
33
napi_derive::napi,
44
};
55

6-
use super::*;
7-
use napi_cst::*;
8-
use napi_text_index::*;
6+
use super::{napi_cst, napi_text_index, RuleKind, RustCursor, TokenKind};
7+
use napi_cst::ToJS;
8+
use napi_text_index::{TextIndex, TextRange};
99

1010
#[napi(namespace = "cursor")]
1111
pub struct Cursor(Box<RustCursor>);

crates/codegen/parser/runtime/src/napi/napi_parse_error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use napi_derive::napi;
22

3-
use super::*;
4-
use napi_text_index::*;
3+
use super::{napi_text_index, RustParseError};
4+
use napi_text_index::TextRange;
55

66
#[napi(namespace = "parse_error")]
77
#[derive(PartialEq, Clone)]

crates/codegen/parser/runtime/src/napi/napi_parse_output.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use {napi::bindgen_prelude::*, napi_derive::napi};
1+
use {napi::bindgen_prelude::Env, napi_derive::napi};
22

3-
use super::*;
4-
use napi_cst::*;
3+
use super::{napi_cst, napi_cursor, napi_parse_error, RustParseOutput};
4+
use napi_cst::ToJS;
55

66
#[napi(namespace = "parse_output")]
77
pub struct ParseOutput(RustParseOutput);

crates/codegen/parser/runtime/src/napi/napi_text_index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use napi_derive::napi;
22

3-
use super::*;
3+
use super::{RustTextIndex, RustTextRange};
44

55
#[napi(object, namespace = "text_index")]
66
#[derive(Copy, Clone)]
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
pub mod choice_helper;
2-
pub mod context;
3-
pub mod optional_helper;
4-
pub mod parser_function;
5-
pub mod parser_result;
6-
pub mod precedence_helper;
7-
pub mod recovery;
8-
pub mod repetition_helper;
9-
pub mod separated_helper;
10-
pub mod sequence_helper;
1+
mod choice_helper;
2+
mod context;
3+
mod optional_helper;
4+
mod parser_function;
5+
mod parser_result;
6+
mod precedence_helper;
7+
mod recovery;
8+
mod repetition_helper;
9+
mod separated_helper;
10+
mod sequence_helper;
1111

1212
#[macro_use]
1313
pub mod scanner_macros;
@@ -18,7 +18,7 @@ pub use optional_helper::OptionalHelper;
1818
pub use parser_function::ParserFunction;
1919
pub use parser_result::ParserResult;
2020
pub use precedence_helper::PrecedenceHelper;
21-
pub use recovery::*;
21+
pub use recovery::RecoverFromNoMatch;
2222
pub use repetition_helper::{OneOrMoreHelper, ZeroOrMoreHelper};
2323
pub use separated_helper::SeparatedHelper;
2424
pub use sequence_helper::SequenceHelper;

crates/codegen/parser/runtime/src/support/parser_function.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use super::{
66
text_index::TextIndex,
77
},
88
context::ParserContext,
9-
parser_result::*,
9+
parser_result::{IncompleteMatch, Match, ParserResult, SkippedUntil},
1010
};
1111

1212
pub trait ParserFunction<L>

crates/codegen/parser/runtime/src/support/parser_result.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use super::super::{cst, kinds::*, text_index::TextIndex};
1+
use super::super::{
2+
cst,
3+
kinds::{RuleKind, TokenKind},
4+
text_index::TextIndex,
5+
};
26

37
#[derive(PartialEq, Eq, Clone, Debug)]
48
pub enum ParserResult {

crates/codegen/parser/runtime/src/templates/kinds.rs.jinja2

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub trait IsLexicalContext {
9292

9393
#[allow(non_snake_case)]
9494
pub mod LexicalContextType {
95-
use super::*;
95+
use super::{IsLexicalContext, LexicalContext};
9696

9797
{%- for context in code.scanner_contexts %}
9898
pub struct {{ context.name }} {}

crates/codegen/parser/runtime/src/templates/language.rs.jinja2

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use super::{
77
kinds::{RuleKind, TokenKind, ProductionKind, IsLexicalContext, LexicalContextType},
88
lexer::Lexer,
99
parse_output::ParseOutput,
10-
support::*,
10+
support::{
11+
ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult,
12+
PrecedenceHelper, RecoverFromNoMatch, SeparatedHelper, SequenceHelper, ZeroOrMoreHelper,
13+
},
1114
};
1215

1316
pub use super::kinds::LexicalContext;

crates/solidity/outputs/cargo/crate/src/generated/cst.rs

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/cursor.rs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/kinds.rs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/language.rs

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/napi/napi_cst.rs

+8-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/napi/napi_cursor.rs

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/napi/napi_parse_error.rs

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/napi/napi_parse_output.rs

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/napi/napi_text_index.rs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/support/mod.rs

+11-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/support/parser_function.rs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)