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

Commit

Permalink
Implemented a show_type function for nightly playbot.
Browse files Browse the repository at this point in the history
This change also defaults `#![feature(core_intrinsics)]` on --nightly
  • Loading branch information
Emilgardis committed Apr 28, 2017
1 parent ac799f6 commit 2d61016
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/bin/playbot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ impl Playbot {

let code = if self.conn.current_nickname().contains("mini") {
String::from(code)
} else if channel == ReleaseChannel::Nightly {
format!(r#"
#![feature(core_intrinsics)]
#![allow(dead_code, unused_variables)]
static VERSION: &'static str = "{version}";
fn show<T: std::fmt::Debug>(e: T) {{ println!("{{:?}}", e) }}
fn show_type<T>(_:T) -> &'static str {{ unsafe {{ std::intrinsics::type_name::<T>() }}}}
fn main() {{
show({{
{code}
}});
}}
"#, version = self.rust_versions[channel as usize], code = code)
} else {
format!(r#"
#![allow(dead_code, unused_variables)]
Expand Down

0 comments on commit 2d61016

Please sign in to comment.