Skip to content

Commit 47fd82c

Browse files
committed
Move ConstVariableOrigin to const_variable.rs
1 parent 185d1fe commit 47fd82c

File tree

6 files changed

+30
-14
lines changed

6 files changed

+30
-14
lines changed

src/librustc/infer/const_variable.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use syntax::symbol::InternedString;
12+
use syntax_pos::Span;
13+
14+
/// Reasons to create a const inference variable
15+
#[derive(Copy, Clone, Debug)]
16+
pub enum ConstVariableOrigin {
17+
ConstInference(Span),
18+
ConstParameterDefinition(Span, InternedString),
19+
}

src/librustc/infer/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ use self::region_constraints::{RegionConstraintCollector, RegionSnapshot};
4646
use self::region_constraints::{GenericKind, VerifyBound, RegionConstraintData, VarInfos};
4747
use self::lexical_region_resolve::LexicalRegionResolutions;
4848
use self::outlives::env::OutlivesEnvironment;
49-
use self::type_variable::{TypeVariableOrigin, ConstVariableOrigin};
49+
use self::type_variable::TypeVariableOrigin;
50+
use self::const_variable::ConstVariableOrigin;
5051
use self::unify_key::ToType;
5152

5253
pub mod anon_types;
@@ -67,6 +68,7 @@ pub mod resolve;
6768
mod freshen;
6869
mod sub;
6970
pub mod type_variable;
71+
pub mod const_variable;
7072
pub mod unify_key;
7173

7274
#[must_use]

src/librustc/infer/type_variable.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ pub enum TypeVariableOrigin {
6868
Generalized(ty::TyVid),
6969
}
7070

71-
/// Reasons to create a type inference variable
72-
// TODO(const_generics): move this somewhere more sensible
73-
#[derive(Copy, Clone, Debug)]
74-
pub enum ConstVariableOrigin {
75-
ConstInference(Span),
76-
ConstParameterDefinition(Span, InternedString),
77-
}
78-
7971
pub type TypeVariableMap = FxHashMap<ty::TyVid, TypeVariableOrigin>;
8072

8173
struct TypeVariableData {

src/librustc/ty/instance.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
198198
let f = item_type.fn_sig(tcx);
199199
f.abi() == Abi::RustIntrinsic ||
200200
f.abi() == Abi::PlatformIntrinsic
201-
} =>
202-
{
201+
} => {
203202
debug!(" => intrinsic");
204203
ty::InstanceDef::Intrinsic(def_id)
205204
}

src/librustc/ty/relate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ pub fn super_relate_consts<'a, 'gcx, 'tcx, R>(relation: &mut R,
599599
// `structural_match` types.
600600
// FIXME(const_generics): check for `structural_match` synthetic attribute.
601601
// TODO(const_generics): possibly need indirection for ByRef?
602-
// TODO(const_generics): Param should be a bug here
603602
match (a.val, b.val) {
604603
(ConstValue::Infer(_), _) | (_, ConstValue::Infer(_)) => {
605604
// The caller should handle these cases!

src/librustc_mir/interpret/eval_context.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,11 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
378378
Ok(Value::new_slice(Scalar::Ptr(ptr), s.len() as u64, self.tcx.tcx))
379379
}
380380

381-
pub(super) fn resolve(&self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> EvalResult<'tcx, ty::Instance<'tcx>> {
381+
pub(super) fn resolve(
382+
&self,
383+
def_id: DefId,
384+
substs: &'tcx Substs<'tcx>
385+
) -> EvalResult<'tcx, ty::Instance<'tcx>> {
382386
trace!("resolve: {:?}, {:#?}", def_id, substs);
383387
trace!("substs: {:#?}", self.substs());
384388
trace!("param_env: {:#?}", self.param_env);
@@ -406,7 +410,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
406410
) -> EvalResult<'tcx, &'tcx mir::Mir<'tcx>> {
407411
// do not continue if typeck errors occurred (can only occur in local crate)
408412
let did = instance.def_id();
409-
if did.is_local() && self.tcx.has_typeck_tables(did) && self.tcx.typeck_tables_of(did).tainted_by_errors {
413+
if did.is_local() && self.tcx.has_typeck_tables(did)
414+
&& self.tcx.typeck_tables_of(did).tainted_by_errors {
410415
return err!(TypeckError);
411416
}
412417
trace!("load mir {:?}", instance);

0 commit comments

Comments
 (0)