Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allocate HIR on an arena 4/4 #67032

Merged
merged 8 commits into from
Dec 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ use syntax_pos::Span;
use rustc_error_codes::*;

macro_rules! arena_vec {
() => (
&[]
);
($this:expr; $($x:expr),*) => (
$this.arena.alloc_from_iter(vec![$($x),*])
);
($this:expr; $($x:expr),*) => ({
let a = [$($x),*];
$this.arena.alloc_from_iter(std::array::IntoIter::new(a))
});
}

mod expr;
Expand Down Expand Up @@ -2018,7 +2016,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
FunctionRetTy::Ty(ty) => this.lower_ty(&ty, ImplTraitContext::disallowed()),
FunctionRetTy::Default(_) => this.arena.alloc(this.ty_tup(span, &[])),
};
let args = vec![GenericArg::Type(this.ty_tup(span, inputs))];
let args = smallvec![GenericArg::Type(this.ty_tup(span, inputs))];
let binding = hir::TypeBinding {
hir_id: this.next_id(),
ident: Ident::with_dummy_span(FN_OUTPUT_NAME),
Expand Down Expand Up @@ -3300,7 +3298,7 @@ fn body_ids(bodies: &BTreeMap<hir::BodyId, hir::Body<'hir>>) -> Vec<hir::BodyId>

/// Helper struct for delayed construction of GenericArgs.
struct GenericArgsCtor<'hir> {
args: Vec<hir::GenericArg<'hir>>,
args: SmallVec<[hir::GenericArg<'hir>; 1]>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put 4 here and in GenericsCtor. 1 seems too small

bindings: &'hir [hir::TypeBinding<'hir>],
parenthesized: bool,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/lowering/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

/// Helper struct for delayed construction of Generics.
pub(super) struct GenericsCtor<'hir> {
pub(super) params: Vec<hir::GenericParam<'hir>>,
pub(super) params: SmallVec<[hir::GenericParam<'hir>; 1]>,
where_clause: hir::WhereClause<'hir>,
span: Span,
}
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(arbitrary_self_types)]
#![feature(array_value_iter)]
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
Expand Down