diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/derive.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/lib.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/mut_visit.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 31 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 27 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/source_map.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/std_inject.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/test.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/test_snippet.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/tokenstream.rs | 34 | ||||
| -rw-r--r-- | src/libsyntax/util/lev_distance.rs | 4 |
14 files changed, 87 insertions, 72 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 0a88d2f8824..489fac4f1ca 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -5,7 +5,7 @@ use crate::attr::HasAttrs; use crate::source_map::{SourceMap, Spanned, respan}; use crate::edition::Edition; use crate::ext::expand::{self, AstFragment, Invocation}; -use crate::ext::hygiene::{self, Mark, SyntaxContext, Transparency}; +use crate::ext::hygiene::{Mark, SyntaxContext, Transparency}; use crate::mut_visit::{self, MutVisitor}; use crate::parse::{self, parser, DirectoryOwnership}; use crate::parse::token; @@ -713,7 +713,7 @@ impl SyntaxExtension { } } - pub fn edition(&self) -> Edition { + pub fn edition(&self, default_edition: Edition) -> Edition { match *self { SyntaxExtension::NormalTT { edition, .. } | SyntaxExtension::DeclMacro { edition, .. } | @@ -725,7 +725,7 @@ impl SyntaxExtension { SyntaxExtension::IdentTT { .. } | SyntaxExtension::MultiDecorator(..) | SyntaxExtension::MultiModifier(..) | - SyntaxExtension::BuiltinDerive(..) => hygiene::default_edition(), + SyntaxExtension::BuiltinDerive(..) => default_edition, } } } @@ -734,6 +734,7 @@ pub type NamedSyntaxExtension = (Name, SyntaxExtension); pub trait Resolver { fn next_node_id(&mut self) -> ast::NodeId; + fn get_module_scope(&mut self, id: ast::NodeId) -> Mark; fn resolve_dollar_crates(&mut self, fragment: &AstFragment); @@ -768,6 +769,7 @@ pub struct DummyResolver; impl Resolver for DummyResolver { fn next_node_id(&mut self) -> ast::NodeId { ast::DUMMY_NODE_ID } + fn get_module_scope(&mut self, _id: ast::NodeId) -> Mark { Mark::root() } fn resolve_dollar_crates(&mut self, _fragment: &AstFragment) {} diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs index a24e09f127e..6e789c4c708 100644 --- a/src/libsyntax/ext/derive.rs +++ b/src/libsyntax/ext/derive.rs @@ -1,6 +1,6 @@ use crate::attr::HasAttrs; use crate::ast; -use crate::source_map::{hygiene, ExpnInfo, ExpnFormat}; +use crate::source_map::{ExpnInfo, ExpnFormat}; use crate::ext::base::ExtCtxt; use crate::ext::build::AstBuilder; use crate::parse::parser::PathStyle; @@ -64,7 +64,7 @@ pub fn add_derived_markers<T>(cx: &mut ExtCtxt<'_>, span: Span, traits: &[ast::P ].into()), allow_internal_unsafe: false, local_inner_macros: false, - edition: hygiene::default_edition(), + edition: cx.parse_sess.edition, }); let span = span.with_ctxt(cx.backtrace()); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 019ebc8566f..478ae4de82b 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -5,7 +5,7 @@ use crate::source_map::{ExpnInfo, MacroBang, MacroAttribute, dummy_spanned, resp use crate::config::StripUnconfigured; use crate::ext::base::*; use crate::ext::derive::{add_derived_markers, collect_derives}; -use crate::ext::hygiene::{self, Mark, SyntaxContext}; +use crate::ext::hygiene::{Mark, SyntaxContext}; use crate::ext::placeholders::{placeholder, PlaceholderExpander}; use crate::feature_gate::{self, Features, GateIssue, is_builtin_attr, emit_feature_err}; use crate::mut_visit::*; @@ -560,7 +560,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { allow_internal_unstable: None, allow_internal_unsafe: false, local_inner_macros: false, - edition: ext.edition(), + edition: ext.edition(self.cx.parse_sess.edition), }); match *ext { @@ -805,7 +805,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { allow_internal_unstable: allow_internal_unstable.clone(), allow_internal_unsafe: false, local_inner_macros: false, - edition: hygiene::default_edition(), + edition: self.cx.parse_sess.edition, }); let input: Vec<_> = mac.node.stream().into_trees().collect(); @@ -921,7 +921,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { allow_internal_unstable: None, allow_internal_unsafe: false, local_inner_macros: false, - edition: ext.edition(), + edition: ext.edition(self.cx.parse_sess.edition), }; match *ext { diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index db10ab7af5a..5eda975bc9e 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -29,6 +29,7 @@ use rustc_data_structures::sync::Lock; use rustc_data_structures::bit_set::GrowableBitSet; pub use rustc_data_structures::thin_vec::ThinVec; use ast::AttrId; +use syntax_pos::edition::Edition; // A variant of 'try!' that panics on an Err. This is used as a crutch on the // way towards a non-panic!-prone parser. It should be used for fatal parsing @@ -82,26 +83,32 @@ pub struct Globals { } impl Globals { - fn new() -> Globals { + fn new(edition: Edition) -> Globals { Globals { // We have no idea how many attributes their will be, so just // initiate the vectors with 0 bits. We'll grow them as necessary. used_attrs: Lock::new(GrowableBitSet::new_empty()), known_attrs: Lock::new(GrowableBitSet::new_empty()), - syntax_pos_globals: syntax_pos::Globals::new(), + syntax_pos_globals: syntax_pos::Globals::new(edition), } } } -pub fn with_globals<F, R>(f: F) -> R +pub fn with_globals<F, R>(edition: Edition, f: F) -> R where F: FnOnce() -> R { - let globals = Globals::new(); + let globals = Globals::new(edition); GLOBALS.set(&globals, || { syntax_pos::GLOBALS.set(&globals.syntax_pos_globals, f) }) } +pub fn with_default_globals<F, R>(f: F) -> R + where F: FnOnce() -> R +{ + with_globals(edition::DEFAULT_EDITION, f) +} + scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals); #[macro_use] diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index f587e63e12b..8fdd15a029f 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -1305,7 +1305,7 @@ mod tests { use crate::util::parser_testing::{string_to_crate, matches_codepattern}; use crate::print::pprust; use crate::mut_visit; - use crate::with_globals; + use crate::with_default_globals; use super::*; // this version doesn't care about getting comments or docstrings in. @@ -1343,7 +1343,7 @@ mod tests { // make sure idents get transformed everywhere #[test] fn ident_transformation () { - with_globals(|| { + with_default_globals(|| { let mut zz_visitor = ToZzIdentMutVisitor; let mut krate = string_to_crate( "#[a] mod b {fn c (d : e, f : g) {h!(i,j,k);l;m}}".to_string()); @@ -1358,7 +1358,7 @@ mod tests { // even inside macro defs.... #[test] fn ident_transformation_in_defs () { - with_globals(|| { + with_default_globals(|| { let mut zz_visitor = ToZzIdentMutVisitor; let mut krate = string_to_crate( "macro_rules! a {(b $c:expr $(d $e:token)f+ => \ diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 47da3ee6a6c..c97d8040761 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -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()); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 0611c1d9b42..d574626e6db 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -13,6 +13,7 @@ use crate::print::pprust::token_to_string; use errors::{Applicability, FatalError, Level, Handler, ColorConfig, Diagnostic, DiagnosticBuilder}; use rustc_data_structures::sync::{Lrc, Lock}; use syntax_pos::{Span, SourceFile, FileName, MultiSpan}; +use syntax_pos::edition::Edition; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; use std::borrow::Cow; @@ -38,6 +39,7 @@ pub struct ParseSess { pub span_diagnostic: Handler, pub unstable_features: UnstableFeatures, pub config: CrateConfig, + pub edition: Edition, pub missing_fragment_specifiers: Lock<FxHashSet<Span>>, /// Places where raw identifiers were used. This is used for feature-gating raw identifiers. pub raw_identifier_spans: Lock<Vec<Span>>, @@ -74,6 +76,7 @@ impl ParseSess { included_mod_stack: Lock::new(vec![]), source_map, buffered_lints: Lock::new(vec![]), + edition: Edition::from_session(), ambiguous_block_expr_parse: Lock::new(FxHashMap::default()), } } @@ -363,7 +366,7 @@ mod tests { use crate::tokenstream::{DelimSpan, TokenTree}; use crate::util::parser_testing::string_to_stream; use crate::util::parser_testing::{string_to_expr, string_to_item}; - use crate::with_globals; + use crate::with_default_globals; use syntax_pos::{Span, BytePos, Pos, NO_EXPANSION}; /// Parses an item. @@ -382,7 +385,7 @@ mod tests { #[should_panic] #[test] fn bad_path_expr_1() { - with_globals(|| { + with_default_globals(|| { string_to_expr("::abc::def::return".to_string()); }) } @@ -390,7 +393,7 @@ mod tests { // check the token-tree-ization of macros #[test] fn string_to_tts_macro () { - with_globals(|| { + with_default_globals(|| { use crate::symbol::sym; let tts: Vec<_> = @@ -447,7 +450,7 @@ mod tests { #[test] fn string_to_tts_1() { - with_globals(|| { + with_default_globals(|| { let tts = string_to_stream("fn a (b : i32) { b; }".to_string()); let expected = TokenStream::new(vec![ @@ -480,7 +483,7 @@ mod tests { } #[test] fn parse_use() { - with_globals(|| { + with_default_globals(|| { let use_s = "use foo::bar::baz;"; let vitem = string_to_item(use_s.to_string()).unwrap(); let vitem_s = item_to_string(&vitem); @@ -494,7 +497,7 @@ mod tests { } #[test] fn parse_extern_crate() { - with_globals(|| { + with_default_globals(|| { let ex_s = "extern crate foo;"; let vitem = string_to_item(ex_s.to_string()).unwrap(); let vitem_s = item_to_string(&vitem); @@ -531,7 +534,7 @@ mod tests { } #[test] fn span_of_self_arg_pat_idents_are_correct() { - with_globals(|| { + with_default_globals(|| { let srcs = ["impl z { fn a (&self, &myarg: i32) {} }", "impl z { fn a (&mut self, &myarg: i32) {} }", @@ -551,7 +554,7 @@ mod tests { } #[test] fn parse_exprs () { - with_globals(|| { + with_default_globals(|| { // just make sure that they parse.... string_to_expr("3 + 4".to_string()); string_to_expr("a::z.froob(b,&(987+3))".to_string()); @@ -559,7 +562,7 @@ mod tests { } #[test] fn attrs_fix_bug () { - with_globals(|| { + with_default_globals(|| { string_to_item("pub fn mk_file_writer(path: &Path, flags: &[FileFlag]) -> Result<Box<Writer>, String> { #[cfg(windows)] @@ -576,7 +579,7 @@ mod tests { } #[test] fn crlf_doc_comments() { - with_globals(|| { + with_default_globals(|| { use crate::symbol::sym; let sess = ParseSess::new(FilePathMapping::empty()); @@ -613,7 +616,7 @@ mod tests { new_parser_from_source_str(sess, name, source).parse_expr() } - with_globals(|| { + with_default_globals(|| { let sess = ParseSess::new(FilePathMapping::empty()); let expr = parse_expr_from_source_str(PathBuf::from("foo").into(), "foo!( fn main() { body } )".to_string(), &sess).unwrap(); @@ -637,7 +640,7 @@ mod tests { // See `recurse_into_file_modules` in the parser. #[test] fn out_of_line_mod() { - with_globals(|| { + with_default_globals(|| { let sess = ParseSess::new(FilePathMapping::empty()); let item = parse_item_from_source_str( PathBuf::from("foo").into(), diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index cd86d94f4b8..ac240359b56 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -3147,12 +3147,12 @@ mod tests { use crate::ast; use crate::source_map; - use crate::with_globals; + use crate::with_default_globals; use syntax_pos; #[test] fn test_fun_to_string() { - with_globals(|| { + with_default_globals(|| { let abba_ident = ast::Ident::from_str("abba"); let decl = ast::FnDecl { @@ -3180,7 +3180,7 @@ mod tests { #[test] fn test_variant_to_string() { - with_globals(|| { + with_default_globals(|| { let ident = ast::Ident::from_str("principal_skinner"); let var = source_map::respan(syntax_pos::DUMMY_SP, ast::Variant_ { diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs index 215618bd09c..8a210db9185 100644 --- a/src/libsyntax/source_map.rs +++ b/src/libsyntax/source_map.rs @@ -947,7 +947,7 @@ impl SourceMap { allow_internal_unstable, allow_internal_unsafe: false, local_inner_macros: false, - edition: hygiene::default_edition(), + edition: edition::Edition::from_session(), }); span.with_ctxt(SyntaxContext::empty().apply_mark(mark)) } diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 1be7986ad53..e01a3260d49 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -3,7 +3,7 @@ use crate::attr; use crate::edition::Edition; use crate::ext::hygiene::{Mark, SyntaxContext}; use crate::symbol::{Ident, Symbol, keywords, sym}; -use crate::source_map::{ExpnInfo, MacroAttribute, dummy_spanned, hygiene, respan}; +use crate::source_map::{ExpnInfo, MacroAttribute, dummy_spanned, respan}; use crate::ptr::P; use crate::tokenstream::TokenStream; @@ -14,7 +14,7 @@ use syntax_pos::{DUMMY_SP, Span}; /// Craft a span that will be ignored by the stability lint's /// call to source_map's `is_internal` check. /// The expanded code uses the unstable `#[prelude_import]` attribute. -fn ignored_span(sp: Span) -> Span { +fn ignored_span(sp: Span, edition: Edition) -> Span { let mark = Mark::fresh(Mark::root()); mark.set_expn_info(ExpnInfo { call_site: DUMMY_SP, @@ -25,7 +25,7 @@ fn ignored_span(sp: Span) -> Span { ].into()), allow_internal_unsafe: false, local_inner_macros: false, - edition: hygiene::default_edition(), + edition, }); sp.with_ctxt(SyntaxContext::empty().apply_mark(mark)) } @@ -94,7 +94,7 @@ pub fn maybe_inject_crates_ref( INJECTED_CRATE_NAME.with(|opt_name| opt_name.set(Some(name))); - let span = ignored_span(DUMMY_SP); + let span = ignored_span(DUMMY_SP, edition); krate.module.items.insert(0, P(ast::Item { attrs: vec![ast::Attribute { style: ast::AttrStyle::Outer, diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 3dc7aad9459..7cd83f3e495 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -291,7 +291,7 @@ fn generate_test_harness(sess: &ParseSess, ].into()), allow_internal_unsafe: false, local_inner_macros: false, - edition: hygiene::default_edition(), + edition: sess.edition, }); TestHarnessGenerator { diff --git a/src/libsyntax/test_snippet.rs b/src/libsyntax/test_snippet.rs index 3cf6699538d..107cbe70a23 100644 --- a/src/libsyntax/test_snippet.rs +++ b/src/libsyntax/test_snippet.rs @@ -1,5 +1,5 @@ use crate::source_map::{SourceMap, FilePathMapping}; -use crate::with_globals; +use crate::with_default_globals; use errors::Handler; use errors::emitter::EmitterWriter; @@ -39,7 +39,7 @@ impl<T: Write> Write for Shared<T> { } fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &str) { - with_globals(|| { + with_default_globals(|| { let output = Arc::new(Mutex::new(Vec::new())); let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty())); diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 3cb16c30a50..79efc6bf689 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -557,7 +557,7 @@ impl DelimSpan { mod tests { use super::*; use crate::syntax::ast::Ident; - use crate::with_globals; + use crate::with_default_globals; use crate::parse::token::Token; use crate::util::parser_testing::string_to_stream; use syntax_pos::{Span, BytePos, NO_EXPANSION}; @@ -572,7 +572,7 @@ mod tests { #[test] fn test_concat() { - with_globals(|| { + with_default_globals(|| { let test_res = string_to_ts("foo::bar::baz"); let test_fst = string_to_ts("foo::bar"); let test_snd = string_to_ts("::baz"); @@ -585,7 +585,7 @@ mod tests { #[test] fn test_to_from_bijection() { - with_globals(|| { + with_default_globals(|| { let test_start = string_to_ts("foo::bar(baz)"); let test_end = test_start.trees().collect(); assert_eq!(test_start, test_end) @@ -594,7 +594,7 @@ mod tests { #[test] fn test_eq_0() { - with_globals(|| { + with_default_globals(|| { let test_res = string_to_ts("foo"); let test_eqs = string_to_ts("foo"); assert_eq!(test_res, test_eqs) @@ -603,7 +603,7 @@ mod tests { #[test] fn test_eq_1() { - with_globals(|| { + with_default_globals(|| { let test_res = string_to_ts("::bar::baz"); let test_eqs = string_to_ts("::bar::baz"); assert_eq!(test_res, test_eqs) @@ -612,7 +612,7 @@ mod tests { #[test] fn test_eq_3() { - with_globals(|| { + with_default_globals(|| { let test_res = string_to_ts(""); let test_eqs = string_to_ts(""); assert_eq!(test_res, test_eqs) @@ -621,7 +621,7 @@ mod tests { #[test] fn test_diseq_0() { - with_globals(|| { + with_default_globals(|| { let test_res = string_to_ts("::bar::baz"); let test_eqs = string_to_ts("bar::baz"); assert_eq!(test_res == test_eqs, false) @@ -630,7 +630,7 @@ mod tests { #[test] fn test_diseq_1() { - with_globals(|| { + with_default_globals(|| { let test_res = string_to_ts("(bar,baz)"); let test_eqs = string_to_ts("bar,baz"); assert_eq!(test_res == test_eqs, false) @@ -639,7 +639,7 @@ mod tests { #[test] fn test_is_empty() { - with_globals(|| { + with_default_globals(|| { let test0: TokenStream = Vec::<TokenTree>::new().into_iter().collect(); let test1: TokenStream = TokenTree::Token(sp(0, 1), Token::Ident(Ident::from_str("a"), false)).into(); @@ -653,12 +653,14 @@ mod tests { #[test] fn test_dotdotdot() { - let mut builder = TokenStreamBuilder::new(); - builder.push(TokenTree::Token(sp(0, 1), Token::Dot).joint()); - builder.push(TokenTree::Token(sp(1, 2), Token::Dot).joint()); - builder.push(TokenTree::Token(sp(2, 3), Token::Dot)); - let stream = builder.build(); - assert!(stream.eq_unspanned(&string_to_ts("..."))); - assert_eq!(stream.trees().count(), 1); + with_default_globals(|| { + let mut builder = TokenStreamBuilder::new(); + builder.push(TokenTree::Token(sp(0, 1), Token::Dot).joint()); + builder.push(TokenTree::Token(sp(1, 2), Token::Dot).joint()); + builder.push(TokenTree::Token(sp(2, 3), Token::Dot)); + let stream = builder.build(); + assert!(stream.eq_unspanned(&string_to_ts("..."))); + assert_eq!(stream.trees().count(), 1); + }) } } diff --git a/src/libsyntax/util/lev_distance.rs b/src/libsyntax/util/lev_distance.rs index 2f150d22159..885b5a4f333 100644 --- a/src/libsyntax/util/lev_distance.rs +++ b/src/libsyntax/util/lev_distance.rs @@ -101,8 +101,8 @@ fn test_lev_distance() { #[test] fn test_find_best_match_for_name() { - use crate::with_globals; - with_globals(|| { + use crate::with_default_globals; + with_default_globals(|| { let input = vec![Symbol::intern("aaab"), Symbol::intern("aaabc")]; assert_eq!( find_best_match_for_name(input.iter(), "aaaa", None), |
