Skip to content

Commit 5abb7c3

Browse files
debuginfo: Test cases for [generic][default][static] methods and functions:
* closure-in-generic-function * generic-functions-nested * generic-method-on-generic-struct * generic-trait-generic-static-default-method * method-on-generic-struct * self-in-generic-default-method * trait-generic-static-default-method Also, fixed an 'unused variable' warning in debuginfo.rs
1 parent 0e7808c commit 5abb7c3

9 files changed

+635
-3
lines changed

src/librustc/middle/trans/debuginfo.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram {
406406
let template_parameters = get_template_parameters(fcx,
407407
generics,
408408
file_metadata,
409-
span,
410409
&mut function_name);
411410

412411
let fn_metadata = do function_name.to_c_str().with_ref |function_name| {
@@ -508,7 +507,6 @@ pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram {
508507
fn get_template_parameters(fcx: &FunctionContext,
509508
generics: &ast::Generics,
510509
file_metadata: DIFile,
511-
span: span,
512510
name_to_append_suffix_to: &mut ~str)
513511
-> DIArray {
514512
let cx = fcx.ccx;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:break zzz
15+
// debugger:run
16+
17+
// debugger:finish
18+
// debugger:print x
19+
// check:$1 = 0.5
20+
// debugger:print y
21+
// check:$2 = 10
22+
// debugger:continue
23+
24+
// debugger:finish
25+
// debugger:print *x
26+
// check:$3 = 29
27+
// debugger:print *y
28+
// check:$4 = 110
29+
// debugger:continue
30+
31+
fn some_generic_fun<T1, T2>(a: T1, b: T2) -> (T2, T1) {
32+
33+
let closure = |x, y| {
34+
zzz();
35+
(y, x)
36+
};
37+
38+
closure(a, b)
39+
}
40+
41+
fn main() {
42+
some_generic_fun(0.5, 10);
43+
some_generic_fun(&29, ~110);
44+
}
45+
46+
fn zzz() {()}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:break zzz
15+
// debugger:run
16+
17+
// debugger:finish
18+
// debugger:print x
19+
// check:$1 = -1
20+
// debugger:print y
21+
// check:$2 = 1
22+
// debugger:continue
23+
24+
// debugger:finish
25+
// debugger:print x
26+
// check:$3 = -1
27+
// debugger:print y
28+
// check:$4 = 2.5
29+
// debugger:continue
30+
31+
// debugger:finish
32+
// debugger:print x
33+
// check:$5 = -2.5
34+
// debugger:print y
35+
// check:$6 = 1
36+
// debugger:continue
37+
38+
// debugger:finish
39+
// debugger:print x
40+
// check:$7 = -2.5
41+
// debugger:print y
42+
// check:$8 = 2.5
43+
// debugger:continue
44+
45+
fn outer<TA: Clone>(a: TA) {
46+
inner(a.clone(), 1);
47+
inner(a.clone(), 2.5);
48+
49+
fn inner<TX, TY>(x: TX, y: TY) {
50+
zzz();
51+
}
52+
}
53+
54+
fn main() {
55+
outer(-1);
56+
outer(-2.5);
57+
}
58+
59+
fn zzz() {()}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:break zzz
15+
// debugger:run
16+
17+
// STACK BY REF
18+
// debugger:finish
19+
// debugger:print *self
20+
// check:$1 = {x = {8888, -8888}}
21+
// debugger:print arg1
22+
// check:$2 = -1
23+
// debugger:print/d arg2
24+
// check:$3 = -2
25+
// debugger:continue
26+
27+
// STACK BY VAL
28+
// debugger:finish
29+
// d ebugger:print self -- ignored for now because of issue #8512
30+
// c heck:$X = {x = {8888, -8888}}
31+
// debugger:print arg1
32+
// check:$4 = -3
33+
// debugger:print arg2
34+
// check:$5 = -4
35+
// debugger:continue
36+
37+
// OWNED BY REF
38+
// debugger:finish
39+
// debugger:print *self
40+
// check:$6 = {x = 1234.5}
41+
// debugger:print arg1
42+
// check:$7 = -5
43+
// debugger:print arg2
44+
// check:$8 = -6
45+
// debugger:continue
46+
47+
// OWNED BY VAL
48+
// debugger:finish
49+
// d ebugger:print self -- ignored for now because of issue #8512
50+
// c heck:$X = {x = 1234.5}
51+
// debugger:print arg1
52+
// check:$9 = -7
53+
// debugger:print arg2
54+
// check:$10 = -8
55+
// debugger:continue
56+
57+
// OWNED MOVED
58+
// debugger:finish
59+
// debugger:print *self
60+
// check:$11 = {x = 1234.5}
61+
// debugger:print arg1
62+
// check:$12 = -9
63+
// debugger:print arg2
64+
// check:$13 = -10.5
65+
// debugger:continue
66+
67+
// MANAGED BY REF
68+
// debugger:finish
69+
// debugger:print *self
70+
// check:$14 = {x = -1}
71+
// debugger:print arg1
72+
// check:$15 = -11
73+
// debugger:print arg2
74+
// check:$16 = -12.5
75+
// debugger:continue
76+
77+
// MANAGED BY VAL
78+
// debugger:finish
79+
// d ebugger:print self -- ignored for now because of issue #8512
80+
// c heck:$X = {x = -1}
81+
// debugger:print arg1
82+
// check:$17 = -13
83+
// debugger:print *arg2
84+
// check:$18 = {-14, 14}
85+
// debugger:continue
86+
87+
// MANAGED SELF
88+
// debugger:finish
89+
// debugger:print self->val
90+
// check:$19 = {x = -1}
91+
// debugger:print arg1
92+
// check:$20 = -15
93+
// debugger:print *arg2
94+
// check:$21 = {-16, 16.5}
95+
// debugger:continue
96+
97+
struct Struct<T> {
98+
x: T
99+
}
100+
101+
impl<T1> Struct<T1> {
102+
103+
fn self_by_ref<T2>(&self, arg1: int, arg2: T2) -> int {
104+
zzz();
105+
arg1
106+
}
107+
108+
fn self_by_val<T2>(self, arg1: int, arg2: T2) -> int {
109+
zzz();
110+
arg1
111+
}
112+
113+
fn self_owned<T2>(~self, arg1: int, arg2: T2) -> int {
114+
zzz();
115+
arg1
116+
}
117+
118+
fn self_managed<T2>(@self, arg1: int, arg2: T2) -> int {
119+
zzz();
120+
arg1
121+
}
122+
}
123+
124+
fn main() {
125+
let stack = Struct { x: (8888_u32, -8888_i32) };
126+
let _ = stack.self_by_ref(-1, -2_i8);
127+
let _ = stack.self_by_val(-3, -4_i16);
128+
129+
let owned = ~Struct { x: 1234.5 };
130+
let _ = owned.self_by_ref(-5, -6_i32);
131+
let _ = owned.self_by_val(-7, -8_i64);
132+
let _ = owned.self_owned(-9, -10.5_f32);
133+
134+
let managed = @Struct { x: -1_i16 };
135+
let _ = managed.self_by_ref(-11, -12.5_f64);
136+
let _ = managed.self_by_val(-13, &(-14, 14));
137+
let _ = managed.self_managed(-15, &(-16, 16.5));
138+
}
139+
140+
fn zzz() {()}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:break zzz
15+
// debugger:run
16+
17+
// debugger:finish
18+
// debugger:print arg1
19+
// check:$1 = 1000
20+
// debugger:print *arg2
21+
// check:$2 = {1, 2.5}
22+
// debugger:continue
23+
24+
// debugger:finish
25+
// debugger:print arg1
26+
// check:$3 = 2000
27+
// debugger:print *arg2
28+
// check:$4 = {3.5, {4, 5, 6}}
29+
// debugger:continue
30+
31+
32+
struct Struct {
33+
x: int
34+
}
35+
36+
trait Trait<T1> {
37+
fn generic_static_default_method<T2>(arg1: int, arg2: &(T1, T2)) -> int {
38+
zzz();
39+
arg1
40+
}
41+
}
42+
43+
impl<T> Trait<T> for Struct;
44+
45+
fn main() {
46+
47+
// Is this really how to use these?
48+
Trait::generic_static_default_method::<int, Struct, float>(1000, &(1, 2.5));
49+
Trait::generic_static_default_method::<float, Struct, (int, int, int)>(2000, &(3.5, (4, 5, 6)));
50+
51+
}
52+
53+
fn zzz() {()}

src/test/debug-info/lexical-scope-in-parameterless-closure.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010

1111
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
1212

13-
// compile-flags:-Z extra-debug-info
13+
// compile-flags:-Z debug-info
1414
// debugger:run
1515

1616
// Nothing to do here really, just make sure it compiles. See issue #8513.
1717
fn main() {
1818
let _ = ||();
19+
let _ = range(1u,3).map(|_| 5);
1920
}
2021

0 commit comments

Comments
 (0)