diff options
Diffstat (limited to 'src/libsyntax_expand/parse/tests.rs')
| -rw-r--r-- | src/libsyntax_expand/parse/tests.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/libsyntax_expand/parse/tests.rs b/src/libsyntax_expand/parse/tests.rs index 154ccb25621..833fda6a2eb 100644 --- a/src/libsyntax_expand/parse/tests.rs +++ b/src/libsyntax_expand/parse/tests.rs @@ -3,12 +3,11 @@ use crate::tests::{matches_codepattern, string_to_stream, with_error_checking_pa use errors::PResult; use rustc_parse::new_parser_from_source_str; use syntax::ast::{self, Name, PatKind}; -use syntax::attr::first_attr_value_str_by_name; use syntax::print::pprust::item_to_string; use syntax::ptr::P; use syntax::sess::ParseSess; use syntax::source_map::FilePathMapping; -use syntax::symbol::{kw, sym}; +use syntax::symbol::{kw, sym, Symbol}; use syntax::token::{self, Token}; use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree}; use syntax::visit; @@ -244,25 +243,20 @@ fn crlf_doc_comments() { let name_1 = FileName::Custom("crlf_source_1".to_string()); let source = "/// doc comment\r\nfn foo() {}".to_string(); let item = parse_item_from_source_str(name_1, source, &sess).unwrap().unwrap(); - let doc = first_attr_value_str_by_name(&item.attrs, sym::doc).unwrap(); + let doc = item.attrs.iter().filter_map(|at| at.doc_str()).next().unwrap(); assert_eq!(doc.as_str(), "/// doc comment"); let name_2 = FileName::Custom("crlf_source_2".to_string()); let source = "/// doc comment\r\n/// line 2\r\nfn foo() {}".to_string(); let item = parse_item_from_source_str(name_2, source, &sess).unwrap().unwrap(); - let docs = item - .attrs - .iter() - .filter(|a| a.has_name(sym::doc)) - .map(|a| a.value_str().unwrap().to_string()) - .collect::<Vec<_>>(); - let b: &[_] = &["/// doc comment".to_string(), "/// line 2".to_string()]; + let docs = item.attrs.iter().filter_map(|at| at.doc_str()).collect::<Vec<_>>(); + let b: &[_] = &[Symbol::intern("/// doc comment"), Symbol::intern("/// line 2")]; assert_eq!(&docs[..], b); let name_3 = FileName::Custom("clrf_source_3".to_string()); let source = "/** doc comment\r\n * with CRLF */\r\nfn foo() {}".to_string(); let item = parse_item_from_source_str(name_3, source, &sess).unwrap().unwrap(); - let doc = first_attr_value_str_by_name(&item.attrs, sym::doc).unwrap(); + let doc = item.attrs.iter().filter_map(|at| at.doc_str()).next().unwrap(); assert_eq!(doc.as_str(), "/** doc comment\n * with CRLF */"); }); } |
