Skip to content

Commit 2a34428

Browse files
Make THIR data structures public
1 parent 61365c0 commit 2a34428

File tree

5 files changed

+62
-62
lines changed

5 files changed

+62
-62
lines changed

Diff for: compiler/rustc_mir_build/src/build/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::build;
22
use crate::build::scope::DropKind;
3-
use crate::thir::cx::build_thir;
4-
use crate::thir::{Arena, BindingMode, Expr, LintLevel, Pat, PatKind};
3+
use crate::thir::{build_thir, Arena, BindingMode, Expr, LintLevel, Pat, PatKind};
54
use rustc_attr::{self as attr, UnwindAttr};
65
use rustc_errors::ErrorReported;
76
use rustc_hir as hir;

Diff for: compiler/rustc_mir_build/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extern crate rustc_middle;
2020

2121
mod build;
2222
mod lints;
23-
mod thir;
23+
pub mod thir;
2424

2525
use rustc_middle::ty::query::Providers;
2626

Diff for: compiler/rustc_mir_build/src/thir/cx/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_middle::middle::region;
1414
use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
1515
use rustc_middle::ty::{self, Ty, TyCtxt};
1616

17-
crate fn build_thir<'thir, 'tcx>(
17+
pub fn build_thir<'thir, 'tcx>(
1818
tcx: TyCtxt<'tcx>,
1919
owner_def: ty::WithOptConstParam<LocalDefId>,
2020
arena: &'thir Arena<'thir, 'tcx>,

Diff for: compiler/rustc_mir_build/src/thir/mod.rs

+40-39
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,51 @@ use rustc_target::abi::VariantIdx;
1818
use rustc_target::asm::InlineAsmRegOrRegClass;
1919

2020
crate mod constant;
21+
2122
crate mod cx;
23+
pub use cx::build_thir;
2224

2325
crate mod pattern;
24-
crate use self::pattern::PatTyProj;
25-
crate use self::pattern::{BindingMode, FieldPat, Pat, PatKind, PatRange};
26+
pub use self::pattern::{Ascription, BindingMode, FieldPat, Pat, PatKind, PatRange, PatTyProj};
2627

2728
mod arena;
28-
crate use arena::Arena;
29+
pub use arena::Arena;
2930

3031
mod util;
3132

3233
#[derive(Copy, Clone, Debug)]
33-
crate enum LintLevel {
34+
pub enum LintLevel {
3435
Inherited,
3536
Explicit(hir::HirId),
3637
}
3738

3839
#[derive(Debug)]
39-
crate struct Block<'thir, 'tcx> {
40-
crate targeted_by_break: bool,
41-
crate region_scope: region::Scope,
42-
crate opt_destruction_scope: Option<region::Scope>,
43-
crate span: Span,
44-
crate stmts: &'thir [Stmt<'thir, 'tcx>],
45-
crate expr: Option<&'thir Expr<'thir, 'tcx>>,
46-
crate safety_mode: BlockSafety,
40+
pub struct Block<'thir, 'tcx> {
41+
pub targeted_by_break: bool,
42+
pub region_scope: region::Scope,
43+
pub opt_destruction_scope: Option<region::Scope>,
44+
pub span: Span,
45+
pub stmts: &'thir [Stmt<'thir, 'tcx>],
46+
pub expr: Option<&'thir Expr<'thir, 'tcx>>,
47+
pub safety_mode: BlockSafety,
4748
}
4849

4950
#[derive(Copy, Clone, Debug)]
50-
crate enum BlockSafety {
51+
pub enum BlockSafety {
5152
Safe,
5253
ExplicitUnsafe(hir::HirId),
5354
PushUnsafe,
5455
PopUnsafe,
5556
}
5657

5758
#[derive(Debug)]
58-
crate struct Stmt<'thir, 'tcx> {
59-
crate kind: StmtKind<'thir, 'tcx>,
60-
crate opt_destruction_scope: Option<region::Scope>,
59+
pub struct Stmt<'thir, 'tcx> {
60+
pub kind: StmtKind<'thir, 'tcx>,
61+
pub opt_destruction_scope: Option<region::Scope>,
6162
}
6263

6364
#[derive(Debug)]
64-
crate enum StmtKind<'thir, 'tcx> {
65+
pub enum StmtKind<'thir, 'tcx> {
6566
Expr {
6667
/// scope for this statement; may be used as lifetime of temporaries
6768
scope: region::Scope,
@@ -111,23 +112,23 @@ rustc_data_structures::static_assert_size!(Expr<'_, '_>, 144);
111112
/// example, method calls and overloaded operators are absent: they are
112113
/// expected to be converted into `Expr::Call` instances.
113114
#[derive(Debug)]
114-
crate struct Expr<'thir, 'tcx> {
115+
pub struct Expr<'thir, 'tcx> {
115116
/// type of this expression
116-
crate ty: Ty<'tcx>,
117+
pub ty: Ty<'tcx>,
117118

118119
/// lifetime of this expression if it should be spilled into a
119120
/// temporary; should be None only if in a constant context
120-
crate temp_lifetime: Option<region::Scope>,
121+
pub temp_lifetime: Option<region::Scope>,
121122

122123
/// span of the expression in the source
123-
crate span: Span,
124+
pub span: Span,
124125

125126
/// kind of expression
126-
crate kind: ExprKind<'thir, 'tcx>,
127+
pub kind: ExprKind<'thir, 'tcx>,
127128
}
128129

129130
#[derive(Debug)]
130-
crate enum ExprKind<'thir, 'tcx> {
131+
pub enum ExprKind<'thir, 'tcx> {
131132
Scope {
132133
region_scope: region::Scope,
133134
lint_level: LintLevel,
@@ -316,41 +317,41 @@ crate enum ExprKind<'thir, 'tcx> {
316317
}
317318

318319
#[derive(Debug)]
319-
crate struct FieldExpr<'thir, 'tcx> {
320-
crate name: Field,
321-
crate expr: &'thir Expr<'thir, 'tcx>,
320+
pub struct FieldExpr<'thir, 'tcx> {
321+
pub name: Field,
322+
pub expr: &'thir Expr<'thir, 'tcx>,
322323
}
323324

324325
#[derive(Debug)]
325-
crate struct FruInfo<'thir, 'tcx> {
326-
crate base: &'thir Expr<'thir, 'tcx>,
327-
crate field_types: &'thir [Ty<'tcx>],
326+
pub struct FruInfo<'thir, 'tcx> {
327+
pub base: &'thir Expr<'thir, 'tcx>,
328+
pub field_types: &'thir [Ty<'tcx>],
328329
}
329330

330331
#[derive(Debug)]
331-
crate struct Arm<'thir, 'tcx> {
332-
crate pattern: Pat<'tcx>,
333-
crate guard: Option<Guard<'thir, 'tcx>>,
334-
crate body: &'thir Expr<'thir, 'tcx>,
335-
crate lint_level: LintLevel,
336-
crate scope: region::Scope,
337-
crate span: Span,
332+
pub struct Arm<'thir, 'tcx> {
333+
pub pattern: Pat<'tcx>,
334+
pub guard: Option<Guard<'thir, 'tcx>>,
335+
pub body: &'thir Expr<'thir, 'tcx>,
336+
pub lint_level: LintLevel,
337+
pub scope: region::Scope,
338+
pub span: Span,
338339
}
339340

340341
#[derive(Debug)]
341-
crate enum Guard<'thir, 'tcx> {
342+
pub enum Guard<'thir, 'tcx> {
342343
If(&'thir Expr<'thir, 'tcx>),
343344
IfLet(Pat<'tcx>, &'thir Expr<'thir, 'tcx>),
344345
}
345346

346347
#[derive(Copy, Clone, Debug)]
347-
crate enum LogicalOp {
348+
pub enum LogicalOp {
348349
And,
349350
Or,
350351
}
351352

352353
#[derive(Debug)]
353-
crate enum InlineAsmOperand<'thir, 'tcx> {
354+
pub enum InlineAsmOperand<'thir, 'tcx> {
354355
In {
355356
reg: InlineAsmRegOrRegClass,
356357
expr: &'thir Expr<'thir, 'tcx>,

Diff for: compiler/rustc_mir_build/src/thir/pattern/mod.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@ crate enum PatternError {
4040
}
4141

4242
#[derive(Copy, Clone, Debug, PartialEq)]
43-
crate enum BindingMode {
43+
pub enum BindingMode {
4444
ByValue,
4545
ByRef(BorrowKind),
4646
}
4747

4848
#[derive(Clone, Debug, PartialEq)]
49-
crate struct FieldPat<'tcx> {
50-
crate field: Field,
51-
crate pattern: Pat<'tcx>,
49+
pub struct FieldPat<'tcx> {
50+
pub field: Field,
51+
pub pattern: Pat<'tcx>,
5252
}
5353

5454
#[derive(Clone, Debug, PartialEq)]
55-
crate struct Pat<'tcx> {
56-
crate ty: Ty<'tcx>,
57-
crate span: Span,
58-
crate kind: Box<PatKind<'tcx>>,
55+
pub struct Pat<'tcx> {
56+
pub ty: Ty<'tcx>,
57+
pub span: Span,
58+
pub kind: Box<PatKind<'tcx>>,
5959
}
6060

6161
impl<'tcx> Pat<'tcx> {
@@ -65,8 +65,8 @@ impl<'tcx> Pat<'tcx> {
6565
}
6666

6767
#[derive(Copy, Clone, Debug, PartialEq)]
68-
crate struct PatTyProj<'tcx> {
69-
crate user_ty: CanonicalUserType<'tcx>,
68+
pub struct PatTyProj<'tcx> {
69+
pub user_ty: CanonicalUserType<'tcx>,
7070
}
7171

7272
impl<'tcx> PatTyProj<'tcx> {
@@ -92,8 +92,8 @@ impl<'tcx> PatTyProj<'tcx> {
9292
}
9393

9494
#[derive(Copy, Clone, Debug, PartialEq)]
95-
crate struct Ascription<'tcx> {
96-
crate user_ty: PatTyProj<'tcx>,
95+
pub struct Ascription<'tcx> {
96+
pub user_ty: PatTyProj<'tcx>,
9797
/// Variance to use when relating the type `user_ty` to the **type of the value being
9898
/// matched**. Typically, this is `Variance::Covariant`, since the value being matched must
9999
/// have a type that is some subtype of the ascribed type.
@@ -112,12 +112,12 @@ crate struct Ascription<'tcx> {
112112
/// requires that `&'static str <: T_x`, where `T_x` is the type of `x`. Really, we should
113113
/// probably be checking for a `PartialEq` impl instead, but this preserves the behavior
114114
/// of the old type-check for now. See #57280 for details.
115-
crate variance: ty::Variance,
116-
crate user_ty_span: Span,
115+
pub variance: ty::Variance,
116+
pub user_ty_span: Span,
117117
}
118118

119119
#[derive(Clone, Debug, PartialEq)]
120-
crate enum PatKind<'tcx> {
120+
pub enum PatKind<'tcx> {
121121
Wild,
122122

123123
AscribeUserType {
@@ -195,10 +195,10 @@ crate enum PatKind<'tcx> {
195195
}
196196

197197
#[derive(Copy, Clone, Debug, PartialEq)]
198-
crate struct PatRange<'tcx> {
199-
crate lo: &'tcx ty::Const<'tcx>,
200-
crate hi: &'tcx ty::Const<'tcx>,
201-
crate end: RangeEnd,
198+
pub struct PatRange<'tcx> {
199+
pub lo: &'tcx ty::Const<'tcx>,
200+
pub hi: &'tcx ty::Const<'tcx>,
201+
pub end: RangeEnd,
202202
}
203203

204204
impl<'tcx> fmt::Display for Pat<'tcx> {

0 commit comments

Comments
 (0)