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
|
@ -298,8 +298,10 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
|
|||
let call_test_main = ecx.stmt_expr(call_test_main);
|
||||
|
||||
// extern crate test
|
||||
let test_extern_stmt =
|
||||
ecx.stmt_item(sp, ecx.item(sp, test_id, vec![], ast::ItemKind::ExternCrate(None)));
|
||||
let test_extern_stmt = ecx.stmt_item(
|
||||
sp,
|
||||
ecx.item(sp, test_id, ast::AttrVec::new(), ast::ItemKind::ExternCrate(None)),
|
||||
);
|
||||
|
||||
// #[rustc_main]
|
||||
let main_meta = ecx.meta_word(sp, sym::rustc_main);
|
||||
|
@ -333,7 +335,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
|
|||
|
||||
let main = P(ast::Item {
|
||||
ident: main_id,
|
||||
attrs: vec![main_attr],
|
||||
attrs: vec![main_attr].into(),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind: main,
|
||||
vis: ast::Visibility { span: sp, kind: ast::VisibilityKind::Public, tokens: None },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue