提交 58b75f7a 编写于 作者: N Niko Matsakis

loosen assertion against proj in collector

The collector was asserting a total absence of projections, but some
projections are expected, even in trans: in particular, projections
containing higher-ranked regions, which we don't currently normalize.
上级 95487305
......@@ -107,6 +107,11 @@ fn add_sty(&mut self, st: &ty::TypeVariants) {
}
&ty::TyProjection(ref data) => {
// currently we can't normalize projections that
// include bound regions, so track those separately.
if !data.has_escaping_regions() {
self.add_flags(TypeFlags::HAS_NORMALIZABLE_PROJECTION);
}
self.add_flags(TypeFlags::HAS_PROJECTION);
self.add_projection_ty(data);
}
......
......@@ -105,7 +105,7 @@ fn is_normalized_for_trans(&self) -> bool {
TypeFlags::HAS_FREE_REGIONS |
TypeFlags::HAS_TY_INFER |
TypeFlags::HAS_PARAMS |
TypeFlags::HAS_PROJECTION |
TypeFlags::HAS_NORMALIZABLE_PROJECTION |
TypeFlags::HAS_TY_ERR |
TypeFlags::HAS_SELF)
}
......
......@@ -462,6 +462,10 @@ pub enum FragmentInfo {
// Only set for TyInfer other than Fresh.
const KEEP_IN_LOCAL_TCX = 1 << 11,
// Is there a projection that does not involve a bound region?
// Currently we can't normalize projections w/ bound regions.
const HAS_NORMALIZABLE_PROJECTION = 1 << 12,
const NEEDS_SUBST = TypeFlags::HAS_PARAMS.bits |
TypeFlags::HAS_SELF.bits |
TypeFlags::HAS_RE_EARLY_BOUND.bits,
......
......@@ -1019,7 +1019,9 @@ fn create_fn_trans_item<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
let concrete_substs = monomorphize::apply_param_substs(scx,
param_substs,
&fn_substs);
assert!(concrete_substs.is_normalized_for_trans());
assert!(concrete_substs.is_normalized_for_trans(),
"concrete_substs not normalized for trans: {:?}",
concrete_substs);
TransItem::Fn(Instance::new(def_id, concrete_substs))
}
......
// Copyright 2014 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.
// Regression test for #36381. The trans collector was asserting that
// there are no projection types, but the `<&str as
// StreamOnce>::Position` projection contained a late-bound region,
// and we don't currently normalize in that case until the function is
// actually invoked.
pub trait StreamOnce {
type Position;
}
impl<'a> StreamOnce for &'a str {
type Position = usize;
}
pub fn parser<F>(_: F) {
}
fn follow(_: &str) -> <&str as StreamOnce>::Position {
panic!()
}
fn main() {
parser(follow);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册