Fix tests

This commit is contained in:
Camille GILLOT 2020-04-25 21:13:56 +02:00
parent 7bf21d4838
commit 32507d6910
6 changed files with 15 additions and 13 deletions

View File

@ -4,11 +4,12 @@
use rustc_ast::with_default_globals;
use rustc_span;
use rustc_span::source_map::respan;
use rustc_span::symbol::Ident;
fn fun_to_string(
decl: &ast::FnDecl,
header: ast::FnHeader,
name: ast::Ident,
name: Ident,
generics: &ast::Generics,
) -> String {
to_string(|s| {
@ -26,7 +27,7 @@ fn variant_to_string(var: &ast::Variant) -> String {
#[test]
fn test_fun_to_string() {
with_default_globals(|| {
let abba_ident = ast::Ident::from_str("abba");
let abba_ident = Ident::from_str("abba");
let decl =
ast::FnDecl { inputs: Vec::new(), output: ast::FnRetTy::Default(rustc_span::DUMMY_SP) };
@ -41,7 +42,7 @@ fn test_fun_to_string() {
#[test]
fn test_variant_to_string() {
with_default_globals(|| {
let ident = ast::Ident::from_str("principal_skinner");
let ident = Ident::from_str("principal_skinner");
let var = ast::Variant {
ident,

View File

@ -1,9 +1,10 @@
use crate::tests::{matches_codepattern, string_to_crate};
use rustc_ast::ast::{self, Ident};
use rustc_ast::ast;
use rustc_ast::mut_visit::{self, MutVisitor};
use rustc_ast::with_default_globals;
use rustc_ast_pretty::pprust;
use rustc_span::symbol::Ident;
// This version doesn't care about getting comments or doc-strings in.
fn fake_print_crate(s: &mut pprust::State<'_>, krate: &ast::Crate) {
@ -14,7 +15,7 @@ fn fake_print_crate(s: &mut pprust::State<'_>, krate: &ast::Crate) {
struct ToZzIdentMutVisitor;
impl MutVisitor for ToZzIdentMutVisitor {
fn visit_ident(&mut self, ident: &mut ast::Ident) {
fn visit_ident(&mut self, ident: &mut Ident) {
*ident = Ident::from_str("zz");
}
fn visit_mac(&mut self, mac: &mut ast::MacCall) {

View File

@ -1,6 +1,6 @@
use crate::tests::{matches_codepattern, string_to_stream, with_error_checking_parse};
use rustc_ast::ast::{self, Name, PatKind};
use rustc_ast::ast::{self, PatKind};
use rustc_ast::ptr::P;
use rustc_ast::token::{self, Token};
use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
@ -100,12 +100,12 @@ fn string_to_tts_1() {
let expected = TokenStream::new(vec![
TokenTree::token(token::Ident(kw::Fn, false), sp(0, 2)).into(),
TokenTree::token(token::Ident(Name::intern("a"), false), sp(3, 4)).into(),
TokenTree::token(token::Ident(Symbol::intern("a"), false), sp(3, 4)).into(),
TokenTree::Delimited(
DelimSpan::from_pair(sp(5, 6), sp(13, 14)),
token::DelimToken::Paren,
TokenStream::new(vec![
TokenTree::token(token::Ident(Name::intern("b"), false), sp(6, 7)).into(),
TokenTree::token(token::Ident(Symbol::intern("b"), false), sp(6, 7)).into(),
TokenTree::token(token::Colon, sp(8, 9)).into(),
TokenTree::token(token::Ident(sym::i32, false), sp(10, 13)).into(),
])
@ -116,7 +116,7 @@ fn string_to_tts_1() {
DelimSpan::from_pair(sp(15, 16), sp(20, 21)),
token::DelimToken::Brace,
TokenStream::new(vec![
TokenTree::token(token::Ident(Name::intern("b"), false), sp(17, 18)).into(),
TokenTree::token(token::Ident(Symbol::intern("b"), false), sp(17, 18)).into(),
TokenTree::token(token::Semi, sp(18, 19)).into(),
])
.into(),

View File

@ -1,10 +1,9 @@
use crate::tests::string_to_stream;
use rustc_ast::ast::Name;
use rustc_ast::token;
use rustc_ast::tokenstream::{TokenStream, TokenStreamBuilder, TokenTree};
use rustc_ast::with_default_globals;
use rustc_span::{BytePos, Span};
use rustc_span::{BytePos, Span, Symbol};
use smallvec::smallvec;
fn string_to_ts(string: &str) -> TokenStream {
@ -87,7 +86,7 @@ fn test_is_empty() {
with_default_globals(|| {
let test0: TokenStream = Vec::<TokenTree>::new().into_iter().collect();
let test1: TokenStream =
TokenTree::token(token::Ident(Name::intern("a"), false), sp(0, 1)).into();
TokenTree::token(token::Ident(Symbol::intern("a"), false), sp(0, 1)).into();
let test2 = string_to_ts("foo(bar::baz)");
assert_eq!(test0.is_empty(), true);

View File

@ -3,7 +3,7 @@
use rustc_ast::ast::*;
use rustc_ast::attr;
use rustc_ast::with_default_globals;
use rustc_span::symbol::Symbol;
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::DUMMY_SP;
fn word_cfg(s: &str) -> Cfg {

View File

@ -32,6 +32,7 @@
use rustc_session::parse::ParseSess;
use rustc_span::source_map::{Spanned, DUMMY_SP, FileName};
use rustc_span::source_map::FilePathMapping;
use rustc_span::symbol::Ident;
use rustc_ast::ast::*;
use rustc_ast::mut_visit::{self, MutVisitor, visit_clobber};
use rustc_ast::ptr::P;