Skip to content

Commit d56b116

Browse files
Rollup merge of #36559 - grimreaper:eax/fix/r1, r=nikomatsakis
Fix a variety of minor issues CSS: - use integer values for font-size in CSS - use correct ordering of @import - "invisible" isn't a tag - presume its a class - "border-color" defines the complete border python: - use "not" instead of == "[]" for python - prefer triple quoted docstrings - prefer static functions where possible - prefer modern style classes where possible - remove semicolons; global: - remove duplicated words words
2 parents 677ede2 + 0c252ff commit d56b116

File tree

15 files changed

+69
-58
lines changed

15 files changed

+69
-58
lines changed

src/bootstrap/bootstrap.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ def stage0_data(rust_root):
131131
def format_build_time(duration):
132132
return str(datetime.timedelta(seconds=int(duration)))
133133

134-
class RustBuild:
134+
135+
class RustBuild(object):
135136
def download_stage0(self):
136137
cache_dst = os.path.join(self.build_dir, "cache")
137138
rustc_cache = os.path.join(cache_dst, self.stage0_rustc_date())
@@ -142,7 +143,7 @@ def download_stage0(self):
142143
os.makedirs(cargo_cache)
143144

144145
if self.rustc().startswith(self.bin_root()) and \
145-
(not os.path.exists(self.rustc()) or self.rustc_out_of_date()):
146+
(not os.path.exists(self.rustc()) or self.rustc_out_of_date()):
146147
if os.path.exists(self.bin_root()):
147148
shutil.rmtree(self.bin_root())
148149
channel = self.stage0_rustc_channel()
@@ -165,7 +166,7 @@ def download_stage0(self):
165166
f.write(self.stage0_rustc_date())
166167

167168
if self.cargo().startswith(self.bin_root()) and \
168-
(not os.path.exists(self.cargo()) or self.cargo_out_of_date()):
169+
(not os.path.exists(self.cargo()) or self.cargo_out_of_date()):
169170
channel = self.stage0_cargo_channel()
170171
filename = "cargo-{}-{}.tar.gz".format(channel, self.build)
171172
url = "https://static.rust-lang.org/cargo-dist/" + self.stage0_cargo_date()
@@ -238,8 +239,8 @@ def rustc(self):
238239

239240
def get_string(self, line):
240241
start = line.find('"')
241-
end = start + 1 + line[start+1:].find('"')
242-
return line[start+1:end]
242+
end = start + 1 + line[start + 1:].find('"')
243+
return line[start + 1:end]
243244

244245
def exe_suffix(self):
245246
if sys.platform == 'win32':

