Skip to content

Commit 9db043f

Browse files
committed
Move ty::MainDefinition to its own little module (cute)
1 parent 32fe946 commit 9db043f

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use rustc_span::Span;
2+
3+
use rustc_ast as ast;
4+
use rustc_hir::def::{DefKind, Res};
5+
use rustc_hir::def_id::DefId;
6+
7+
#[derive(Clone, Copy, Debug)]
8+
pub struct MainDefinition {
9+
pub res: Res<ast::NodeId>,
10+
pub is_import: bool,
11+
pub span: Span,
12+
}
13+
14+
impl MainDefinition {
15+
pub fn opt_fn_def_id(self) -> Option<DefId> {
16+
if let Res::Def(DefKind::Fn, def_id) = self.res { Some(def_id) } else { None }
17+
}
18+
}

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ mod alias_relation_direction;
137137
mod bound_constness;
138138
mod field_def;
139139
mod impl_polarity;
140+
mod main_definition;
140141
mod opaque_hidden_type;
141142
mod param_env;
142143
mod placeholder;
@@ -152,6 +153,7 @@ pub use alias_relation_direction::AliasRelationDirection;
152153
pub use bound_constness::BoundConstness;
153154
pub use field_def::FieldDef;
154155
pub use impl_polarity::ImplPolarity;
156+
pub use main_definition::MainDefinition;
155157
pub use opaque_hidden_type::OpaqueHiddenType;
156158
pub use param_env::{ParamEnv, ParamEnvAnd};
157159
pub use placeholder::{Placeholder, PlaceholderConst, PlaceholderRegion, PlaceholderType};
@@ -168,19 +170,6 @@ pub use ty_::Ty;
168170
pub use variant_def::VariantDef;
169171
pub use visibility::Visibility;
170172

171-
#[derive(Clone, Copy, Debug)]
172-
pub struct MainDefinition {
173-
pub res: Res<ast::NodeId>,
174-
pub is_import: bool,
175-
pub span: Span,
176-
}
177-
178-
impl MainDefinition {
179-
pub fn opt_fn_def_id(self) -> Option<DefId> {
180-
if let Res::Def(DefKind::Fn, def_id) = self.res { Some(def_id) } else { None }
181-
}
182-
}
183-
184173
/// The "header" of an impl is everything outside the body: a Self type, a trait
185174
/// ref (in the case of a trait impl), and a set of predicates (from the
186175
/// bounds / where-clauses).

0 commit comments

Comments
 (0)