Skip to content

Commit c067e17

Browse files
committed
rollup merge of rust-lang#19166: richo/lldb-cleanups
While poking at rust in lldb I found a few nits to clean up.
2 parents 5c53617 + 68f90a2 commit c067e17

File tree

2 files changed

+27
-36
lines changed

2 files changed

+27
-36
lines changed

src/compiletest/runtest.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ fn compile_test_(config: &Config, props: &TestProps,
11611161
let args = make_compile_args(config,
11621162
props,
11631163
link_args,
1164-
|a, b| ThisFile(make_exe_name(a, b)), testfile);
1164+
|a, b| TargetLocation::ThisFile(make_exe_name(a, b)), testfile);
11651165
compose_and_run_compiler(config, props, testfile, args, None)
11661166
}
11671167

@@ -1219,7 +1219,7 @@ fn compose_and_run_compiler(
12191219
crate_type,
12201220
|a,b| {
12211221
let f = make_lib_name(a, b, testfile);
1222-
ThisDirectory(f.dir_path())
1222+
TargetLocation::ThisDirectory(f.dir_path())
12231223
},
12241224
&abs_ab);
12251225
let auxres = compose_and_run(config,
@@ -1296,11 +1296,11 @@ fn make_compile_args(config: &Config,
12961296
args.push("prefer-dynamic".to_string());
12971297
}
12981298
let path = match xform_file {
1299-
ThisFile(path) => {
1299+
TargetLocation::ThisFile(path) => {
13001300
args.push("-o".to_string());
13011301
path
13021302
}
1303-
ThisDirectory(path) => {
1303+
TargetLocation::ThisDirectory(path) => {
13041304
args.push("--out-dir".to_string());
13051305
path
13061306
}
@@ -1672,7 +1672,8 @@ fn compile_test_and_save_bitcode(config: &Config, props: &TestProps,
16721672
let args = make_compile_args(config,
16731673
props,
16741674
link_args,
1675-
|a, b| ThisDirectory(output_base_name(a, b).dir_path()),
1675+
|a, b| TargetLocation::ThisDirectory(
1676+
output_base_name(a, b).dir_path()),
16761677
testfile);
16771678
compose_and_run_compiler(config, props, testfile, args, None)
16781679
}

src/etc/lldb_rust_formatters.py

+21-31
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ def print_struct_val(val, internal_dict):
4343
return print_struct_val_starting_from(0, val, internal_dict)
4444

4545
def print_vec_slice_val(val, internal_dict):
46-
output = "&["
47-
4846
length = val.GetChildAtIndex(1).GetValueAsUnsigned()
4947

5048
data_ptr_val = val.GetChildAtIndex(0)
@@ -56,16 +54,12 @@ def print_vec_slice_val(val, internal_dict):
5654

5755
start_address = data_ptr_val.GetValueAsUnsigned()
5856

59-
for i in range(length):
57+
def render_element(i):
6058
address = start_address + i * element_type_size
61-
element_val = val.CreateValueFromAddress( val.GetName() + ("[%s]" % i), address, element_type )
62-
output += print_val(element_val, internal_dict)
63-
64-
if i != length - 1:
65-
output += ", "
59+
element_val = val.CreateValueFromAddress( val.GetName() + ("[%s]" % i), address, element_type)
60+
return print_val(element_val, internal_dict)
6661

67-
output += "]"
68-
return output
62+
return "&[%s]" % (', '.join([render_element(i) for i in range(length)]))
6963

7064
def print_struct_val_starting_from(field_start_index, val, internal_dict):
7165
'''
@@ -77,39 +71,33 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict):
7771
t = val.GetType()
7872
has_field_names = type_has_field_names(t)
7973
type_name = extract_type_name(t.GetName())
80-
output = ""
81-
82-
if not type_name.startswith("("):
83-
# this is a tuple, so don't print the type name
84-
output += type_name
8574

8675
if has_field_names:
87-
output += " { \n"
76+
template = "%(type_name)s {\n%(body)s\n}"
77+
separator = ", \n"
8878
else:
89-
output += "("
79+
template = "%(type_name)s(%(body)s)"
80+
separator = ", "
81+
82+
if type_name.startswith("("):
83+
# this is a tuple, so don't print the type name
84+
type_name = ""
9085

9186
num_children = val.num_children
9287

93-
for child_index in range(field_start_index, num_children):
88+
def render_child(child_index):
89+
this = ""
9490
if has_field_names:
9591
field_name = t.GetFieldAtIndex(child_index).GetName()
96-
output += field_name + ": "
92+
this += field_name + ": "
9793

9894
field_val = val.GetChildAtIndex(child_index)
99-
output += print_val(field_val, internal_dict)
95+
return this + print_val(field_val, internal_dict)
10096

101-
if child_index != num_children - 1:
102-
output += ", "
103-
104-
if has_field_names:
105-
output += "\n"
106-
107-
if has_field_names:
108-
output += "}"
109-
else:
110-
output += ")"
97+
body = separator.join([render_child(idx) for idx in range(field_start_index, num_children)])
11198

112-
return output
99+
return template % {"type_name": type_name,
100+
"body": body}
113101

114102

115103
def print_enum_val(val, internal_dict):
@@ -243,3 +231,5 @@ def is_vec_slice(val):
243231

244232
type_name = extract_type_name(ty.GetName()).replace("&'static", "&").replace(" ", "")
245233
return type_name.startswith("&[") and type_name.endswith("]")
234+
235+
# vi: sw=2:ts=2

0 commit comments

Comments
 (0)