Move edition outside the hygiene lock and avoid accessing it

This commit is contained in:
John Kåre Alsaker 2019-04-06 00:15:49 +02:00
parent 50a0defd5a
commit a1f2dceaeb
39 changed files with 155 additions and 139 deletions

View file

@ -1558,10 +1558,10 @@ mod tests {
use crate::feature_gate::UnstableFeatures;
use crate::parse::token;
use crate::diagnostics::plugin::ErrorMap;
use crate::with_globals;
use crate::with_default_globals;
use std::io;
use std::path::PathBuf;
use syntax_pos::{BytePos, Span, NO_EXPANSION};
use syntax_pos::{BytePos, Span, NO_EXPANSION, edition::Edition};
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
use rustc_data_structures::sync::Lock;
@ -1581,6 +1581,7 @@ mod tests {
raw_identifier_spans: Lock::new(Vec::new()),
registered_diagnostics: Lock::new(ErrorMap::new()),
buffered_lints: Lock::new(vec![]),
edition: Edition::from_session(),
ambiguous_block_expr_parse: Lock::new(FxHashMap::default()),
}
}
@ -1601,7 +1602,7 @@ mod tests {
#[test]
fn t1() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
let mut string_reader = setup(&sm,
@ -1649,7 +1650,7 @@ mod tests {
#[test]
fn doublecolonparsing() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(setup(&sm, &sh, "a b".to_string()),
@ -1659,7 +1660,7 @@ mod tests {
#[test]
fn dcparsing_2() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(setup(&sm, &sh, "a::b".to_string()),
@ -1669,7 +1670,7 @@ mod tests {
#[test]
fn dcparsing_3() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(setup(&sm, &sh, "a ::b".to_string()),
@ -1679,7 +1680,7 @@ mod tests {
#[test]
fn dcparsing_4() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(setup(&sm, &sh, "a:: b".to_string()),
@ -1689,7 +1690,7 @@ mod tests {
#[test]
fn character_a() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "'a'".to_string()).next_token().tok,
@ -1699,7 +1700,7 @@ mod tests {
#[test]
fn character_space() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "' '".to_string()).next_token().tok,
@ -1709,7 +1710,7 @@ mod tests {
#[test]
fn character_escaped() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "'\\n'".to_string()).next_token().tok,
@ -1719,7 +1720,7 @@ mod tests {
#[test]
fn lifetime_name() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "'abc".to_string()).next_token().tok,
@ -1729,7 +1730,7 @@ mod tests {
#[test]
fn raw_string() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string())
@ -1741,7 +1742,7 @@ mod tests {
#[test]
fn literal_suffixes() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
macro_rules! test {
@ -1787,7 +1788,7 @@ mod tests {
#[test]
fn nested_block_comments() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
let mut lexer = setup(&sm, &sh, "/* /* */ */'a'".to_string());
@ -1802,7 +1803,7 @@ mod tests {
#[test]
fn crlf_comments() {
with_globals(|| {
with_default_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
let mut lexer = setup(&sm, &sh, "// test\r\n/// test\r\n".to_string());