Skip to content

Commit 591508d

Browse files
committed
---
yaml --- r: 235570 b: refs/heads/stable c: 58fb9b5 h: refs/heads/master v: v3
1 parent 8f41220 commit 591508d

File tree

13 files changed

+131
-21
lines changed

13 files changed

+131
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: ef2f4cd40a5eeb729699cf9e06bfe43d3d147fb9
32+
refs/heads/stable: 58fb9b5c2d2f45b95866171720244edc1d06cde2
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/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/stable/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/stable/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/stable/src/librustc_resolve/diagnostics.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ mod bar {
9393
```
9494
"##,
9595

96+
E0253: r##"
97+
Attempt was made to import an unimportable value. This can happen when
98+
trying to import a method from a trait. An example of this error:
99+
100+
```
101+
mod foo {
102+
pub trait MyTrait {
103+
fn do_something();
104+
}
105+
}
106+
use foo::MyTrait::do_something;
107+
```
108+
109+
In general, it's not legal to directly import methods belonging to a
110+
trait or concrete type.
111+
"##,
112+
96113
E0255: r##"
97114
You can't import a value whose name is the same as another value defined in the
98115
module.
@@ -262,7 +279,6 @@ http://doc.rust-lang.org/reference.html#use-declarations
262279
register_diagnostics! {
263280
E0153, // called no where
264281
E0157, // called from no where
265-
E0253, // not directly importable
266282
E0254, // import conflicts with imported crate in this module
267283
E0257,
268284
E0258,

branches/stable/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/stable/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/stable/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/stable/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/stable/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/stable/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/stable/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() { }

0 commit comments

Comments
 (0)