Do not panic in return_type_impl_trait
This commit is contained in:
parent
f1e691da2e
commit
a141d29612
@ -44,6 +44,7 @@
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_hir::{
|
||||
Constness, HirId, ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet, Node, TraitCandidate,
|
||||
TraitItemKind,
|
||||
};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_macros::HashStable;
|
||||
@ -1509,6 +1510,12 @@ pub fn return_type_impl_trait(self, scope_def_id: LocalDefId) -> Option<(Ty<'tcx
|
||||
}
|
||||
}
|
||||
}
|
||||
Node::TraitItem(item) => {
|
||||
// #86483: Return early if it doesn't have a concrete type.
|
||||
if let TraitItemKind::Type(_, None) = item.kind {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
_ => { /* `type_of_def_id()` will work or panic */ }
|
||||
}
|
||||
|
||||
|
15
src/test/ui/generic-associated-types/issue-86483.rs
Normal file
15
src/test/ui/generic-associated-types/issue-86483.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Regression test of #86483.
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
pub trait IceIce<T> //~ ERROR: the parameter type `T` may not live long enough
|
||||
where
|
||||
for<'a> T: 'a,
|
||||
{
|
||||
type Ice<'v>: IntoIterator<Item = &'v T>;
|
||||
//~^ ERROR: the parameter type `T` may not live long enough
|
||||
//~| ERROR: the parameter type `T` may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
36
src/test/ui/generic-associated-types/issue-86483.stderr
Normal file
36
src/test/ui/generic-associated-types/issue-86483.stderr
Normal file
@ -0,0 +1,36 @@
|
||||
error[E0311]: the parameter type `T` may not live long enough
|
||||
--> $DIR/issue-86483.rs:6:1
|
||||
|
|
||||
LL | pub trait IceIce<T>
|
||||
| ^ - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
| _|
|
||||
| |
|
||||
LL | | where
|
||||
LL | | for<'a> T: 'a,
|
||||
LL | | {
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0311]: the parameter type `T` may not live long enough
|
||||
--> $DIR/issue-86483.rs:10:5
|
||||
|
|
||||
LL | pub trait IceIce<T>
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
...
|
||||
LL | type Ice<'v>: IntoIterator<Item = &'v T>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/issue-86483.rs:10:32
|
||||
|
|
||||
LL | pub trait IceIce<T>
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'v`
|
||||
...
|
||||
LL | type Ice<'v>: IntoIterator<Item = &'v T>;
|
||||
| ^^^^^^^^^^^^ ...so that the reference type `&'v T` does not outlive the data it points at
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0309`.
|
Loading…
Reference in New Issue
Block a user