summary refs log tree commit diff
path: root/src/librustc_const_eval
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-06-01 11:34:13 +0000
committerbors <bors@rust-lang.org>2017-06-01 11:34:13 +0000
commit4ed2edaafe82fb8d44e81e00ca3e4f7659855ba2 (patch)
treebac575e79cb4c10b9ad04ddc752c1428735291e4 /src/librustc_const_eval
parentafd4b81c8642016dcb3a641d45a1258193dab958 (diff)
parent5fb37beecdb7827aada42a2ab4e7e0228d02c13a (diff)
downloadrust-4ed2edaafe82fb8d44e81e00ca3e4f7659855ba2.tar.gz
rust-4ed2edaafe82fb8d44e81e00ca3e4f7659855ba2.zip
Auto merge of #42281 - eddyb:well-adjusted, r=nikomatsakis
Decompose Adjustment into smaller steps and remove the method map.

The method map held method callee information for:
* actual method calls (`x.f(...)`)
* overloaded unary, binary, indexing and call operators
* *every overloaded deref adjustment* (many can exist for each expression)

That last one was a historical ~~accident~~ hack, and part of the motivation for this PR, along with:
* a desire to compose adjustments more freely
* containing the autoderef logic better to avoid mutation within an inference snapshot
* not creating `TyFnDef` types which are incompatible with the original one
  * i.e. we used to take a`TyFnDef`'s `for<'a> &'a T -> &'a U` signature and instantiate `'a` using a region inference variable, *then* package the resulting `&'b T -> &'b U` signature in another `TyFnDef`, while keeping *the same* `DefId` and `Substs`
* to fix #3548 by explicitly writing autorefs for the RHS of comparison operators

Individual commits tell their own story, of "atomic" changes avoiding breaking semantics.

Future work based on this PR could include:
* removing the signature from `TyFnDef`, now that it's always "canonical"
  * some questions of variance remain, as subtyping *still* treats the signature differently
* moving part of the typeck logic for methods, autoderef and coercion into `rustc::traits`
* allowing LUB coercions (joining multiple expressions) to "stack up" many adjustments
* transitive coercions (e.g. reify or unsize after multiple steps of autoderef)

r? @nikomatsakis
Diffstat (limited to 'src/librustc_const_eval')
-rw-r--r--src/librustc_const_eval/eval.rs3
-rw-r--r--src/librustc_const_eval/pattern.rs3
2 files changed, 2 insertions, 4 deletions
diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs
index e79f23aee11..a6b39f22277 100644
--- a/src/librustc_const_eval/eval.rs
+++ b/src/librustc_const_eval/eval.rs
@@ -286,8 +286,7 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>,
         }
       }
       hir::ExprPath(ref qpath) => {
-        let substs = cx.tables.node_id_item_substs(e.id)
-            .unwrap_or_else(|| tcx.intern_substs(&[]));
+        let substs = cx.tables.node_substs(e.id);
 
         // Avoid applying substitutions if they're empty, that'd ICE.
         let substs = if cx.substs.is_empty() {
diff --git a/src/librustc_const_eval/pattern.rs b/src/librustc_const_eval/pattern.rs
index a2e0bb80d23..d175920e8a6 100644
--- a/src/librustc_const_eval/pattern.rs
+++ b/src/librustc_const_eval/pattern.rs
@@ -584,8 +584,7 @@ impl<'a, 'gcx, 'tcx> PatternContext<'a, 'gcx, 'tcx> {
         let kind = match def {
             Def::Const(def_id) | Def::AssociatedConst(def_id) => {
                 let tcx = self.tcx.global_tcx();
-                let substs = self.tables.node_id_item_substs(id)
-                    .unwrap_or_else(|| tcx.intern_substs(&[]));
+                let substs = self.tables.node_substs(id);
                 match eval::lookup_const_by_id(tcx, def_id, substs) {
                     Some((def_id, _substs)) => {
                         // Enter the inlined constant's tables temporarily.