Skip to content

Commit d82e941

Browse files
committed
---
yaml --- r: 220879 b: refs/heads/auto c: cb87ea8 h: refs/heads/master i: 220877: 9bf236c 220875: 28e8c3d 220871: 7c88280 220863: 181d813 v: v3
1 parent b341f57 commit d82e941

File tree

13 files changed

+142
-20
lines changed

13 files changed

+142
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 4ea02b72b77a7d077e6a249564314c39a597ded0
11+
refs/heads/auto: cb87ea80a6f3411c889f9a48b65724b32659c171
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/libcollections/borrow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl<'a, B: ?Sized> Clone for Cow<'a, B> where B: ToOwned {
215215
impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
216216
/// Acquires a mutable reference to the owned form of the data.
217217
///
218-
/// Copies the data if it is not already owned.
218+
/// Clones the data if it is not already owned.
219219
///
220220
/// # Examples
221221
///
@@ -241,7 +241,7 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
241241

242242
/// Extracts the owned data.
243243
///
244-
/// Copies the data if it is not already owned.
244+
/// Clones the data if it is not already owned.
245245
///
246246
/// # Examples
247247
///

branches/auto/src/libcore/cell.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@
3636
//! would otherwise be disallowed though, there are occasions when interior mutability might be
3737
//! appropriate, or even *must* be used, e.g.
3838
//!
39-
//! * Introducing inherited mutability roots to shared types.
39+
//! * Introducing mutability 'inside' of something immutable
4040
//! * Implementation details of logically-immutable methods.
4141
//! * Mutating implementations of `Clone`.
4242
//!
43-
//! ## Introducing inherited mutability roots to shared types
43+
//! ## Introducing mutability 'inside' of something immutable
4444
//!
45-
//! Shared smart pointer types, including `Rc<T>` and `Arc<T>`, provide containers that can be
45+
//! Many shared smart pointer types, including `Rc<T>` and `Arc<T>`, provide containers that can be
4646
//! cloned and shared between multiple parties. Because the contained values may be
47-
//! multiply-aliased, they can only be borrowed as shared references, not mutable references.
48-
//! Without cells it would be impossible to mutate data inside of shared boxes at all!
47+
//! multiply-aliased, they can only be borrowed with `&`, not `&mut`. Without cells it would be
48+
//! impossible to mutate data inside of these smart pointers at all.
4949
//!
5050
//! It's very common then to put a `RefCell<T>` inside shared pointer types to reintroduce
5151
//! mutability:
@@ -65,8 +65,8 @@
6565
//! ```
6666
//!
6767
//! Note that this example uses `Rc<T>` and not `Arc<T>`. `RefCell<T>`s are for single-threaded
68-
//! scenarios. Consider using `Mutex<T>` if you need shared mutability in a multi-threaded
69-
//! situation.
68+
//! scenarios. Consider using `RwLock<T>` or `Mutex<T>` if you need shared mutability in a
69+
//! multi-threaded situation.
7070
//!
7171
//! ## Implementation details of logically-immutable methods
7272
//!

branches/auto/src/librustc/session/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ fn split_msg_into_multilines(msg: &str) -> Option<String> {
301301
!msg.contains("if and else have incompatible types") &&
302302
!msg.contains("if may be missing an else clause") &&
303303
!msg.contains("match arms have incompatible types") &&
304-
!msg.contains("structure constructor specifies a structure of type") {
304+
!msg.contains("structure constructor specifies a structure of type") &&
305+
!msg.contains("has an incompatible type for trait") {
305306
return None
306307
}
307308
let first = msg.match_indices("expected").filter(|s| {

branches/auto/src/librustc_typeck/diagnostics.rs

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2109,6 +2109,66 @@ E0380: r##"
21092109
Default impls are only allowed for traits with no methods or associated items.
21102110
For more information see the [opt-in builtin traits RFC](https://github.com/rust
21112111
-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md).
2112+
"##,
2113+
2114+
E0392: r##"
2115+
This error indicates that a type or lifetime parameter has been declared
2116+
but not actually used. Here is an example that demonstrates the error:
2117+
2118+
```
2119+
enum Foo<T> {
2120+
Bar
2121+
}
2122+
```
2123+
2124+
If the type parameter was included by mistake, this error can be fixed
2125+
by simply removing the type parameter, as shown below:
2126+
2127+
```
2128+
enum Foo {
2129+
Bar
2130+
}
2131+
```
2132+
2133+
Alternatively, if the type parameter was intentionally inserted, it must be
2134+
used. A simple fix is shown below:
2135+
2136+
```
2137+
enum Foo<T> {
2138+
Bar(T)
2139+
}
2140+
```
2141+
2142+
This error may also commonly be found when working with unsafe code. For
2143+
example, when using raw pointers one may wish to specify the lifetime for
2144+
which the pointed-at data is valid. An initial attempt (below) causes this
2145+
error:
2146+
2147+
```
2148+
struct Foo<'a, T> {
2149+
x: *const T
2150+
}
2151+
```
2152+
2153+
We want to express the constraint that Foo should not outlive `'a`, because
2154+
the data pointed to by `T` is only valid for that lifetime. The problem is
2155+
that there are no actual uses of `'a`. It's possible to work around this
2156+
by adding a PhantomData type to the struct, using it to tell the compiler
2157+
to act as if the struct contained a borrowed reference `&'a T`:
2158+
2159+
```
2160+
use std::marker::PhantomData;
2161+
2162+
struct Foo<'a, T: 'a> {
2163+
x: *const T,
2164+
phantom: PhantomData<&'a T>
2165+
}
2166+
```
2167+
2168+
PhantomData can also be used to express information about unused type
2169+
parameters. You can read more about it in the API documentation:
2170+
2171+
https://doc.rust-lang.org/std/marker/struct.PhantomData.html
21122172
"##
21132173

21142174
}
@@ -2211,7 +2271,6 @@ register_diagnostics! {
22112271
E0390, // only a single inherent implementation marked with
22122272
// `#[lang = \"{}\"]` is allowed for the `{}` primitive
22132273
E0391, // unsupported cyclic reference between types/traits detected
2214-
E0392, // parameter `{}` is never used
22152274
E0393, // the type parameter `{}` must be explicitly specified in an object
22162275
// type because its default value `{}` references the type `Self`"
22172276
E0399, // trait items need to be implemented because the associated

branches/auto/src/test/compile-fail/associated-const-impl-wrong-type.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ struct SignedBar;
1818

1919
impl Foo for SignedBar {
2020
const BAR: i32 = -1;
21-
//~^ ERROR E0326
21+
//~^ ERROR implemented const `BAR` has an incompatible type for trait
22+
//~| expected u32,
23+
//~| found i32 [E0326]
2224
}
2325

2426
fn main() {}

branches/auto/src/test/compile-fail/issue-15094.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ struct Debuger<T> {
1919
impl<T: fmt::Debug> ops::FnOnce<(),> for Debuger<T> {
2020
type Output = ();
2121
fn call_once(self, _args: ()) {
22-
//~^ ERROR `call_once` has an incompatible type for trait: expected "rust-call" fn, found "Rust" fn
22+
//~^ ERROR `call_once` has an incompatible type for trait
23+
//~| expected "rust-call" fn,
24+
//~| found "Rust" fn
2325
println!("{:?}", self.x);
2426
}
2527
}

branches/auto/src/test/compile-fail/issue-20225.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@ struct Foo;
1414

1515
impl<'a, T> Fn<(&'a T,)> for Foo {
1616
extern "rust-call" fn call(&self, (_,): (T,)) {}
17-
//~^ ERROR: has an incompatible type for trait: expected &-ptr
17+
//~^ ERROR: has an incompatible type for trait
18+
//~| expected &-ptr
1819
}
1920

2021
impl<'a, T> FnMut<(&'a T,)> for Foo {
2122
extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
22-
//~^ ERROR: has an incompatible type for trait: expected &-ptr
23+
//~^ ERROR: has an incompatible type for trait
24+
//~| expected &-ptr
2325
}
2426

2527
impl<'a, T> FnOnce<(&'a T,)> for Foo {
2628
type Output = ();
2729

2830
extern "rust-call" fn call_once(self, (_,): (T,)) {}
29-
//~^ ERROR: has an incompatible type for trait: expected &-ptr
31+
//~^ ERROR: has an incompatible type for trait
32+
//~| expected &-ptr
3033
}
3134

3235
fn main() {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
struct S;
12+
13+
impl Iterator for S {
14+
type Item = i32;
15+
fn next(&mut self) -> Result<i32, i32> { Ok(7) }
16+
//~^ ERROR method `next` has an incompatible type for trait
17+
//~| expected enum `core::option::Option`
18+
//~| found enum `core::result::Result` [E0053]
19+
}
20+
21+
fn main() {}

branches/auto/src/test/compile-fail/issue-24356.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ fn main() {
3030
impl Deref for Thing {
3131
//~^ ERROR not all trait items implemented, missing: `Target` [E0046]
3232
fn deref(&self) -> i8 { self.0 }
33-
//~^ ERROR method `deref` has an incompatible type for trait: expected &-ptr, found i8 [E0053]
33+
//~^ ERROR method `deref` has an incompatible type for trait
34+
//~| expected &-ptr
35+
//~| found i8 [E0053]
3436
}
3537

3638
let thing = Thing(72);

branches/auto/src/test/compile-fail/trait-impl-method-mismatch.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ trait Mumbo {
1616
impl Mumbo for usize {
1717
// Cannot have a larger effect than the trait:
1818
unsafe fn jumbo(&self, x: &usize) { *self + *x; }
19-
//~^ ERROR expected normal fn, found unsafe fn
19+
//~^ ERROR method `jumbo` has an incompatible type for trait
20+
//~| expected normal fn,
21+
//~| found unsafe fn
2022
}
2123

2224
fn main() {}

branches/auto/src/test/compile-fail/unsafe-trait-impl.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ trait Foo {
1616

1717
impl Foo for u32 {
1818
fn len(&self) -> u32 { *self }
19-
//~^ ERROR incompatible type for trait: expected unsafe fn, found normal fn
19+
//~^ ERROR method `len` has an incompatible type for trait
20+
//~| expected unsafe fn,
21+
//~| found normal fn
2022
}
2123

2224
fn main() { }
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 SomeTrait {}
12+
struct Meow;
13+
impl SomeTrait for Meow {}
14+
15+
struct Foo<'a> {
16+
x: &'a SomeTrait,
17+
y: &'a SomeTrait,
18+
}
19+
20+
impl<'a> Foo<'a> {
21+
pub fn new<'b>(x: &'b SomeTrait, y: &'b SomeTrait) -> Foo<'b> { Foo { x: x, y: y } }
22+
}
23+
24+
fn main() {
25+
let r = Meow;
26+
let s = Meow;
27+
let q = Foo::new(&r as &SomeTrait, &s as &SomeTrait);
28+
}

0 commit comments

Comments
 (0)