Rollup merge of #61118 - pnkfelix:issue-60654-dont-ice-on-gat, r=varkor
Dont ICE on an attempt to use GAT without feature gate Fix #60654
This commit is contained in:
commit
57139e2055
|
@ -658,12 +658,15 @@ impl<'tcx> ScopeTree {
|
||||||
// The lifetime was defined on node that doesn't own a body,
|
// The lifetime was defined on node that doesn't own a body,
|
||||||
// which in practice can only mean a trait or an impl, that
|
// which in practice can only mean a trait or an impl, that
|
||||||
// is the parent of a method, and that is enforced below.
|
// is the parent of a method, and that is enforced below.
|
||||||
assert_eq!(Some(param_owner_id), self.root_parent,
|
if Some(param_owner_id) != self.root_parent {
|
||||||
"free_scope: {:?} not recognized by the \
|
tcx.sess.delay_span_bug(
|
||||||
region scope tree for {:?} / {:?}",
|
DUMMY_SP,
|
||||||
param_owner,
|
&format!("free_scope: {:?} not recognized by the \
|
||||||
self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)),
|
region scope tree for {:?} / {:?}",
|
||||||
self.root_body.map(|hir_id| DefId::local(hir_id.owner)));
|
param_owner,
|
||||||
|
self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)),
|
||||||
|
self.root_body.map(|hir_id| DefId::local(hir_id.owner))));
|
||||||
|
}
|
||||||
|
|
||||||
// The trait/impl lifetime is in scope for the method's body.
|
// The trait/impl lifetime is in scope for the method's body.
|
||||||
self.root_body.unwrap().local_id
|
self.root_body.unwrap().local_id
|
||||||
|
|
|
@ -479,21 +479,22 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx> {
|
||||||
// the specialized routine `ty::replace_late_regions()`.
|
// the specialized routine `ty::replace_late_regions()`.
|
||||||
match *r {
|
match *r {
|
||||||
ty::ReEarlyBound(data) => {
|
ty::ReEarlyBound(data) => {
|
||||||
let r = self.substs.get(data.index as usize).map(|k| k.unpack());
|
let rk = self.substs.get(data.index as usize).map(|k| k.unpack());
|
||||||
match r {
|
match rk {
|
||||||
Some(UnpackedKind::Lifetime(lt)) => {
|
Some(UnpackedKind::Lifetime(lt)) => {
|
||||||
self.shift_region_through_binders(lt)
|
self.shift_region_through_binders(lt)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let span = self.span.unwrap_or(DUMMY_SP);
|
let span = self.span.unwrap_or(DUMMY_SP);
|
||||||
span_bug!(
|
let msg = format!(
|
||||||
span,
|
|
||||||
"Region parameter out of range \
|
"Region parameter out of range \
|
||||||
when substituting in region {} (root type={:?}) \
|
when substituting in region {} (root type={:?}) \
|
||||||
(index={})",
|
(index={})",
|
||||||
data.name,
|
data.name,
|
||||||
self.root_ty,
|
self.root_ty,
|
||||||
data.index);
|
data.index);
|
||||||
|
self.tcx.sess.delay_span_bug(span, &msg);
|
||||||
|
r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
// rust-lang/rust#60654: Do not ICE on an attempt to use GATs that is
|
||||||
|
// missing the feature gate.
|
||||||
|
|
||||||
|
struct Foo;
|
||||||
|
|
||||||
|
impl Iterator for Foo {
|
||||||
|
type Item<'b> = &'b Foo; //~ ERROR generic associated types are unstable [E0658]
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() { }
|
|
@ -0,0 +1,12 @@
|
||||||
|
error[E0658]: generic associated types are unstable
|
||||||
|
--> $DIR/gat-dont-ice-on-absent-feature.rs:7:5
|
||||||
|
|
|
||||||
|
LL | type Item<'b> = &'b Foo;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/44265
|
||||||
|
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0658`.
|
Loading…
Reference in New Issue