auto merge of #8554 : michaelwoerister/rust/generics, r=brson

This pull request includes support for generic functions and self arguments in methods, and combinations thereof. This also encompasses any kind of trait methods, regular and static, with and without default implementation. The implementation is backed up by a felt ton of test cases `:)`

This is a very important step towards being able to compile larger programs with debug info, since practically any generic function caused an ICE before.

One point worth discussing is that activating debug info now automatically (and silently) sets the `no_monomorphic_collapse` flag. Otherwise debug info would show wrong type names in all but one instance of the monomorphized function.

Another thing to note is that the handling of generic types does not strictly follow the DWARF specification. That is, variables with type `T` (where `T=int`) are described as having type `int` and not as having type `T`. In other words, we are losing information whether a variable has been declared with a type parameter as its type. In practice this should not make much of difference though since the concrete type is mostly what one is interested in. I'll post an issue later so this won't be forgotten.

Also included are a number of bug fixes:
* Closes #1758
* Closes #8513
* Closes #8443
* Fixes handling of field names in tuple structs
* Fixes and re-enables test case for option-like enums that relied on undefined behavior before
* Closes #1339 (should have been closed a while ago)

Cheers,
Michael
This commit is contained in:
bors 2013-08-17 15:22:04 -07:00
commit 679102109f
28 changed files with 2230 additions and 104 deletions

View file

@ -691,6 +691,14 @@ pub fn build_session_options(binary: @str,
let extra_debuginfo = debugging_opts & session::extra_debug_info != 0;
let debuginfo = debugging_opts & session::debug_info != 0 ||
extra_debuginfo;
// If debugging info is generated, do not collapse monomorphized function instances.
// Functions with equivalent llvm code still need separate debugging descriptions because names
// might differ.
if debuginfo {
debugging_opts |= session::no_monomorphic_collapse;
}
let statik = debugging_opts & session::statik != 0;
let addl_lib_search_paths = getopts::opt_strs(matches, "L").map(|s| Path(*s));

View file

@ -2086,6 +2086,16 @@ pub mod llvm {
#[fast_ffi]
pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
#[fast_ffi]
pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
Scope: ValueRef,
Name: *c_char,
Ty: ValueRef,
File: ValueRef,
LineNo: c_uint,
ColumnNo: c_uint)
-> ValueRef;
}
}

View file

