fix own_substs
ICE
This commit is contained in:
parent
ee1c3b385b
commit
0b6fa0d418
@ -902,11 +902,18 @@ fn expr_inferred_subst_iter(
|
||||
// impl is currently the `DefId` of `Output` in the trait definition
|
||||
// which makes this somewhat difficult and prevents us from just
|
||||
// using `self.path_inferred_subst_iter` here.
|
||||
hir::ExprKind::Struct(&hir::QPath::Resolved(_self_ty, path), _, _) => {
|
||||
if let Some(ty) = self.opt_node_type(expr.hir_id) {
|
||||
if let ty::Adt(_, substs) = ty.kind() {
|
||||
return Box::new(self.resolved_path_inferred_subst_iter(path, substs));
|
||||
}
|
||||
hir::ExprKind::Struct(&hir::QPath::Resolved(_self_ty, path), _, _)
|
||||
// FIXME(TaKO8Ki): Ideally we should support this. For that
|
||||
// we have to map back from the self type to the
|
||||
// type alias though. That's difficult.
|
||||
//
|
||||
// See the `need_type_info/issue-103053.rs` test for
|
||||
// a example.
|
||||
if !matches!(path.res, Res::Def(DefKind::TyAlias, _)) => {
|
||||
if let Some(ty) = self.opt_node_type(expr.hir_id)
|
||||
&& let ty::Adt(_, substs) = ty.kind()
|
||||
{
|
||||
return Box::new(self.resolved_path_inferred_subst_iter(path, substs));
|
||||
}
|
||||
}
|
||||
hir::ExprKind::MethodCall(segment, ..) => {
|
||||
|
18
src/test/ui/inference/need_type_info/issue-103053.rs
Normal file
18
src/test/ui/inference/need_type_info/issue-103053.rs
Normal file
@ -0,0 +1,18 @@
|
||||
trait TypeMapper {
|
||||
type MapType;
|
||||
}
|
||||
|
||||
type Mapped<T> = <T as TypeMapper>::MapType;
|
||||
|
||||
struct Test {}
|
||||
|
||||
impl TypeMapper for () {
|
||||
type MapType = Test;
|
||||
}
|
||||
|
||||
fn test() {
|
||||
Mapped::<()> {};
|
||||
None; //~ ERROR type annotations needed
|
||||
}
|
||||
|
||||
fn main() {}
|
14
src/test/ui/inference/need_type_info/issue-103053.stderr
Normal file
14
src/test/ui/inference/need_type_info/issue-103053.stderr
Normal file
@ -0,0 +1,14 @@
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/issue-103053.rs:15:5
|
||||
|
|
||||
LL | None;
|
||||
| ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
|
||||
|
|
||||
help: consider specifying the generic argument
|
||||
|
|
||||
LL | None::<T>;
|
||||
| +++++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0282`.
|
Loading…
Reference in New Issue
Block a user