@@ -1763,13 +1763,33 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
17631763 // to something unusable as a pattern (e.g., constructor function),
17641764 // but we still conservatively report an error, see
17651765 // issues/33118#issuecomment-233962221 for one reason why.
1766+ let binding = binding. expect ( "no binding for a ctor or static" ) ;
17661767 self . report_error (
17671768 ident. span ,
1768- ResolutionError :: BindingShadowsSomethingUnacceptable (
1769- pat_src. descr ( ) ,
1770- ident. name ,
1771- binding. expect ( "no binding for a ctor or static" ) ,
1772- ) ,
1769+ ResolutionError :: BindingShadowsSomethingUnacceptable {
1770+ shadowing_binding_descr : pat_src. descr ( ) ,
1771+ name : ident. name ,
1772+ participle : if binding. is_import ( ) { "imported" } else { "defined" } ,
1773+ article : binding. res ( ) . article ( ) ,
1774+ shadowed_binding_descr : binding. res ( ) . descr ( ) ,
1775+ shadowed_binding_span : binding. span ,
1776+ } ,
1777+ ) ;
1778+ None
1779+ }
1780+ Res :: Def ( DefKind :: ConstParam , def_id) => {
1781+ // Same as for DefKind::Const above, but here, `binding` is `None`, so we
1782+ // have to construct the error differently
1783+ self . report_error (
1784+ ident. span ,
1785+ ResolutionError :: BindingShadowsSomethingUnacceptable {
1786+ shadowing_binding_descr : pat_src. descr ( ) ,
1787+ name : ident. name ,
1788+ participle : "defined" ,
1789+ article : res. article ( ) ,
1790+ shadowed_binding_descr : res. descr ( ) ,
1791+ shadowed_binding_span : self . r . opt_span ( def_id) . expect ( "const parameter defined outside of local crate" ) ,
1792+ }
17731793 ) ;
17741794 None
17751795 }
0 commit comments