/// into libsyntax itself.
///
/// For more information, see documentation for `std`'s macros.
+#[cfg(dox)]
mod builtin {
/// Unconditionally causes compilation to fail with the given error message when encountered.
///
/// [`std::compile_error!`]: ../std/macro.compile_error.html
#[stable(feature = "compile_error_macro", since = "1.20.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! compile_error {
($msg:expr) => ({ /* compiler built-in */ });
($msg:expr,) => ({ /* compiler built-in */ });
///
/// [`std::format_args!`]: ../std/macro.format_args.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! format_args {
($fmt:expr) => ({ /* compiler built-in */ });
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ });
///
/// [`std::env!`]: ../std/macro.env.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! env {
($name:expr) => ({ /* compiler built-in */ });
($name:expr,) => ({ /* compiler built-in */ });
///
/// [`std::option_env!`]: ../std/macro.option_env.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! option_env {
($name:expr) => ({ /* compiler built-in */ });
($name:expr,) => ({ /* compiler built-in */ });
///
/// [`std::concat_idents!`]: ../std/macro.concat_idents.html
#[unstable(feature = "concat_idents_macro", issue = "29599")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! concat_idents {
($($e:ident),+) => ({ /* compiler built-in */ });
($($e:ident,)+) => ({ /* compiler built-in */ });
///
/// [`std::concat!`]: ../std/macro.concat.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! concat {
($($e:expr),*) => ({ /* compiler built-in */ });
($($e:expr,)*) => ({ /* compiler built-in */ });
///
/// [`std::line!`]: ../std/macro.line.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! line { () => ({ /* compiler built-in */ }) }
/// A macro which expands to the column number on which it was invoked.
///
/// [`std::column!`]: ../std/macro.column.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! column { () => ({ /* compiler built-in */ }) }
/// A macro which expands to the file name from which it was invoked.
///
/// [`std::file!`]: ../std/macro.file.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! file { () => ({ /* compiler built-in */ }) }
/// A macro which stringifies its arguments.
///
/// [`std::stringify!`]: ../std/macro.stringify.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! stringify { ($($t:tt)*) => ({ /* compiler built-in */ }) }
/// Includes a utf8-encoded file as a string.
///
/// [`std::include_str!`]: ../std/macro.include_str.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! include_str {
($file:expr) => ({ /* compiler built-in */ });
($file:expr,) => ({ /* compiler built-in */ });
///
/// [`std::include_bytes!`]: ../std/macro.include_bytes.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! include_bytes {
($file:expr) => ({ /* compiler built-in */ });
($file:expr,) => ({ /* compiler built-in */ });
///
/// [`std::module_path!`]: ../std/macro.module_path.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! module_path { () => ({ /* compiler built-in */ }) }
/// Boolean evaluation of configuration flags, at compile-time.
///
/// [`std::cfg!`]: ../std/macro.cfg.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
/// Parse a file as an expression or an item according to the context.
///
/// [`std::include!`]: ../std/macro.include.html
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
- #[cfg(dox)]
+ #[rustc_doc_only_macro]
macro_rules! include {
($file:expr) => ({ /* compiler built-in */ });
($file:expr,) => ({ /* compiler built-in */ });
/// For more information, see the documentation for [`std::assert!`].
///
/// [`std::assert!`]: ../std/macro.assert.html
- #[macro_export]
+ #[rustc_doc_only_macro]
#[stable(feature = "rust1", since = "1.0.0")]
- #[cfg(dox)]
macro_rules! assert {
($cond:expr) => ({ /* compiler built-in */ });
($cond:expr,) => ({ /* compiler built-in */ });
let mut vis = self.lower_visibility(&i.vis, None);
let attrs = self.lower_attrs(&i.attrs);
if let ItemKind::MacroDef(ref def) = i.node {
- if !def.legacy || attr::contains_name(&i.attrs, "macro_export") {
+ if !def.legacy || attr::contains_name(&i.attrs, "macro_export") ||
+ attr::contains_name(&i.attrs, "rustc_doc_only_macro") {
let body = self.lower_token_stream(def.stream());
self.exported_macros.push(hir::MacroDef {
name,
.resolve_macro_to_def_inner(mark, &path, MacroKind::Bang, false);
if let Ok(def) = res {
if let SyntaxExtension::DeclMacro { .. } = *resolver.get_macro(def) {
- Some(def)
- } else {
- None
+ return Some(def);
}
- } else if let Some(def) = resolver.all_macros.get(&Symbol::intern(path_str)) {
- Some(*def)
- } else {
- None
}
+ if let Some(def) = resolver.all_macros.get(&Symbol::intern(path_str)) {
+ return Some(*def);
+ }
+ None
}
#[derive(Debug)]
/// macro, but are documented here. Their implementations can be found hardcoded
/// into libsyntax itself.
#[cfg(dox)]
-pub mod builtin {
+mod builtin {
/// Unconditionally causes compilation to fail with the given error message when encountered.
///
///
/// [`panic!`]: ../std/macro.panic.html
#[stable(feature = "compile_error_macro", since = "1.20.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! compile_error {
($msg:expr) => ({ /* compiler built-in */ });
($msg:expr,) => ({ /* compiler built-in */ });
/// assert_eq!(s, format!("hello {}", "world"));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! format_args {
($fmt:expr) => ({ /* compiler built-in */ });
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ });
/// error: what's that?!
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! env {
($name:expr) => ({ /* compiler built-in */ });
($name:expr,) => ({ /* compiler built-in */ });
/// println!("the secret key might be: {:?}", key);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! option_env {
($name:expr) => ({ /* compiler built-in */ });
($name:expr,) => ({ /* compiler built-in */ });
/// # }
/// ```
#[unstable(feature = "concat_idents_macro", issue = "29599")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! concat_idents {
($($e:ident),+) => ({ /* compiler built-in */ });
($($e:ident,)+) => ({ /* compiler built-in */ });
/// assert_eq!(s, "test10btrue");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! concat {
($($e:expr),*) => ({ /* compiler built-in */ });
($($e:expr,)*) => ({ /* compiler built-in */ });
/// println!("defined on line: {}", current_line);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! line { () => ({ /* compiler built-in */ }) }
/// A macro which expands to the column number on which it was invoked.
/// println!("defined on column: {}", current_col);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! column { () => ({ /* compiler built-in */ }) }
/// A macro which expands to the file name from which it was invoked.
/// println!("defined in file: {}", this_file);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! file { () => ({ /* compiler built-in */ }) }
/// A macro which stringifies its arguments.
/// assert_eq!(one_plus_one, "1 + 1");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! stringify { ($($t:tt)*) => ({ /* compiler built-in */ }) }
/// Includes a utf8-encoded file as a string.
///
/// Compiling 'main.rs' and running the resulting binary will print "adiรณs".
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! include_str {
($file:expr) => ({ /* compiler built-in */ });
($file:expr,) => ({ /* compiler built-in */ });
///
/// Compiling 'main.rs' and running the resulting binary will print "adiรณs".
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! include_bytes {
($file:expr) => ({ /* compiler built-in */ });
($file:expr,) => ({ /* compiler built-in */ });
/// test::foo();
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! module_path { () => ({ /* compiler built-in */ }) }
/// Boolean evaluation of configuration flags, at compile-time.
/// };
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
/// Parse a file as an expression or an item according to the context.
/// Compiling 'main.rs' and running the resulting binary will print
/// "๐๐๐๐๐๐".
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! include {
($file:expr) => ({ /* compiler built-in */ });
($file:expr,) => ({ /* compiler built-in */ });
/// assert!(a + b == 30, "a = {}, b = {}", a, b);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[macro_export]
+ #[rustc_doc_only_macro]
macro_rules! assert {
($cond:expr) => ({ /* compiler built-in */ });
($cond:expr,) => ({ /* compiler built-in */ });
}
pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
- BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.check_name(builtin_name))
+ BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.check_name(builtin_name)) ||
+ attr.name().as_str().starts_with("rustc_")
}
// Attributes that have a special meaning to rustc or rustdoc