Auto merge of #33833 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 7 pull requests - Successful merges: #33692, #33759, #33779, #33781, #33797, #33810, #33832 - Failed merges:
This commit is contained in:
commit
8393d99c35
@ -84,4 +84,4 @@ which do not trigger a panic can be assured that this function is never
|
||||
called. The second function, `panic_fmt`, is also used by the failure
|
||||
mechanisms of the compiler.
|
||||
|
||||
[unwind]: https://github.com/rust-lang/rust/blob/master/src/libstd/sys/common/unwind/gcc.rs
|
||||
[unwind]: https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/gcc.rs
|
||||
|
@ -175,8 +175,6 @@ You can use a combo of `&` and `[]` to create a slice from various things. The
|
||||
detail later in this section. The `[]`s, with a range, let you define the
|
||||
length of the slice:
|
||||
|
||||
[references]: references-and-borrowing.html
|
||||
|
||||
```rust
|
||||
let a = [0, 1, 2, 3, 4];
|
||||
let complete = &a[..]; // A slice containing all of the elements in a
|
||||
|
@ -978,18 +978,18 @@ struct Foo { x: Option<Box<Foo>> }
|
||||
This will cause an error:
|
||||
|
||||
```compile_fail
|
||||
#![feature(simd)]
|
||||
#![feature(repr_simd)]
|
||||
|
||||
#[simd]
|
||||
#[repr(simd)]
|
||||
struct Bad<T>(T, T, T);
|
||||
```
|
||||
|
||||
This will not:
|
||||
|
||||
```
|
||||
#![feature(simd)]
|
||||
#![feature(repr_simd)]
|
||||
|
||||
#[simd]
|
||||
#[repr(simd)]
|
||||
struct Good(u32, u32, u32);
|
||||
```
|
||||
"##,
|
||||
@ -1026,18 +1026,18 @@ struct Foo { x: Option<Box<Foo>> }
|
||||
This will cause an error:
|
||||
|
||||
```compile_fail
|
||||
#![feature(simd)]
|
||||
#![feature(repr_simd)]
|
||||
|
||||
#[simd]
|
||||
#[repr(simd)]
|
||||
struct Bad(u16, u32, u32);
|
||||
```
|
||||
|
||||
This will not:
|
||||
|
||||
```
|
||||
#![feature(simd)]
|
||||
#![feature(repr_simd)]
|
||||
|
||||
#[simd]
|
||||
#[repr(simd)]
|
||||
struct Good(u32, u32, u32);
|
||||
```
|
||||
"##,
|
||||
@ -1049,18 +1049,18 @@ struct Foo { x: Option<Box<Foo>> }
|
||||
This will cause an error:
|
||||
|
||||
```compile_fail
|
||||
#![feature(simd)]
|
||||
#![feature(repr_simd)]
|
||||
|
||||
#[simd]
|
||||
#[repr(simd)]
|
||||
struct Bad(String);
|
||||
```
|
||||
|
||||
This will not:
|
||||
|
||||
```
|
||||
#![feature(simd)]
|
||||
#![feature(repr_simd)]
|
||||
|
||||
#[simd]
|
||||
#[repr(simd)]
|
||||
struct Good(u32, u32, u32);
|
||||
```
|
||||
"##,
|
||||
@ -2387,39 +2387,135 @@ impl Copy for &'static Bar { } // error
|
||||
"##,
|
||||
|
||||
E0207: r##"
|
||||
You declared an unused type parameter when implementing a trait on an object.
|
||||
Erroneous code example:
|
||||
Any type parameter or lifetime parameter of an `impl` must meet at least one of
|
||||
the following criteria:
|
||||
|
||||
- it appears in the self type of the impl
|
||||
- for a trait impl, it appears in the trait reference
|
||||
- it is bound as an associated type
|
||||
|
||||
### Error example 1
|
||||
|
||||
Suppose we have a struct `Foo` and we would like to define some methods for it.
|
||||
The following definition leads to a compiler error:
|
||||
|
||||
```compile_fail
|
||||
trait MyTrait {
|
||||
fn get(&self) -> usize;
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl<T> MyTrait for Foo {
|
||||
fn get(&self) -> usize {
|
||||
0
|
||||
impl<T: Default> Foo {
|
||||
// error: the type parameter `T` is not constrained by the impl trait, self
|
||||
// type, or predicates [E0207]
|
||||
fn get(&self) -> T {
|
||||
<T as Default>::default()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Please check your object definition and remove unused type
|
||||
parameter(s). Example:
|
||||
The problem is that the parameter `T` does not appear in the self type (`Foo`)
|
||||
of the impl. In this case, we can fix the error by moving the type parameter
|
||||
from the `impl` to the method `get`:
|
||||
|
||||
|
||||
```
|
||||
trait MyTrait {
|
||||
fn get(&self) -> usize;
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl MyTrait for Foo {
|
||||
fn get(&self) -> usize {
|
||||
0
|
||||
// Move the type parameter from the impl to the method
|
||||
impl Foo {
|
||||
fn get<T: Default>(&self) -> T {
|
||||
<T as Default>::default()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Error example 2
|
||||
|
||||
As another example, suppose we have a `Maker` trait and want to establish a
|
||||
type `FooMaker` that makes `Foo`s:
|
||||
|
||||
```compile_fail
|
||||
trait Maker {
|
||||
type Item;
|
||||
fn make(&mut self) -> Self::Item;
|
||||
}
|
||||
|
||||
struct Foo<T> {
|
||||
foo: T
|
||||
}
|
||||
|
||||
struct FooMaker;
|
||||
|
||||
impl<T: Default> Maker for FooMaker {
|
||||
// error: the type parameter `T` is not constrained by the impl trait, self
|
||||
// type, or predicates [E0207]
|
||||
type Item = Foo<T>;
|
||||
|
||||
fn make(&mut self) -> Foo<T> {
|
||||
Foo { foo: <T as Default>::default() }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This fails to compile because `T` does not appear in the trait or in the
|
||||
implementing type.
|
||||
|
||||
One way to work around this is to introduce a phantom type parameter into
|
||||
`FooMaker`, like so:
|
||||
|
||||
```
|
||||
use std::marker::PhantomData;
|
||||
|
||||
trait Maker {
|
||||
type Item;
|
||||
fn make(&mut self) -> Self::Item;
|
||||
}
|
||||
|
||||
struct Foo<T> {
|
||||
foo: T
|
||||
}
|
||||
|
||||
// Add a type parameter to `FooMaker`
|
||||
struct FooMaker<T> {
|
||||
phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: Default> Maker for FooMaker<T> {
|
||||
type Item = Foo<T>;
|
||||
|
||||
fn make(&mut self) -> Foo<T> {
|
||||
Foo {
|
||||
foo: <T as Default>::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Another way is to do away with the associated type in `Maker` and use an input
|
||||
type parameter instead:
|
||||
|
||||
```
|
||||
// Use a type parameter instead of an associated type here
|
||||
trait Maker<Item> {
|
||||
fn make(&mut self) -> Item;
|
||||
}
|
||||
|
||||
struct Foo<T> {
|
||||
foo: T
|
||||
}
|
||||
|
||||
struct FooMaker;
|
||||
|
||||
impl<T: Default> Maker<Foo<T>> for FooMaker {
|
||||
fn make(&mut self) -> Foo<T> {
|
||||
Foo { foo: <T as Default>::default() }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Additional information
|
||||
|
||||
For more information, please see [RFC 447].
|
||||
|
||||
[RFC 447]: https://github.com/rust-lang/rfcs/blob/master/text/0447-no-unused-impl-parameters.md
|
||||
"##,
|
||||
|
||||
E0210: r##"
|
||||
|
@ -125,6 +125,7 @@
|
||||
break;
|
||||
|
||||
case "+":
|
||||
ev.preventDefault();
|
||||
toggleAllDocs();
|
||||
break;
|
||||
|
||||
|
20
src/test/compile-fail/E0062.rs
Normal file
20
src/test/compile-fail/E0062.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Foo {
|
||||
x: i32
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = Foo {
|
||||
x: 0,
|
||||
x: 0, //~ ERROR E0062
|
||||
};
|
||||
}
|
18
src/test/compile-fail/E0063.rs
Normal file
18
src/test/compile-fail/E0063.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Foo {
|
||||
x: i32,
|
||||
y: i32
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = Foo { x: 0 }; //~ ERROR E0063
|
||||
}
|
16
src/test/compile-fail/E0067.rs
Normal file
16
src/test/compile-fail/E0067.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::collections::LinkedList;
|
||||
|
||||
fn main() {
|
||||
LinkedList::new() += 1; //~ ERROR E0368
|
||||
//~^ ERROR E0067
|
||||
}
|
16
src/test/compile-fail/E0069.rs
Normal file
16
src/test/compile-fail/E0069.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn foo() -> u8 {
|
||||
return; //~ ERROR E0069
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
23
src/test/compile-fail/E0070.rs
Normal file
23
src/test/compile-fail/E0070.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const SOME_CONST : i32 = 12;
|
||||
|
||||
fn some_other_func() {}
|
||||
|
||||
fn some_function() {
|
||||
SOME_CONST = 14; //~ ERROR E0070
|
||||
1 = 3; //~ ERROR E0070
|
||||
some_other_func() = 4; //~ ERROR E0070
|
||||
//~^ ERROR E0308
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
16
src/test/compile-fail/E0071.rs
Normal file
16
src/test/compile-fail/E0071.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
enum Foo { FirstValue(i32) }
|
||||
|
||||
fn main() {
|
||||
let u = Foo::FirstValue { value: 0 }; //~ ERROR E0071
|
||||
let t = u32 { value: 4 }; //~ ERROR E0071
|
||||
}
|
17
src/test/compile-fail/E0072.rs
Normal file
17
src/test/compile-fail/E0072.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct ListNode { //~ ERROR E0072
|
||||
head: u8,
|
||||
tail: Option<ListNode>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
17
src/test/compile-fail/E0075.rs
Normal file
17
src/test/compile-fail/E0075.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(repr_simd)]
|
||||
|
||||
#[repr(simd)]
|
||||
struct Bad; //~ ERROR E0075
|
||||
|
||||
fn main() {
|
||||
}
|
17
src/test/compile-fail/E0076.rs
Normal file
17
src/test/compile-fail/E0076.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(repr_simd)]
|
||||
|
||||
#[repr(simd)]
|
||||
struct Bad(u16, u32, u32); //~ ERROR E0076
|
||||
|
||||
fn main() {
|
||||
}
|
17
src/test/compile-fail/E0077.rs
Normal file
17
src/test/compile-fail/E0077.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(repr_simd)]
|
||||
|
||||
#[repr(simd)]
|
||||
struct Bad(String); //~ ERROR E0077
|
||||
|
||||
fn main() {
|
||||
}
|
16
src/test/compile-fail/E0079.rs
Normal file
16
src/test/compile-fail/E0079.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
enum Foo {
|
||||
Q = "32" //~ ERROR E0079
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
17
src/test/compile-fail/E0080.rs
Normal file
17
src/test/compile-fail/E0080.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
enum Enum {
|
||||
X = (1 << 500), //~ ERROR E0080
|
||||
Y = (1 / 0) //~ ERROR E0080
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
18
src/test/compile-fail/E0081.rs
Normal file
18
src/test/compile-fail/E0081.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
enum Enum {
|
||||
P = 3,
|
||||
X = 3, //~ ERROR E0081
|
||||
Y = 5
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
Loading…
Reference in New Issue
Block a user