@@ -197,13 +197,15 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
197197 err. span_label ( span, "use of type variable from outer function" ) ;
198198
199199 let cm = resolver. session . source_map ( ) ;
200+ let mut is_self = false ;
200201 match outer_def {
201202 Def :: SelfTy ( _, maybe_impl_defid) => {
202203 if let Some ( impl_span) = maybe_impl_defid. map_or ( None ,
203204 |def_id| resolver. definitions . opt_span ( def_id) ) {
204205 err. span_label ( reduce_impl_span_to_impl_keyword ( cm, impl_span) ,
205206 "`Self` type implicitly declared here, on the `impl`" ) ;
206207 }
208+ is_self = true ;
207209 } ,
208210 Def :: TyParam ( typaram_defid) => {
209211 if let Some ( typaram_span) = resolver. definitions . opt_span ( typaram_defid) {
@@ -219,7 +221,12 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
219221 // Try to retrieve the span of the function signature and generate a new message with
220222 // a local type parameter
221223 let sugg_msg = "try using a local type parameter instead" ;
222- if let Some ( ( sugg_span, new_snippet) ) = cm. generate_local_type_param_snippet ( span) {
224+ if is_self {
225+ // Suggest using the actual type
226+ err. span_label ( span, "use a materialized type here instead" ) ;
227+ } else if let Some (
228+ ( sugg_span, new_snippet) ,
229+ ) = cm. generate_local_type_param_snippet ( span) {
223230 // Suggest the modification to the user
224231 err. span_suggestion_with_applicability (
225232 sugg_span,
0 commit comments