#[rustc_builtin_macro]
macro_rules! include { () => {} }
+#[rustc_builtin_macro]
+macro_rules! compile_error { () => {} }
+
include!("doesntexist");
-//^^^^^^^^^^^^^^^^^^^^^^^^ failed to load file `doesntexist`
+//^^^^^^^^^^^^^^^^^^^^^^^^ error: failed to load file `doesntexist`
+
+ compile_error!("compile_error macro works");
+//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: compile_error macro works
+ "#,
+ );
+ }
+
+ #[test]
+ fn eager_macro_concat() {
+ // FIXME: this is incorrectly handling `$crate`, resulting in a wrong diagnostic.
+ // See: https://github.com/rust-analyzer/rust-analyzer/issues/10300
+
+ check_diagnostics(
+ r#"
+//- /lib.rs crate:lib deps:core
+use core::{panic, concat};
+
+mod private {
+ pub use core::concat;
+}
+
+macro_rules! m {
+ () => {
+ panic!(concat!($crate::private::concat!("")));
+ };
+}
+
+fn f() {
+ m!();
+ //^^^^ error: unresolved macro `$crate::private::concat!`
+}
+
+//- /core.rs crate:core
+#[macro_export]
+#[rustc_builtin_macro]
+macro_rules! concat { () => {} }
+
+pub macro panic {
+ ($msg:expr) => (
+ $crate::panicking::panic_str($msg)
+ ),
+}
"#,
);
}
macro_rules! concat { () => {} }
include!(concat!(env!("OUT_DIR"), "/out.rs"));
-//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "run build scripts" to fix
+//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `OUT_DIR` not set, enable "run build scripts" to fix
"#,
);
}
// Test a handful of built-in (eager) macros:
include!(invalid);
- //^^^^^^^^^^^^^^^^^ could not convert tokens
+ //^^^^^^^^^^^^^^^^^ error: could not convert tokens
include!("does not exist");
- //^^^^^^^^^^^^^^^^^^^^^^^^^^ failed to load file `does not exist`
+ //^^^^^^^^^^^^^^^^^^^^^^^^^^ error: failed to load file `does not exist`
env!(invalid);
- //^^^^^^^^^^^^^ could not convert tokens
+ //^^^^^^^^^^^^^ error: could not convert tokens
env!("OUT_DIR");
- //^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "run build scripts" to fix
+ //^^^^^^^^^^^^^^^ error: `OUT_DIR` not set, enable "run build scripts" to fix
compile_error!("compile_error works");
- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compile_error works
+ //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: compile_error works
// Lazy:
format_args!();
- //^^^^^^^^^^^^^^ no rule matches input tokens
+ //^^^^^^^^^^^^^^ error: no rule matches input tokens
}
"#,
);
m!();
m!(hi);
- //^^^^^^ leftover tokens
+ //^^^^^^ error: leftover tokens
}
"#,
);
fn f() {
outer!();
-} //^^^^^^^^ leftover tokens
+} //^^^^^^^^ error: leftover tokens
"#,
)
}