Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc: allow "omitting" visit glue. #11793

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ debugging_opts!(
GEN_CRATE_MAP,
PREFER_DYNAMIC,
NO_INTEGRATED_AS,
LTO
LTO,
NOOP_REFLECTION
]
0
)
Expand Down Expand Up @@ -124,6 +125,8 @@ pub fn debugging_opts_map() -> ~[(&'static str, &'static str, u64)] {
("no-integrated-as",
"Use external assembler rather than LLVM's integrated one", NO_INTEGRATED_AS),
("lto", "Perform LLVM link-time optimizations", LTO),
("noop-reflection", "Avoid generating the visit glue (stops {:?} working)",
NOOP_REFLECTION)
]
}

Expand Down Expand Up @@ -348,6 +351,9 @@ impl Session_ {
pub fn no_landing_pads(&self) -> bool {
self.debugging_opt(NO_LANDING_PADS)
}
pub fn noop_reflection(&self) -> bool {
self.debugging_opt(NOOP_REFLECTION)
}

// pointless function, now...
pub fn str_of(&self, id: ast::Ident) -> @str {
Expand Down
7 changes: 5 additions & 2 deletions src/librustc/middle/trans/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,13 @@ fn call_tydesc_glue<'a>(cx: &'a Block<'a>, v: ValueRef, t: ty::t, field: uint)
cx
}

fn make_visit_glue<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t)
fn make_visit_glue<'a>(mut bcx: &'a Block<'a>, v: ValueRef, t: ty::t)
-> &'a Block<'a> {
let _icx = push_ctxt("make_visit_glue");
let mut bcx = bcx;
if bcx.tcx().sess.noop_reflection() {
return bcx;
}

let (visitor_trait, object_ty) = match ty::visitor_object_ty(bcx.tcx(),
ty::ReStatic) {
Ok(pair) => pair,
Expand Down
16 changes: 16 additions & 0 deletions src/test/run-pass/noop-reflection.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// xfail-fast compile flags doesn't work
// compile-flags: -Z noop-reflection

pub fn main() {
assert_eq!(format!("{:?}", 1), ~"");
}