src/doc/rust.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ em {
159159

160160
footer {
161161
border-top: 1px solid #ddd;
162-
font-size: 14.3px;
162+
font-size: 14px;
163163
font-style: italic;
164164
padding-top: 5px;
165165
margin-top: 3em;

src/etc/debugger_pretty_printers_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def extract_length_and_ptr_from_slice(slice_val):
328328
UNQUALIFIED_TYPE_MARKERS = frozenset(["(", "[", "&", "*"])
329329

330330
def extract_type_name(qualified_type_name):
331-
'''Extracts the type name from a fully qualified path'''
331+
"""Extracts the type name from a fully qualified path"""
332332
if qualified_type_name[0] in UNQUALIFIED_TYPE_MARKERS:
333333
return qualified_type_name
334334

src/etc/gdb_rust_pretty_printing.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def rust_pretty_printer_lookup_function(gdb_val):
170170
#=------------------------------------------------------------------------------
171171
# Pretty Printer Classes
172172
#=------------------------------------------------------------------------------
173-
class RustStructPrinter:
173+
class RustStructPrinter(object):
174174
def __init__(self, val, omit_first_field, omit_type_name, is_tuple_like):
175175
self.__val = val
176176
self.__omit_first_field = omit_first_field
@@ -205,11 +205,12 @@ def display_hint(self):
205205
return ""
206206

207207

208-
class RustSlicePrinter:
208+
class RustSlicePrinter(object):
209209
def __init__(self, val):
210210
self.__val = val
211211

212-
def display_hint(self):
212+
@staticmethod
213+
def display_hint():
213214
return "array"
214215

215216
def to_string(self):
@@ -226,7 +227,7 @@ def children(self):
226227
yield (str(index), (raw_ptr + index).dereference())
227228

228229

229-
class RustStringSlicePrinter:
230+
class RustStringSlicePrinter(object):
230231
def __init__(self, val):
231232
self.__val = val
232233

@@ -236,11 +237,12 @@ def to_string(self):
236237
return '"%s"' % raw_ptr.string(encoding="utf-8", length=length)
237238

238239

239-
class RustStdVecPrinter:
240+
class RustStdVecPrinter(object):
240241
def __init__(self, val):
241242
self.__val = val
242243

243-
def display_hint(self):
244+
@staticmethod
245+
def display_hint():
244246
return "array"
245247

246248
def to_string(self):
@@ -255,7 +257,7 @@ def children(self):
255257
yield (str(index), (gdb_ptr + index).dereference())
256258

257259

258-
class RustStdStringPrinter:
260+
class RustStdStringPrinter(object):
259261
def __init__(self, val):
260262
self.__val = val
261263

@@ -266,7 +268,7 @@ def to_string(self):
266268
length=length)
267269

268270

269-
class RustCStyleVariantPrinter:
271+
class RustCStyleVariantPrinter(object):
270272
def __init__(self, val):
271273
assert val.type.get_dwarf_type_kind() == rustpp.DWARF_TYPE_CODE_ENUM
272274
self.__val = val
@@ -275,7 +277,7 @@ def to_string(self):
275277
return str(self.__val.get_wrapped_value())
276278

277279

278-
class IdentityPrinter:
280+
class IdentityPrinter(object):
279281
def __init__(self, string):
280282
self.string = string
281283

src/etc/lldb_batchmode.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737

3838

3939
def print_debug(s):
40-
"Print something if DEBUG_OUTPUT is True"
40+
"""Print something if DEBUG_OUTPUT is True"""
4141
global DEBUG_OUTPUT
4242
if DEBUG_OUTPUT:
4343
print("DEBUG: " + str(s))
4444

4545

4646
def normalize_whitespace(s):
47-
"Replace newlines, tabs, multiple spaces, etc with exactly one space"
47+
"""Replace newlines, tabs, multiple spaces, etc with exactly one space"""
4848
return re.sub("\s+", " ", s)
4949

5050

@@ -71,7 +71,7 @@ def breakpoint_callback(frame, bp_loc, dict):
7171

7272

7373
def execute_command(command_interpreter, command):
74-
"Executes a single CLI command"
74+
"""Executes a single CLI command"""
7575
global new_breakpoints
7676
global registered_breakpoints
7777

src/etc/lldb_rust_formatters.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ def print_val(lldb_val, internal_dict):
171171
#=--------------------------------------------------------------------------------------------------
172172

173173
def print_struct_val(val, internal_dict, omit_first_field, omit_type_name, is_tuple_like):
174-
'''
174+
"""
175175
Prints a struct, tuple, or tuple struct value with Rust syntax.
176176
Ignores any fields before field_start_index.
177-
'''
177+
"""
178178
assert val.type.get_dwarf_type_kind() == rustpp.DWARF_TYPE_CODE_STRUCT
179179

180180
if omit_type_name:
@@ -221,7 +221,7 @@ def render_child(child_index):
221221
"body": body}
222222

223223
def print_pointer_val(val, internal_dict):
224-
'''Prints a pointer value with Rust syntax'''
224+
"""Prints a pointer value with Rust syntax"""
225225
assert val.type.get_dwarf_type_kind() == rustpp.DWARF_TYPE_CODE_PTR
226226
sigil = "&"
227227
type_name = val.type.get_unqualified_type_name()
@@ -275,8 +275,8 @@ def print_std_string_val(val, internal_dict):
275275
#=--------------------------------------------------------------------------------------------------
276276

277277
def print_array_of_values(array_name, data_ptr_val, length, internal_dict):
278-
'''Prints a contigous memory range, interpreting it as values of the
279-
pointee-type of data_ptr_val.'''
278+
"""Prints a contigous memory range, interpreting it as values of the
279+
pointee-type of data_ptr_val."""
280280

281281
data_ptr_type = data_ptr_val.type
282282
assert data_ptr_type.get_dwarf_type_kind() == rustpp.DWARF_TYPE_CODE_PTR

src/etc/platform-intrinsics/generator.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,19 @@ class Void(Type):
119119
def __init__(self):
120120
Type.__init__(self, 0)
121121

122-
def compiler_ctor(self):
122+
@staticmethod
123+
def compiler_ctor():
123124
return '::VOID'
124125

125126
def compiler_ctor_ref(self):
126127
return '&' + self.compiler_ctor()
127128

128-
def rust_name(self):
129+
@staticmethod
130+
def rust_name():
129131
return '()'
130132

131-
def type_info(self, platform_info):
133+
@staticmethod
134+
def type_info(platform_info):
132135
return None
133136

134137
def __eq__(self, other):
@@ -282,7 +285,7 @@ def __eq__(self, other):
282285

283286
class Pointer(Type):
284287
def __init__(self, elem, llvm_elem, const):
285-
self._elem = elem;
288+
self._elem = elem
286289
self._llvm_elem = llvm_elem
287290
self._const = const
288291
Type.__init__(self, BITWIDTH_POINTER)
@@ -503,7 +506,7 @@ def monomorphise(self):
503506
# must be a power of two
504507
assert width & (width - 1) == 0
505508
def recur(processed, untouched):
506-
if untouched == []:
509+
if not untouched:
507510
ret = processed[0]
508511
args = processed[1:]
509512
yield MonomorphicIntrinsic(self._platform, self.intrinsic, width,
@@ -756,22 +759,26 @@ class ExternBlock(object):
756759
def __init__(self):
757760
pass
758761

759-
def open(self, platform):
762+
@staticmethod
763+
def open(platform):
760764
return 'extern "platform-intrinsic" {'
761765

762-
def render(self, mono):
766+
@staticmethod
767+
def render(mono):
763768
return ' fn {}{}{};'.format(mono.platform_prefix(),
764769
mono.intrinsic_name(),
765770
mono.intrinsic_signature())
766771

767-
def close(self):
772+
@staticmethod
773+
def close():
768774
return '}'
769775

770776
class CompilerDefs(object):
771777
def __init__(self):
772778
pass
773779

774-
def open(self, platform):
780+
@staticmethod
781+
def open(platform):
775782
return '''\
776783
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
777784
// file at the top-level directory of this distribution and at
@@ -798,7 +805,8 @@ def open(self, platform):
798805
if !name.starts_with("{0}") {{ return None }}
799806
Some(match &name["{0}".len()..] {{'''.format(platform.platform_prefix())
800807

801-
def render(self, mono):
808+
@staticmethod
809+
def render(mono):
802810
return '''\
803811
"{}" => Intrinsic {{
804812
inputs: {{ static INPUTS: [&'static Type; {}] = [{}]; &INPUTS }},
@@ -810,7 +818,8 @@ def render(self, mono):
810818
mono.compiler_ret(),
811819
mono.llvm_name())
812820

813-
def close(self):
821+
@staticmethod
822+
def close():
814823
return '''\
815824
_ => return None,
816825
})

src/etc/test-float-parse/runtests.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,13 @@ def run(test):
177177

178178

179179
def interact(proc, queue):
180-
line = ""
181180
n = 0
182181
while proc.poll() is None:
183182
line = proc.stdout.readline()
184183
if not line:
185184
continue
186185
assert line.endswith('\n'), "incomplete line: " + repr(line)
187186
queue.put(line)
188-
line = ""
189187
n += 1
190188
if n % UPDATE_EVERY_N == 0:
191189
msg("got", str(n // 1000) + "k", "records")

src/etc/unicode.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,28 @@ def load_unicode_data(f):
8282
canon_decomp = {}
8383
compat_decomp = {}
8484

85-
udict = {};
86-
range_start = -1;
85+
udict = {}
86+
range_start = -1
8787
for line in fileinput.input(f):
88-
data = line.split(';');
88+
data = line.split(';')
8989
if len(data) != 15:
9090
continue
91-
cp = int(data[0], 16);
91+
cp = int(data[0], 16)
9292
if is_surrogate(cp):
9393
continue
9494
if range_start >= 0:
9595
for i in xrange(range_start, cp):
96-
udict[i] = data;
97-
range_start = -1;
96+
udict[i] = data
97+
range_start = -1
9898
if data[1].endswith(", First>"):
99-
range_start = cp;
100-
continue;
101-
udict[cp] = data;
99+
range_start = cp
100+
continue
101+
udict[cp] = data
102102

103103
for code in udict:
104-
[code_org, name, gencat, combine, bidi,
104+
(code_org, name, gencat, combine, bidi,
105105
decomp, deci, digit, num, mirror,
106-
old, iso, upcase, lowcase, titlecase ] = udict[code];
106+
old, iso, upcase, lowcase, titlecase) = udict[code]
107107

108108
# generate char to char direct common and simple conversions
109109
# uppercase to lowercase
@@ -382,7 +382,7 @@ def emit_bool_trie(f, name, t_data, is_pub=True):
382382
global bytes_old, bytes_new
383383
bytes_old += 8 * len(t_data)
384384
CHUNK = 64
385-
rawdata = [False] * 0x110000;
385+
rawdata = [False] * 0x110000
386386
for (lo, hi) in t_data:
387387
for cp in range(lo, hi + 1):
388388
rawdata[cp] = True

src/librustc/mir/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl<'tcx> Mir<'tcx> {
180180
Some(Local::new(idx))
181181
}
182182

183-
/// Counts the number of locals, such that that local_index
183+
/// Counts the number of locals, such that local_index
184184
/// will always return an index smaller than this count.
185185
pub fn count_locals(&self) -> usize {
186186
self.arg_decls.len() +

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2808,7 +2808,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
28082808

28092809
/// See `ParameterEnvironment` struct def'n for details.
28102810
/// If you were using `free_id: NodeId`, you might try `self.region_maps.item_extent(free_id)`
2811-
/// for the `free_id_outlive` parameter. (But note that that is not always quite right.)
2811+
/// for the `free_id_outlive` parameter. (But note that this is not always quite right.)
28122812
pub fn construct_parameter_environment(self,
28132813
span: Span,
28142814
def_id: DefId,

src/librustc_trans/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
//! The collection algorithm handles this more or less transparently. If it is
154154
//! about to create a translation item for something with an external `DefId`,
155155
//! it will take a look if the MIR for that item is available, and if so just
156-
//! proceed normally. If the MIR is not available, it assumes that that item is
156+
//! proceed normally. If the MIR is not available, it assumes that the item is
157157
//! just linked to and no node is created; which is exactly what we want, since
158158
//! no machine code should be generated in the current crate for such an item.
159159
//!

src/librustdoc/html/highlight.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! the `render_inner_with_highlighting` or `render_with_highlighting`
1818
//! functions. For more advanced use cases (if you want to supply your own css
1919
//! classes or control how the HTML is generated, or even generate something
20-
//! other then HTML), then you should implement the the `Writer` trait and use a
20+
//! other then HTML), then you should implement the `Writer` trait and use a
2121
//! `Classifier`.
2222
2323
use html::escape::Escape;

0 commit comments

Comments
 (0)