fn test_highlighting() {
check_highlighting(
r#"
+//- proc_macros: identity, mirror
//- /main.rs crate:main deps:foo
use inner::{self as inner_mod};
mod inner {}
pub trait Copy {}
}
+#[proc_macros::identity]
pub mod ops {
#[lang = "fn_once"]
pub trait FnOnce<Args> {}
pub trait Fn<Args>: FnMut<Args> {}
}
-
-struct Foo {
- pub x: i32,
- pub y: i32,
+proc_macros::mirror! {
+ {
+ ,i32 :x pub
+ ,i32 :y pub
+ } Foo struct
}
trait Bar where Self: {
str();
}
-static mut STATIC_MUT: i32 = 0;
-
fn foo<'a, T>() -> T {
foo::<'a, i32>()
}
let x = 92;
vec.push(Foo { x, y: 1 });
}
- unsafe {
- vec.set_len(0);
- STATIC_MUT = 1;
- }
for e in vec {
// Do nothing
noop!(noop!(1));
let mut x = 42;
+ x += 1;
let y = &mut x;
let z = &y;
futures::join!(f1, f2);
}
-unsafe trait Dangerous {}
-impl Dangerous for () {}
-
fn use_foo_items() {
let bob = foo::Person {
name: "Bob",
.filter(|it| it.highlight.tag == HlTag::Symbol(SymbolKind::Function))
.count()
};
- assert_eq!(hash, 1632);
+ assert_eq!(hash, 1616);
}
#[test]
})
}
#[rustc_builtin_macro]
-macro_rules! format_args_nl {
- ($fmt:expr) => {{ /* compiler built-in */ }};
- ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
+#[macro_export]
+macro_rules! format_args {}
+#[rustc_builtin_macro]
+#[macro_export]
+macro_rules! const_format_args {}
+#[rustc_builtin_macro]
+#[macro_export]
+macro_rules! format_args_nl {}
+
+mod panic {
+ pub macro panic_2015 {
+ () => (
+ $crate::panicking::panic("explicit panic")
+ ),
+ ($msg:literal $(,)?) => (
+ $crate::panicking::panic($msg)
+ ),
+ // Use `panic_str` instead of `panic_display::<&str>` for non_fmt_panic lint.
+ ($msg:expr $(,)?) => (
+ $crate::panicking::panic_str($msg)
+ ),
+ // Special-case the single-argument case for const_panic.
+ ("{}", $arg:expr $(,)?) => (
+ $crate::panicking::panic_display(&$arg)
+ ),
+ ($fmt:expr, $($arg:tt)+) => (
+ $crate::panicking::panic_fmt($crate::const_format_args!($fmt, $($arg)+))
+ ),
+ }
+}
+
+#[rustc_builtin_macro(std_panic)]
+#[macro_export]
+macro_rules! panic {}
+#[rustc_builtin_macro]
+macro_rules! assert {}
+
+macro_rules! toho {
+ () => ($crate::panic!("not yet implemented"));
+ ($($arg:tt)+) => ($crate::panic!("not yet implemented: {}", $crate::format_args!($($arg)+)));
}
fn main() {
println!("{ничоси}", ничоси = 92);
println!("{:x?} {} ", thingy, n2);
+ panic!("{}", 0);
+ panic!("more {}", 1);
+ assert!(true, "{}", 1);
+ assert!(true, "{} asdasd", 1);
+ toho!("{}fmt", 0);
}"#
.trim(),
expect_file!["./test_data/highlight_strings.html"],
fn test_unsafe_highlighting() {
check_highlighting(
r#"
+static mut MUT_GLOBAL: Struct = Struct { field: 0 };
+static GLOBAL: Struct = Struct { field: 0 };
unsafe fn unsafe_fn() {}
union Union {
b: f32,
}
-struct HasUnsafeFn;
-
-impl HasUnsafeFn {
+struct Struct { field: i32 }
+impl Struct {
unsafe fn unsafe_method(&self) {}
}
-struct TypeForStaticMut {
- a: u8
-}
-
-static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 };
-
#[repr(packed)]
struct Packed {
a: u16,
unsafe trait UnsafeTrait {}
unsafe impl UnsafeTrait for Packed {}
+impl !UnsafeTrait for () {}
-fn require_unsafe_trait<T: UnsafeTrait>(_: T) {}
+fn unsafe_trait_bound<T: UnsafeTrait>(_: T) {}
trait DoTheAutoref {
fn calls_autoref(&self);
Union { b: 0 } => (),
Union { a } => (),
}
- HasUnsafeFn.unsafe_method();
+ Struct { field: 0 }.unsafe_method();
// unsafe deref
- let y = *x;
+ *x;
// unsafe access to a static mut
- let a = global_mut.a;
+ MUT_GLOBAL.field;
+ GLOBAL.field;
// unsafe ref of packed fields
let packed = Packed { a: 0 };