Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor call & function handling in trans, enable MIR bootstrap. #32080

Merged
merged 77 commits into from
Mar 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
b47fcb8
trans: Use fmt::Debug for debugging instead of ad-hoc methods.
eddyb Feb 18, 2016
9723a3b
Move simd_ffi gating from trans to typeck.
eddyb Feb 23, 2016
b918e37
metedata: Remove the unnecessary indirection to astencode.
eddyb Feb 23, 2016
062a05d
metadata: Constrain FoundAst::FoundParent to an Item.
eddyb Feb 23, 2016
16201d4
trans: Get functions and do calls only through Callee.
eddyb Feb 23, 2016
e097049
trans: Move trans_foreign_mod and trans_impl to trans_item.
eddyb Feb 23, 2016
c3f856e
trans: Remove dead code for variants and structs from get_item_val.
eddyb Feb 23, 2016
5af3c12
trans: Move static item handling to consts.
eddyb Feb 23, 2016
55b5a36
trans: Remove unused return type argument from declare_cfn.
eddyb Feb 23, 2016
7011e30
trans: Remove the old ExprOrMethodCall.
eddyb Feb 23, 2016
9221b91
trans: Pass the Rust type for the closure env in type_of_rust_fn.
eddyb Feb 23, 2016
c6d214b
trans: Revamp and empower cabi::FnType.
eddyb Feb 23, 2016
b122d16
trans: simplify the declare interface.
eddyb Feb 23, 2016
89766a8
trans: use Cell instead of RefCell where it suffices.
eddyb Feb 23, 2016
d6e72c4
trans: Don't store extra copies of intrinsics ID/substs.
eddyb Feb 23, 2016
b05556e
trans: Rename MonoId to Instance and start using it in more places.
eddyb Feb 23, 2016
cdfad40
trans: Condense the fn instantiation logic into callee.
eddyb Feb 23, 2016
da66431
trans: Combine cabi and back::abi into abi.
eddyb Feb 23, 2016
3342da4
trans: Don't treat closure types like function types in declare.
eddyb Feb 23, 2016
200d001
trans: Pass fat pointers as two arguments even for FFI.
eddyb Feb 24, 2016
cf0ea78
tests: Force instantiation of extern fns.
eddyb Feb 24, 2016
f6bbbe1
trans: Remove dropflag-unaware type_is_newtype_immediate shortcut.
eddyb Feb 24, 2016
0394205
trans: Handle type_of for Rust fn's via abi::FnType.
eddyb Feb 24, 2016
ac60318
trans: Only mutate ArgTy's in C ABI handling, don't create them.
eddyb Feb 25, 2016
d492d09
trans: Apply ZExt and StructRet attributes uniformly.
eddyb Feb 25, 2016
1d7c9bd
trans: use sizing_type_of for interacting with potentially incomplete…
eddyb Feb 25, 2016
763b6cb
rustc_llvm: Update the Attribute bitflags and remove OtherAttribute.
eddyb Feb 25, 2016
c7172a9
rustc_llvm: An AttrBuilder that's not completely wasteful.
eddyb Feb 25, 2016
de5f824
trans: Use llvm::Attributes directly in ArgTy.
eddyb Feb 25, 2016
77f3484
trans: Apply all attributes through FnType.
eddyb Feb 25, 2016
7454b5c
trans: Set the calling convention in apply_attrs_callsite.
eddyb Mar 6, 2016
80d939f
trans: Handle ignored arguments/returns uniformly.
eddyb Mar 6, 2016
9e036c0
trans: Provide the FnType for a direct call via Callee::direct_fn_type.
eddyb Mar 6, 2016
0399388
trans: Handle calls for all ABIs through FnType.
eddyb Mar 6, 2016
bd0a849
trans: datum::lvalue_scratch_datum doesn't need a move-into-closure t…
eddyb Mar 6, 2016
aec6382
trans: Handle all function setup for all ABIs via FnType.
eddyb Mar 6, 2016
6c0674e
trans: Remove the foreign module.
eddyb Mar 6, 2016
bffb0de
tests: Use arguments in codegen/stores.rs to turn aggregates into imm…
eddyb Mar 6, 2016
f9c06ab
trans: Simplify "try" intrinsic.
eddyb Mar 6, 2016
56417b3
mir: Monomorphize LvalueTy's of projections.
eddyb Mar 8, 2016
b38627d
mir: Use the right form of GEPi for indexing slices vs arrays.
eddyb Mar 8, 2016
1de6a96
mir: Don't use ConstVal kinds that contain local NodeId's.
eddyb Mar 8, 2016
ccc5e07
mir: Ignore noop casts (e.g. when `as` used for coercion).
eddyb Mar 8, 2016
9cc5ee3
mir: Unsize ConstVal::ByteStr before comparing &[u8] against it.
eddyb Mar 8, 2016
d3a6d67
mir: Don't use ConstVal when adjustments are involved, as they would …
eddyb Mar 8, 2016
eb43d95
mir: Don't load the discriminant, it's already in immediate form.
eddyb Mar 8, 2016
92e4858
mir: Load FatPtr constants instead of keeping them indirect.
eddyb Mar 8, 2016
b63a5ee
mir: Support RustCall ABI functions.
eddyb Mar 8, 2016
38638d3
trans: Take a &Builder in call_memcpy, like call_memset.
eddyb Mar 8, 2016
9c6bfe4
mir: Truncate bool to i1 for SwitchInt.
eddyb Mar 8, 2016
47cd05c
mir: Don't shadow the "args" variable in Call translation.
eddyb Mar 8, 2016
6c551b3
trans: Load and cache cross-crate Mir instances in the shared context.
eddyb Mar 8, 2016
41fc5f7
mir: Trigger closure instantiations when the closure value is created.
eddyb Mar 8, 2016
ee7687a
mir: Reintroduce the temporary block after invokes, to handle critica…
eddyb Mar 8, 2016
3e98220
mir: Translate intrinsics, via old trans where possible.
eddyb Mar 8, 2016
82fad1d
mir: Call set_operand_dropped in more places, specifically Unsize casts.
eddyb Mar 8, 2016
d9277b1
trans: Make everything used from within at_start Builder-friendly.
eddyb Mar 9, 2016
41499f4
mir: Match against slices by calling PartialEq::eq.
eddyb Mar 9, 2016
cf4daf7
mir: Don't lose sub-patterns inside slice patterns.
eddyb Mar 9, 2016
aca4f93
mir: Get the right non-reference type for binding patterns.
eddyb Mar 9, 2016
415d95f
mir: Translate Rvalue::Slice without relying on tvec.
eddyb Mar 9, 2016
856185d
hir, mir: Separate HIR expressions / MIR operands from InlineAsm.
eddyb Mar 9, 2016
835e2bd
Add -Z orbit for forcing MIR for everything, unless #[rustc_no_mir] i…
eddyb Mar 9, 2016
5eeda54
mir: Use usize instead of u32 for indexing slices.
eddyb Mar 10, 2016
7912f94
const_eval: Take just one set of substitutions in lookup_const_by_id.
eddyb Mar 10, 2016
5739ed1
trans: Do not depend on having Expr's around for generic_simd_intrinsic.
eddyb Mar 10, 2016
cfd768e
hir_map: Provide expression and statement attributes.
eddyb Mar 10, 2016
5f990fb
mir: Don't forget to drop arguments.
eddyb Mar 10, 2016
080bd97
compiletest: Add rustc-env for run-pass/super-fast-paren-parsing.
eddyb Mar 10, 2016
473f804
Add #[rustc_no_mir] to make tests pass with -Z orbit.
eddyb Mar 10, 2016
460e664
mir: Store immediates used for indirect arguments in an alloca.
eddyb Mar 10, 2016
02a141a
mir: Don't memset allocas of types that do not require drop.
eddyb Mar 10, 2016
9a8b807
trans: Pass newtypes of immediates as their inner-most type again.
eddyb Mar 17, 2016
d6689e5
Update the not-at-all-pretty pain-o-tron-4000+264 test.
eddyb Mar 18, 2016
181097d
trans: Decide whether to load volatile_store's argument based on its …
eddyb Mar 18, 2016
e177207
trans: Don't ignore zero-sized struct arguments on x86_64-pc-windows-…
eddyb Mar 18, 2016
b12dcde
tests: Update run-make/issue-25581 to reflect how fat pointers are pa…
eddyb Mar 18, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ opt dist-host-only 0 "only install bins for the host architecture"
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
opt llvm-version-check 1 "check if the LLVM version is supported, build anyway"
opt rustbuild 0 "use the rust and cargo based build system"
opt orbit 0 "get MIR where it belongs - everywhere; most importantly, in orbit"

