some style fixes
This commit is contained in:
parent
824c9ebbd5
commit
b38992c63d
@ -52,14 +52,16 @@ pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||||||
tables: tables,
|
tables: tables,
|
||||||
graph: graph,
|
graph: graph,
|
||||||
fn_exit: fn_exit,
|
fn_exit: fn_exit,
|
||||||
loop_scopes: Vec::new()
|
loop_scopes: Vec::new(),
|
||||||
};
|
};
|
||||||
body_exit = cfg_builder.expr(&body.value, entry);
|
body_exit = cfg_builder.expr(&body.value, entry);
|
||||||
cfg_builder.add_contained_edge(body_exit, fn_exit);
|
cfg_builder.add_contained_edge(body_exit, fn_exit);
|
||||||
let CFGBuilder {graph, ..} = cfg_builder;
|
let CFGBuilder { graph, .. } = cfg_builder;
|
||||||
CFG {graph: graph,
|
CFG {
|
||||||
entry: entry,
|
graph: graph,
|
||||||
exit: fn_exit}
|
entry: entry,
|
||||||
|
exit: fn_exit,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
||||||
@ -81,7 +83,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||||||
self.add_ast_node(id, &[exit])
|
self.add_ast_node(id, &[exit])
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::StmtExpr(ref expr, id) | hir::StmtSemi(ref expr, id) => {
|
hir::StmtExpr(ref expr, id) |
|
||||||
|
hir::StmtSemi(ref expr, id) => {
|
||||||
let exit = self.expr(&expr, pred);
|
let exit = self.expr(&expr, pred);
|
||||||
self.add_ast_node(id, &[exit])
|
self.add_ast_node(id, &[exit])
|
||||||
}
|
}
|
||||||
@ -95,9 +98,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||||||
self.pat(&local.pat, init_exit)
|
self.pat(&local.pat, init_exit)
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::DeclItem(_) => {
|
hir::DeclItem(_) => pred,
|
||||||
pred
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,9 +108,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||||||
PatKind::Path(_) |
|
PatKind::Path(_) |
|
||||||
PatKind::Lit(..) |
|
PatKind::Lit(..) |
|
||||||
PatKind::Range(..) |
|
PatKind::Range(..) |
|
||||||
PatKind::Wild => {
|
PatKind::Wild => self.add_ast_node(pat.id, &[pred]),
|
||||||
self.add_ast_node(pat.id, &[pred])
|
|
||||||
}
|
|
||||||
|
|
||||||
PatKind::Box(ref subpat) |
|
PatKind::Box(ref subpat) |
|
||||||
PatKind::Ref(ref subpat, _) |
|
PatKind::Ref(ref subpat, _) |
|
||||||
@ -125,8 +124,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PatKind::Struct(_, ref subpats, _) => {
|
PatKind::Struct(_, ref subpats, _) => {
|
||||||
let pats_exit =
|
let pats_exit = self.pats_all(subpats.iter().map(|f| &f.node.pat), pred);
|
||||||
self.pats_all(subpats.iter().map(|f| &f.node.pat), pred);
|
|
||||||
self.add_ast_node(pat.id, &[pats_exit])
|
self.add_ast_node(pat.id, &[pats_exit])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +383,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||||||
let method_call = ty::MethodCall::expr(call_expr.id);
|
let method_call = ty::MethodCall::expr(call_expr.id);
|
||||||
let fn_ty = match self.tables.method_map.get(&method_call) {
|
let fn_ty = match self.tables.method_map.get(&method_call) {
|
||||||
Some(method) => method.ty,
|
Some(method) => method.ty,
|
||||||
None => self.tables.expr_ty_adjusted(func_or_rcvr)
|
None => self.tables.expr_ty_adjusted(func_or_rcvr),
|
||||||
};
|
};
|
||||||
|
|
||||||
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
|
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
|
||||||
@ -556,7 +554,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||||||
from_index: CFGIndex,
|
from_index: CFGIndex,
|
||||||
to_loop: LoopScope,
|
to_loop: LoopScope,
|
||||||
to_index: CFGIndex) {
|
to_index: CFGIndex) {
|
||||||
let mut data = CFGEdgeData {exiting_scopes: vec![] };
|
let mut data = CFGEdgeData { exiting_scopes: vec![] };
|
||||||
let mut scope = self.tcx.region_maps.node_extent(from_expr.id);
|
let mut scope = self.tcx.region_maps.node_extent(from_expr.id);
|
||||||
let target_scope = self.tcx.region_maps.node_extent(to_loop.loop_id);
|
let target_scope = self.tcx.region_maps.node_extent(to_loop.loop_id);
|
||||||
while scope != target_scope {
|
while scope != target_scope {
|
||||||
@ -591,7 +589,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
span_bug!(expr.span, "no loop scope for id {}", loop_id);
|
span_bug!(expr.span, "no loop scope for id {}", loop_id);
|
||||||
}
|
}
|
||||||
Err(err) => span_bug!(expr.span, "loop scope error: {}", err)
|
Err(err) => span_bug!(expr.span, "loop scope error: {}", err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ impl<M: DepTrackingMapConfig> DepTrackingMap<M> {
|
|||||||
DepTrackingMap {
|
DepTrackingMap {
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
graph: graph,
|
graph: graph,
|
||||||
map: FxHashMap()
|
map: FxHashMap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>
|
|||||||
struct TrackingVisitor<'visit, 'tcx: 'visit, F: 'visit, V: 'visit> {
|
struct TrackingVisitor<'visit, 'tcx: 'visit, F: 'visit, V: 'visit> {
|
||||||
tcx: TyCtxt<'visit, 'tcx, 'tcx>,
|
tcx: TyCtxt<'visit, 'tcx, 'tcx>,
|
||||||
dep_node_fn: &'visit mut F,
|
dep_node_fn: &'visit mut F,
|
||||||
visitor: &'visit mut V
|
visitor: &'visit mut V,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'visit, 'tcx, F, V> ItemLikeVisitor<'tcx> for TrackingVisitor<'visit, 'tcx, F, V>
|
impl<'visit, 'tcx, F, V> ItemLikeVisitor<'tcx> for TrackingVisitor<'visit, 'tcx, F, V>
|
||||||
@ -70,13 +70,16 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>
|
|||||||
let mut tracking_visitor = TrackingVisitor {
|
let mut tracking_visitor = TrackingVisitor {
|
||||||
tcx: tcx,
|
tcx: tcx,
|
||||||
dep_node_fn: &mut dep_node_fn,
|
dep_node_fn: &mut dep_node_fn,
|
||||||
visitor: visitor
|
visitor: visitor,
|
||||||
};
|
};
|
||||||
krate.visit_all_item_likes(&mut tracking_visitor)
|
krate.visit_all_item_likes(&mut tracking_visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn visit_all_bodies_in_krate<'a, 'tcx, C>(tcx: TyCtxt<'a, 'tcx, 'tcx>, callback: C)
|
pub fn visit_all_bodies_in_krate<'a, 'tcx, C>(tcx: TyCtxt<'a, 'tcx, 'tcx>, callback: C)
|
||||||
where C: Fn(/* body_owner */ DefId, /* body id */ hir::BodyId),
|
where C: Fn(/* body_owner */
|
||||||
|
DefId,
|
||||||
|
/* body id */
|
||||||
|
hir::BodyId)
|
||||||
{
|
{
|
||||||
let krate = tcx.hir.krate();
|
let krate = tcx.hir.krate();
|
||||||
for &body_id in &krate.body_ids {
|
for &body_id in &krate.body_ids {
|
||||||
|
@ -113,13 +113,19 @@ impl<'a, S: Into<MultiSpan>> IntoEarlyLint for (S, &'a str) {
|
|||||||
let (span, msg) = self;
|
let (span, msg) = self;
|
||||||
let mut diagnostic = Diagnostic::new(errors::Level::Warning, msg);
|
let mut diagnostic = Diagnostic::new(errors::Level::Warning, msg);
|
||||||
diagnostic.set_span(span);
|
diagnostic.set_span(span);
|
||||||
EarlyLint { id: id, diagnostic: diagnostic }
|
EarlyLint {
|
||||||
|
id: id,
|
||||||
|
diagnostic: diagnostic,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoEarlyLint for Diagnostic {
|
impl IntoEarlyLint for Diagnostic {
|
||||||
fn into_early_lint(self, id: LintId) -> EarlyLint {
|
fn into_early_lint(self, id: LintId) -> EarlyLint {
|
||||||
EarlyLint { id: id, diagnostic: self }
|
EarlyLint {
|
||||||
|
id: id,
|
||||||
|
diagnostic: self,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +152,7 @@ enum TargetLint {
|
|||||||
|
|
||||||
enum FindLintError {
|
enum FindLintError {
|
||||||
NotFound,
|
NotFound,
|
||||||
Removed
|
Removed,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LintStore {
|
impl LintStore {
|
||||||
@ -1127,7 +1133,7 @@ enum CheckLintNameResult {
|
|||||||
NoLint,
|
NoLint,
|
||||||
// The lint is either renamed or removed. This is the warning
|
// The lint is either renamed or removed. This is the warning
|
||||||
// message.
|
// message.
|
||||||
Warning(String)
|
Warning(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks the name of a lint for its existence, and whether it was
|
/// Checks the name of a lint for its existence, and whether it was
|
||||||
|
@ -25,7 +25,10 @@ pub struct VariantInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||||
pub enum SizeKind { Exact, Min }
|
pub enum SizeKind {
|
||||||
|
Exact,
|
||||||
|
Min,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct FieldInfo {
|
pub struct FieldInfo {
|
||||||
|
@ -37,7 +37,7 @@ pub mod specialization_graph;
|
|||||||
pub struct OverlapError {
|
pub struct OverlapError {
|
||||||
pub with_impl: DefId,
|
pub with_impl: DefId,
|
||||||
pub trait_desc: String,
|
pub trait_desc: String,
|
||||||
pub self_desc: Option<String>
|
pub self_desc: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a subst for the requested impl, translate it to a subst
|
/// Given a subst for the requested impl, translate it to a subst
|
||||||
@ -274,7 +274,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct SpecializesCache {
|
pub struct SpecializesCache {
|
||||||
map: FxHashMap<(DefId, DefId), bool>
|
map: FxHashMap<(DefId, DefId), bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SpecializesCache {
|
impl SpecializesCache {
|
||||||
|
@ -23,7 +23,7 @@ use hir;
|
|||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct ExpectedFound<T> {
|
pub struct ExpectedFound<T> {
|
||||||
pub expected: T,
|
pub expected: T,
|
||||||
pub found: T
|
pub found: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data structures used in type unification
|
// Data structures used in type unification
|
||||||
|
@ -374,14 +374,13 @@ impl LocalPathBuffer {
|
|||||||
fn new(root_mode: RootMode) -> LocalPathBuffer {
|
fn new(root_mode: RootMode) -> LocalPathBuffer {
|
||||||
LocalPathBuffer {
|
LocalPathBuffer {
|
||||||
root_mode: root_mode,
|
root_mode: root_mode,
|
||||||
str: String::new()
|
str: String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn into_string(self) -> String {
|
fn into_string(self) -> String {
|
||||||
self.str
|
self.str
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemPathBuffer for LocalPathBuffer {
|
impl ItemPathBuffer for LocalPathBuffer {
|
||||||
|
@ -85,7 +85,7 @@ impl<'tcx> Value<'tcx> for Ty<'tcx> {
|
|||||||
|
|
||||||
pub struct CycleError<'a> {
|
pub struct CycleError<'a> {
|
||||||
span: Span,
|
span: Span,
|
||||||
cycle: RefMut<'a, [(Span, Query)]>
|
cycle: RefMut<'a, [(Span, Query)]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
@ -45,7 +45,7 @@ pub struct TypeAndMut<'tcx> {
|
|||||||
/// at least as big as the scope `fr.scope`".
|
/// at least as big as the scope `fr.scope`".
|
||||||
pub struct FreeRegion {
|
pub struct FreeRegion {
|
||||||
pub scope: region::CodeExtent,
|
pub scope: region::CodeExtent,
|
||||||
pub bound_region: BoundRegion
|
pub bound_region: BoundRegion,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash,
|
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash,
|
||||||
@ -65,7 +65,7 @@ pub enum BoundRegion {
|
|||||||
|
|
||||||
// Anonymous region for the implicit env pointer parameter
|
// Anonymous region for the implicit env pointer parameter
|
||||||
// to a closure
|
// to a closure
|
||||||
BrEnv
|
BrEnv,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// When a region changed from late-bound to early-bound when #32330
|
/// When a region changed from late-bound to early-bound when #32330
|
||||||
@ -320,7 +320,7 @@ impl<'tcx> Slice<ExistentialPredicate<'tcx>> {
|
|||||||
pub fn principal(&self) -> Option<ExistentialTraitRef<'tcx>> {
|
pub fn principal(&self) -> Option<ExistentialTraitRef<'tcx>> {
|
||||||
match self.get(0) {
|
match self.get(0) {
|
||||||
Some(&ExistentialPredicate::Trait(tr)) => Some(tr),
|
Some(&ExistentialPredicate::Trait(tr)) => Some(tr),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,13 +520,13 @@ impl<T> Binder<T> {
|
|||||||
ty::Binder(&self.0)
|
ty::Binder(&self.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn map_bound_ref<F,U>(&self, f: F) -> Binder<U>
|
pub fn map_bound_ref<F, U>(&self, f: F) -> Binder<U>
|
||||||
where F: FnOnce(&T) -> U
|
where F: FnOnce(&T) -> U
|
||||||
{
|
{
|
||||||
self.as_ref().map_bound(f)
|
self.as_ref().map_bound(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn map_bound<F,U>(self, f: F) -> Binder<U>
|
pub fn map_bound<F, U>(self, f: F) -> Binder<U>
|
||||||
where F: FnOnce(T) -> U
|
where F: FnOnce(T) -> U
|
||||||
{
|
{
|
||||||
ty::Binder(f(self.0))
|
ty::Binder(f(self.0))
|
||||||
@ -790,22 +790,22 @@ pub struct TyVid {
|
|||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
||||||
pub struct IntVid {
|
pub struct IntVid {
|
||||||
pub index: u32
|
pub index: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
||||||
pub struct FloatVid {
|
pub struct FloatVid {
|
||||||
pub index: u32
|
pub index: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
|
||||||
pub struct RegionVid {
|
pub struct RegionVid {
|
||||||
pub index: u32
|
pub index: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
||||||
pub struct SkolemizedRegionVid {
|
pub struct SkolemizedRegionVid {
|
||||||
pub index: u32
|
pub index: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
||||||
@ -819,7 +819,7 @@ pub enum InferTy {
|
|||||||
/// `infer::freshen` for more details.
|
/// `infer::freshen` for more details.
|
||||||
FreshTy(u32),
|
FreshTy(u32),
|
||||||
FreshIntTy(u32),
|
FreshIntTy(u32),
|
||||||
FreshFloatTy(u32)
|
FreshFloatTy(u32),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A `ProjectionPredicate` for an `ExistentialTraitRef`.
|
/// A `ProjectionPredicate` for an `ExistentialTraitRef`.
|
||||||
@ -827,7 +827,7 @@ pub enum InferTy {
|
|||||||
pub struct ExistentialProjection<'tcx> {
|
pub struct ExistentialProjection<'tcx> {
|
||||||
pub trait_ref: ExistentialTraitRef<'tcx>,
|
pub trait_ref: ExistentialTraitRef<'tcx>,
|
||||||
pub item_name: Name,
|
pub item_name: Name,
|
||||||
pub ty: Ty<'tcx>
|
pub ty: Ty<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PolyExistentialProjection<'tcx> = Binder<ExistentialProjection<'tcx>>;
|
pub type PolyExistentialProjection<'tcx> = Binder<ExistentialProjection<'tcx>>;
|
||||||
@ -860,9 +860,9 @@ impl<'a, 'tcx, 'gcx> ExistentialProjection<'tcx> {
|
|||||||
ty::ProjectionPredicate {
|
ty::ProjectionPredicate {
|
||||||
projection_ty: ty::ProjectionTy {
|
projection_ty: ty::ProjectionTy {
|
||||||
trait_ref: self.trait_ref.with_self_ty(tcx, self_ty),
|
trait_ref: self.trait_ref.with_self_ty(tcx, self_ty),
|
||||||
item_name: self.item_name
|
item_name: self.item_name,
|
||||||
},
|
},
|
||||||
ty: self.ty
|
ty: self.ty,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -899,7 +899,7 @@ impl Region {
|
|||||||
match *self {
|
match *self {
|
||||||
ty::ReEarlyBound(..) => true,
|
ty::ReEarlyBound(..) => true,
|
||||||
ty::ReLateBound(..) => true,
|
ty::ReLateBound(..) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -969,7 +969,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn is_nil(&self) -> bool {
|
pub fn is_nil(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyTuple(ref tys, _) => tys.is_empty(),
|
TyTuple(ref tys, _) => tys.is_empty(),
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1047,7 +1047,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn is_ty_var(&self) -> bool {
|
pub fn is_ty_var(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyInfer(TyVar(_)) => true,
|
TyInfer(TyVar(_)) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1071,7 +1071,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn is_self(&self) -> bool {
|
pub fn is_self(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyParam(ref p) => p.is_self(),
|
TyParam(ref p) => p.is_self(),
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1088,7 +1088,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn is_structural(&self) -> bool {
|
pub fn is_structural(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyAdt(..) | TyTuple(..) | TyArray(..) | TyClosure(..) => true,
|
TyAdt(..) | TyTuple(..) | TyArray(..) | TyClosure(..) => true,
|
||||||
_ => self.is_slice() | self.is_trait()
|
_ => self.is_slice() | self.is_trait(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1096,7 +1096,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn is_simd(&self) -> bool {
|
pub fn is_simd(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyAdt(def, _) => def.repr.simd,
|
TyAdt(def, _) => def.repr.simd,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1127,7 +1127,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn is_region_ptr(&self) -> bool {
|
pub fn is_region_ptr(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyRef(..) => true,
|
TyRef(..) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1145,7 +1145,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn is_unsafe_ptr(&self) -> bool {
|
pub fn is_unsafe_ptr(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyRawPtr(_) => return true,
|
TyRawPtr(_) => return true,
|
||||||
_ => return false
|
_ => return false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1189,7 +1189,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn is_trait(&self) -> bool {
|
pub fn is_trait(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyDynamic(..) => true,
|
TyDynamic(..) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1205,7 +1205,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
TyInfer(FreshTy(_)) => true,
|
TyInfer(FreshTy(_)) => true,
|
||||||
TyInfer(FreshIntTy(_)) => true,
|
TyInfer(FreshIntTy(_)) => true,
|
||||||
TyInfer(FreshFloatTy(_)) => true,
|
TyInfer(FreshFloatTy(_)) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1219,7 +1219,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn is_char(&self) -> bool {
|
pub fn is_char(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyChar => true,
|
TyChar => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1237,7 +1237,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn is_signed(&self) -> bool {
|
pub fn is_signed(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyInt(_) => true,
|
TyInt(_) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1245,7 +1245,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
match self.sty {
|
match self.sty {
|
||||||
TyInt(ast::IntTy::Is) | TyUint(ast::UintTy::Us) => false,
|
TyInt(ast::IntTy::Is) | TyUint(ast::UintTy::Us) => false,
|
||||||
TyInt(..) | TyUint(..) | TyFloat(..) => true,
|
TyInt(..) | TyUint(..) | TyFloat(..) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1276,7 +1276,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
},
|
},
|
||||||
TyRef(_, mt) => Some(mt),
|
TyRef(_, mt) => Some(mt),
|
||||||
TyRawPtr(mt) if explicit => Some(mt),
|
TyRawPtr(mt) if explicit => Some(mt),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1284,7 +1284,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn builtin_index(&self) -> Option<Ty<'tcx>> {
|
pub fn builtin_index(&self) -> Option<Ty<'tcx>> {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyArray(ty, _) | TySlice(ty) => Some(ty),
|
TyArray(ty, _) | TySlice(ty) => Some(ty),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1307,7 +1307,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
pub fn is_fn(&self) -> bool {
|
pub fn is_fn(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyFnDef(..) | TyFnPtr(_) => true,
|
TyFnDef(..) | TyFnPtr(_) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1316,14 +1316,14 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
TyDynamic(ref tt, ..) => tt.principal().map(|p| p.def_id()),
|
TyDynamic(ref tt, ..) => tt.principal().map(|p| p.def_id()),
|
||||||
TyAdt(def, _) => Some(def.did),
|
TyAdt(def, _) => Some(def.did),
|
||||||
TyClosure(id, _) => Some(id),
|
TyClosure(id, _) => Some(id),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> {
|
pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyAdt(adt, _) => Some(adt),
|
TyAdt(adt, _) => Some(adt),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ use infer::InferCtxt;
|
|||||||
use hir::map as hir_map;
|
use hir::map as hir_map;
|
||||||
use traits::{self, Reveal};
|
use traits::{self, Reveal};
|
||||||
use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable};
|
use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable};
|
||||||
use ty::{ParameterEnvironment};
|
use ty::ParameterEnvironment;
|
||||||
use ty::fold::TypeVisitor;
|
use ty::fold::TypeVisitor;
|
||||||
use ty::layout::{Layout, LayoutError};
|
use ty::layout::{Layout, LayoutError};
|
||||||
use ty::TypeVariants::*;
|
use ty::TypeVariants::*;
|
||||||
@ -39,13 +39,13 @@ use hir;
|
|||||||
|
|
||||||
type Disr = ConstInt;
|
type Disr = ConstInt;
|
||||||
|
|
||||||
pub trait IntTypeExt {
|
pub trait IntTypeExt {
|
||||||
fn to_ty<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx>;
|
fn to_ty<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx>;
|
||||||
fn disr_incr<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, val: Option<Disr>)
|
fn disr_incr<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, val: Option<Disr>)
|
||||||
-> Option<Disr>;
|
-> Option<Disr>;
|
||||||
fn assert_ty_matches(&self, val: Disr);
|
fn assert_ty_matches(&self, val: Disr);
|
||||||
fn initial_discriminant<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Disr;
|
fn initial_discriminant<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Disr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
macro_rules! typed_literal {
|
macro_rules! typed_literal {
|
||||||
@ -133,7 +133,7 @@ impl IntTypeExt for attr::IntType {
|
|||||||
pub enum CopyImplementationError<'tcx> {
|
pub enum CopyImplementationError<'tcx> {
|
||||||
InfrigingField(&'tcx ty::FieldDef),
|
InfrigingField(&'tcx ty::FieldDef),
|
||||||
NotAnAdt,
|
NotAnAdt,
|
||||||
HasDestructor
|
HasDestructor,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Describes whether a type is representable. For types that are not
|
/// Describes whether a type is representable. For types that are not
|
||||||
@ -159,14 +159,14 @@ impl<'tcx> ParameterEnvironment<'tcx> {
|
|||||||
tcx.infer_ctxt(self.clone(), Reveal::UserFacing).enter(|infcx| {
|
tcx.infer_ctxt(self.clone(), Reveal::UserFacing).enter(|infcx| {
|
||||||
let (adt, substs) = match self_type.sty {
|
let (adt, substs) = match self_type.sty {
|
||||||
ty::TyAdt(adt, substs) => (adt, substs),
|
ty::TyAdt(adt, substs) => (adt, substs),
|
||||||
_ => return Err(CopyImplementationError::NotAnAdt)
|
_ => return Err(CopyImplementationError::NotAnAdt),
|
||||||
};
|
};
|
||||||
|
|
||||||
let field_implements_copy = |field: &ty::FieldDef| {
|
let field_implements_copy = |field: &ty::FieldDef| {
|
||||||
let cause = traits::ObligationCause::dummy();
|
let cause = traits::ObligationCause::dummy();
|
||||||
match traits::fully_normalize(&infcx, cause, &field.ty(tcx, substs)) {
|
match traits::fully_normalize(&infcx, cause, &field.ty(tcx, substs)) {
|
||||||
Ok(ty) => !infcx.type_moves_by_default(ty, span),
|
Ok(ty) => !infcx.type_moves_by_default(ty, span),
|
||||||
Err(..) => false
|
Err(..) => false,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => (),
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@ -218,7 +218,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||||||
adt.variants[0].fields.get(i).map(|f| f.ty(self, substs))
|
adt.variants[0].fields.get(i).map(|f| f.ty(self, substs))
|
||||||
}
|
}
|
||||||
(&TyTuple(ref v, _), None) => v.get(i).cloned(),
|
(&TyTuple(ref v, _), None) => v.get(i).cloned(),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,11 +245,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||||||
pub fn struct_tail(self, mut ty: Ty<'tcx>) -> Ty<'tcx> {
|
pub fn struct_tail(self, mut ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
while let TyAdt(def, substs) = ty.sty {
|
while let TyAdt(def, substs) = ty.sty {
|
||||||
if !def.is_struct() {
|
if !def.is_struct() {
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
match def.struct_variant().fields.last() {
|
match def.struct_variant().fields.last() {
|
||||||
Some(f) => ty = f.ty(self, substs),
|
Some(f) => ty = f.ty(self, substs),
|
||||||
None => break
|
None => break,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty
|
ty
|
||||||
@ -267,14 +267,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||||||
let (mut a, mut b) = (source, target);
|
let (mut a, mut b) = (source, target);
|
||||||
while let (&TyAdt(a_def, a_substs), &TyAdt(b_def, b_substs)) = (&a.sty, &b.sty) {
|
while let (&TyAdt(a_def, a_substs), &TyAdt(b_def, b_substs)) = (&a.sty, &b.sty) {
|
||||||
if a_def != b_def || !a_def.is_struct() {
|
if a_def != b_def || !a_def.is_struct() {
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
match a_def.struct_variant().fields.last() {
|
match a_def.struct_variant().fields.last() {
|
||||||
Some(f) => {
|
Some(f) => {
|
||||||
a = f.ty(self, a_substs);
|
a = f.ty(self, a_substs);
|
||||||
b = f.ty(self, b_substs);
|
b = f.ty(self, b_substs);
|
||||||
}
|
}
|
||||||
_ => break
|
_ => break,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(a, b)
|
(a, b)
|
||||||
@ -373,7 +373,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||||||
|
|
||||||
let dtor_did = match dtor_did {
|
let dtor_did = match dtor_did {
|
||||||
Some(dtor) => dtor,
|
Some(dtor) => dtor,
|
||||||
None => return None
|
None => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
// RFC 1238: if the destructor method is tagged with the
|
// RFC 1238: if the destructor method is tagged with the
|
||||||
@ -725,9 +725,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||||||
|
|
||||||
substs_a.types().zip(substs_b.types()).all(|(a, b)| same_type(a, b))
|
substs_a.types().zip(substs_b.types()).all(|(a, b)| same_type(a, b))
|
||||||
}
|
}
|
||||||
_ => {
|
_ => a == b,
|
||||||
a == b
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ pub fn to_readable_str(mut val: usize) -> String {
|
|||||||
|
|
||||||
if val == 0 {
|
if val == 0 {
|
||||||
groups.push(format!("{}", group));
|
groups.push(format!("{}", group));
|
||||||
break
|
break;
|
||||||
} else {
|
} else {
|
||||||
groups.push(format!("{:03}", group));
|
groups.push(format!("{:03}", group));
|
||||||
}
|
}
|
||||||
@ -142,7 +142,8 @@ fn get_resident() -> Option<usize> {
|
|||||||
type HANDLE = *mut u8;
|
type HANDLE = *mut u8;
|
||||||
use libc::size_t;
|
use libc::size_t;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
#[repr(C)] #[allow(non_snake_case)]
|
#[repr(C)]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
struct PROCESS_MEMORY_COUNTERS {
|
struct PROCESS_MEMORY_COUNTERS {
|
||||||
cb: DWORD,
|
cb: DWORD,
|
||||||
PageFaultCount: DWORD,
|
PageFaultCount: DWORD,
|
||||||
@ -184,7 +185,7 @@ pub fn indent<R, F>(op: F) -> R where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Indenter {
|
pub struct Indenter {
|
||||||
_cannot_construct_outside_of_this_module: ()
|
_cannot_construct_outside_of_this_module: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Indenter {
|
impl Drop for Indenter {
|
||||||
|
@ -116,7 +116,7 @@ pub fn create_dir_racy(path: &Path) -> io::Result<()> {
|
|||||||
match fs::create_dir(path) {
|
match fs::create_dir(path) {
|
||||||
Ok(()) => return Ok(()),
|
Ok(()) => return Ok(()),
|
||||||
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => return Ok(()),
|
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => return Ok(()),
|
||||||
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {}
|
Err(ref e) if e.kind() == io::ErrorKind::NotFound => (),
|
||||||
Err(e) => return Err(e),
|
Err(e) => return Err(e),
|
||||||
}
|
}
|
||||||
match path.parent() {
|
match path.parent() {
|
||||||
|
Loading…
Reference in New Issue
Block a user