@@ -214,6 +214,8 @@ enum ResolutionError<'a> {
214
214
BindingShadowsSomethingUnacceptable ( & ' a str , Name , & ' a NameBinding < ' a > ) ,
215
215
/// Error E0128: type parameters with a default cannot use forward-declared identifiers.
216
216
ForwardDeclaredTyParam , // FIXME(const_generics:defaults)
217
+ /// Error E0735: type parameters with a default cannot use `Self`
218
+ SelfInTyParamDefault ,
217
219
/// Error E0671: const parameter cannot depend on type parameter.
218
220
ConstParamDependentOnTypeParam ,
219
221
}
@@ -1536,7 +1538,7 @@ impl<'a> Resolver<'a> {
1536
1538
if let Some ( res) = ribs[ i] . bindings . get ( & rib_ident) . cloned ( ) {
1537
1539
// The ident resolves to a type parameter or local variable.
1538
1540
return Some ( LexicalScopeBinding :: Res (
1539
- self . validate_res_from_ribs ( i, res, record_used, path_span, ribs) ,
1541
+ self . validate_res_from_ribs ( i, rib_ident , res, record_used, path_span, ribs) ,
1540
1542
) ) ;
1541
1543
}
1542
1544
@@ -2122,6 +2124,7 @@ impl<'a> Resolver<'a> {
2122
2124
fn validate_res_from_ribs (
2123
2125
& mut self ,
2124
2126
rib_index : usize ,
2127
+ rib_ident : Ident ,
2125
2128
res : Res ,
2126
2129
record_used : bool ,
2127
2130
span : Span ,
@@ -2133,7 +2136,12 @@ impl<'a> Resolver<'a> {
2133
2136
// An invalid forward use of a type parameter from a previous default.
2134
2137
if let ForwardTyParamBanRibKind = all_ribs[ rib_index] . kind {
2135
2138
if record_used {
2136
- self . report_error ( span, ResolutionError :: ForwardDeclaredTyParam ) ;
2139
+ let res_error = if rib_ident. name == kw:: SelfUpper {
2140
+ ResolutionError :: SelfInTyParamDefault
2141
+ } else {
2142
+ ResolutionError :: ForwardDeclaredTyParam
2143
+ } ;
2144
+ self . report_error ( span, res_error) ;
2137
2145
}
2138
2146
assert_eq ! ( res, Res :: Err ) ;
2139
2147
return Res :: Err ;
0 commit comments