Skip to content

Commit e87e180

Browse files
committed
auto merge of #14712 : alexcrichton/rust/rollup, r=alexcrichton
Closes #14675 (rustc: Encode argument names for traits) Closes #14681 (rustc: Avoid UB with signed division/remainder) Closes #14682 (librustc: Update AutoObject adjustment in writeback.) Closes #14683 (Avoid 16-byte filenames in rlibs) Closes #14687 (rustdoc: Inline static documentation across crates) Closes #14689 (Remove reference to ~str in documentation) Closes #14692 (Rename Iterator::len to count) Closes #14693 (Implement Eq for HashSet and HashMap) Closes #14699 (url: encode small bytes correctly.) Closes #14700 (rustdoc: Submit examples to play.rust-lang.org) Closes #14701 (mk: Run doc tests with --cfg dox) Closes #14710 (rustc: Preserve reachable extern fns with LTO) Closes #14711 (Removing unused wrapper to libc::close.)
2 parents bd6683c + 8bf6da0 commit e87e180

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+645
-234
lines changed

mk/docs.mk

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ L10N_LANGS := ja
4343

4444
# The options are passed to the documentation generators.
4545
RUSTDOC_HTML_OPTS_NO_CSS = --markdown-before-content=doc/version_info.html \
46-
--markdown-in-header=doc/favicon.inc --markdown-after-content=doc/footer.inc
46+
--markdown-in-header=doc/favicon.inc \
47+
--markdown-after-content=doc/footer.inc \
48+
--markdown-playground-url='http://play.rust-lang.org/'
4749

4850
RUSTDOC_HTML_OPTS = $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css rust.css
4951

mk/tests.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ endif
818818
ifeq ($(2),$$(CFG_BUILD))
819819
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)): $$(CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4))
820820
@$$(call E, run doc-crate-$(4) [$(2)])
821-
$$(Q)$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test \
821+
$$(Q)$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test --cfg dox \
822822
$$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && touch $$@
823823
else
824824
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)):

