Use AttrVec
in more places.
In some places we use `Vec<Attribute>` and some places we use `ThinVec<Attribute>` (a.k.a. `AttrVec`). This results in various points where we have to convert between `Vec` and `ThinVec`. This commit changes the places that use `Vec<Attribute>` to use `AttrVec`. A lot of this is mechanical and boring, but there are some interesting parts: - It adds a few new methods to `ThinVec`. - It implements `MapInPlace` for `ThinVec`, and introduces a macro to avoid the repetition of this trait for `Vec`, `SmallVec`, and `ThinVec`. Overall, it makes the code a little nicer, and has little effect on performance. But it is a precursor to removing `rustc_data_structures::thin_vec::ThinVec` and replacing it with `thin_vec::ThinVec`, which is implemented more efficiently.
This commit is contained in:
parent
650bff80a6
commit
619b8abaa6
49 changed files with 352 additions and 392 deletions
|
@ -62,7 +62,7 @@ pub fn parse_crate_from_file<'a>(input: &Path, sess: &'a ParseSess) -> PResult<'
|
|||
pub fn parse_crate_attrs_from_file<'a>(
|
||||
input: &Path,
|
||||
sess: &'a ParseSess,
|
||||
) -> PResult<'a, Vec<ast::Attribute>> {
|
||||
) -> PResult<'a, ast::AttrVec> {
|
||||
let mut parser = new_parser_from_file(sess, input, None);
|
||||
parser.parse_inner_attributes()
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ pub fn parse_crate_attrs_from_source_str(
|
|||
name: FileName,
|
||||
source: String,
|
||||
sess: &ParseSess,
|
||||
) -> PResult<'_, Vec<ast::Attribute>> {
|
||||
) -> PResult<'_, ast::AttrVec> {
|
||||
new_parser_from_source_str(sess, name, source).parse_inner_attributes()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue