about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2017-08-29 11:32:10 +0200
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2017-08-29 11:58:22 +0200
commit88fc45b37cb6bdae3d7102e79e247179a4130b2d (patch)
treea268846a5cf215ff320f7f152bb54cc443f2873a
parentfb96a090af28b01ff1eb8318d0a5a5de60a64b97 (diff)
downloadrust-88fc45b37cb6bdae3d7102e79e247179a4130b2d.tar.gz
rust-88fc45b37cb6bdae3d7102e79e247179a4130b2d.zip
Get some more rustc tests working
-rw-r--r--miri/fn_call.rs1
-rw-r--r--src/librustc_mir/interpret/eval_context.rs13
-rw-r--r--src/librustc_mir/interpret/terminator/mod.rs7
-rw-r--r--tests/run-pass/issue-27901.rs20
4 files changed, 27 insertions, 14 deletions
diff --git a/miri/fn_call.rs b/miri/fn_call.rs
index 7dc8f54849f..a74a53fa758 100644
--- a/miri/fn_call.rs
+++ b/miri/fn_call.rs
@@ -522,6 +522,7 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
         // In some cases in non-MIR libstd-mode, not having a destination is legit.  Handle these early.
         match &path[..] {
             "std::panicking::rust_panic_with_hook" |
+            "core::panicking::panic_fmt::::panic_impl" |
             "std::rt::begin_panic_fmt" => return err!(Panic),
             _ => {}
         }
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index 044f37947d3..2a4515959d1 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -9,7 +9,7 @@ use rustc::mir;
 use rustc::traits::Reveal;
 use rustc::ty::layout::{self, Layout, Size, Align, HasDataLayout};
 use rustc::ty::subst::{Subst, Substs, Kind};
-use rustc::ty::{self, Ty, TyCtxt, TypeFoldable, Binder};
+use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
 use rustc_data_structures::indexed_vec::Idx;
 use syntax::codemap::{self, DUMMY_SP};
 use syntax::ast::Mutability;
@@ -282,15 +282,8 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
         // let's simply get rid of them
         let without_lifetimes = self.tcx.erase_regions(&ty);
         let substituted = without_lifetimes.subst(self.tcx, substs);
-        self.tcx.normalize_associated_type(&substituted)
-    }
-
-    pub fn erase_lifetimes<T>(&self, value: &Binder<T>) -> T
-    where
-        T: TypeFoldable<'tcx>,
-    {
-        let value = self.tcx.erase_late_bound_regions(value);
-        self.tcx.erase_regions(&value)
+        let substituted = self.tcx.normalize_associated_type(&substituted);
+        substituted
     }
 
     /// Return the size and aligment of the value at the given type.
diff --git a/src/librustc_mir/interpret/terminator/mod.rs b/src/librustc_mir/interpret/terminator/mod.rs
index 60893fcec18..ebd6649c447 100644
--- a/src/librustc_mir/interpret/terminator/mod.rs
+++ b/src/librustc_mir/interpret/terminator/mod.rs
@@ -75,9 +75,8 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
                         match instance_ty.sty {
                             ty::TyFnDef(..) => {
                                 let real_sig = instance_ty.fn_sig(self.tcx);
-                                let sig = self.erase_lifetimes(&sig);
-                                let real_sig = self.erase_lifetimes(&real_sig);
-                                let real_sig = self.tcx.normalize_associated_type(&real_sig);
+                                let sig = self.tcx.erase_late_bound_regions_and_normalize(&sig);
+                                let real_sig = self.tcx.erase_late_bound_regions_and_normalize(&real_sig);
                                 if !self.check_sig_compat(sig, real_sig)? {
                                     return err!(FunctionPointerTyMismatch(real_sig, sig));
                                 }
@@ -96,7 +95,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
                     }
                 };
                 let args = self.operands_to_args(args)?;
-                let sig = self.erase_lifetimes(&sig);
+                let sig = self.tcx.erase_late_bound_regions_and_normalize(&sig);
                 self.eval_fn_call(
                     fn_def,
                     destination,
diff --git a/tests/run-pass/issue-27901.rs b/tests/run-pass/issue-27901.rs
new file mode 100644
index 00000000000..b7a9daaf8ab
--- /dev/null
+++ b/tests/run-pass/issue-27901.rs
@@ -0,0 +1,20 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+trait Stream { type Item; }
+impl<'a> Stream for &'a str { type Item = u8; }
+fn f<'s>(s: &'s str) -> (&'s str, <&'s str as Stream>::Item) {
+    (s, 42)
+}
+
+fn main() {
+    let fx = f as for<'t> fn(&'t str) -> (&'t str, <&'t str as Stream>::Item);
+    assert_eq!(fx("hi"), ("hi", 42));
+}