src/compiletest/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ fn disassemble_extract(config: &Config, _props: &TestProps,
15451545
fn count_extracted_lines(p: &Path) -> uint {
15461546
let x = File::open(&p.with_extension("ll")).read_to_end().unwrap();
15471547
let x = str::from_utf8(x.as_slice()).unwrap();
1548-
x.lines().len()
1548+
x.lines().count()
15491549
}
15501550

15511551

src/doc/footer.inc

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ or the <a href="http://opensource.org/licenses/MIT">MIT license</a>, at your opt
55
</p><p>
66
This file may not be copied, modified, or distributed except according to those terms.
77
</p></footer>
8+
<script type="text/javascript" src="jquery.js"></script>
9+
<script type="text/javascript" src="playpen.js"></script>

src/doc/guide-macros.md

+26-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ which both pattern-match on their input and both return early in one case,
1111
doing nothing otherwise:
1212

1313
~~~~
14-
# enum T { SpecialA(uint), SpecialB(uint) };
14+
# enum T { SpecialA(uint), SpecialB(uint) }
1515
# fn f() -> uint {
1616
# let input_1 = SpecialA(0);
1717
# let input_2 = SpecialA(0);
@@ -37,7 +37,8 @@ lightweight custom syntax extensions, themselves defined using the
3737
the pattern in the above code:
3838

3939
~~~~
40-
# enum T { SpecialA(uint), SpecialB(uint) };
40+
# #![feature(macro_rules)]
41+
# enum T { SpecialA(uint), SpecialB(uint) }
4142
# fn f() -> uint {
4243
# let input_1 = SpecialA(0);
4344
# let input_2 = SpecialA(0);
@@ -55,6 +56,7 @@ early_return!(input_1 SpecialA);
5556
early_return!(input_2 SpecialB);
5657
# return 0;
5758
# }
59+
# fn main() {}
5860
~~~~
5961

6062
Macros are defined in pattern-matching style: in the above example, the text
@@ -155,7 +157,8 @@ separator token (a comma-separated list could be written `$(...),*`), and `+`
155157
instead of `*` to mean "at least one".
156158

157159
~~~~
158-
# enum T { SpecialA(uint),SpecialB(uint),SpecialC(uint),SpecialD(uint)};
160+
# #![feature(macro_rules)]
161+
# enum T { SpecialA(uint),SpecialB(uint),SpecialC(uint),SpecialD(uint)}
159162
# fn f() -> uint {
160163
# let input_1 = SpecialA(0);
161164
# let input_2 = SpecialA(0);
@@ -175,6 +178,7 @@ early_return!(input_1, [SpecialA|SpecialC|SpecialD]);
175178
early_return!(input_2, [SpecialB]);
176179
# return 0;
177180
# }
181+
# fn main() {}
178182
~~~~
179183

180184
### Transcription
@@ -215,9 +219,10 @@ solves the problem.
215219
Now consider code like the following:
216220

217221
~~~~
218-
# enum T1 { Good1(T2, uint), Bad1};
222+
# #![feature(macro_rules)]
223+
# enum T1 { Good1(T2, uint), Bad1}
219224
# struct T2 { body: T3 }
220-
# enum T3 { Good2(uint), Bad2};
225+
# enum T3 { Good2(uint), Bad2}
221226
# fn f(x: T1) -> uint {
222227
match x {
223228
Good1(g1, val) => {
@@ -232,6 +237,7 @@ match x {
232237
_ => return 0 // default value
233238
}
234239
# }
240+
# fn main() {}
235241
~~~~
236242

237243
All the complicated stuff is deeply indented, and the error-handling code is
@@ -240,6 +246,7 @@ a match, but with a syntax that suits the problem better. The following macro
240246
can solve the problem:
241247

242248
~~~~
249+
# #![feature(macro_rules)]
243250
macro_rules! biased_match (
244251
// special case: `let (x) = ...` is illegal, so use `let x = ...` instead
245252
( ($e:expr) ~ ($p:pat) else $err:stmt ;
@@ -261,9 +268,9 @@ macro_rules! biased_match (
261268
)
262269
)
263270
264-
# enum T1 { Good1(T2, uint), Bad1};
271+
# enum T1 { Good1(T2, uint), Bad1}
265272
# struct T2 { body: T3 }
266-
# enum T3 { Good2(uint), Bad2};
273+
# enum T3 { Good2(uint), Bad2}
267274
# fn f(x: T1) -> uint {
268275
biased_match!((x) ~ (Good1(g1, val)) else { return 0 };
269276
binds g1, val )
@@ -273,13 +280,16 @@ biased_match!((g1.body) ~ (Good2(result) )
273280
// complicated stuff goes here
274281
return result + val;
275282
# }
283+
# fn main() {}
276284
~~~~
277285

278286
This solves the indentation problem. But if we have a lot of chained matches
279287
like this, we might prefer to write a single macro invocation. The input
280288
pattern we want is clear:
281289

282290
~~~~
291+
# #![feature(macro_rules)]
292+
# fn main() {}
283293
# macro_rules! b(
284294
( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
285295
binds $( $bind_res:ident ),*
@@ -301,14 +311,18 @@ process the semicolon-terminated lines, one-by-one. So, we want the following
301311
input patterns:
302312

303313
~~~~
314+
# #![feature(macro_rules)]
304315
# macro_rules! b(
305316
( binds $( $bind_res:ident ),* )
306317
# => (0))
318+
# fn main() {}
307319
~~~~
308320

309321
...and:
310322

311323
~~~~
324+
# #![feature(macro_rules)]
325+
# fn main() {}
312326
# macro_rules! b(
313327
( ($e :expr) ~ ($p :pat) else $err :stmt ;
314328
$( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*
@@ -322,6 +336,8 @@ The resulting macro looks like this. Note that the separation into
322336
piece of syntax (the `let`) which we only want to transcribe once.
323337

324338
~~~~
339+
# #![feature(macro_rules)]
340+
# fn main() {
325341
326342
macro_rules! biased_match_rec (
327343
// Handle the first layer
@@ -365,9 +381,9 @@ macro_rules! biased_match (
365381
)
366382
367383
368-
# enum T1 { Good1(T2, uint), Bad1};
384+
# enum T1 { Good1(T2, uint), Bad1}
369385
# struct T2 { body: T3 }
370-
# enum T3 { Good2(uint), Bad2};
386+
# enum T3 { Good2(uint), Bad2}
371387
# fn f(x: T1) -> uint {
372388
biased_match!(
373389
(x) ~ (Good1(g1, val)) else { return 0 };
@@ -376,6 +392,7 @@ biased_match!(
376392
// complicated stuff goes here
377393
return result + val;
378394
# }
395+
# }
379396
~~~~
380397

381398
This technique applies to many cases where transcribing a result all at once is not possible.

src/doc/guide-unsafe.md

+1
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ vectors provided from C, using idiomatic Rust practices.
523523

524524
```
525525
#![no_std]
526+
#![feature(globs)]
526527
527528
# extern crate libc;
528529
extern crate core;

src/doc/rust.css

+13
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,19 @@ table th {
313313
padding: 5px;
314314
}
315315

316+
/* Code snippets */
317+
318+
.rusttest { display: none; }
319+
pre.rust { position: relative; }
320+
pre.rust a { transform: scaleX(-1); }
321+
.test-arrow {
322+
display: inline-block;
323+
position: absolute;
324+
top: 0;
325+
right: 10px;
326+
font-size: 150%;
327+
}
328+
316329
@media (min-width: 1170px) {
317330
pre {
318331
font-size: 15px;

src/doc/rust.md

+3
Original file line numberDiff line numberDiff line change
@@ -1260,13 +1260,16 @@ a = Cat;
12601260
Enumeration constructors can have either named or unnamed fields:
12611261

12621262
~~~~
1263+
# #![feature(struct_variant)]
1264+
# fn main() {
12631265
enum Animal {
12641266
Dog (String, f64),
12651267
Cat { name: String, weight: f64 }
12661268
}
12671269
12681270
let mut a: Animal = Dog("Cocoa".to_string(), 37.2);
12691271
a = Cat { name: "Spotty".to_string(), weight: 2.7 };
1272+
# }
12701273
~~~~
12711274

12721275
In this example, `Cat` is a _struct-like enum variant_,

src/doc/tutorial.md

+3
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ fn point_from_direction(dir: Direction) -> Point {
774774
Enum variants may also be structs. For example:
775775

776776
~~~~
777+
# #![feature(struct_variant)]
777778
use std::f64;
778779
# struct Point { x: f64, y: f64 }
779780
# fn square(x: f64) -> f64 { x * x }
@@ -789,6 +790,7 @@ fn area(sh: Shape) -> f64 {
789790
}
790791
}
791792
}
793+
# fn main() {}
792794
~~~~
793795

794796
> *Note:* This feature of the compiler is currently gated behind the
@@ -3046,6 +3048,7 @@ use farm::{chicken, cow};
30463048
2. Import everything in a module with a wildcard:
30473049

30483050
~~~
3051+
# #![feature(globs)]
30493052
use farm::*;
30503053
# mod farm {
30513054
# pub fn cow() { println!("Bat-chicken? What a stupid name!") }

src/libcollections/bitv.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -241,17 +241,17 @@ enum Op {Union, Intersect, Assign, Difference}
241241
/// bv.set(5, true);
242242
/// bv.set(7, true);
243243
/// println!("{}", bv.to_str());
244-
/// println!("total bits set to true: {}", bv.iter().count(|x| x));
244+
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
245245
///
246246
/// // flip all values in bitvector, producing non-primes less than 10
247247
/// bv.negate();
248248
/// println!("{}", bv.to_str());
249-
/// println!("total bits set to true: {}", bv.iter().count(|x| x));
249+
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
250250
///
251251
/// // reset bitvector to empty
252252
/// bv.clear();
253253
/// println!("{}", bv.to_str());
254-
/// println!("total bits set to true: {}", bv.iter().count(|x| x));
254+
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
255255
/// ```
256256
#[deriving(Clone)]
257257
pub struct Bitv {
@@ -461,7 +461,7 @@ impl Bitv {
461461
/// bv.set(5, true);
462462
/// bv.set(8, true);
463463
/// // Count bits set to 1; result should be 5
464-
/// println!("{}", bv.iter().count(|x| x));
464+
/// println!("{}", bv.iter().filter(|x| *x).count());
465465
/// ```
466466
#[inline]
467467
pub fn iter<'a>(&'a self) -> Bits<'a> {

src/libcollections/dlist.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1131,31 +1131,31 @@ mod tests {
11311131
let v = &[0, ..128];
11321132
let m: DList<int> = v.iter().map(|&x|x).collect();
11331133
b.iter(|| {
1134-
assert!(m.iter().len() == 128);
1134+
assert!(m.iter().count() == 128);
11351135
})
11361136
}
11371137
#[bench]
11381138
fn bench_iter_mut(b: &mut test::Bencher) {
11391139
let v = &[0, ..128];
11401140
let mut m: DList<int> = v.iter().map(|&x|x).collect();
11411141
b.iter(|| {
1142-
assert!(m.mut_iter().len() == 128);
1142+
assert!(m.mut_iter().count() == 128);
11431143
})
11441144
}
11451145
#[bench]
11461146
fn bench_iter_rev(b: &mut test::Bencher) {
11471147
let v = &[0, ..128];
11481148
let m: DList<int> = v.iter().map(|&x|x).collect();
11491149
b.iter(|| {
1150-
assert!(m.iter().rev().len() == 128);
1150+
assert!(m.iter().rev().count() == 128);
11511151
})
11521152
}
11531153
#[bench]
11541154
fn bench_iter_mut_rev(b: &mut test::Bencher) {
11551155
let v = &[0, ..128];
11561156
let mut m: DList<int> = v.iter().map(|&x|x).collect();
11571157
b.iter(|| {
1158-
assert!(m.mut_iter().rev().len() == 128);
1158+
assert!(m.mut_iter().rev().count() == 128);
11591159
})
11601160
}
11611161
}

src/libcollections/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#![license = "MIT/ASL2"]
1818
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1919
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
20-
html_root_url = "http://doc.rust-lang.org/")]
20+
html_root_url = "http://doc.rust-lang.org/",
21+
html_playground_url = "http://play.rust-lang.org/")]
2122

2223
#![feature(macro_rules, managed_boxes, default_type_params, phase, globs)]
2324
#![no_std]

src/libcollections/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2155,7 +2155,7 @@ mod tests {
21552155
#[test]
21562156
fn test_mut_splitator() {
21572157
let mut xs = [0,1,0,2,3,0,0,4,5,0];
2158-
assert_eq!(xs.mut_split(|x| *x == 0).len(), 6);
2158+
assert_eq!(xs.mut_split(|x| *x == 0).count(), 6);
21592159
for slice in xs.mut_split(|x| *x == 0) {
21602160
slice.reverse();
21612161
}

src/libcollections/smallintmap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct SmallIntMap<T> {
3131
impl<V> Container for SmallIntMap<V> {
3232
/// Return the number of elements in the map
3333
fn len(&self) -> uint {
34-
self.v.iter().count(|elt| elt.is_some())
34+
self.v.iter().filter(|elt| elt.is_some()).count()
3535
}
3636

3737
/// Return true if there are no elements in the map

0 commit comments

Comments
 (0)