diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-12-07 21:28:29 +0300 | 
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-12-28 12:33:18 +0300 | 
| commit | 3d57b8bcc0a6a0378a9cea0291bb76d44bec6ff8 (patch) | |
| tree | 6ed3c1b94ff90cfe6e72625d51824ed67e5e0112 /src/libsyntax_expand/parse/tests.rs | |
| parent | 3a087ad3a924be12343bb035bf9b63ed81f650bf (diff) | |
| download | rust-3d57b8bcc0a6a0378a9cea0291bb76d44bec6ff8.tar.gz rust-3d57b8bcc0a6a0378a9cea0291bb76d44bec6ff8.zip | |
doc comments: Less attribute mimicking
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 */"); }); } | 
