1
Fork 0

Use ThinVec in various AST types.

This commit changes the sequence parsers to produce `ThinVec`, which
triggers numerous conversions.
This commit is contained in:
Nicholas Nethercote 2022-11-23 11:55:16 +11:00
parent 6a56c3a930
commit 4143b101f9
52 changed files with 355 additions and 292 deletions

View file

@ -14,7 +14,8 @@ use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_target::spec::PanicStrategy;
use smallvec::{smallvec, SmallVec};
use thin_vec::thin_vec;
use thin_vec::{thin_vec, ThinVec};
use tracing::debug;
use std::{iter, mem};
@ -299,7 +300,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
test_runner.span = sp;
let test_main_path_expr = ecx.expr_path(test_runner);
let call_test_main = ecx.expr_call(sp, test_main_path_expr, vec![mk_tests_slice(cx, sp)]);
let call_test_main = ecx.expr_call(sp, test_main_path_expr, thin_vec![mk_tests_slice(cx, sp)]);
let call_test_main = ecx.stmt_expr(call_test_main);
// extern crate test
@ -312,7 +313,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
let main_attr = ecx.attr_word(sym::rustc_main, sp);
// pub fn main() { ... }
let main_ret_ty = ecx.ty(sp, ast::TyKind::Tup(vec![]));
let main_ret_ty = ecx.ty(sp, ast::TyKind::Tup(ThinVec::new()));
// If no test runner is provided we need to import the test crate
let main_body = if cx.test_runner.is_none() {
@ -321,7 +322,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
ecx.block(sp, vec![call_test_main])
};
let decl = ecx.fn_decl(vec![], ast::FnRetTy::Ty(main_ret_ty));
let decl = ecx.fn_decl(ThinVec::new(), ast::FnRetTy::Ty(main_ret_ty));
let sig = ast::FnSig { decl, header: ast::FnHeader::default(), span: sp };
let defaultness = ast::Defaultness::Final;
let main = ast::ItemKind::Fn(Box::new(ast::Fn {