Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b942cd4

Browse files
committedFeb 16, 2017
Auto merge of #39863 - frewsxcv:rollup, r=frewsxcv
Rollup of 11 pull requests - Successful merges: #39775, #39793, #39804, #39824, #39834, #39837, #39839, #39840, #39843, #39844, #39846 - Failed merges:
2 parents 4d6019d + e7a68c9 commit b942cd4

File tree

20 files changed

+339
-86
lines changed

20 files changed

+339
-86
lines changed
 

‎configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ opt ninja 0 "build LLVM using the Ninja generator (for MSVC, requires building i
650650
opt locked-deps 0 "force Cargo.lock to be up to date"
651651
opt vendor 0 "enable usage of vendored Rust crates"
652652
opt sanitizers 0 "build the sanitizer runtimes (asan, lsan, msan, tsan)"
653+
opt dist-src 1 "when building tarballs enables building a source tarball"
653654

654655
# Optimization and debugging options. These may be overridden by the release channel, etc.
655656
opt_nosave optimize 1 "build optimized rust code"

‎src/bootstrap/bin/rustc.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ fn main() {
205205
}
206206
}
207207
}
208+
209+
if target.contains("pc-windows-msvc") {
210+
cmd.arg("-Z").arg("unstable-options");
211+
cmd.arg("-C").arg("target-feature=+crt-static");
212+
}
208213
}
209214

