Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed May 8, 2020
1 parent 7bf21d4 commit 32507d6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src/librustc_ast_pretty/pprust/tests.rs
Expand Up @@ -4,11 +4,12 @@ use rustc_ast::ast;
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| {
Expand All @@ -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) };
Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_expand/mut_visit/tests.rs
@@ -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) {
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_expand/parse/tests.rs
@@ -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};
Expand Down Expand Up @@ -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(),
])
Expand All @@ -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(),
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_expand/tokenstream/tests.rs
@@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/cfg/tests.rs
Expand Up @@ -3,7 +3,7 @@ use super::*;
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 {
Expand Down
1 change: 1 addition & 0 deletions src/test/ui-fulldeps/pprust-expr-roundtrip.rs
Expand Up @@ -32,6 +32,7 @@ use rustc_parse::new_parser_from_source_str;
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;
Expand Down

0 comments on commit 32507d6

Please sign in to comment.