Skip to content

Commit b43cf84

Browse files
committed
Don't import Status/State enum variants into the global namespace.
Signed-off-by: Simon Wülker <[email protected]>
1 parent 6d0d9bb commit b43cf84

File tree

2 files changed

+42
-48
lines changed

2 files changed

+42
-48
lines changed

html5ever/src/tokenizer/char_ref/mod.rs

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ use mac::format_if;
1717
use std::borrow::Cow::Borrowed;
1818
use std::char::from_u32;
1919

20-
use self::State::*;
21-
pub(super) use self::Status::*;
22-
2320
//§ tokenizing-character-references
2421
pub(super) struct CharRef {
2522
/// The resulting character(s)
@@ -64,7 +61,7 @@ impl CharRefTokenizer {
6461
pub(super) fn new(is_consumed_in_attribute: bool) -> CharRefTokenizer {
6562
CharRefTokenizer {
6663
is_consumed_in_attribute,
67-
state: Begin,
64+
state: State::Begin,
6865
result: None,
6966
num: 0,
7067
num_too_big: false,
@@ -99,15 +96,15 @@ impl CharRefTokenizer {
9996
chars: ['\0', '\0'],
10097
num_chars: 0,
10198
});
102-
Done
99+
Status::Done
103100
}
104101

105102
fn finish_one(&mut self, c: char) -> Status {
106103
self.result = Some(CharRef {
107104
chars: [c, '\0'],
108105
num_chars: 1,
109106
});
110-
Done
107+
Status::Done
111108
}
112109
}
113110

@@ -118,17 +115,17 @@ impl CharRefTokenizer {
118115
input: &BufferQueue,
119116
) -> Status {
120117
if self.result.is_some() {
121-
return Done;
118+
return Status::Done;
122119
}
123120

124121
debug!("char ref tokenizer stepping in state {:?}", self.state);
125122
match self.state {
126-
Begin => self.do_begin(tokenizer, input),
127-
Octothorpe => self.do_octothorpe(tokenizer, input),
128-
Numeric(base) => self.do_numeric(tokenizer, input, base),
129-
NumericSemicolon => self.do_numeric_semicolon(tokenizer, input),
130-
Named => self.do_named(tokenizer, input),
131-
BogusName => self.do_bogus_name(tokenizer, input),
123+
State::Begin => self.do_begin(tokenizer, input),
124+
State::Octothorpe => self.do_octothorpe(tokenizer, input),
125+
State::Numeric(base) => self.do_numeric(tokenizer, input, base),
126+
State::NumericSemicolon => self.do_numeric_semicolon(tokenizer, input),
127+
State::Named => self.do_named(tokenizer, input),
128+
State::BogusName => self.do_bogus_name(tokenizer, input),
132129
}
133130
}
134131

@@ -139,17 +136,17 @@ impl CharRefTokenizer {
139136
) -> Status {
140137
match tokenizer.peek(input) {
141138
Some('a'..='z' | 'A'..='Z' | '0'..='9') => {
142-
self.state = Named;
139+
self.state = State::Named;
143140
self.name_buf_opt = Some(StrTendril::new());
144-
Progress
141+
Status::Progress
145142
},
146143
Some('#') => {
147144
tokenizer.discard_char(input);
148-
self.state = Octothorpe;
149-
Progress
145+
self.state = State::Octothorpe;
146+
Status::Progress
150147
},
151148
Some(_) => self.finish_none(),
152-
None => Stuck,
149+
None => Status::Stuck,
153150
}
154151
}
155152

@@ -162,15 +159,15 @@ impl CharRefTokenizer {
162159
Some(c @ ('x' | 'X')) => {
163160
tokenizer.discard_char(input);
164161
self.hex_marker = Some(c);
165-
self.state = Numeric(16);
162+
self.state = State::Numeric(16);
166163
},
167164
Some(_) => {
168165
self.hex_marker = None;
169-
self.state = Numeric(10);
166+
self.state = State::Numeric(10);
170167
},
171-
None => return Stuck,
168+
None => return Status::Stuck,
172169
}
173-
Progress
170+
Status::Progress
174171
}
175172