210215
if verbose > 1 {

‎src/bootstrap/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub struct Config {
7272
pub rustc_default_ar: Option<String>,
7373
pub rust_optimize_tests: bool,
7474
pub rust_debuginfo_tests: bool,
75+
pub rust_dist_src: bool,
7576

7677
pub build: String,
7778
pub host: Vec<String>,
@@ -183,6 +184,7 @@ struct Dist {
183184
sign_folder: Option<String>,
184185
gpg_password_file: Option<String>,
185186
upload_addr: Option<String>,
187+
src_tarball: Option<bool>,
186188
}
187189

188190
#[derive(RustcDecodable)]
@@ -380,6 +382,7 @@ impl Config {
380382
config.dist_sign_folder = t.sign_folder.clone().map(PathBuf::from);
381383
config.dist_gpg_password_file = t.gpg_password_file.clone().map(PathBuf::from);
382384
config.dist_upload_addr = t.upload_addr.clone();
385+
set(&mut config.rust_dist_src, t.src_tarball);
383386
}
384387

385388
return config
@@ -448,6 +451,7 @@ impl Config {
448451
("FULL_BOOTSTRAP", self.full_bootstrap),
449452
("EXTENDED", self.extended),
450453
("SANITIZERS", self.sanitizers),
454+
("DIST_SRC", self.rust_dist_src),
451455
}
452456

453457
match key {

‎src/bootstrap/dist.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ const CARGO_VENDOR_VERSION: &'static str = "0.1.4";
364364

365365
/// Creates the `rust-src` installer component and the plain source tarball
366366
pub fn rust_src(build: &Build) {
367+
if !build.config.rust_dist_src {
368+
return
369+
}
370+
367371
println!("Dist src");
368372

369373
let name = pkgname(build, "rust-src");

‎src/bootstrap/native.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ pub fn llvm(build: &Build, target: &str) {
9999
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
100100
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);
101101

102+
if target.contains("msvc") {
103+
cfg.define("LLVM_USE_CRT_DEBUG", "MT");
104+
cfg.define("LLVM_USE_CRT_RELEASE", "MT");
105+
cfg.define("LLVM_USE_CRT_RELWITHDEBINFO", "MT");
106+
}
107+
102108
if target.starts_with("i686") {
103109
cfg.define("LLVM_BUILD_32_BITS", "ON");
104110
}

‎src/ci/docker/dist-x86-linux/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,9 @@ RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST |
8282
ENV HOSTS=i686-unknown-linux-gnu
8383
ENV HOSTS=$HOSTS,x86_64-unknown-linux-gnu
8484

85-
ENV RUST_CONFIGURE_ARGS --host=$HOSTS --enable-extended --enable-sanitizers
85+
ENV RUST_CONFIGURE_ARGS \
86+
--host=$HOSTS \
87+
--enable-extended \
88+
--enable-sanitizers
8689
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
90+
ENV DIST_SRC 1

‎src/ci/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-quiet-tests"
2525
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
2626
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"
2727

28+
if [ "$DIST_SRC" == "" ]; then
29+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src"
30+
fi
31+
2832
# If we're deploying artifacts then we set the release channel, otherwise if
2933
# we're not deploying then we want to be sure to enable all assertions becauase
3034
# we'll be running tests

‎src/doc/book/src/macros.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,36 +261,34 @@ The metavariable `$x` is parsed as a single expression node, and keeps its
261261
place in the syntax tree even after substitution.
262262

263263
Another common problem in macro systems is ‘variable capture’. Here’s a C
264-
macro, using [a GNU C extension] to emulate Rust’s expression blocks.
265-
266-
[a GNU C extension]: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
264+
macro using a block with multiple statements.
267265

268266
```text
269-
#define LOG(msg) ({ \
267+
#define LOG(msg) do { \
270268
int state = get_log_state(); \
271269
if (state > 0) { \
272270
printf("log(%d): %s\n", state, msg); \
273271
} \
274-
})
272+
} while (0)
275273
```
276274

277275
Here’s a simple use case that goes terribly wrong:
278276

279277
```text
280278
const char *state = "reticulating splines";
281-
LOG(state)
279+
LOG(state);
282280
```
283281

284282
This expands to
285283

286284
```text
287285
const char *state = "reticulating splines";
288-
{
286+
do {
289287
int state = get_log_state();
290288
if (state > 0) {
291289
printf("log(%d): %s\n", state, state);
292290
}
293-
}
291+
} while (0);
294292
```
295293

296294
The second variable named `state` shadows the first one. This is a problem

‎src/doc/book/src/procedural-macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ created, we'll add it to our toml:
9999
hello-world-derive = { path = "hello-world-derive" }
100100
```
101101

102-
As for our the source of our `hello-world-derive` crate, here's an example:
102+
As for the source of our `hello-world-derive` crate, here's an example:
103103

104104
```rust,ignore
105105
extern crate proc_macro;

‎src/etc/natvis/libcollections.natvis

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
3+
<Type Name="collections::vec::Vec&lt;*&gt;">
4+
    <DisplayString>{{ size={len} }}</DisplayString>
5+
    <Expand>
6+
<Item Name="[size]" ExcludeView="simple">len</Item>
7+
<Item Name="[capacity]" ExcludeView="simple">buf.cap</Item>
8+
<ArrayItems>
9+
<Size>len</Size>
10+
<ValuePointer>buf.ptr.pointer.__0</ValuePointer>
11+
</ArrayItems>
12+
    </Expand>
13+
  </Type>
14+
<Type Name="collections::vec_deque::VecDeque&lt;*&gt;">
15+
<DisplayString>{{ size={tail &lt;= head ? head - tail : buf.cap - tail + head} }}</DisplayString>
16+
<Expand>
17+
<Item Name="[size]" ExcludeView="simple">tail &lt;= head ? head - tail : buf.cap - tail + head</Item>
18+
<Item Name="[capacity]" ExcludeView="simple">buf.cap</Item>
19+
<CustomListItems>
20+
<Variable Name="i" InitialValue="tail" />
21+
22+
<Size>tail &lt;= head ? head - tail : buf.cap - tail + head</Size>
23+
<Loop>
24+
<If Condition="i == head">
25+
<Break/>
26+
</If>
27+
<Item>buf.ptr.pointer.__0 + i</Item>
28+
<Exec>i = (i + 1 == buf.cap ? 0 : i + 1)</Exec>
29+
</Loop>
30+
</CustomListItems>
31+
</Expand>
32+
</Type>
33+
<Type Name="collections::linked_list::LinkedList&lt;*&gt;">
34+
<DisplayString>{{ size={len} }}</DisplayString>
35+
<Expand>
36+
<LinkedListItems>
37+
<Size>len</Size>
38+
<HeadPointer>*(collections::linked_list::Node&lt;$T1&gt; **)&amp;head</HeadPointer>
39+
<NextPointer>*(collections::linked_list::Node&lt;$T1&gt; **)&amp;next</NextPointer>
40+
<ValueNode>element</ValueNode>
41+
</LinkedListItems>
42+
</Expand>
43+
</Type>
44+
<Type Name="collections::string::String">
45+
<DisplayString>{*(char**)this,[vec.len]}</DisplayString>
46+
<StringView>*(char**)this,[vec.len]</StringView>
47+
<Expand>
48+
<Item Name="[size]" ExcludeView="simple">vec.len</Item>
49+
<Item Name="[capacity]" ExcludeView="simple">vec.buf.cap</Item>
50+
<ArrayItems>
51+
<Size>vec.len</Size>
52+
<ValuePointer>*(char**)this</ValuePointer>
53+
</ArrayItems>
54+
</Expand>
55+
</Type>
56+
</AutoVisualizer>

‎src/etc/natvis/libcore.natvis

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
3+
<Type Name="core::ptr::Unique&lt;*&gt;">
4+
<DisplayString>{{ Unique {*pointer.__0} }}</DisplayString>
5+
<Expand>
6+
<Item Name="[ptr]">pointer.__0</Item>
7+
</Expand>
8+
</Type>
9+
<Type Name="core::ptr::Shared&lt;*&gt;">
10+
<DisplayString>{{ Shared {*pointer.__0} }}</DisplayString>
11+
<Expand>
12+
<Item Name="[ptr]">pointer.__0</Item>
13+
</Expand>
14+
</Type>
15+
<Type Name="core::option::Option&lt;*&gt;">
16+
<DisplayString Condition="RUST$ENUM$DISR == 0x0">{{ None }}</DisplayString>
17+
<DisplayString Condition="RUST$ENUM$DISR == 0x1">{{ Some {__0} }}</DisplayString>
18+
<Expand>
19+
<Item Name="[size]" ExcludeView="simple">(ULONG)(RUST$ENUM$DISR != 0)</Item>
20+
<Item Name="[value]" ExcludeView="simple">__0</Item>
21+
<ArrayItems>
22+
<Size>(ULONG)(RUST$ENUM$DISR != 0)</Size>
23+
<ValuePointer>&amp;__0</ValuePointer>
24+
</ArrayItems>
25+
</Expand>
26+
</Type>
27+
<Type Name="core::option::Option&lt;*&gt;" Priority="MediumLow">
28+
<DisplayString Condition="*(PVOID *)this == nullptr">{{ None }}</DisplayString>
29+
<DisplayString>{{ Some {($T1 *)this} }}</DisplayString>
30+
<Expand>
31+
<Item Name="[size]" ExcludeView="simple">(ULONG)(*(PVOID *)this != nullptr)</Item>
32+
<Item Name="[value]" ExcludeView="simple" Condition="*(PVOID *)this != nullptr">($T1 *)this</Item>
33+
<ArrayItems>
34+
<Size>(ULONG)(*(PVOID *)this != nullptr)</Size>
35+
<ValuePointer>($T1 *)this</ValuePointer>
36+
</ArrayItems>
37+
</Expand>
38+
</Type>
39+
</AutoVisualizer>

‎src/grammar/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The build of the rust part is included with `make tidy` and can be run with `mak
88

99
# Manual build
1010

11-
To use manually, assuming antlr4 ist installed at `/usr/share/java/antlr-complete.jar`:
11+
To use manually, assuming antlr4 is installed at `/usr/share/java/antlr-complete.jar`:
1212

1313
```
1414
antlr4 RustLexer.g4
@@ -20,8 +20,8 @@ for file in ../*/**.rs; do
2020
done
2121
```
2222

23-
Note That the `../*/**.rs` glob will match every `*.rs` file in the above
24-
directory and all of its recursive children. This is a zsh extension.
23+
Note that the `../*/**.rs` glob will match every `*.rs` file in the above
24+
directory and all of its recursive children. This is a Zsh extension.
2525

2626

2727
## Cleanup

‎src/libcore/cell.rs

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -213,66 +213,6 @@ impl<T:Copy> Cell<T> {
213213
pub fn get(&self) -> T {
214214
unsafe{ *self.value.get() }
215215
}
216-
217-
/// Returns a reference to the underlying `UnsafeCell`.
218-
///
219-
/// # Examples
220-
///
221-
/// ```
222-
/// #![feature(as_unsafe_cell)]
223-
///
224-
/// use std::cell::Cell;
225-
///
226-
/// let c = Cell::new(5);
227-
///
228-
/// let uc = c.as_unsafe_cell();
229-
/// ```
230-
#[inline]
231-
#[unstable(feature = "as_unsafe_cell", issue = "27708")]
232-
#[rustc_deprecated(since = "1.12.0", reason = "renamed to as_ptr")]
233-
pub fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
234-
&self.value
235-
}
236-
237-
/// Returns a raw pointer to the underlying data in this cell.
238-
///
239-
/// # Examples
240-
///
241-
/// ```
242-
/// use std::cell::Cell;
243-
///
244-
/// let c = Cell::new(5);
245-
///
246-
/// let ptr = c.as_ptr();
247-
/// ```
248-
#[inline]
249-
#[stable(feature = "cell_as_ptr", since = "1.12.0")]
250-
pub fn as_ptr(&self) -> *mut T {
251-
self.value.get()
252-
}
253-
254-
/// Returns a mutable reference to the underlying data.
255-
///
256-
/// This call borrows `Cell` mutably (at compile-time) which guarantees
257-
/// that we possess the only reference.
258-
///
259-
/// # Examples
260-
///
261-
/// ```
262-
/// use std::cell::Cell;
263-
///
264-
/// let mut c = Cell::new(5);
265-
/// *c.get_mut() += 1;
266-
///
267-
/// assert_eq!(c.get(), 6);
268-
/// ```
269-
#[inline]
270-
#[stable(feature = "cell_get_mut", since = "1.11.0")]
271-
pub fn get_mut(&mut self) -> &mut T {
272-
unsafe {
273-
&mut *self.value.get()
274-
}
275-
}
276216
}
277217

278218
#[stable(feature = "rust1", since = "1.0.0")]
@@ -290,7 +230,7 @@ impl<T:Copy> Clone for Cell<T> {
290230
}
291231

292232
#[stable(feature = "rust1", since = "1.0.0")]
293-
impl<T:Default + Copy> Default for Cell<T> {
233+
impl<T:Default> Default for Cell<T> {
294234
/// Creates a `Cell<T>`, with the `Default` value for T.
295235
#[inline]
296236
fn default() -> Cell<T> {
@@ -346,7 +286,7 @@ impl<T:Ord + Copy> Ord for Cell<T> {
346286
}
347287

348288
#[stable(feature = "cell_from", since = "1.12.0")]
349-
impl<T: Copy> From<T> for Cell<T> {
289+
impl<T> From<T> for Cell<T> {
350290
fn from(t: T) -> Cell<T> {
351291
Cell::new(t)
352292
}
@@ -370,6 +310,66 @@ impl<T> Cell<T> {
370310
}
371311
}
372312

313+
/// Returns a reference to the underlying `UnsafeCell`.
314+
///
315+
/// # Examples
316+
///
317+
/// ```
318+
/// #![feature(as_unsafe_cell)]
319+
///
320+
/// use std::cell::Cell;
321+
///
322+
/// let c = Cell::new(5);
323+
///
324+
/// let uc = c.as_unsafe_cell();
325+
/// ```
326+
#[inline]
327+
#[unstable(feature = "as_unsafe_cell", issue = "27708")]
328+
#[rustc_deprecated(since = "1.12.0", reason = "renamed to as_ptr")]
329+
pub fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
330+
&self.value
331+
}
332+
333+
/// Returns a raw pointer to the underlying data in this cell.
334+
///
335+
/// # Examples
336+
///
337+
/// ```
338+
/// use std::cell::Cell;
339+
///
340+
/// let c = Cell::new(5);
341+
///
342+
/// let ptr = c.as_ptr();
343+
/// ```
344+
#[inline]
345+
#[stable(feature = "cell_as_ptr", since = "1.12.0")]
346+
pub fn as_ptr(&self) -> *mut T {
347+
self.value.get()
348+
}
349+
350+
/// Returns a mutable reference to the underlying data.
351+
///
352+
/// This call borrows `Cell` mutably (at compile-time) which guarantees
353+
/// that we possess the only reference.
354+
///
355+
/// # Examples
356+
///
357+
/// ```
358+
/// use std::cell::Cell;
359+
///
360+
/// let mut c = Cell::new(5);
361+
/// *c.get_mut() += 1;
362+
///
363+
/// assert_eq!(c.get(), 6);
364+
/// ```
365+
#[inline]
366+
#[stable(feature = "cell_get_mut", since = "1.11.0")]
367+
pub fn get_mut(&mut self) -> &mut T {
368+
unsafe {
369+
&mut *self.value.get()
370+
}
371+
}
372+
373373
/// Sets the contained value.
374374
///
375375
/// # Examples

‎src/librustc/traits/error_reporting.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use ty::fold::TypeFolder;
3636
use ty::subst::Subst;
3737
use util::nodemap::{FxHashMap, FxHashSet};
3838

39-
use std::cmp;
4039
use std::fmt;
4140
use syntax::ast;
4241
use hir::{intravisit, Local, Pat};
@@ -392,12 +391,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
392391
return;
393392
}
394393

395-
let end = cmp::min(4, impl_candidates.len());
394+
let end = if impl_candidates.len() <= 5 {
395+
impl_candidates.len()
396+
} else {
397+
4
398+
};
396399
err.help(&format!("the following implementations were found:{}{}",
397400
&impl_candidates[0..end].iter().map(|candidate| {
398401
format!("\n {:?}", candidate)
399402
}).collect::<String>(),
400-
if impl_candidates.len() > 4 {
403+
if impl_candidates.len() > 5 {
401404
format!("\nand {} others", impl_candidates.len() - 4)
402405
} else {
403406
"".to_owned()

‎src/libstd/collections/hash/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ fn pop_internal<K, V>(starting_bucket: FullBucketMut<K, V>)
441441
/// Perform robin hood bucket stealing at the given `bucket`. You must
442442
/// also pass that bucket's displacement so we don't have to recalculate it.
443443
///
444-
/// `hash`, `k`, and `v` are the elements to "robin hood" into the hashtable.
444+
/// `hash`, `key`, and `val` are the elements to "robin hood" into the hashtable.
445445
fn robin_hood<'a, K: 'a, V: 'a>(bucket: FullBucketMut<'a, K, V>,
446446
mut displacement: usize,
447447
mut hash: SafeHash,

‎src/libstd/sys/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
//! The `std::sys` module is the abstracted interface through which
1414
//! `std` talks to the underlying operating system. It has different
1515
//! implementations for different operating system families, today
16-
//! just Unix and Windows.
16+
//! just Unix and Windows, and initial support for Redox.
1717
//!
1818
//! The centralization of platform-specific code in this module is
1919
//! enforced by the "platform abstraction layer" tidy script in
20-
//! `tools/tidy/pal.rs`.
20+
//! `tools/tidy/src/pal.rs`.
2121
//!
2222
//! This module is closely related to the platform-independent system
2323
//! integration code in `std::sys_common`. See that module's
@@ -34,14 +34,14 @@
3434

3535
pub use self::imp::*;
3636

37-
#[cfg(target_os = "redox")]
38-
#[path = "redox/mod.rs"]
39-
mod imp;
40-
4137
#[cfg(unix)]
4238
#[path = "unix/mod.rs"]
4339
mod imp;
4440

4541
#[cfg(windows)]
4642
#[path = "windows/mod.rs"]
4743
mod imp;
44+
45+
#[cfg(target_os = "redox")]
46+
#[path = "redox/mod.rs"]
47+
mod imp;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright 2015 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+
static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 };
12+
//~^ ERROR recursive static (see issue #29719)
13+
14+
struct StaticDoubleLinked {
15+
prev: &'static StaticDoubleLinked,
16+
next: &'static StaticDoubleLinked,
17+
data: i32,
18+
head: bool,
19+
}
20+
21+
static L1: StaticDoubleLinked = StaticDoubleLinked{prev: &L3, next: &L2, data: 1, head: true};
22+
//~^ ERROR recursive static (see issue #29719)
23+
//~^^ ERROR recursive static (see issue #29719)
24+
//~^^^ ERROR recursive static (see issue #29719)
25+
static L2: StaticDoubleLinked = StaticDoubleLinked{prev: &L1, next: &L3, data: 2, head: false};
26+
static L3: StaticDoubleLinked = StaticDoubleLinked{prev: &L2, next: &L1, data: 3, head: false};
27+
28+
29+
pub fn main() {
30+
unsafe { assert_eq!(S, *(S as *const *const u8)); }
31+
32+
let mut test_vec = Vec::new();
33+
let mut cur = &L1;
34+
loop {
35+
test_vec.push(cur.data);
36+
cur = cur.next;
37+
if cur.head { break }
38+
}
39+
assert_eq!(&test_vec, &[1,2,3]);
40+
41+
let mut test_vec = Vec::new();
42+
let mut cur = &L1;
43+
loop {
44+
cur = cur.prev;
45+
test_vec.push(cur.data);
46+
if cur.head { break }
47+
}
48+
assert_eq!(&test_vec, &[3,2,1]);
49+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2015 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+
trait Foo<B> {
12+
fn bar(&self){}
13+
}
14+
15+
impl Foo<u8> for i8 {}
16+
impl Foo<u16> for i8 {}
17+
impl Foo<u32> for i8 {}
18+
impl Foo<u64> for i8 {}
19+
impl Foo<bool> for i8 {}
20+
21+
impl Foo<u16> for u8 {}
22+
impl Foo<u32> for u8 {}
23+
impl Foo<u64> for u8 {}
24+
impl Foo<bool> for u8 {}
25+
26+
impl Foo<u8> for bool {}
27+
impl Foo<u16> for bool {}
28+
impl Foo<u32> for bool {}
29+
impl Foo<u64> for bool {}
30+
impl Foo<bool> for bool {}
31+
impl Foo<i8> for bool {}
32+
33+
fn main() {
34+
Foo::<i32>::bar(&1i8);
35+
Foo::<i32>::bar(&1u8);
36+
Foo::<i32>::bar(&true);
37+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0277]: the trait bound `i8: Foo<i32>` is not satisfied
2+
--> $DIR/issue-39802-show-5-trait-impls.rs:34:5
3+
|
4+
34 | Foo::<i32>::bar(&1i8);
5+
| ^^^^^^^^^^^^^^^ the trait `Foo<i32>` is not implemented for `i8`
6+
|
7+
= help: the following implementations were found:
8+
<i8 as Foo<u8>>
9+
<i8 as Foo<u16>>
10+
<i8 as Foo<u32>>
11+
<i8 as Foo<u64>>
12+
<i8 as Foo<bool>>
13+
= note: required by `Foo::bar`
14+
15+
error[E0277]: the trait bound `u8: Foo<i32>` is not satisfied
16+
--> $DIR/issue-39802-show-5-trait-impls.rs:35:5
17+
|
18+
35 | Foo::<i32>::bar(&1u8);
19+
| ^^^^^^^^^^^^^^^ the trait `Foo<i32>` is not implemented for `u8`
20+
|
21+
= help: the following implementations were found:
22+
<u8 as Foo<u16>>
23+
<u8 as Foo<u32>>
24+
<u8 as Foo<u64>>
25+
<u8 as Foo<bool>>
26+
= note: required by `Foo::bar`
27+
28+
error[E0277]: the trait bound `bool: Foo<i32>` is not satisfied
29+
--> $DIR/issue-39802-show-5-trait-impls.rs:36:5
30+
|
31+
36 | Foo::<i32>::bar(&true);
32+
| ^^^^^^^^^^^^^^^ the trait `Foo<i32>` is not implemented for `bool`
33+
|
34+
= help: the following implementations were found:
35+
<bool as Foo<u8>>
36+
<bool as Foo<u16>>
37+
<bool as Foo<u32>>
38+
<bool as Foo<u64>>
39+
and 2 others
40+
= note: required by `Foo::bar`
41+
42+
error: aborting due to 3 previous errors
43+

‎src/tools/tidy/src/features.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub fn check(path: &Path, bad: &mut bool) {
166166

167167
// FIXME get this whitelist empty.
168168
let whitelist = vec![
169-
"abi_ptx", "simd", "static_recursion",
169+
"abi_ptx", "simd",
170170
"cfg_target_has_atomic",
171171
"unboxed_closures", "stmt_expr_attributes",
172172
"cfg_target_thread_local", "unwind_attributes",

0 commit comments

Comments
 (0)
Please sign in to comment.