11use crate :: base:: * ;
22use crate :: config:: StripUnconfigured ;
33use crate :: errors:: {
4- EmptyDelegationMac , GlobDelegationOutsideImpls , IncompleteParse , RecursionLimitReached ,
5- RemoveExprNotSupported , RemoveNodeNotSupported , UnsupportedKeyValue , WrongFragmentKind ,
4+ EmptyDelegationMac , GlobDelegationOutsideImpls , GlobDelegationTraitlessQpath , IncompleteParse ,
5+ RecursionLimitReached , RemoveExprNotSupported , RemoveNodeNotSupported , UnsupportedKeyValue ,
6+ WrongFragmentKind ,
67} ;
78use crate :: mbe:: diagnostics:: annotate_err_with_kind;
89use crate :: module:: { mod_dir_path, parse_external_mod, DirOwnership , ParsedExternalMod } ;
@@ -1989,6 +1990,8 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
19891990 }
19901991 None if let Some ( ( deleg, item) ) = node. delegation ( ) => {
19911992 let Some ( suffixes) = & deleg. suffixes else {
1993+ let traitless_qself =
1994+ matches ! ( & deleg. qself, Some ( qself) if qself. position == 0 ) ;
19921995 let item = match node. to_annotatable ( ) {
19931996 Annotatable :: ImplItem ( item) => item,
19941997 ann @ ( Annotatable :: Item ( _)
@@ -2000,6 +2003,11 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
20002003 }
20012004 _ => unreachable ! ( ) ,
20022005 } ;
2006+ if traitless_qself {
2007+ let span = item. span ;
2008+ self . cx . dcx ( ) . emit_err ( GlobDelegationTraitlessQpath { span } ) ;
2009+ return Default :: default ( ) ;
2010+ }
20032011 return self . collect_glob_delegation ( item, Node :: KIND ) . make_ast :: < Node > ( ) ;
20042012 } ;
20052013
0 commit comments