@@ -198,12 +198,25 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
198198
199199 let cm = resolver. session . source_map ( ) ;
200200 match outer_def {
201- Def :: SelfTy ( _, maybe_impl_defid) => {
202- if let Some ( impl_span) = maybe_impl_defid. map_or ( None ,
203- |def_id| resolver. definitions . opt_span ( def_id) ) {
204- err. span_label ( reduce_impl_span_to_impl_keyword ( cm, impl_span) ,
205- "`Self` type implicitly declared here, on the `impl`" ) ;
201+ Def :: SelfTy ( maybe_trait_defid, maybe_impl_defid) => {
202+ if let Some ( impl_span) = maybe_impl_defid. and_then ( |def_id| {
203+ resolver. definitions . opt_span ( def_id)
204+ } ) {
205+ err. span_label (
206+ reduce_impl_span_to_impl_keyword ( cm, impl_span) ,
207+ "`Self` type implicitly declared here, by this `impl`" ,
208+ ) ;
209+ }
210+ match ( maybe_trait_defid, maybe_impl_defid) {
211+ ( Some ( _) , None ) => {
212+ err. span_label ( span, "can't use `Self` here" ) ;
213+ }
214+ ( _, Some ( _) ) => {
215+ err. span_label ( span, "use a type here instead" ) ;
216+ }
217+ ( None , None ) => bug ! ( "`impl` without trait nor type?" ) ,
206218 }
219+ return err;
207220 } ,
208221 Def :: TyParam ( typaram_defid) => {
209222 if let Some ( typaram_span) = resolver. definitions . opt_span ( typaram_defid) {
0 commit comments