# Optimization and debugging options. These may be overridden by the release channel, etc.
opt_nosave optimize 1 "build optimized rust code"
Expand Down Expand Up @@ -713,6 +714,8 @@ if [ -n "$CFG_ENABLE_DEBUG_ASSERTIONS" ]; then putvar CFG_ENABLE_DEBUG_ASSERTION
if [ -n "$CFG_ENABLE_DEBUGINFO" ]; then putvar CFG_ENABLE_DEBUGINFO; fi
if [ -n "$CFG_ENABLE_DEBUG_JEMALLOC" ]; then putvar CFG_ENABLE_DEBUG_JEMALLOC; fi

if [ -n "$CFG_ENABLE_ORBIT" ]; then putvar CFG_ENABLE_ORBIT; fi

# A magic value that allows the compiler to use unstable features
# during the bootstrap even when doing so would normally be an error
# because of feature staging or because the build turns on
Expand Down
5 changes: 5 additions & 0 deletions mk/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ ifdef CFG_ENABLE_DEBUGINFO
CFG_RUSTC_FLAGS += -g
endif

ifdef CFG_ENABLE_ORBIT
$(info cfg: launching MIR (CFG_ENABLE_ORBIT))
CFG_RUSTC_FLAGS += -Z orbit
endif

ifdef SAVE_TEMPS
CFG_RUSTC_FLAGS += --save-temps
endif
Expand Down
13 changes: 10 additions & 3 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub struct TestProps {
pub pp_exact: Option<PathBuf>,
// Modules from aux directory that should be compiled
pub aux_builds: Vec<String> ,
// Environment settings to use for compiling
pub rustc_env: Vec<(String,String)> ,
// Environment settings to use during execution
pub exec_env: Vec<(String,String)> ,
// Lines to check if they appear in the expected debugger output
Expand Down Expand Up @@ -77,6 +79,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
pp_exact: pp_exact,
aux_builds: aux_builds,
revisions: vec![],
rustc_env: vec![],
exec_env: exec_env,
check_lines: check_lines,
build_aux_docs: build_aux_docs,
Expand Down Expand Up @@ -153,10 +156,14 @@ pub fn load_props_into(props: &mut TestProps, testfile: &Path, cfg: Option<&str>
props.aux_builds.push(ab);
}

if let Some(ee) = parse_exec_env(ln) {
if let Some(ee) = parse_env(ln, "exec-env") {
props.exec_env.push(ee);
}

if let Some(ee) = parse_env(ln, "rustc-env") {
props.rustc_env.push(ee);
}

if let Some(cl) = parse_check_line(ln) {
props.check_lines.push(cl);
}
Expand Down Expand Up @@ -372,8 +379,8 @@ fn parse_pretty_compare_only(line: &str) -> bool {
parse_name_directive(line, "pretty-compare-only")
}

fn parse_exec_env(line: &str) -> Option<(String, String)> {
parse_name_value_directive(line, "exec-env").map(|nv| {
fn parse_env(line: &str, name: &str) -> Option<(String, String)> {
parse_name_value_directive(line, name).map(|nv| {
// nv is either FOO or FOO=BAR
let mut strs: Vec<String> = nv
.splitn(2, '=')
Expand Down
26 changes: 21 additions & 5 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,12 +863,28 @@ fn cleanup_debug_info_options(options: &Option<String>) -> Option<String> {
"-g".to_owned(),
"--debuginfo".to_owned()
];
let new_options =
let mut new_options =
split_maybe_args(options).into_iter()
.filter(|x| !options_to_remove.contains(x))
.collect::<Vec<String>>()
.join(" ");
Some(new_options)
.collect::<Vec<String>>();

let mut i = 0;
while i + 1 < new_options.len() {
if new_options[i] == "-Z" {
// FIXME #31005 MIR missing debuginfo currently.
if new_options[i + 1] == "orbit" {
// Remove "-Z" and "orbit".
new_options.remove(i);
new_options.remove(i);
continue;
}
// Always skip over -Z's argument.
i += 1;
}
i += 1;
}

Some(new_options.join(" "))
}

fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String]) {
Expand Down Expand Up @@ -1386,7 +1402,7 @@ fn compose_and_run_compiler(config: &Config, props: &TestProps,
compose_and_run(config,
testpaths,
args,
Vec::new(),
props.rustc_env.clone(),
&config.compile_lib_path,
Some(aux_dir.to_str().unwrap()),
input)
Expand Down
1 change: 1 addition & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#![feature(reflect)]
#![feature(unwind_attributes)]
#![feature(repr_simd, platform_intrinsics)]
#![feature(rustc_attrs)]
#![feature(staged_api)]
#![feature(unboxed_closures)]

Expand Down
3 changes: 3 additions & 0 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,7 @@ macro_rules! int_impl {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
#[cfg_attr(not(stage0), rustc_no_mir)] // FIXME #29769 MIR overflow checking is TBD.
pub fn pow(self, mut exp: u32) -> Self {
let mut base = self;
let mut acc = Self::one();
Expand Down Expand Up @@ -1049,6 +1050,7 @@ macro_rules! int_impl {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
#[cfg_attr(not(stage0), rustc_no_mir)] // FIXME #29769 MIR overflow checking is TBD.
pub fn abs(self) -> Self {
if self.is_negative() {
// Note that the #[inline] above means that the overflow
Expand Down Expand Up @@ -2013,6 +2015,7 @@ macro_rules! uint_impl {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
#[cfg_attr(not(stage0), rustc_no_mir)] // FIXME #29769 MIR overflow checking is TBD.
pub fn pow(self, mut exp: u32) -> Self {
let mut base = self;
let mut acc = Self::one();
Expand Down
3 changes: 3 additions & 0 deletions src/librustc/front/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use middle::def_id::DefId;

use syntax::abi::Abi;
use syntax::ast::{self, Name, NodeId, DUMMY_NODE_ID};
use syntax::attr::ThinAttributesExt;
use syntax::codemap::{Span, Spanned};
use syntax::parse::token;

Expand Down Expand Up @@ -718,6 +719,8 @@ impl<'ast> Map<'ast> {
Some(NodeTraitItem(ref ti)) => Some(&ti.attrs[..]),
Some(NodeImplItem(ref ii)) => Some(&ii.attrs[..]),
Some(NodeVariant(ref v)) => Some(&v.node.attrs[..]),
Some(NodeExpr(ref e)) => Some(e.attrs.as_attr_slice()),
Some(NodeStmt(ref s)) => Some(s.node.attrs()),
// unit/tuple structs take the attributes straight from
// the struct definition.
Some(NodeStructCtor(_)) => {
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ mod macros;
pub mod diagnostics;

pub mod back {
pub use rustc_back::abi;
pub use rustc_back::rpath;
pub use rustc_back::svh;
}
Expand Down
17 changes: 4 additions & 13 deletions src/librustc/middle/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,19 +354,10 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
self.straightline(expr, pred, Some(&**e).into_iter())
}

hir::ExprInlineAsm(ref inline_asm) => {
let inputs = inline_asm.inputs.iter();
let outputs = inline_asm.outputs.iter();
let post_inputs = self.exprs(inputs.map(|a| {
debug!("cfg::construct InlineAsm id:{} input:{:?}", expr.id, a);
let &(_, ref expr) = a;
&**expr
}), pred);
let post_outputs = self.exprs(outputs.map(|a| {
debug!("cfg::construct InlineAsm id:{} output:{:?}", expr.id, a);
&*a.expr
}), post_inputs);
self.add_ast_node(expr.id, &[post_outputs])
hir::ExprInlineAsm(_, ref outputs, ref inputs) => {
let post_outputs = self.exprs(outputs.iter().map(|e| &**e), pred);
let post_inputs = self.exprs(inputs.iter().map(|e| &**e), post_outputs);
self.add_ast_node(expr.id, &[post_inputs])
}

hir::ExprClosure(..) |
Expand Down
11 changes: 5 additions & 6 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,9 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> {
let def = self.tcx.def_map.borrow().get(&pat.id).map(|d| d.full_def());
match def {
Some(Def::AssociatedConst(did)) |
Some(Def::Const(did)) => match lookup_const_by_id(self.tcx, did,
Some(pat.id), None) {
Some((const_expr, _const_ty)) => {
Some(Def::Const(did)) => {
let substs = Some(self.tcx.node_id_item_substs(pat.id).substs);
if let Some((const_expr, _)) = lookup_const_by_id(self.tcx, did, substs) {
const_expr_to_pat(self.tcx, const_expr, pat.span).map(|new_pat| {

if let Some(ref mut renaming_map) = self.renaming_map {
Expand All @@ -487,14 +487,13 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> {

new_pat
})
}
None => {
} else {
self.failed = true;
span_err!(self.tcx.sess, pat.span, E0158,
"statics cannot be referenced in patterns");
pat
}
},
}
_ => noop_fold_pat(pat, self)
}
}
Expand Down
67 changes: 25 additions & 42 deletions src/librustc/middle/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use front::map::blocks::FnLikeNode;
use middle::cstore::{self, CrateStore, InlinedItem};
use middle::{infer, subst, traits};
use middle::def::Def;
use middle::subst::Subst;
use middle::def_id::DefId;
use middle::pat_util::def_to_path;
use middle::ty::{self, Ty, TyCtxt};
Expand Down Expand Up @@ -89,16 +88,13 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::TyCtxt,
}

/// * `def_id` is the id of the constant.
/// * `maybe_ref_id` is the id of the expr referencing the constant.
/// * `param_substs` is the monomorphization substitution for the expression.
/// * `substs` is the monomorphized substitutions for the expression.
///
/// `maybe_ref_id` and `param_substs` are optional and are used for
/// finding substitutions in associated constants. This generally
/// happens in late/trans const evaluation.
/// `substs` is optional and is used for associated constants.
/// This generally happens in late/trans const evaluation.
pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>,
def_id: DefId,
maybe_ref_id: Option<ast::NodeId>,
param_substs: Option<&'tcx subst::Substs<'tcx>>)
substs: Option<subst::Substs<'tcx>>)
-> Option<(&'tcx Expr, Option<ty::Ty<'tcx>>)> {
if let Some(node_id) = tcx.map.as_local_node_id(def_id) {
match tcx.map.find(node_id) {
Expand All @@ -111,28 +107,20 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>,
},
Some(ast_map::NodeTraitItem(ti)) => match ti.node {
hir::ConstTraitItem(_, _) => {
match maybe_ref_id {
// If we have a trait item, and we know the expression
// that's the source of the obligation to resolve it,
if let Some(substs) = substs {
// If we have a trait item and the substitutions for it,
// `resolve_trait_associated_const` will select an impl
// or the default.
Some(ref_id) => {
let trait_id = tcx.trait_of_item(def_id)
.unwrap();
let mut substs = tcx.node_id_item_substs(ref_id)
.substs;
if let Some(param_substs) = param_substs {
substs = substs.subst(tcx, param_substs);
}
resolve_trait_associated_const(tcx, ti, trait_id, substs)
}
let trait_id = tcx.trait_of_item(def_id).unwrap();
resolve_trait_associated_const(tcx, ti, trait_id, substs)
} else {
// Technically, without knowing anything about the
// expression that generates the obligation, we could
// still return the default if there is one. However,
// it's safer to return `None` than to return some value
// that may differ from what you would get from
// correctly selecting an impl.
None => None
None
}
}
_ => None
Expand All @@ -153,7 +141,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>,
}
None => {}
}
let mut used_ref_id = false;
let mut used_substs = false;
let expr_ty = match tcx.sess.cstore.maybe_get_item_ast(tcx, def_id) {
cstore::FoundAst::Found(&InlinedItem::Item(ref item)) => match item.node {
hir::ItemConst(ref ty, ref const_expr) => {
Expand All @@ -163,21 +151,15 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>,
},
cstore::FoundAst::Found(&InlinedItem::TraitItem(trait_id, ref ti)) => match ti.node {
hir::ConstTraitItem(_, _) => {
used_ref_id = true;
match maybe_ref_id {
used_substs = true;
if let Some(substs) = substs {
// As mentioned in the comments above for in-crate
// constants, we only try to find the expression for
// a trait-associated const if the caller gives us
// the expression that refers to it.
Some(ref_id) => {
let mut substs = tcx.node_id_item_substs(ref_id)
.substs;
if let Some(param_substs) = param_substs {
substs = substs.subst(tcx, param_substs);
}
resolve_trait_associated_const(tcx, ti, trait_id, substs)
}
None => None
// the substitutions for the reference to it.
resolve_trait_associated_const(tcx, ti, trait_id, substs)
} else {
None
}
}
_ => None
Expand All @@ -190,10 +172,10 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>,
},
_ => None
};
// If we used the reference expression, particularly to choose an impl
// If we used the substitutions, particularly to choose an impl
// of a trait-associated const, don't cache that, because the next
// lookup with the same def_id may yield a different result.
if !used_ref_id {
if !used_substs {
tcx.extern_const_statics
.borrow_mut()
.insert(def_id, expr_ty.map(|(e, t)| (e.id, t)));
Expand Down Expand Up @@ -389,7 +371,8 @@ pub fn const_expr_to_pat(tcx: &TyCtxt, expr: &Expr, span: Span) -> P<hir::Pat> {
PatKind::Path(path.clone()),
Some(Def::Const(def_id)) |
Some(Def::AssociatedConst(def_id)) => {
let (expr, _ty) = lookup_const_by_id(tcx, def_id, Some(expr.id), None).unwrap();
let substs = Some(tcx.node_id_item_substs(expr.id).substs);
let (expr, _ty) = lookup_const_by_id(tcx, def_id, substs).unwrap();
return const_expr_to_pat(tcx, expr, span);
},
_ => unreachable!(),
Expand Down Expand Up @@ -788,12 +771,12 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
match opt_def {
Def::Const(def_id) |
Def::AssociatedConst(def_id) => {
let maybe_ref_id = if let ExprTypeChecked = ty_hint {
Some(e.id)
let substs = if let ExprTypeChecked = ty_hint {
Some(tcx.node_id_item_substs(e.id).substs)
} else {
None
};
if let Some((e, ty)) = lookup_const_by_id(tcx, def_id, maybe_ref_id, None) {
if let Some((e, ty)) = lookup_const_by_id(tcx, def_id, substs) {
let item_hint = match ty {
Some(ty) => ty_hint.checked_or(ty),
None => ty_hint,
Expand Down Expand Up @@ -1077,7 +1060,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>,
traits::VtableImpl(ref impl_data) => {
match tcx.associated_consts(impl_data.impl_def_id)
.iter().find(|ic| ic.name == ti.name) {
Some(ic) => lookup_const_by_id(tcx, ic.def_id, None, None),
Some(ic) => lookup_const_by_id(tcx, ic.def_id, None),
None => match ti.node {
hir::ConstTraitItem(ref ty, Some(ref expr)) => {
Some((&*expr, ast_ty_to_prim_ty(tcx, ty)))
Expand Down
Loading