From 2d610165ea9c0b2a66a81779eab36272bf0d7eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Fri, 28 Apr 2017 16:22:49 +0200 Subject: [PATCH] Implemented a `show_type` function for nightly playbot. This change also defaults `#![feature(core_intrinsics)]` on --nightly --- src/bin/playbot.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/bin/playbot.rs b/src/bin/playbot.rs index cff8579..c77b315 100644 --- a/src/bin/playbot.rs +++ b/src/bin/playbot.rs @@ -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(e: T) {{ println!("{{:?}}", e) }} +fn show_type(_:T) -> &'static str {{ unsafe {{ std::intrinsics::type_name::() }}}} + +fn main() {{ + show({{ + {code} + }}); +}} +"#, version = self.rust_versions[channel as usize], code = code) } else { format!(r#" #![allow(dead_code, unused_variables)]