Why can't I import `std::assert` via `use` while it works for other macros from std?

Luk*_*odt 4 macros rust

With Rust 2018, this code works (Playground):

use std::panic;
use std::format;
use std::assert_eq;
Run Code Online (Sandbox Code Playgroud)

But this:

use std::assert;
Run Code Online (Sandbox Code Playgroud)

Results in this error:

error[E0432]: unresolved import `std::assert`
 --> src/lib.rs:4:5
  |
4 | use std::assert;
  |     ^^^^^^^^^^^ no `assert` in the root
Run Code Online (Sandbox Code Playgroud)

I read the edition guide about this topic and it says that use should work with macro_rules! macros and procedural macros. Thus, I'm confused.

She*_*ter 5

use should work with macro_rules! macros and procedural macros

Except assert is neither of those:

/// Built-in macros to the compiler itself.
///
/// These macros do not have any corresponding definition with a `macro_rules!`
/// macro, but are documented here. Their implementations can be found hardcoded
/// into libsyntax itself.
Run Code Online (Sandbox Code Playgroud)

It is a compiler built-in:

#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_doc_only_macro]
macro_rules! assert {
    ($cond:expr) => ({ /* compiler built-in */ });
    ($cond:expr,) => ({ /* compiler built-in */ });
    ($cond:expr, $($arg:tt)+) => ({ /* compiler built-in */ });
}
Run Code Online (Sandbox Code Playgroud)

Other faux-macros include:

  • compile_error
  • format_args
  • env
  • option_env
  • concat_idents
  • concat
  • line
  • column
  • file
  • stringify
  • include_str
  • include_bytes
  • module_path
  • cfg
  • include

The actual definition of assert is buried much lower in libsyntax_ext/assert.rs


Stabilize uniform paths on Rust 2018 (#56417) does mention these in passing:

Built-in macros, for example use env. Currently an error due to some (fixable) implementation details of built-in macros. No known issues to resolve before stabilization (after the error is removed).