176173
fn do_numeric<Sink: TokenSink>(
@@ -180,7 +177,7 @@ impl CharRefTokenizer {
180177
base: u32,
181178
) -> Status {
182179
let Some(c) = tokenizer.peek(input) else {
183-
return Stuck;
180+
return Status::Stuck;
184181
};
185182
match c.to_digit(base) {
186183
Some(n) => {
@@ -193,14 +190,14 @@ impl CharRefTokenizer {
193190
}
194191
self.num = self.num.wrapping_add(n);
195192
self.seen_digit = true;
196-
Progress
193+
Status::Progress
197194
},
198195

199196
None if !self.seen_digit => self.unconsume_numeric(tokenizer, input),
200197

201198
None => {
202-
self.state = NumericSemicolon;
203-
Progress
199+
self.state = State::NumericSemicolon;
200+
Status::Progress
204201
},
205202
}
206203
}
@@ -215,7 +212,7 @@ impl CharRefTokenizer {
215212
Some(_) => tokenizer.emit_error(Borrowed(
216213
"Semicolon missing after numeric character reference",
217214
)),
218-
None => return Stuck,
215+
None => return Status::Stuck,
219216
};
220217
self.finish_numeric(tokenizer)
221218
}
@@ -277,7 +274,7 @@ impl CharRefTokenizer {
277274
// peek + discard skips over newline normalization, therefore making it easier to
278275
// un-consume
279276
let Some(c) = tokenizer.peek(input) else {
280-
return Stuck;
277+
return Status::Stuck;
281278
};
282279
tokenizer.discard_char(input);
283280
self.name_buf_mut().push_char(c);
@@ -290,7 +287,7 @@ impl CharRefTokenizer {
290287
self.name_len = self.name_buf().len();
291288
}
292289
// Otherwise we just have a prefix match.
293-
Progress
290+
Status::Progress
294291
},
295292

296293
// Can't continue the match.
@@ -324,8 +321,8 @@ impl CharRefTokenizer {
324321
Some(c) if c.is_ascii_alphanumeric() => {
325322
// Keep looking for a semicolon, to determine whether
326323
// we emit a parse error.
327-
self.state = BogusName;
328-
return Progress;
324+
self.state = State::BogusName;
325+
return Status::Progress;
329326
},
330327

331328
// Check length because &; is not a parse error.
@@ -390,7 +387,7 @@ impl CharRefTokenizer {
390387
chars: [from_u32(c1).unwrap(), from_u32(c2).unwrap()],
391388
num_chars: if c2 == 0 { 1 } else { 2 },
392389
});
393-
Done
390+
Status::Done
394391
}
395392
},
396393
}
@@ -404,12 +401,12 @@ impl CharRefTokenizer {
404401
// peek + discard skips over newline normalization, therefore making it easier to
405402
// un-consume
406403
let Some(c) = tokenizer.peek(input) else {
407-
return Stuck;
404+
return Status::Stuck;
408405
};
409406
tokenizer.discard_char(input);
410407
self.name_buf_mut().push_char(c);
411408
match c {
412-
_ if c.is_ascii_alphanumeric() => return Progress,
409+
_ if c.is_ascii_alphanumeric() => return Status::Progress,
413410
';' => self.emit_name_error(tokenizer),
414411
_ => (),
415412
}
@@ -424,23 +421,20 @@ impl CharRefTokenizer {
424421
) {
425422
while self.result.is_none() {
426423
match self.state {
427-
Begin => drop(self.finish_none()),
428-
429-
Numeric(_) if !self.seen_digit => drop(self.unconsume_numeric(tokenizer, input)),
430-
431-
Numeric(_) | NumericSemicolon => {
424+
State::Begin => drop(self.finish_none()),
425+
State::Numeric(_) if !self.seen_digit => {
426+
self.unconsume_numeric(tokenizer, input);
427+
},
428+
State::Numeric(_) | State::NumericSemicolon => {
432429
tokenizer.emit_error(Borrowed("EOF in numeric character reference"));
433430
self.finish_numeric(tokenizer);
434431
},
435-
436-
Named => drop(self.finish_named(tokenizer, input, None)),
437-
438-
BogusName => {
432+
State::Named => drop(self.finish_named(tokenizer, input, None)),
433+
State::BogusName => {
439434
self.unconsume_name(input);
440435
self.finish_none();
441436
},
442-
443-
Octothorpe => {
437+
State::Octothorpe => {
444438
input.push_front(StrTendril::from_slice("#"));
445439
tokenizer.emit_error(Borrowed("EOF after '#' in character reference"));
446440
self.finish_none();

html5ever/src/tokenizer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,13 +1666,13 @@ impl<Sink: TokenSink> Tokenizer<Sink> {
16661666
let outcome = tok.step(self, input);
16671667

16681668
let progress = match outcome {
1669-
char_ref::Done => {
1669+
char_ref::Status::Done => {
16701670
self.process_char_ref(tok.get_result());
16711671
return ProcessResult::Continue;
16721672
},
16731673

1674-
char_ref::Stuck => ProcessResult::Suspend,
1675-
char_ref::Progress => ProcessResult::Continue,
1674+
char_ref::Status::Stuck => ProcessResult::Suspend,
1675+
char_ref::Status::Progress => ProcessResult::Continue,
16761676
};
16771677

16781678
*self.char_ref_tokenizer.borrow_mut() = Some(tok);

0 commit comments

Comments
 (0)