Replace another lock with an append-only vec
This commit is contained in:
parent
4699632637
commit
7edd1d8799
@ -76,3 +76,19 @@ pub fn get(&self, i: usize) -> Option<T> {
|
|||||||
return self.vec.get(i);
|
return self.vec.get(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Copy + PartialEq> AppendOnlyVec<T> {
|
||||||
|
pub fn contains(&self, val: T) -> bool {
|
||||||
|
for i in 0.. {
|
||||||
|
match self.get(i) {
|
||||||
|
None => return false,
|
||||||
|
Some(v) => {
|
||||||
|
if val == v {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1947,7 +1947,7 @@ fn check_ident_token(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Don't lint `r#foo`.
|
// Don't lint `r#foo`.
|
||||||
if cx.sess().parse_sess.raw_identifier_spans.borrow().contains(&ident.span) {
|
if cx.sess().parse_sess.raw_identifier_spans.contains(ident.span) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ fn next_token(&mut self) -> (Token, bool) {
|
|||||||
if !sym.can_be_raw() {
|
if !sym.can_be_raw() {
|
||||||
self.sess.emit_err(errors::CannotBeRawIdent { span, ident: sym });
|
self.sess.emit_err(errors::CannotBeRawIdent { span, ident: sym });
|
||||||
}
|
}
|
||||||
self.sess.raw_identifier_spans.borrow_mut().push(span);
|
self.sess.raw_identifier_spans.push(span);
|
||||||
token::Ident(sym, true)
|
token::Ident(sym, true)
|
||||||
}
|
}
|
||||||
rustc_lexer::TokenKind::UnknownPrefix => {
|
rustc_lexer::TokenKind::UnknownPrefix => {
|
||||||
|
@ -194,7 +194,7 @@ pub struct ParseSess {
|
|||||||
pub edition: Edition,
|
pub edition: Edition,
|
||||||
/// Places where raw identifiers were used. This is used to avoid complaining about idents
|
/// Places where raw identifiers were used. This is used to avoid complaining about idents
|
||||||
/// clashing with keywords in new editions.
|
/// clashing with keywords in new editions.
|
||||||
pub raw_identifier_spans: Lock<Vec<Span>>,
|
pub raw_identifier_spans: AppendOnlyVec<Span>,
|
||||||
/// Places where identifiers that contain invalid Unicode codepoints but that look like they
|
/// Places where identifiers that contain invalid Unicode codepoints but that look like they
|
||||||
/// should be. Useful to avoid bad tokenization when encountering emoji. We group them to
|
/// should be. Useful to avoid bad tokenization when encountering emoji. We group them to
|
||||||
/// provide a single error per unique incorrect identifier.
|
/// provide a single error per unique incorrect identifier.
|
||||||
@ -247,7 +247,7 @@ pub fn with_span_handler(handler: Handler, source_map: Lrc<SourceMap>) -> Self {
|
|||||||
config: FxIndexSet::default(),
|
config: FxIndexSet::default(),
|
||||||
check_config: CrateCheckConfig::default(),
|
check_config: CrateCheckConfig::default(),
|
||||||
edition: ExpnId::root().expn_data().edition,
|
edition: ExpnId::root().expn_data().edition,
|
||||||
raw_identifier_spans: Lock::new(Vec::new()),
|
raw_identifier_spans: Default::default(),
|
||||||
bad_unicode_identifiers: Lock::new(Default::default()),
|
bad_unicode_identifiers: Lock::new(Default::default()),
|
||||||
source_map,
|
source_map,
|
||||||
buffered_lints: Lock::new(vec![]),
|
buffered_lints: Lock::new(vec![]),
|
||||||
|
Loading…
Reference in New Issue
Block a user