Rollup merge of #34495 - jseyfried:only_ident_macro_invocations, r=eddyb
Forbid type parameters and global paths in macro invocations Fixes #28558. This is a [breaking-change]. For example, the following would break: ```rust macro_rules! m { () => { () } } fn main() { m::<T>!(); // Type parameters are no longer allowed in macro invocations ::m!(); // Global paths are no longer allowed in macro invocations } ``` Any breakage can be fixed by removing the type parameters or the leading `::` (respectively). r? @eddyb
This commit is contained in:
@@ -202,7 +202,7 @@ fn expand_mac_invoc<T>(mac: ast::Mac, ident: Option<Ident>, attrs: Vec<ast::Attr
|
|||||||
&fld.cx.ecfg.features.unwrap());
|
&fld.cx.ecfg.features.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
if path.segments.len() > 1 {
|
if path.segments.len() > 1 || path.global || !path.segments[0].parameters.is_empty() {
|
||||||
fld.cx.span_err(path.span, "expected macro name without module separators");
|
fld.cx.span_err(path.span, "expected macro name without module separators");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// error-pattern:expected macro name without module separators
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
globnar::brotz!();
|
globnar::brotz!(); //~ ERROR expected macro name without module separators
|
||||||
|
::foo!(); //~ ERROR expected macro name without module separators
|
||||||
|
foo::<T>!(); //~ ERROR expected macro name without module separators
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user