@ -133,7 +133,7 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
fn fcx_has_nonzero_span(fcx: &FunctionContext) -> bool {
match fcx.span {
None => true,
None => false,
Some(span) => *span.lo != 0 || *span.hi != 0
}
}
@ -1739,6 +1739,10 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
fcx.llself = Some(ValSelfData {v: self_val, ..slf});
add_clean(bcx, self_val, slf.t);
if fcx.ccx.sess.opts.extra_debuginfo && fcx_has_nonzero_span(fcx) {
debuginfo::create_self_argument_metadata(bcx, slf.t, self_val);
}
}
_ => {}
}
@ -1859,6 +1863,10 @@ pub fn trans_closure(ccx: @mut CrateContext,
set_fixed_stack_segment(fcx.llfn);
}
if ccx.sess.opts.debuginfo && fcx_has_nonzero_span(fcx) {
debuginfo::create_function_metadata(fcx);
}
// Create the first basic block in the function and keep a handle on it to
// pass to finish_fn later.
let bcx_top = fcx.entry_bcx.unwrap();
@ -1929,12 +1937,7 @@ pub fn trans_fn(ccx: @mut CrateContext,
id,
attrs,
output_type,
|fcx| {
if ccx.sess.opts.debuginfo
&& fcx_has_nonzero_span(fcx) {
debuginfo::create_function_metadata(fcx);
}
});
|_fcx| { });
}
fn insert_synthetic_type_entries(bcx: @mut Block,

View file

@ -51,7 +51,7 @@ This file consists of three conceptual sections:
use driver::session;
use lib::llvm::llvm;
use lib::llvm::{ModuleRef, ContextRef};
use lib::llvm::{ModuleRef, ContextRef, ValueRef};
use lib::llvm::debuginfo::*;
use middle::trans::common::*;
use middle::trans::machine;
@ -69,7 +69,8 @@ use std::libc::{c_uint, c_ulonglong, c_longlong};
use std::ptr;
use std::vec;
use syntax::codemap::span;
use syntax::{ast, codemap, ast_util, ast_map};
use syntax::{ast, codemap, ast_util, ast_map, opt_vec};
use syntax::parse::token::special_idents;
static DW_LANG_RUST: int = 0x9000;
@ -97,7 +98,7 @@ pub struct DebugContext {
priv builder: DIBuilderRef,
priv curr_loc: (uint, uint),
priv created_files: HashMap<~str, DIFile>,
priv created_functions: HashMap<ast::NodeId, DISubprogram>,
priv created_functions: HashMap<FunctionCacheKey, DISubprogram>,
priv created_blocks: HashMap<ast::NodeId, DILexicalBlock>,
priv created_types: HashMap<uint, DIType>
}
@ -121,21 +122,25 @@ impl DebugContext {
}
}
#[deriving(Eq,IterBytes)]
struct FunctionCacheKey {
// Use the address of the llvm function (FunctionContext::llfn) as key for the cache. This
// nicely takes care of monomorphization, where two specializations will have the same
// ast::NodeId but different llvm functions (each needing its own debug description).
priv llfn: ValueRef
}
impl FunctionCacheKey {
fn for_function_context(fcx: &FunctionContext) -> FunctionCacheKey {
FunctionCacheKey { llfn: fcx.llfn }
}
}
pub struct FunctionDebugContext {
priv scope_map: HashMap<ast::NodeId, DIScope>,
priv argument_counter: uint,
}
impl FunctionDebugContext {
fn new() -> FunctionDebugContext {
return FunctionDebugContext {
scope_map: HashMap::new(),
argument_counter: 1,
};
}
}
/// Create any deferred debug metadata nodes
pub fn finalize(cx: @mut CrateContext) {
debug!("finalize");
@ -162,6 +167,9 @@ pub fn create_local_var_metadata(bcx: @mut Block, local: &ast::Local) {
}
}
/// Creates debug information for a local variable introduced in the head of a match-statement arm.
///
/// Adds the created metadata nodes directly to the crate's IR.
pub fn create_match_binding_metadata(bcx: @mut Block,
variable_ident: ast::ident,
node_id: ast::NodeId,
@ -170,6 +178,52 @@ pub fn create_match_binding_metadata(bcx: @mut Block,
declare_local(bcx, variable_ident, node_id, variable_type, span);
}
/// Creates debug information for the self argument of a method.
///
/// Adds the created metadata nodes directly to the crate's IR.
pub fn create_self_argument_metadata(bcx: @mut Block,
variable_type: ty::t,
llptr: ValueRef) {
assert_fcx_has_span(bcx.fcx);
let span = bcx.fcx.span.unwrap();
let cx = bcx.ccx();
let filename = span_start(cx, span).file.name;
let file_metadata = file_metadata(cx, filename);
let loc = span_start(cx, span);
let type_metadata = type_metadata(cx, variable_type, span);
let scope = create_function_metadata(bcx.fcx);
let var_metadata = do cx.sess.str_of(special_idents::self_).to_c_str().with_ref |name| {
unsafe {
llvm::LLVMDIBuilderCreateLocalVariable(
DIB(cx),
DW_TAG_arg_variable,
scope,
name,
file_metadata,
loc.line as c_uint,
type_metadata,
false,
0,
1)
}
};
set_debug_location(cx, scope, loc.line, loc.col.to_uint());
unsafe {
let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(
DIB(cx),
llptr,
var_metadata,
bcx.llbb);
llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr);
}
}
/// Creates debug information for the given function argument.
///
/// Adds the created metadata nodes directly to the crate's IR.
@ -243,9 +297,10 @@ pub fn create_argument_metadata(bcx: @mut Block,
}
}
/// Sets the current debug location at the beginning of the span
/// Sets the current debug location at the beginning of the span.
///
/// Maps to a call to llvm::LLVMSetCurrentDebugLocation(...)
/// Maps to a call to llvm::LLVMSetCurrentDebugLocation(...). The node_id parameter is used to
/// reliably find the correct visibility scope for the code position.
pub fn update_source_pos(fcx: &FunctionContext,
node_id: ast::NodeId,
span: span) {
@ -269,13 +324,24 @@ pub fn update_source_pos(fcx: &FunctionContext,
/// The return value should be ignored if called from outside of the debuginfo module.
pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram {
let cx = fcx.ccx;
let cache_key = FunctionCacheKey::for_function_context(fcx);
match dbg_cx(cx).created_functions.find_copy(&cache_key) {
Some(fn_metadata) => {
assert!(fcx.debug_context.is_some());
return fn_metadata;
}
None => { /* fallthrough */}
}
let empty_generics = ast::Generics { lifetimes: opt_vec::Empty, ty_params: opt_vec::Empty };
let fnitem = cx.tcx.items.get_copy(&fcx.id);
let (ident, fn_decl, id) = match fnitem {
let (ident, fn_decl, generics, span) = match fnitem {
ast_map::node_item(ref item, _) => {
match item.node {
ast::item_fn(ref fn_decl, _, _, _, _) => {
(item.ident, fn_decl, item.id)
ast::item_fn(ref fn_decl, _, _, ref generics, _) => {
(item.ident, fn_decl, generics, item.span)
}
_ => fcx.ccx.sess.span_bug(item.span,
"create_function_metadata: item bound to non-function")
@ -284,19 +350,24 @@ pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram {
ast_map::node_method(
@ast::method {
decl: ref fn_decl,
id: id,
ident: ident,
generics: ref generics,
span: span,
_
},
_,
_) => {
(ident, fn_decl, id)
(ident, fn_decl, generics, span)
}
ast_map::node_expr(ref expr) => {
match expr.node {
ast::expr_fn_block(ref fn_decl, _) => {
let name = gensym_name("fn");
(name, fn_decl, expr.id)
(name, fn_decl,
// This is not quite right. It should actually inherit the generics of the
// enclosing function.
&empty_generics,
expr.span)
}
_ => fcx.ccx.sess.span_bug(expr.span,
"create_function_metadata: expected an expr_fn_block here")
@ -306,27 +377,18 @@ pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram {
@ast::provided(
@ast::method {
decl: ref fn_decl,
id: id,
ident: ident,
generics: ref generics,
span: span,
_
}),
_,
_) => {
(ident, fn_decl, id)
(ident, fn_decl, generics, span)
}
_ => fcx.ccx.sess.bug(fmt!("create_function_metadata: unexpected sort of node: %?", fnitem))
};
match dbg_cx(cx).created_functions.find_copy(&id) {
Some(fn_metadata) => return fn_metadata,
None => ()
}
let span = match fcx.span {
Some(value) => value,
None => codemap::dummy_sp()
};
debug!("create_function_metadata: %s, %s",
cx.sess.str_of(ident),
cx.sess.codemap.span_to_str(span));
@ -334,68 +396,210 @@ pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram {
let loc = span_start(cx, span);
let file_metadata = file_metadata(cx, loc.file.name);
let return_type_metadata = if cx.sess.opts.extra_debuginfo {
match fn_decl.output.node {
ast::ty_nil => ptr::null(),
_ => type_metadata(cx, ty::node_id_to_type(cx.tcx, id), fn_decl.output.span)
let function_type_metadata = unsafe {
let fn_signature = get_function_signature(fcx, fn_decl);
llvm::LLVMDIBuilderCreateSubroutineType(DIB(cx), file_metadata, fn_signature)
};
// get_template_parameters() will append a `<...>` clause to the function name if necessary.
let mut function_name = cx.sess.str_of(ident).to_owned();
let template_parameters = get_template_parameters(fcx,
generics,
file_metadata,
&mut function_name);
let fn_metadata = do function_name.to_c_str().with_ref |function_name| {
unsafe {
llvm::LLVMDIBuilderCreateFunction(
DIB(cx),
file_metadata,
function_name,
function_name,
file_metadata,
loc.line as c_uint,
function_type_metadata,
false,
true,
loc.line as c_uint,
FlagPrototyped as c_uint,
cx.sess.opts.optimize != session::No,
fcx.llfn,
template_parameters,
ptr::null())
}
} else {
ptr::null()
};
let fn_ty = unsafe {
llvm::LLVMDIBuilderCreateSubroutineType(
DIB(cx),
file_metadata,
create_DIArray(DIB(cx), [return_type_metadata]))
};
dbg_cx(cx).created_functions.insert(cache_key, fn_metadata);
let fn_metadata =
do cx.sess.str_of(ident).with_c_str |name| {
do cx.sess.str_of(ident).with_c_str |linkage| {
unsafe {
llvm::LLVMDIBuilderCreateFunction(
DIB(cx),
file_metadata,
name,
linkage,
file_metadata,
loc.line as c_uint,
fn_ty,
false,
true,
loc.line as c_uint,
FlagPrototyped as c_uint,
cx.sess.opts.optimize != session::No,
fcx.llfn,
ptr::null(),
ptr::null())
// Initialize fn debug context (including scope map)
{
assert!(fcx.debug_context.is_none());
let mut fn_debug_context = ~FunctionDebugContext {
scope_map: HashMap::new(),
argument_counter: if fcx.llself.is_some() { 2 } else { 1 }
};
let entry_block_id = fcx.entry_bcx.get_ref().node_info.get_ref().id;
let entry_block = cx.tcx.items.get(&entry_block_id);
match *entry_block {
ast_map::node_block(ref block) => {
let scope_map = &mut fn_debug_context.scope_map;
let arg_pats = do fn_decl.inputs.map |arg_ref| { arg_ref.pat };
populate_scope_map(cx, arg_pats, block, fn_metadata, scope_map);
}
}};
assert!(fcx.debug_context.is_none());
let mut fn_debug_context = ~FunctionDebugContext::new();
let entry_block_id = fcx.entry_bcx.get_ref().node_info.get_ref().id;
let entry_block = cx.tcx.items.get(&entry_block_id);
match *entry_block {
ast_map::node_block(ref block) => {
let scope_map = &mut fn_debug_context.scope_map;
let arg_pats = do fn_decl.inputs.map |arg_ref| { arg_ref.pat };
populate_scope_map(cx, arg_pats, block, fn_metadata, scope_map);
_ => cx.sess.span_bug(span,
fmt!("debuginfo::create_function_metadata() - \
FunctionContext::entry_bcx::node_info points to wrong type of ast_map \
entry. Expected: ast_map::node_block, actual: %?", *entry_block))
}
_ => cx.sess.span_bug(span,
fmt!("debuginfo::create_function_metadata() - \
FunctionContext::entry_bcx::node_info points to wrong type of ast_map entry. \
Expected: ast_map::node_block, actual: %?", *entry_block))
fcx.debug_context = Some(fn_debug_context);
}
fcx.debug_context = Some(fn_debug_context);
dbg_cx(cx).created_functions.insert(id, fn_metadata);
return fn_metadata;
fn get_function_signature(fcx: &FunctionContext, fn_decl: &ast::fn_decl) -> DIArray {
let cx = fcx.ccx;
if !cx.sess.opts.extra_debuginfo {
return create_DIArray(DIB(cx), []);
}
let mut signature = vec::with_capacity(fn_decl.inputs.len() + 1);
// Return type -- llvm::DIBuilder wants this at index 0
match fn_decl.output.node {
ast::ty_nil => {
signature.push(ptr::null());
}
_ => {
let return_type = ty::node_id_to_type(cx.tcx, fcx.id);
let return_type = match fcx.param_substs {
None => return_type,
Some(substs) => {
ty::subst_tps(cx.tcx, substs.tys, substs.self_ty, return_type)
}
};
signature.push(type_metadata(cx, return_type, codemap::dummy_sp()));
}
}
// arguments types
for arg in fn_decl.inputs.iter() {
let arg_type = ty::node_id_to_type(cx.tcx, arg.pat.id);
let arg_type = match fcx.param_substs {
None => arg_type,
Some(substs) => {
ty::subst_tps(cx.tcx, substs.tys, substs.self_ty, arg_type)
}
};
signature.push(type_metadata(cx, arg_type, codemap::dummy_sp()));
}
return create_DIArray(DIB(cx), signature);
}
fn get_template_parameters(fcx: &FunctionContext,
generics: &ast::Generics,
file_metadata: DIFile,
name_to_append_suffix_to: &mut ~str)
-> DIArray {
let cx = fcx.ccx;
let self_type = match fcx.param_substs {
Some(@param_substs{ self_ty: self_type, _ }) => self_type,
_ => None
};
// Only true for static default methods:
let has_self_type = self_type.is_some();
if !generics.is_type_parameterized() && !has_self_type {
return ptr::null();
}
name_to_append_suffix_to.push_char('<');
// The list to be filled with template parameters:
let mut template_params: ~[DIDescriptor] = vec::with_capacity(generics.ty_params.len() + 1);
// Handle self type
if has_self_type {
let actual_self_type = self_type.unwrap();
let actual_self_type_metadata = type_metadata(cx,
actual_self_type,
codemap::dummy_sp());
// Add self type name to <...> clause of function name
let actual_self_type_name = ty_to_str(cx.tcx, actual_self_type);
name_to_append_suffix_to.push_str(actual_self_type_name);
if generics.is_type_parameterized() {
name_to_append_suffix_to.push_str(",");
}
let ident = special_idents::type_self;
let param_metadata = do cx.sess.str_of(ident).to_c_str().with_ref |name| {
unsafe {
llvm::LLVMDIBuilderCreateTemplateTypeParameter(
DIB(cx),
file_metadata,
name,
actual_self_type_metadata,
ptr::null(),
0,
0)
}
};
template_params.push(param_metadata);
}
// Handle other generic parameters
let actual_types = match fcx.param_substs {
Some(@param_substs { tys: ref types, _ }) => types,
None => {
return create_DIArray(DIB(cx), template_params);
}
};
for (index, &ast::TyParam{ ident: ident, _ }) in generics.ty_params.iter().enumerate() {
let actual_type = actual_types[index];
let actual_type_metadata = type_metadata(cx, actual_type, codemap::dummy_sp());
// Add actual type name to <...> clause of function name
let actual_type_name = ty_to_str(cx.tcx, actual_type);
name_to_append_suffix_to.push_str(actual_type_name);
if index != generics.ty_params.len() - 1 {
name_to_append_suffix_to.push_str(",");
}
let param_metadata = do cx.sess.str_of(ident).to_c_str().with_ref |name| {
unsafe {
llvm::LLVMDIBuilderCreateTemplateTypeParameter(
DIB(cx),
file_metadata,
name,
actual_type_metadata,
ptr::null(),
0,
0)
}
};
template_params.push(param_metadata);
}
name_to_append_suffix_to.push_char('>');
return create_DIArray(DIB(cx), template_params);
}
}
@ -611,7 +815,13 @@ fn struct_metadata(cx: &mut CrateContext,
let struct_llvm_type = type_of::type_of(cx, struct_type);
let field_llvm_types = do fields.map |field| { type_of::type_of(cx, field.mt.ty) };
let field_names = do fields.map |field| { cx.sess.str_of(field.ident).to_owned() };
let field_names = do fields.map |field| {
if field.ident == special_idents::unnamed_field {
~""
} else {
cx.sess.str_of(field.ident).to_owned()
}
};
let field_types_metadata = do fields.map |field| {
type_metadata(cx, field.mt.ty, span)
};
@ -1271,6 +1481,13 @@ fn DIB(cx: &CrateContext) -> DIBuilderRef {
cx.dbg_cx.get_ref().builder
}
fn assert_fcx_has_span(fcx: &FunctionContext) {
if fcx.span.is_none() {
fcx.ccx.sess.bug(fmt!("debuginfo: Encountered function %s with invalid source span. \
This function should have been ignored by debuginfo generation.",
ast_map::path_to_str(fcx.path, fcx.ccx.sess.intr())));
}
}
// This procedure builds the *scope map* for a given function, which maps any given ast::NodeId in
// the function's AST to the correct DIScope metadata instance.

View file

@ -838,3 +838,21 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateUnionType(
extern "C" void LLVMSetUnnamedAddr(LLVMValueRef Value, LLVMBool Unnamed) {
unwrap<GlobalValue>(Value)->setUnnamedAddr(Unnamed);
}
extern "C" LLVMValueRef LLVMDIBuilderCreateTemplateTypeParameter(
DIBuilderRef Builder,
LLVMValueRef Scope,
const char* Name,
LLVMValueRef Ty,
LLVMValueRef File = 0,
unsigned LineNo = 0,
unsigned ColumnNo = 0)
{
return wrap(Builder->createTemplateTypeParameter(
unwrapDI<DIDescriptor>(Scope),
Name,
unwrapDI<DIType>(Ty),
unwrapDI<MDNode*>(File),
LineNo,
ColumnNo));
}

View file

@ -613,4 +613,5 @@ LLVMDIBuilderInsertDeclareBefore
LLVMDIBuilderCreateEnumerator
LLVMDIBuilderCreateEnumerationType
LLVMDIBuilderCreateUnionType
LLVMDIBuilderCreateTemplateTypeParameter
LLVMSetUnnamedAddr

View file

@ -0,0 +1,37 @@
// Copyright 2013 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.
// Does not work yet, see issue #8512
// xfail-test
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print s
// check:$1 = {a = 1, b = 2.5}
// debugger:continue
#[deriving(Clone)]
struct Struct {
a: int,
b: float
}
fn fun(s: Struct) {
zzz();
}
fn main() {
fun(Struct { a: 1, b: 2.5 });
}
fn zzz() {()}

View file

@ -0,0 +1,46 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print x
// check:$1 = 0.5
// debugger:print y
// check:$2 = 10
// debugger:continue
// debugger:finish
// debugger:print *x
// check:$3 = 29
// debugger:print *y
// check:$4 = 110
// debugger:continue
fn some_generic_fun<T1, T2>(a: T1, b: T2) -> (T2, T1) {
let closure = |x, y| {
zzz();
(y, x)
};
closure(a, b)
}
fn main() {
some_generic_fun(0.5, 10);
some_generic_fun(&29, ~110);
}
fn zzz() {()}

View file

@ -0,0 +1,63 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print *t0
// check:$1 = 1
// debugger:print *t1
// check:$2 = 2.5
// debugger:print ret
// check:$3 = {{1, 2.5}, {2.5, 1}}
// debugger:continue
// debugger:finish
// debugger:print *t0
// check:$4 = 3.5
// debugger:print *t1
// check:$5 = 4
// debugger:print ret
// check:$6 = {{3.5, 4}, {4, 3.5}}
// debugger:continue
// debugger:finish
// debugger:print *t0
// check:$7 = 5
// debugger:print *t1
// check:$8 = {a = 6, b = 7.5}
// debugger:print ret
// check:$9 = {{5, {a = 6, b = 7.5}}, {{a = 6, b = 7.5}, 5}}
// debugger:continue
#[deriving(Clone)]
struct Struct {
a: int,
b: float
}
fn dup_tup<T0: Clone, T1: Clone>(t0: &T0, t1: &T1) -> ((T0, T1), (T1, T0)) {
let ret = ((t0.clone(), t1.clone()), (t1.clone(), t0.clone()));
zzz();
ret
}
fn main() {
let _ = dup_tup(&1, &2.5);
let _ = dup_tup(&3.5, &4_u16);
let _ = dup_tup(&5, &Struct { a: 6, b: 7.5 });
}
fn zzz() {()}

View file

@ -0,0 +1,59 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print x
// check:$1 = -1
// debugger:print y
// check:$2 = 1
// debugger:continue
// debugger:finish
// debugger:print x
// check:$3 = -1
// debugger:print y
// check:$4 = 2.5
// debugger:continue
// debugger:finish
// debugger:print x
// check:$5 = -2.5
// debugger:print y
// check:$6 = 1
// debugger:continue
// debugger:finish
// debugger:print x
// check:$7 = -2.5
// debugger:print y
// check:$8 = 2.5
// debugger:continue
fn outer<TA: Clone>(a: TA) {
inner(a.clone(), 1);
inner(a.clone(), 2.5);
fn inner<TX, TY>(x: TX, y: TY) {
zzz();
}
}
fn main() {
outer(-1);
outer(-2.5);
}
fn zzz() {()}

View file

@ -0,0 +1,140 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// STACK BY REF
// debugger:finish
// debugger:print *self
// check:$1 = {x = {8888, -8888}}
// debugger:print arg1
// check:$2 = -1
// debugger:print/d arg2
// check:$3 = -2
// debugger:continue
// STACK BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = {8888, -8888}}
// debugger:print arg1
// check:$4 = -3
// debugger:print arg2
// check:$5 = -4
// debugger:continue
// OWNED BY REF
// debugger:finish
// debugger:print *self
// check:$6 = {x = 1234.5}
// debugger:print arg1
// check:$7 = -5
// debugger:print arg2
// check:$8 = -6
// debugger:continue
// OWNED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 1234.5}
// debugger:print arg1
// check:$9 = -7
// debugger:print arg2
// check:$10 = -8
// debugger:continue
// OWNED MOVED
// debugger:finish
// debugger:print *self
// check:$11 = {x = 1234.5}
// debugger:print arg1
// check:$12 = -9
// debugger:print arg2
// check:$13 = -10.5
// debugger:continue
// MANAGED BY REF
// debugger:finish
// debugger:print *self
// check:$14 = {x = -1}
// debugger:print arg1
// check:$15 = -11
// debugger:print arg2
// check:$16 = -12.5
// debugger:continue
// MANAGED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = -1}
// debugger:print arg1
// check:$17 = -13
// debugger:print *arg2
// check:$18 = {-14, 14}
// debugger:continue
// MANAGED SELF
// debugger:finish
// debugger:print self->val
// check:$19 = {x = -1}
// debugger:print arg1
// check:$20 = -15
// debugger:print *arg2
// check:$21 = {-16, 16.5}
// debugger:continue
struct Struct<T> {
x: T
}
impl<T1> Struct<T1> {
fn self_by_ref<T2>(&self, arg1: int, arg2: T2) -> int {
zzz();
arg1
}
fn self_by_val<T2>(self, arg1: int, arg2: T2) -> int {
zzz();
arg1
}
fn self_owned<T2>(~self, arg1: int, arg2: T2) -> int {
zzz();
arg1
}
fn self_managed<T2>(@self, arg1: int, arg2: T2) -> int {
zzz();
arg1
}
}
fn main() {
let stack = Struct { x: (8888_u32, -8888_i32) };
let _ = stack.self_by_ref(-1, -2_i8);
let _ = stack.self_by_val(-3, -4_i16);
let owned = ~Struct { x: 1234.5 };
let _ = owned.self_by_ref(-5, -6_i32);
let _ = owned.self_by_val(-7, -8_i64);
let _ = owned.self_owned(-9, -10.5_f32);
let managed = @Struct { x: -1_i16 };
let _ = managed.self_by_ref(-11, -12.5_f64);
let _ = managed.self_by_val(-13, &(-14, 14));
let _ = managed.self_managed(-15, &(-16, 16.5));
}
fn zzz() {()}

View file

@ -0,0 +1,67 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// STRUCT
// debugger:finish
// debugger:print arg1
// check:$1 = 1
// debugger:print arg2
// check:$2 = 2
// debugger:continue
// ENUM
// debugger:finish
// debugger:print arg1
// check:$3 = -3
// debugger:print arg2
// check:$4 = 4.5
// debugger:print arg3
// check:$5 = 5
// debugger:continue
struct Struct {
x: int
}
impl Struct {
fn static_method<T1, T2>(arg1: T1, arg2: T2) -> int {
zzz();
return 0;
}
}
enum Enum {
Variant1 { x: int },
Variant2,
Variant3(float, int, char),
}
impl Enum {
fn static_method<T1, T2, T3>(arg1: T1, arg2: T2, arg3: T3) -> int {
zzz();
return 1;
}
}
fn main() {
Struct::static_method(1, 2);
Enum::static_method(-3, 4.5, 5);
}
fn zzz() {()}

View file

@ -0,0 +1,77 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:set print union on
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print case1
// check:$1 = {{Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {Case1, a = 0, b = 2088533116, c = 2088533116}, {Case1, a = 0, b = 8970181431921507452}}
// debugger:print case2
// check:$2 = {{Case2, a = 0, b = 4369, c = 4369, d = 4369, e = 4369}, {Case2, a = 0, b = 286331153, c = 286331153}, {Case2, a = 0, b = 1229782938247303441}}
// debugger:print case3
// check:$3 = {{Case3, a = 0, b = 22873, c = 22873, d = 22873, e = 22873}, {Case3, a = 0, b = 1499027801, c = 1499027801}, {Case3, a = 0, b = 6438275382588823897}}
// debugger:print univariant
// check:$4 = {a = -1}
// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be
// substituted with something of size `xx` bits and the same alignment as an integer type of the
// same size.
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
// the size of the discriminant value is machine dependent, this has be taken into account when
// datatype layout should be predictable as in this case.
enum Regular<T16, T32, T64> {
Case1 { a: T64, b: T16, c: T16, d: T16, e: T16},
Case2 { a: T64, b: T32, c: T32},
Case3 { a: T64, b: T64 }
}
enum Univariant<T> {
TheOnlyCase { a: T }
}
fn main() {
// In order to avoid endianess trouble all of the following test values consist of a single
// repeated byte. This way each interpretation of the union should look the same, no matter if
// this is a big or little endian machine.
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
// 0b01111100011111000111110001111100 = 2088533116
// 0b0111110001111100 = 31868
// 0b01111100 = 124
let case1: Regular<u16, u32, i64> = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 };
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
// 0b00010001000100010001000100010001 = 286331153
// 0b0001000100010001 = 4369
// 0b00010001 = 17
let case2: Regular<i16, u32, i64> = Case2 { a: 0, b: 286331153, c: 286331153 };
// 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
// 0b01011001010110010101100101011001 = 1499027801
// 0b0101100101011001 = 22873
// 0b01011001 = 89
let case3: Regular<u16, i32, u64> = Case3 { a: 0, b: 6438275382588823897 };
let univariant = TheOnlyCase { a: -1 };
zzz();
}
fn zzz() {()}

View file

@ -0,0 +1,42 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print int_int
// check:$1 = {key = 0, value = 1}
// debugger:print int_float
// check:$2 = {key = 2, value = 3.5}
// debugger:print float_int
// check:$3 = {key = 4.5, value = 5}
// debugger:print float_int_float
// check:$4 = {key = 6.5, value = {key = 7, value = 8.5}}
struct AGenericStruct<TKey, TValue> {
key: TKey,
value: TValue
}
fn main() {
let int_int = AGenericStruct { key: 0, value: 1 };
let int_float = AGenericStruct { key: 2, value: 3.5 };
let float_int = AGenericStruct { key: 4.5, value: 5 };
let float_int_float = AGenericStruct { key: 6.5, value: AGenericStruct { key: 7, value: 8.5 } };
zzz();
}
fn zzz() {()}

View file

@ -0,0 +1,53 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print arg1
// check:$1 = 1000
// debugger:print *arg2
// check:$2 = {1, 2.5}
// debugger:continue
// debugger:finish
// debugger:print arg1
// check:$3 = 2000
// debugger:print *arg2
// check:$4 = {3.5, {4, 5, 6}}
// debugger:continue
struct Struct {
x: int
}
trait Trait<T1> {
fn generic_static_default_method<T2>(arg1: int, arg2: &(T1, T2)) -> int {
zzz();
arg1
}
}
impl<T> Trait<T> for Struct;
fn main() {
// Is this really how to use these?
Trait::generic_static_default_method::<int, Struct, float>(1000, &(1, 2.5));
Trait::generic_static_default_method::<float, Struct, (int, int, int)>(2000, &(3.5, (4, 5, 6)));
}
fn zzz() {()}

View file

@ -0,0 +1,78 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:set print union on
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print case1
// check:$1 = {{Case1, 0, 31868, 31868, 31868, 31868}, {Case1, 0, 2088533116, 2088533116}, {Case1, 0, 8970181431921507452}}
// debugger:print case2
// check:$2 = {{Case2, 0, 4369, 4369, 4369, 4369}, {Case2, 0, 286331153, 286331153}, {Case2, 0, 1229782938247303441}}
// debugger:print case3
// check:$3 = {{Case3, 0, 22873, 22873, 22873, 22873}, {Case3, 0, 1499027801, 1499027801}, {Case3, 0, 6438275382588823897}}
// debugger:print univariant
// check:$4 = {-1}
// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be
// substituted with something of size `xx` bits and the same alignment as an integer type of the
// same size.
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
// the size of the discriminant value is machine dependent, this has be taken into account when
// datatype layout should be predictable as in this case.
enum Regular<T16, T32, T64> {
Case1(T64, T16, T16, T16, T16),
Case2(T64, T32, T32),
Case3(T64, T64)
}
enum Univariant<T64> {
TheOnlyCase(T64)
}
fn main() {
// In order to avoid endianess trouble all of the following test values consist of a single
// repeated byte. This way each interpretation of the union should look the same, no matter if
// this is a big or little endian machine.
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
// 0b01111100011111000111110001111100 = 2088533116
// 0b0111110001111100 = 31868
// 0b01111100 = 124
let case1: Regular<u16, u32, u64> = Case1(0_u64, 31868_u16, 31868_u16, 31868_u16, 31868_u16);
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
// 0b00010001000100010001000100010001 = 286331153
// 0b0001000100010001 = 4369
// 0b00010001 = 17
let case2: Regular<i16, i32, i64> = Case2(0_i64, 286331153_i32, 286331153_i32);
// 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
// 0b01011001010110010101100101011001 = 1499027801
// 0b0101100101011001 = 22873
// 0b01011001 = 89
let case3: Regular<i16, i32, i64> = Case3(0_i64, 6438275382588823897_i64);
let univariant = TheOnlyCase(-1_i64);
zzz();
}
fn zzz() {()}

View file

@ -0,0 +1,21 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z debug-info
// debugger:run
// Nothing to do here really, just make sure it compiles. See issue #8513.
fn main() {
let _ = ||();
let _ = range(1u,3).map(|_| 5);
}

View file

@ -0,0 +1,141 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// STACK BY REF
// debugger:finish
// debugger:print *self
// check:$1 = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}}
// debugger:print arg1
// check:$2 = -1
// debugger:print arg2
// check:$3 = -2
// debugger:continue
// STACK BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}}
// debugger:print arg1
// check:$4 = -3
// debugger:print arg2
// check:$5 = -4
// debugger:continue
// OWNED BY REF
// debugger:finish
// debugger:print *self
// check:$6 = {{Variant1, x = 1799, y = 1799}, {Variant1, 117901063}}
// debugger:print arg1
// check:$7 = -5
// debugger:print arg2
// check:$8 = -6
// debugger:continue
// OWNED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {{Variant1, x = 1799, y = 1799}, {Variant1, 117901063}}
// debugger:print arg1
// check:$9 = -7
// debugger:print arg2
// check:$10 = -8
// debugger:continue
// OWNED MOVED
// debugger:finish
// debugger:print *self
// check:$11 = {{Variant1, x = 1799, y = 1799}, {Variant1, 117901063}}
// debugger:print arg1
// check:$12 = -9
// debugger:print arg2
// check:$13 = -10
// debugger:continue
// MANAGED BY REF
// debugger:finish
// debugger:print *self
// check:$14 = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}}
// debugger:print arg1
// check:$15 = -11
// debugger:print arg2
// check:$16 = -12
// debugger:continue
// MANAGED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}}
// debugger:print arg1
// check:$17 = -13
// debugger:print arg2
// check:$18 = -14
// debugger:continue
// MANAGED SELF
// debugger:finish
// debugger:print self->val
// check:$19 = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}}
// debugger:print arg1
// check:$20 = -15
// debugger:print arg2
// check:$21 = -16
// debugger:continue
enum Enum {
Variant1 { x: u16, y: u16 },
Variant2 (u32)
}
impl Enum {
fn self_by_ref(&self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_by_val(self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_owned(~self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_managed(@self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
}
fn main() {
let stack = Variant2(117901063);
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);
let owned = ~Variant1{ x: 1799, y: 1799 };
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
let managed = @Variant2(117901063);
let _ = managed.self_by_ref(-11, -12);
let _ = managed.self_by_val(-13, -14);
let _ = managed.self_managed(-15, -16);
}
fn zzz() {()}

View file

@ -0,0 +1,140 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// STACK BY REF
// debugger:finish
// debugger:print *self
// check:$1 = {x = {8888, -8888}}
// debugger:print arg1
// check:$2 = -1
// debugger:print arg2
// check:$3 = -2
// debugger:continue
// STACK BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = {8888, -8888}}
// debugger:print arg1
// check:$4 = -3
// debugger:print arg2
// check:$5 = -4
// debugger:continue
// OWNED BY REF
// debugger:finish
// debugger:print *self
// check:$6 = {x = 1234.5}
// debugger:print arg1
// check:$7 = -5
// debugger:print arg2
// check:$8 = -6
// debugger:continue
// OWNED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 1234.5}
// debugger:print arg1
// check:$9 = -7
// debugger:print arg2
// check:$10 = -8
// debugger:continue
// OWNED MOVED
// debugger:finish
// debugger:print *self
// check:$11 = {x = 1234.5}
// debugger:print arg1
// check:$12 = -9
// debugger:print arg2
// check:$13 = -10
// debugger:continue
// MANAGED BY REF
// debugger:finish
// debugger:print *self
// check:$14 = {x = -1}
// debugger:print arg1
// check:$15 = -11
// debugger:print arg2
// check:$16 = -12
// debugger:continue
// MANAGED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = -1}
// debugger:print arg1
// check:$17 = -13
// debugger:print arg2
// check:$18 = -14
// debugger:continue
// MANAGED SELF
// debugger:finish
// debugger:print self->val
// check:$19 = {x = -1}
// debugger:print arg1
// check:$20 = -15
// debugger:print arg2
// check:$21 = -16
// debugger:continue
struct Struct<T> {
x: T
}
impl<T> Struct<T> {
fn self_by_ref(&self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_by_val(self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_owned(~self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_managed(@self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
}
fn main() {
let stack = Struct { x: (8888_u32, -8888_i32) };
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);
let owned = ~Struct { x: 1234.5 };
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
let managed = @Struct { x: -1_i16 };
let _ = managed.self_by_ref(-11, -12);
let _ = managed.self_by_val(-13, -14);
let _ = managed.self_managed(-15, -16);
}
fn zzz() {()}

View file

@ -0,0 +1,140 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// STACK BY REF
// debugger:finish
// debugger:print *self
// check:$1 = {x = 100}
// debugger:print arg1
// check:$2 = -1
// debugger:print arg2
// check:$3 = -2
// debugger:continue
// STACK BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 100}
// debugger:print arg1
// check:$4 = -3
// debugger:print arg2
// check:$5 = -4
// debugger:continue
// OWNED BY REF
// debugger:finish
// debugger:print *self
// check:$6 = {x = 200}
// debugger:print arg1
// check:$7 = -5
// debugger:print arg2
// check:$8 = -6
// debugger:continue
// OWNED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 200}
// debugger:print arg1
// check:$9 = -7
// debugger:print arg2
// check:$10 = -8
// debugger:continue
// OWNED MOVED
// debugger:finish
// debugger:print *self
// check:$11 = {x = 200}
// debugger:print arg1
// check:$12 = -9
// debugger:print arg2
// check:$13 = -10
// debugger:continue
// MANAGED BY REF
// debugger:finish
// debugger:print *self
// check:$14 = {x = 300}
// debugger:print arg1
// check:$15 = -11
// debugger:print arg2
// check:$16 = -12
// debugger:continue
// MANAGED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 300}
// debugger:print arg1
// check:$17 = -13
// debugger:print arg2
// check:$18 = -14
// debugger:continue
// MANAGED SELF
// debugger:finish
// debugger:print self->val
// check:$19 = {x = 300}
// debugger:print arg1
// check:$20 = -15
// debugger:print arg2
// check:$21 = -16
// debugger:continue
struct Struct {
x: int
}
impl Struct {
fn self_by_ref(&self, arg1: int, arg2: int) -> int {
zzz();
self.x + arg1 + arg2
}
fn self_by_val(self, arg1: int, arg2: int) -> int {
zzz();
self.x + arg1 + arg2
}
fn self_owned(~self, arg1: int, arg2: int) -> int {
zzz();
self.x + arg1 + arg2
}
fn self_managed(@self, arg1: int, arg2: int) -> int {
zzz();
self.x + arg1 + arg2
}
}
fn main() {
let stack = Struct { x: 100 };
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);
let owned = ~Struct { x: 200 };
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
let managed = @Struct { x: 300 };
let _ = managed.self_by_ref(-11, -12);
let _ = managed.self_by_val(-13, -14);
let _ = managed.self_managed(-15, -16);
}
fn zzz() {()}

View file

@ -0,0 +1,147 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// STACK BY REF
// debugger:finish
// debugger:print *self
// check:$1 = {x = 100}
// debugger:print arg1
// check:$2 = -1
// debugger:print arg2
// check:$3 = -2
// debugger:continue
// STACK BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 100}
// debugger:print arg1
// check:$4 = -3
// debugger:print arg2
// check:$5 = -4
// debugger:continue
// OWNED BY REF
// debugger:finish
// debugger:print *self
// check:$6 = {x = 200}
// debugger:print arg1
// check:$7 = -5
// debugger:print arg2
// check:$8 = -6
// debugger:continue
// OWNED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 200}
// debugger:print arg1
// check:$9 = -7
// debugger:print arg2
// check:$10 = -8
// debugger:continue
// OWNED MOVED
// debugger:finish
// debugger:print *self
// check:$11 = {x = 200}
// debugger:print arg1
// check:$12 = -9
// debugger:print arg2
// check:$13 = -10
// debugger:continue
// MANAGED BY REF
// debugger:finish
// debugger:print *self
// check:$14 = {x = 300}
// debugger:print arg1
// check:$15 = -11
// debugger:print arg2
// check:$16 = -12
// debugger:continue
// MANAGED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 300}
// debugger:print arg1
// check:$17 = -13
// debugger:print arg2
// check:$18 = -14
// debugger:continue
// MANAGED SELF
// debugger:finish
// debugger:print self->val
// check:$19 = {x = 300}
// debugger:print arg1
// check:$20 = -15
// debugger:print arg2
// check:$21 = -16
// debugger:continue
struct Struct {
x: int
}
trait Trait {
fn self_by_ref(&self, arg1: int, arg2: int) -> int;
fn self_by_val(self, arg1: int, arg2: int) -> int;
fn self_owned(~self, arg1: int, arg2: int) -> int;
fn self_managed(@self, arg1: int, arg2: int) -> int;
}
impl Trait for Struct {
fn self_by_ref(&self, arg1: int, arg2: int) -> int {
zzz();
self.x + arg1 + arg2
}
fn self_by_val(self, arg1: int, arg2: int) -> int {
zzz();
self.x + arg1 + arg2
}
fn self_owned(~self, arg1: int, arg2: int) -> int {
zzz();
self.x + arg1 + arg2
}
fn self_managed(@self, arg1: int, arg2: int) -> int {
zzz();
self.x + arg1 + arg2
}
}
fn main() {
let stack = Struct { x: 100 };
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);
let owned = ~Struct { x: 200 };
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
let managed = @Struct { x: 300 };
let _ = managed.self_by_ref(-11, -12);
let _ = managed.self_by_val(-13, -14);
let _ = managed.self_managed(-15, -16);
}
fn zzz() {()}

View file

@ -0,0 +1,138 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// STACK BY REF
// debugger:finish
// debugger:print *self
// check:$1 = {100, -100.5}
// debugger:print arg1
// check:$2 = -1
// debugger:print arg2
// check:$3 = -2
// debugger:continue
// STACK BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {100, -100.5}
// debugger:print arg1
// check:$4 = -3
// debugger:print arg2
// check:$5 = -4
// debugger:continue
// OWNED BY REF
// debugger:finish
// debugger:print *self
// check:$6 = {200, -200.5}
// debugger:print arg1
// check:$7 = -5
// debugger:print arg2
// check:$8 = -6
// debugger:continue
// OWNED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {200, -200.5}
// debugger:print arg1
// check:$9 = -7
// debugger:print arg2
// check:$10 = -8
// debugger:continue
// OWNED MOVED
// debugger:finish
// debugger:print *self
// check:$11 = {200, -200.5}
// debugger:print arg1
// check:$12 = -9
// debugger:print arg2
// check:$13 = -10
// debugger:continue
// MANAGED BY REF
// debugger:finish
// debugger:print *self
// check:$14 = {300, -300.5}
// debugger:print arg1
// check:$15 = -11
// debugger:print arg2
// check:$16 = -12
// debugger:continue
// MANAGED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {300, -300.5}
// debugger:print arg1
// check:$17 = -13
// debugger:print arg2
// check:$18 = -14
// debugger:continue
// MANAGED SELF
// debugger:finish
// debugger:print self->val
// check:$19 = {300, -300.5}
// debugger:print arg1
// check:$20 = -15
// debugger:print arg2
// check:$21 = -16
// debugger:continue
struct TupleStruct(int, float);
impl TupleStruct {
fn self_by_ref(&self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_by_val(self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_owned(~self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_managed(@self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
}
fn main() {
let stack = TupleStruct(100, -100.5);
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);
let owned = ~TupleStruct(200, -200.5);
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
let managed = @TupleStruct(300, -300.5);
let _ = managed.self_by_ref(-11, -12);
let _ = managed.self_by_val(-13, -14);
let _ = managed.self_managed(-15, -16);
}
fn zzz() {()}

View file

@ -9,7 +9,6 @@
// except according to those terms.
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// xfail-test broken in newrt?
// compile-flags:-Z extra-debug-info
// debugger:break zzz
@ -25,31 +24,47 @@
// debugger:print full
// check:$3 = {454545, 0x87654321, 9988}
// debugger:print empty
// check:$4 = {0, 0x0, 0}
// debugger:print empty->discr
// check:$4 = (int *) 0x0
// debugger:print droid
// check:$5 = {id = 675675, range = 10000001, internals = 0x43218765}
// debugger:print void_droid
// check:$6 = {id = 0, range = 0, internals = 0x0}
// debugger:print void_droid->internals
// check:$6 = (int *) 0x0
// debugger:continue
// If a struct has exactly two variants, one of them is empty, and the other one
// contains a non-nullable pointer, then this value is used as the discriminator.
// The test cases in this file make sure that something readable is generated for
// this kind of types.
// Unfortunately (for these test cases) the content of the non-discriminant fields
// in the null-case is not defined. So we just read the discriminator field in
// this case (by casting the value to a memory-equivalent struct).
enum MoreFields<'self> {
Full(u32, &'self int, i16),
Empty
}
struct MoreFieldsRepr<'self> {
a: u32,
discr: &'self int,
b: i16
}
enum NamedFields<'self> {
Droid { id: i32, range: i64, internals: &'self int },
Void
}
struct NamedFieldsRepr<'self> {
id: i32,
range: i64,
internals: &'self int
}
fn main() {
let some: Option<&u32> = Some(unsafe { std::cast::transmute(0x12345678) });
@ -58,15 +73,17 @@ fn main() {
let full = Full(454545, unsafe { std::cast::transmute(0x87654321) }, 9988);
let int_val = 0;
let mut empty = Full(0, &int_val, 0);
empty = Empty;
let empty: &MoreFieldsRepr = unsafe { std::cast::transmute(&Empty) };
let droid = Droid { id: 675675, range: 10000001, internals: unsafe { std::cast::transmute(0x43218765) } };
let droid = Droid {
id: 675675,
range: 10000001,
internals: unsafe { std::cast::transmute(0x43218765) }
};
let mut void_droid = Droid { id: 0, range: 0, internals: &int_val };
void_droid = Void;
let void_droid: &NamedFieldsRepr = unsafe { std::cast::transmute(&Void) };
zzz();
}
fn zzz() {()}
fn zzz() {()}

View file

@ -0,0 +1,141 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// STACK BY REF
// debugger:finish
// debugger:print *self
// check:$1 = {x = 100}
// debugger:print arg1
// check:$2 = -1
// debugger:print arg2
// check:$3 = -2
// debugger:continue
// STACK BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 100}
// debugger:print arg1
// check:$4 = -3
// debugger:print arg2
// check:$5 = -4
// debugger:continue
// OWNED BY REF
// debugger:finish
// debugger:print *self
// check:$6 = {x = 200}
// debugger:print arg1
// check:$7 = -5
// debugger:print arg2
// check:$8 = -6
// debugger:continue
// OWNED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 200}
// debugger:print arg1
// check:$9 = -7
// debugger:print arg2
// check:$10 = -8
// debugger:continue
// OWNED MOVED
// debugger:finish
// debugger:print *self
// check:$11 = {x = 200}
// debugger:print arg1
// check:$12 = -9
// debugger:print arg2
// check:$13 = -10
// debugger:continue
// MANAGED BY REF
// debugger:finish
// debugger:print *self
// check:$14 = {x = 300}
// debugger:print arg1
// check:$15 = -11
// debugger:print arg2
// check:$16 = -12
// debugger:continue
// MANAGED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 300}
// debugger:print arg1
// check:$17 = -13
// debugger:print arg2
// check:$18 = -14
// debugger:continue
// MANAGED SELF
// debugger:finish
// debugger:print self->val
// check:$19 = {x = 300}
// debugger:print arg1
// check:$20 = -15
// debugger:print arg2
// check:$21 = -16
// debugger:continue
struct Struct {
x: int
}
trait Trait {
fn self_by_ref(&self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_by_val(self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_owned(~self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
fn self_managed(@self, arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
}
impl Trait for Struct;
fn main() {
let stack = Struct { x: 100 };
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);
let owned = ~Struct { x: 200 };
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
let managed = @Struct { x: 300 };
let _ = managed.self_by_ref(-11, -12);
let _ = managed.self_by_val(-13, -14);
let _ = managed.self_managed(-15, -16);
}
fn zzz() {()}

View file

@ -0,0 +1,142 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// STACK BY REF
// debugger:finish
// debugger:print *self
// check:$1 = {x = 987}
// debugger:print arg1
// check:$2 = -1
// debugger:print/d arg2
// check:$3 = -2
// debugger:continue
// STACK BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 987}
// debugger:print arg1
// check:$4 = -3
// debugger:print arg2
// check:$5 = -4
// debugger:continue
// OWNED BY REF
// debugger:finish
// debugger:print *self
// check:$6 = {x = 879}
// debugger:print arg1
// check:$7 = -5
// debugger:print arg2
// check:$8 = -6
// debugger:continue
// OWNED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 879}
// debugger:print arg1
// check:$9 = -7
// debugger:print arg2
// check:$10 = -8
// debugger:continue
// OWNED MOVED
// debugger:finish
// debugger:print *self
// check:$11 = {x = 879}
// debugger:print arg1
// check:$12 = -9
// debugger:print arg2
// check:$13 = -10.5
// debugger:continue
// MANAGED BY REF
// debugger:finish
// debugger:print *self
// check:$14 = {x = 897}
// debugger:print arg1
// check:$15 = -11
// debugger:print arg2
// check:$16 = -12.5
// debugger:continue
// MANAGED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {x = 897}
// debugger:print arg1
// check:$17 = -13
// debugger:print *arg2
// check:$18 = {-14, 14}
// debugger:continue
// MANAGED SELF
// debugger:finish
// debugger:print self->val
// check:$19 = {x = 897}
// debugger:print arg1
// check:$20 = -15
// debugger:print *arg2
// check:$21 = {-16, 16.5}
// debugger:continue
struct Struct {
x: int
}
trait Trait {
fn self_by_ref<T>(&self, arg1: int, arg2: T) -> int {
zzz();
arg1
}
fn self_by_val<T>(self, arg1: int, arg2: T) -> int {
zzz();
arg1
}
fn self_owned<T>(~self, arg1: int, arg2: T) -> int {
zzz();
arg1
}
fn self_managed<T>(@self, arg1: int, arg2: T) -> int {
zzz();
arg1
}
}
impl Trait for Struct;
fn main() {
let stack = Struct { x: 987 };
let _ = stack.self_by_ref(-1, -2_i8);
let _ = stack.self_by_val(-3, -4_i16);
let owned = ~Struct { x: 879 };
let _ = owned.self_by_ref(-5, -6_i32);
let _ = owned.self_by_val(-7, -8_i64);
let _ = owned.self_owned(-9, -10.5_f32);
let managed = @Struct { x: 897 };
let _ = managed.self_by_ref(-11, -12.5_f64);
let _ = managed.self_by_val(-13, &(-14, 14));
let _ = managed.self_managed(-15, &(-16, 16.5));
}
fn zzz() {()}

View file

@ -0,0 +1,67 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// STRUCT
// debugger:finish
// debugger:print arg1
// check:$1 = 1
// debugger:print arg2
// check:$2 = 2
// debugger:continue
// ENUM
// debugger:finish
// debugger:print arg1
// check:$3 = -3
// debugger:print arg2
// check:$4 = 4.5
// debugger:print arg3
// check:$5 = 5
// debugger:continue
struct Struct {
x: int
}
impl Struct {
fn static_method(arg1: int, arg2: int) -> int {
zzz();
arg1 + arg2
}
}
enum Enum {
Variant1 { x: int },
Variant2,
Variant3(float, int, char),
}
impl Enum {
fn static_method(arg1: int, arg2: float, arg3: uint) -> int {
zzz();
arg1
}
}
fn main() {
Struct::static_method(1, 2);
Enum::static_method(-3, 4.5, 5);
}
fn zzz() {()}

View file

@ -0,0 +1,53 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print arg1
// check:$1 = 1000
// debugger:print arg2
// check:$2 = 0.5
// debugger:continue
// debugger:finish
// debugger:print arg1
// check:$3 = 2000
// debugger:print *arg2
// check:$4 = {1, 2, 3}
// debugger:continue
struct Struct {
x: int
}
trait Trait {
fn generic_static_default_method<T>(arg1: int, arg2: T) -> int {
zzz();
arg1
}
}
impl Trait for Struct;
fn main() {
// Is this really how to use these?
Trait::generic_static_default_method::<Struct, float>(1000, 0.5);
Trait::generic_static_default_method::<Struct, &(int, int, int)>(2000, &(1, 2, 3));
}
fn zzz() {()}

View file

@ -0,0 +1,60 @@
// Copyright 2013 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-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:set print pretty off
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print no_padding16
// check:$1 = {10000, -10001}
// debugger:print no_padding32
// check:$2 = {-10002, -10003.5, 10004}
// debugger:print no_padding64
// check:$3 = {-10005.5, 10006, 10007}
// debugger:print no_padding163264
// check:$4 = {-10008, 10009, 10010, 10011}
// debugger:print internal_padding
// check:$5 = {10012, -10013}
// debugger:print padding_at_end
// check:$6 = {-10014, 10015}
// This test case mainly makes sure that no field names are generated for tuple structs (as opposed
// to all fields having the name "__field__"). Otherwise they are handled the same a normal structs.
struct NoPadding16(u16, i16);
struct NoPadding32(i32, f32, u32);
struct NoPadding64(f64, i64, u64);
struct NoPadding163264(i16, u16, i32, u64);
struct InternalPadding(u16, i64);
struct PaddingAtEnd(i64, u16);
fn main() {
let no_padding16 = NoPadding16(10000, -10001);
let no_padding32 = NoPadding32(-10002, -10003.5, 10004);
let no_padding64 = NoPadding64(-10005.5, 10006, 10007);
let no_padding163264 = NoPadding163264(-10008, 10009, 10010, 10011);
let internal_padding = InternalPadding(10012, -10013);
let padding_at_end = PaddingAtEnd(-10014, 10015);
zzz();
}
fn zzz() {()}