Skip to content

Commit cdcdd8a

Browse files
committed
(github) fix: deny warning on GitHub CI for cargo doc
1 parent 497657c commit cdcdd8a

File tree

7 files changed

+21
-19
lines changed

7 files changed

+21
-19
lines changed

.github/workflows/rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Rust nightly
1+
name: Rust
22

33
on:
44
push:
@@ -56,4 +56,4 @@ jobs:
5656
steps:
5757
- uses: actions/checkout@v4
5858
- name: Check doc
59-
run: cargo doc --document-private-items --all --verbose --release
59+
run: RUSTDOCFLAGS="-D warnings" cargo doc --document-private-items --all --verbose --release

src/lexer/lex_content.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ fn lex_char(
103103
end_current(state, lex_data, location);
104104
lex_data.set_end_line();
105105
}
106-
('.', Identifier(ident), _) if !ident.contains('.') && ident.is_number() => {
106+
('.', Ident(ident), _) if !ident.contains('.') && ident.is_number() => {
107107
ident.push('.');
108108
}
109-
('+' | '-', Identifier(ident), _)
109+
('+' | '-', Ident(ident), _)
110110
if !ident.contains('-') && !ident.contains('+') && ident.last_is_exp() =>
111111
{
112112
ident.push(ch);
@@ -133,7 +133,7 @@ fn lex_char(
133133
}
134134

135135
// Whitespace: end of everyone
136-
(_, Identifier(val), _) if ch.is_alphanumeric() || matches!(ch, '_' | '.' | '+' | '-') => {
136+
(_, Ident(val), _) if ch.is_alphanumeric() || matches!(ch, '_' | '.' | '+' | '-') => {
137137
// dbg!("here", &val, ch);
138138
val.push(ch);
139139
// dbg!("there", &val);
@@ -160,7 +160,9 @@ fn lex_char(
160160
/// Function that lexes a whole source file.
161161
///
162162
/// This function creates the automaton and the data to be modified by the other
163-
/// functions. Every character is parsed one by one by [`lex_char`].
163+
/// functions. Every character is parsed one by one, and the state is modified
164+
/// accordingly. When the state changes, the buffers of the state are empty into
165+
/// the data.
164166
#[inline]
165167
pub fn lex_file(content: &str, location: &mut Location) -> Res<Vec<Token>> {
166168
let mut lex_data = LexingData::default();

src/lexer/state/end_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn end_current(state: &mut LexingState, lex_data: &mut LexingData, location:
1616
match state {
1717
LexingState::Comment(_) | LexingState::Unset | LexingState::StartOfLine => return,
1818
LexingState::Symbols(symbol_state) => end_symbols(symbol_state, lex_data, location),
19-
LexingState::Identifier(ident) => end_ident(ident, lex_data, location),
19+
LexingState::Ident(ident) => end_ident(ident, lex_data, location),
2020
LexingState::Char(None) => {
2121
lex_data.push_err(
2222
location.to_error(

src/lexer/state/lex_state.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub enum LexingState {
3333
/// Reading a block comment.
3434
Comment(CommentState),
3535
/// Reading an identifier.
36-
Identifier(Ident),
36+
Ident(Ident),
3737
/// No specific state: just started parsing.
3838
#[default]
3939
StartOfLine,
@@ -57,12 +57,12 @@ impl LexingState {
5757

5858
/// Creates an identifier from a char.
5959
pub fn new_ident(&mut self, ch: char) {
60-
*self = Self::Identifier(Ident::from(ch.to_string()));
60+
*self = Self::Ident(Ident::from(ch.to_string()));
6161
}
6262

6363
/// Creates an identifier from a string.
6464
pub fn new_ident_str(&mut self, str: String) {
65-
*self = Self::Identifier(Ident::from(str));
65+
*self = Self::Ident(Ident::from(str));
6666
}
6767

6868
/// Gets a user-readable representation for displaying user errors.
@@ -71,7 +71,7 @@ impl LexingState {
7171
Self::StartOfLine => "start of line",
7272
Self::Unset => "no context",
7373
Self::Symbols(_) => "symbols",
74-
Self::Identifier(_) => "identifier",
74+
Self::Ident(_) => "identifier",
7575
Self::Char(_) => "char",
7676
Self::Str(_) => "string",
7777
Self::Comment(_) => "comment",

src/lexer/types/keywords.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use core::fmt;
66
macro_rules! impl_keywords {
77
($($pascal:ident $type:ident $str:expr ,)*) => {
88

9-
/// Keyword type
9+
/// Keywords of the language
1010
///
11-
/// Type to store and manage the C keywords.
11+
/// See [CppReference](https://en.cppreference.com/w/c/keyword) for the list of C keywords.
1212
#[derive(Debug, PartialEq, Eq)]
1313
pub enum Keyword {
1414
$($pascal,)*

src/lexer/types/tokens.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl Token {
128128
lex_data.push_err(location.to_owned().into_past_with_length(len).to_warning(format!("Underscore operators are deprecated since C23. Consider using the new keyword: {new_keyword}")));
129129
TokenValue::Keyword(keyword)
130130
}
131-
TryKeyword::Failure => TokenValue::Identifier(value),
131+
TryKeyword::Failure => TokenValue::Ident(value),
132132
};
133133
Self {
134134
location: location.to_owned().into_past_with_length(len),
@@ -213,12 +213,12 @@ pub enum TokenValue {
213213
/// # Examples
214214
///
215215
/// `_Hello` and `STRUCT_NAME`.
216-
Identifier(String),
216+
Ident(String),
217217
/// Keywords
218218
///
219219
/// # Rules
220220
///
221-
/// For the list of keywords, see [`Keyword`].
221+
/// See [CppReference](https://en.cppreference.com/w/c/keyword) for the list of C keywords.
222222
///
223223
/// # Examples
224224
///
@@ -249,7 +249,7 @@ pub enum TokenValue {
249249
///
250250
/// # Rules
251251
///
252-
/// See [`Symbol`] for the list of valid symbols.
252+
/// - All characters that don't fit in the other types.
253253
///
254254
/// # Examples
255255
///
@@ -266,7 +266,7 @@ impl fmt::Display for TokenValue {
266266
Self::Keyword(arg0) => write!(f, "Keyword({arg0})"),
267267
Self::Number(arg0) => write!(f, "{arg0}"),
268268
Self::Symbol(arg0) => write!(f, "{arg0:?}"),
269-
Self::Identifier(arg0) => write!(f, "Ident({arg0})"),
269+
Self::Ident(arg0) => write!(f, "Ident({arg0})"),
270270
Self::Str(arg0) => write!(f, "\"{arg0}\""),
271271
}
272272
}

src/parser/parse_content.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn parse_block(
5959
TokenValue::Char(ch) => {
6060
handle_literal(current, Literal::Char(ch), location, p_state, tokens)
6161
}
62-
TokenValue::Identifier(val) => handle_literal(
62+
TokenValue::Ident(val) => handle_literal(
6363
current,
6464
Literal::Variable(Variable::from(val)),
6565
location,

0 commit comments

Comments
 (0)