Get some more rustc tests working
This commit is contained in:
parent
fb96a090af
commit
88fc45b37c
@ -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),
|
||||
_ => {}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
|
20
tests/run-pass/issue-27901.rs
Normal file
20
tests/run-pass/issue-27901.rs
Normal file
@ -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));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user