Skip to content
This repository was archived by the owner on Jun 27, 2018. It is now read-only.

Commit 3762cf9

Browse files
committed
Implemented a show_type function for nightly.
This change also defaults `#![feature(core_intrinsics)]` on --nightly
1 parent ac799f6 commit 3762cf9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/bin/playbot.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,22 @@ impl Playbot {
119119

120120
let code = if self.conn.current_nickname().contains("mini") {
121121
String::from(code)
122+
} else if channel == ReleaseChannel::Nightly {
123+
format!(r#"
124+
#![feature(core_intrinsics)]
125+
#![allow(dead_code, unused_variables)]
126+
127+
static VERSION: &'static str = "{version}";
128+
129+
fn show<T: std::fmt::Debug>(e: T) {{ println!("{{:?}}", e) }}
130+
fn show_type<T>(_:T) -> &'static str {{ unsafe {{ std::intrinsics::type_name::<T>() }}}}
131+
132+
fn main() {{
133+
show({{
134+
{code}
135+
}});
136+
}}
137+
"#, version = self.rust_versions[channel as usize], code = code)
122138
} else {
123139
format!(r#"
124140
#![allow(dead_code, unused_variables)]

0 commit comments

Comments
 (0)