Skip to content

Commit 6a54c48

Browse files
CoAlloc: compiler/ uses <Global as Allocator>::CoAllocMeta
1 parent b959940 commit 6a54c48

File tree

7 files changed

+22
-10
lines changed

7 files changed

+22
-10
lines changed

compiler/rustc_middle/src/mir/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use crate::ty::visit::{TypeVisitable, TypeVisitor};
1313
use crate::ty::{self, ir, DefIdTree, 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};
@@ -3078,7 +3078,10 @@ mod size_asserts {
30783078
use super::*;
30793079
use rustc_data_structures::static_assert_size;
30803080
// tidy-alphabetical-start
3081-
static_assert_size!(BasicBlockData<'_>, 144 + mem::size_of::<GlobalCoAllocMeta>());
3081+
static_assert_size!(
3082+
BasicBlockData<'_>,
3083+
144 + mem::size_of::<<Global as Allocator>::CoAllocMeta>()
3084+
);
30823085
static_assert_size!(LocalDecl<'_>, 56);
30833086
static_assert_size!(Statement<'_>, 32);
30843087
static_assert_size!(StatementKind<'_>, 16);

compiler/rustc_middle/src/mir/syntax.rs

+3-2
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
@@ -1286,6 +1287,6 @@ mod size_asserts {
12861287
static_assert_size!(Operand<'_>, 24);
12871288
static_assert_size!(Place<'_>, 16);
12881289
static_assert_size!(PlaceElem<'_>, 24);
1289-
static_assert_size!(Rvalue<'_>, 40 + mem::size_of::<GlobalCoAllocMeta>());
1290+
static_assert_size!(Rvalue<'_>, 40 + mem::size_of::<<Global as Allocator>::CoAllocMeta>());
12901291
// tidy-alphabetical-end
12911292
}

compiler/rustc_parse/src/lib.rs

+1
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

+5-2
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ mod ty;
1212

1313
use crate::lexer::UnmatchedBrace;
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};
@@ -38,6 +37,7 @@ use rustc_session::parse::ParseSess;
3837
use rustc_span::source_map::{Span, DUMMY_SP};
3938
use rustc_span::symbol::{kw, sym, Ident, Symbol};
4039

40+
use std::alloc::{Allocator, Global};
4141
use std::ops::Range;
4242
use std::{cmp, mem, slice};
4343

@@ -170,7 +170,7 @@ pub struct Parser<'a> {
170170
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
171171
rustc_data_structures::static_assert_size!(
172172
Parser<'_>,
173-
312 + 4 * mem::size_of::<GlobalCoAllocMeta>()
173+
312 + 4 * mem::size_of::<<Global as Allocator>::CoAllocMeta>()
174174
);
175175

176176
/// Stores span information about a closure.

compiler/rustc_trait_selection/src/lib.rs

+1
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

+5-2
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;
@@ -12,6 +11,7 @@ use rustc_middle::ty::abstract_const::NotConstEvaluatable;
1211
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1312
use rustc_middle::ty::subst::SubstsRef;
1413
use rustc_middle::ty::{self, Binder, Const, TypeVisitable};
14+
use std::alloc::{Allocator, Global};
1515
use std::marker::PhantomData;
1616

1717
use super::const_evaluatable;
@@ -80,7 +80,10 @@ pub struct PendingPredicateObligation<'tcx> {
8080

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

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

0 commit comments

Comments
 (0)