mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 14:31:55 +00:00
Rollup merge of #59118 - seanmonstar:alias-where-self-ice, r=alexreg
rustc: fix ICE when trait alias has bare Self Fixes https://github.com/rust-lang/rust/issues/59029
This commit is contained in:
commit
464478fbbb
@ -541,7 +541,8 @@ impl<'hir> Map<'hir> {
|
||||
|
||||
pub fn ty_param_owner(&self, id: HirId) -> HirId {
|
||||
match self.get_by_hir_id(id) {
|
||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) => id,
|
||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
|
||||
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id,
|
||||
Node::GenericParam(_) => self.get_parent_node_by_hir_id(id),
|
||||
_ => bug!("ty_param_owner: {} not a type parameter", self.hir_to_string(id))
|
||||
}
|
||||
@ -549,7 +550,8 @@ impl<'hir> Map<'hir> {
|
||||
|
||||
pub fn ty_param_name(&self, id: HirId) -> Name {
|
||||
match self.get_by_hir_id(id) {
|
||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) => keywords::SelfUpper.name(),
|
||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
|
||||
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => keywords::SelfUpper.name(),
|
||||
Node::GenericParam(param) => param.name.ident().name,
|
||||
_ => bug!("ty_param_name: {} not a type parameter", self.hir_to_string(id)),
|
||||
}
|
||||
|
8
src/test/ui/issues/issue-59029-1.rs
Normal file
8
src/test/ui/issues/issue-59029-1.rs
Normal file
@ -0,0 +1,8 @@
|
||||
#![feature(trait_alias)]
|
||||
|
||||
trait Svc<Req> { type Res; }
|
||||
|
||||
trait MkSvc<Target, Req> = Svc<Target> where Self::Res: Svc<Req>;
|
||||
//~^ ERROR associated type `Res` not found for `Self`
|
||||
|
||||
fn main() {}
|
9
src/test/ui/issues/issue-59029-1.stderr
Normal file
9
src/test/ui/issues/issue-59029-1.stderr
Normal file
@ -0,0 +1,9 @@
|
||||
error[E0220]: associated type `Res` not found for `Self`
|
||||
--> $DIR/issue-59029-1.rs:5:46
|
||||
|
|
||||
LL | trait MkSvc<Target, Req> = Svc<Target> where Self::Res: Svc<Req>;
|
||||
| ^^^^^^^^^ associated type `Res` not found
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0220`.
|
8
src/test/ui/issues/issue-59029-2.rs
Normal file
8
src/test/ui/issues/issue-59029-2.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// run-pass
|
||||
#![feature(trait_alias)]
|
||||
|
||||
trait Svc<Req> { type Res; }
|
||||
|
||||
trait MkSvc<Target, Req> = Svc<Target> where <Self as Svc<Target>>::Res: Svc<Req>;
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user