Skip to content

Commit 4d65d80

Browse files
CoAlloc: compiler/ uses <Global as Allocator>::CoAllocMeta
1 parent 0d21037 commit 4d65d80

File tree

7 files changed

+22
-10
lines changed

7 files changed

+22
-10
lines changed

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor};
1313
use crate::ty::{self, List, Ty, TyCtxt};
1414
use crate::ty::{AdtDef, InstanceDef, ScalarInt, UserTypeAnnotationIndex};
1515
use crate::ty::{GenericArg, InternalSubsts, SubstsRef};
16-
use core::alloc::GlobalCoAllocMeta;
1716

1817
use rustc_data_structures::captures::Captures;
1918
use rustc_errors::ErrorGuaranteed;
@@ -35,6 +34,7 @@ use rustc_span::{Span, DUMMY_SP};
3534

3635
use either::Either;
3736

37+
use std::alloc::{Allocator, Global};
3838
use std::borrow::Cow;
3939
use std::fmt::{self, Debug, Display, Formatter, Write};
4040
use std::ops::{ControlFlow, Index, IndexMut};
@@ -3082,7 +3082,10 @@ mod size_asserts {
30823082
use super::*;
30833083
use rustc_data_structures::static_assert_size;
30843084
// tidy-alphabetical-start
3085-
static_assert_size!(BasicBlockData<'_>, 144 + mem::size_of::<GlobalCoAllocMeta>());
3085+
static_assert_size!(
3086+
BasicBlockData<'_>,
3087+
144 + mem::size_of::<<Global as Allocator>::CoAllocMeta>()
3088+
);
30863089
static_assert_size!(LocalDecl<'_>, 40);
30873090
static_assert_size!(Statement<'_>, 32);
30883091
static_assert_size!(StatementKind<'_>, 16);

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//! The intention is that this file only contains datatype declarations, no code.
55
66
use super::{BasicBlock, Constant, Field, Local, SwitchTargets, UserTypeProjection};
7-
use core::alloc::GlobalCoAllocMeta;
87
use core::mem;
98

109
use crate::mir::coverage::{CodeRegion, CoverageKind};
@@ -26,6 +25,8 @@ use rustc_span::symbol::Symbol;
2625
use rustc_span::Span;
2726
use rustc_target::asm::InlineAsmRegOrRegClass;
2827

28+
use std::alloc::{Allocator, Global};
29+
2930
/// Represents the "flavors" of MIR.
3031
///
3132
/// All flavors of MIR use the same data structure, but there are some important differences. These
@@ -1253,6 +1254,6 @@ mod size_asserts {
12531254
static_assert_size!(Operand<'_>, 24);
12541255
static_assert_size!(Place<'_>, 16);
12551256
static_assert_size!(PlaceElem<'_>, 24);
1256-
static_assert_size!(Rvalue<'_>, 40 + mem::size_of::<GlobalCoAllocMeta>());
1257+
static_assert_size!(Rvalue<'_>, 40 + mem::size_of::<<Global as Allocator>::CoAllocMeta>());
12571258
// tidy-alphabetical-end
12581259
}

compiler/rustc_parse/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! The main parser interface.
22
3+
#![feature(allocator_api)]
34
#![feature(array_windows)]
45
#![feature(box_patterns)]
56
#![feature(global_co_alloc_meta)]

compiler/rustc_parse/src/parser/attr_wrapper.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor, TrailingToken};
2-
use core::alloc::GlobalCoAllocMeta;
32
use core::mem;
43
use rustc_ast::token::{self, Delimiter, Token, TokenKind};
54
use rustc_ast::tokenstream::{AttrTokenStream, AttributesData, ToAttrTokenStream};
@@ -10,6 +9,7 @@ use rustc_errors::PResult;
109
use rustc_session::parse::ParseSess;
1110
use rustc_span::{sym, Span, DUMMY_SP};
1211

12+
use std::alloc::{Allocator, Global};
1313
use std::ops::Range;
1414

1515
/// A wrapper type to ensure that the parser handles outer attributes correctly.
@@ -471,6 +471,9 @@ mod size_asserts {
471471
use rustc_data_structures::static_assert_size;
472472
// tidy-alphabetical-start
473473
static_assert_size!(AttrWrapper, 16);
474-
static_assert_size!(LazyAttrTokenStreamImpl, 120 + mem::size_of::<GlobalCoAllocMeta>());
474+
static_assert_size!(
475+
LazyAttrTokenStreamImpl,
476+
120 + mem::size_of::<<Global as Allocator>::CoAllocMeta>()
477+
);
475478
// tidy-alphabetical-end
476479
}

compiler/rustc_parse/src/parser/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ mod ty;
1212

1313
use crate::lexer::UnmatchedDelim;
1414
pub use attr_wrapper::AttrWrapper;
15-
use core::alloc::GlobalCoAllocMeta;
1615
pub use diagnostics::AttemptLocalParseRecovery;
1716
pub(crate) use item::FnParseMode;
1817
pub use pat::{CommaRecoveryMode, RecoverColon, RecoverComma};
@@ -37,6 +36,7 @@ use rustc_errors::{
3736
use rustc_session::parse::ParseSess;
3837
use rustc_span::source_map::{Span, DUMMY_SP};
3938
use rustc_span::symbol::{kw, sym, Ident, Symbol};
39+
use std::alloc::{Allocator, Global};
4040
use std::ops::Range;
4141
use std::{cmp, mem, slice};
4242
use thin_vec::ThinVec;
@@ -168,7 +168,7 @@ pub struct Parser<'a> {
168168
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
169169
rustc_data_structures::static_assert_size!(
170170
Parser<'_>,
171-
288 + 4 * mem::size_of::<GlobalCoAllocMeta>()
171+
288 + 4 * mem::size_of::<<Global as Allocator>::CoAllocMeta>()
172172
);
173173

174174
/// Stores span information about a closure.

compiler/rustc_trait_selection/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//! This API is completely unstable and subject to change.
1212
1313
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
14+
#![feature(allocator_api)]
1415
#![feature(associated_type_bounds)]
1516
#![feature(box_patterns)]
1617
#![feature(control_flow_enum)]

compiler/rustc_trait_selection/src/traits/fulfill.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::infer::{InferCtxt, TyOrConstInferVar};
2-
use core::alloc::GlobalCoAllocMeta;
32
use core::mem;
43
// use rustc_data_structures::fx::FxHashMap;
54
use rustc_data_structures::obligation_forest::ProcessResult;
@@ -13,6 +12,7 @@ use rustc_middle::ty::abstract_const::NotConstEvaluatable;
1312
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1413
use rustc_middle::ty::subst::SubstsRef;
1514
use rustc_middle::ty::{self, Binder, Const, TypeVisitableExt};
15+
use std::alloc::{Allocator, Global};
1616
use std::marker::PhantomData;
1717

1818
use super::const_evaluatable;
@@ -81,7 +81,10 @@ pub struct PendingPredicateObligation<'tcx> {
8181

8282
// `PendingPredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
8383
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
84-
static_assert_size!(PendingPredicateObligation<'_>, 72 + mem::size_of::<GlobalCoAllocMeta>());
84+
static_assert_size!(
85+
PendingPredicateObligation<'_>,
86+
72 + mem::size_of::<<Global as Allocator>::CoAllocMeta>()
87+
);
8588

8689
impl<'a, 'tcx> FulfillmentContext<'tcx> {
8790
/// Creates a new fulfillment context.

0 commit comments

Comments
 (0)