Skip to content

Rollup of 13 pull requests #27194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fc16c3e
Improve the expected constant integer error message
jawline Jul 4, 2015
3a009cb
Merge branch 'master' of https://github.com/mmjack/rust
jawline Jul 4, 2015
f395b2b
Make the message slightly clearer
jawline Jul 4, 2015
8c5ffd3
Reduce line length
jawline Jul 4, 2015
02dd732
Self.sess -> txc.sess
jawline Jul 5, 2015
4872463
Remove 'valid' from error
jawline Jul 5, 2015
affbc72
Modified to add 'found' to error message instead
jawline Jul 19, 2015
b684826
add test for #20162
apasel422 Jul 19, 2015
871ccfb
Add a test for #26468
dotdash Jul 20, 2015
9bb6545
add test for #14229
apasel422 Jul 20, 2015
4c73dbd
add test for #19404
apasel422 Jul 20, 2015
31a62d3
s/has gained/has not gained/g
pfalabella Jul 20, 2015
a7e5c63
add test for #10436
apasel422 Jul 20, 2015
3ae7b72
Fix wording nit for E0253
AlisdairO Jul 20, 2015
27fc0f2
Document iterators in std::io
steveklabnik Jul 20, 2015
5a2bcd3
add test for #14382
apasel422 Jul 20, 2015
686d326
Add diagnostics for E0172, fix inline error message for E0139
AlisdairO Jul 19, 2015
7e7ec6b
Document structures in std::io::utils
steveklabnik Jul 20, 2015
9e18326
Update docs for take and broadcast
steveklabnik Jul 20, 2015
d12130b
Rollup merge of #26778 - jawline:master, r=pnkfelix
steveklabnik Jul 21, 2015
98b53cb
Rollup merge of #27127 - AlisdairO:diagnostics172, r=Manishearth
steveklabnik Jul 21, 2015
87f3c88
Rollup merge of #27131 - apasel422:issue-20162, r=arielb1
steveklabnik Jul 21, 2015
a7b766f
Rollup merge of #27140 - dotdash:test-26468, r=luqmana
steveklabnik Jul 21, 2015
40450c0
Rollup merge of #27146 - apasel422:issue-14229, r=alexcrichton
steveklabnik Jul 21, 2015
6b3c3f5
Rollup merge of #27147 - apasel422:issue-19404, r=alexcrichton
steveklabnik Jul 21, 2015
fc8f260
Rollup merge of #27151 - pfalabella:patch-2, r=steveklabnik
steveklabnik Jul 21, 2015
ab51a96
Rollup merge of #27154 - apasel422:issue-10436, r=Gankro
steveklabnik Jul 21, 2015
c6f1a60
Rollup merge of #27156 - AlisdairO:diagnostics253, r=Manishearth
steveklabnik Jul 21, 2015
8cad8a2
Rollup merge of #27157 - steveklabnik:doc_std_io_iterators, r=alexcri…
steveklabnik Jul 21, 2015
2b287c1
Rollup merge of #27158 - apasel422:issue-14382, r=alexcrichton
steveklabnik Jul 21, 2015
c0f0ae2
Rollup merge of #27164 - steveklabnik:doc_io_utils, r=alexcrichton
steveklabnik Jul 21, 2015
da8036e
Rollup merge of #27167 - steveklabnik:doc_std_io_take, r=alexcrichton
steveklabnik Jul 21, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,7 @@ impl<I: RandomAccessIterator, F> RandomAccessIterator for Inspect<I, F>
#[unstable(feature = "iter_unfold")]
#[derive(Clone)]
#[deprecated(since = "1.2.0",
reason = "has gained enough traction to retain its position \
reason = "has not gained enough traction to retain its position \
in the standard library")]
#[allow(deprecated)]
pub struct Unfold<St, F> {
Expand All @@ -2567,7 +2567,7 @@ pub struct Unfold<St, F> {

#[unstable(feature = "iter_unfold")]
#[deprecated(since = "1.2.0",
reason = "has gained enough traction to retain its position \
reason = "has not gained enough traction to retain its position \
in the standard library")]
#[allow(deprecated)]
impl<A, St, F> Unfold<St, F> where F: FnMut(&mut St) -> Option<A> {
Expand Down Expand Up @@ -3018,7 +3018,7 @@ type IterateState<T, F> = (F, Option<T>, bool);
/// from a given seed value.
#[unstable(feature = "iter_iterate")]
#[deprecated(since = "1.2.0",
reason = "has gained enough traction to retain its position \
reason = "has not gained enough traction to retain its position \
in the standard library")]
#[allow(deprecated)]
pub type Iterate<T, F> = Unfold<IterateState<T, F>, fn(&mut IterateState<T, F>) -> Option<T>>;
Expand All @@ -3027,7 +3027,7 @@ pub type Iterate<T, F> = Unfold<IterateState<T, F>, fn(&mut IterateState<T, F>)
/// repeated applications of the given function `f`.
#[unstable(feature = "iter_iterate")]
#[deprecated(since = "1.2.0",
reason = "has gained enough traction to retain its position \
reason = "has not gained enough traction to retain its position \
in the standard library")]
#[allow(deprecated)]
pub fn iterate<T, F>(seed: T, f: F) -> Iterate<T, F> where
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/intrinsicck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
if from_tc.interior_param() || to_tc.interior_param() {
span_err!(self.tcx.sess, span, E0139,
"cannot transmute to or from a type that contains \
type parameters in its interior");
unsubstituted type parameters");
return;
}

Expand Down
16 changes: 8 additions & 8 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use metadata::csearch;
use middle;
use middle::cast;
use middle::check_const;
use middle::const_eval::{self, ConstVal};
use middle::const_eval::{self, ConstVal, ErrKind};
use middle::def::{self, DefMap, ExportMap};
use middle::dependency_format;
use middle::fast_reject;
Expand Down Expand Up @@ -6104,20 +6104,20 @@ impl<'tcx> ctxt<'tcx> {
found);
}
Err(err) => {
let err_description = err.description();
let found = match count_expr.node {
let err_msg = match count_expr.node {
ast::ExprPath(None, ast::Path {
global: false,
ref segments,
..
}) if segments.len() == 1 =>
format!("{}", "found variable"),
_ =>
format!("but {}", err_description),
format!("found variable"),
_ => match err.kind {
ErrKind::MiscCatchAll => format!("but found {}", err.description()),
_ => format!("but {}", err.description())
}
};
span_err!(self.sess, count_expr.span, E0307,
"expected constant integer for repeat count, {}",
found);
"expected constant integer for repeat count, {}", err_msg);
}
}
0
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ mod foo {
use foo::MyTrait::do_something;
```

In general, it's not legal to directly import methods belonging to a
trait or concrete type.
It's illegal to directly import methods belonging to a trait or concrete type.
"##,

E0255: r##"
Expand Down
28 changes: 27 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,33 @@ return, for example with a `loop` that never breaks or a call to another
diverging function (such as `panic!()`).
"##,

E0172: r##"
This error means that an attempt was made to specify the type of a variable with
a combination of a concrete type and a trait. Consider the following example:

```
fn foo(bar: i32+std::fmt::Display) {}
```

The code is trying to specify that we want to receive a signed 32-bit integer
which also implements `Display`. This doesn't make sense: when we pass `i32`, a
concrete type, it implicitly includes all of the traits that it implements.
This includes `Display`, `Debug`, `Clone`, and a host of others.

If `i32` implements the trait we desire, there's no need to specify the trait
separately. If it does not, then we need to `impl` the trait for `i32` before
passing it into `foo`. Either way, a fixed definition for `foo` will look like
the following:

```
fn foo(bar: i32) {}
```

To learn more about traits, take a look at the Book:

https://doc.rust-lang.org/book/traits.html
"##,

E0178: r##"
In types, the `+` type operator has low precedence, so it is often necessary
to use parentheses.
Expand Down Expand Up @@ -2196,7 +2223,6 @@ register_diagnostics! {
E0164,
E0167,
E0168,
E0172,
E0173, // manual implementations of unboxed closure traits are experimental
E0174, // explicit use of unboxed closure methods are experimental
E0182,
Expand Down
49 changes: 36 additions & 13 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,10 @@ pub trait BufRead: Read {

/// A `Write` adaptor which will write data to multiple locations.
///
/// For more information, see `Write::broadcast`.
/// This struct is generally created by calling [`broadcast()`][broadcast] on a
/// writer. Please see the documentation of `broadcast()` for more details.
///
/// [broadcast]: trait.Write.html#method.broadcast
#[unstable(feature = "io", reason = "awaiting stability of Write::broadcast")]
pub struct Broadcast<T, U> {
first: T,
Expand All @@ -1417,9 +1420,12 @@ impl<T: Write, U: Write> Write for Broadcast<T, U> {
}
}

/// Adaptor to chain together two instances of `Read`.
/// Adaptor to chain together two readers.
///
/// This struct is generally created by calling [`chain()`][chain] on a reader.
/// Please see the documentation of `chain()` for more details.
///
/// For more information, see `Read::chain`.
/// [chain]: trait.Read.html#method.chain
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Chain<T, U> {
first: T,
Expand All @@ -1442,7 +1448,10 @@ impl<T: Read, U: Read> Read for Chain<T, U> {

/// Reader adaptor which limits the bytes read from an underlying reader.
///
/// For more information, see `Read::take`.
/// This struct is generally created by calling [`take()`][take] on a reader.
/// Please see the documentation of `take()` for more details.
///
/// [take]: trait.Read.html#method.take
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Take<T> {
inner: T,
Expand Down Expand Up @@ -1495,7 +1504,10 @@ impl<T: BufRead> BufRead for Take<T> {

/// An adaptor which will emit all read data to a specified writer as well.
///
/// For more information see `Read::tee`
/// This struct is generally created by calling [`tee()`][tee] on a reader.
/// Please see the documentation of `tee()` for more details.
///
/// [tee]: trait.Read.html#method.tee
#[unstable(feature = "io", reason = "awaiting stability of Read::tee")]
pub struct Tee<R, W> {
reader: R,
Expand All @@ -1512,9 +1524,12 @@ impl<R: Read, W: Write> Read for Tee<R, W> {
}
}

/// A bridge from implementations of `Read` to an `Iterator` of `u8`.
/// An iterator over `u8` values of a reader.
///
/// See `Read::bytes` for more information.
/// This struct is generally created by calling [`bytes()`][bytes] on a reader.
/// Please see the documentation of `bytes()` for more details.
///
/// [bytes]: trait.Read.html#method.bytes
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Bytes<R> {
inner: R,
Expand All @@ -1534,9 +1549,12 @@ impl<R: Read> Iterator for Bytes<R> {
}
}

/// A bridge from implementations of `Read` to an `Iterator` of `char`.
/// An iterator over the `char`s of a reader.
///
/// This struct is generally created by calling [`chars()`][chars] on a reader.
/// Please see the documentation of `chars()` for more details.
///
/// See `Read::chars` for more information.
/// [chars]: trait.Read.html#method.chars
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
pub struct Chars<R> {
inner: R,
Expand Down Expand Up @@ -1618,7 +1636,10 @@ impl fmt::Display for CharsError {
/// An iterator over the contents of an instance of `BufRead` split on a
/// particular byte.
///
/// See `BufRead::split` for more information.
/// This struct is generally created by calling [`split()`][split] on a
/// `BufRead`. Please see the documentation of `split()` for more details.
///
/// [split]: trait.BufRead.html#method.split
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Split<B> {
buf: B,
Expand All @@ -1644,10 +1665,12 @@ impl<B: BufRead> Iterator for Split<B> {
}
}

/// An iterator over the lines of an instance of `BufRead` split on a newline
/// byte.
/// An iterator over the lines of an instance of `BufRead`.
///
/// This struct is generally created by calling [`lines()`][lines] on a
/// `BufRead`. Please see the documentation of `lines()` for more details.
///
/// See `BufRead::lines` for more information.
/// [lines]: trait.BufRead.html#method.lines
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Lines<B> {
buf: B,
Expand Down
17 changes: 16 additions & 1 deletion src/libstd/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ pub fn copy<R: Read, W: Write>(reader: &mut R, writer: &mut W) -> io::Result<u64
}

/// A reader which is always at EOF.
///
/// This struct is generally created by calling [`empty()`][empty]. Please see
/// the documentation of `empty()` for more details.
///
/// [empty]: fn.empty.html
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Empty { _priv: () }

Expand Down Expand Up @@ -95,7 +100,12 @@ impl BufRead for Empty {
fn consume(&mut self, _n: usize) {}
}

/// A reader which infinitely yields one byte.
/// A reader which yields one byte over and over and over and over and over and...
///
/// This struct is generally created by calling [`repeat()`][repeat]. Please
/// see the documentation of `repeat()` for more details.
///
/// [empty]: fn.repeat.html
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Repeat { byte: u8 }

Expand All @@ -117,6 +127,11 @@ impl Read for Repeat {
}

/// A writer which will move data into the void.
///
/// This struct is generally created by calling [`sink()`][sink]. Please
/// see the documentation of `sink()` for more details.
///
/// [empty]: fn.sink.html
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Sink { _priv: () }

Expand Down
17 changes: 17 additions & 0 deletions src/test/compile-fail/issue-20162.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2015 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 X { x: i32 }

fn main() {
let mut b: Vec<X> = vec![];
b.sort();
//~^ ERROR the trait `core::cmp::Ord` is not implemented for the type `X`
}
20 changes: 20 additions & 0 deletions src/test/run-pass/issue-10436.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2015 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 works<T>(x: T) -> Vec<T> { vec![x] }

fn also_works<T: Clone>(x: T) -> Vec<T> { vec![x] }

fn main() {
let _: Vec<usize> = works(0);
let _: Vec<usize> = also_works(0);
let _ = works(0);
let _ = also_works(0);
}
30 changes: 30 additions & 0 deletions src/test/run-pass/issue-14229.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2015 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.

trait Foo: Sized {
fn foo(self) {}
}

trait Bar: Sized {
fn bar(self) {}
}

struct S;

impl<'l> Foo for &'l S {}

impl<T: Foo> Bar for T {}

fn main() {
let s = S;
s.foo();
(&s).bar();
s.bar();
}
24 changes: 24 additions & 0 deletions src/test/run-pass/issue-14382.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2015 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.

#[derive(Debug)]
struct Matrix4<S>(S);
trait POrd<S> {}

fn translate<S: POrd<S>>(_: S) -> Matrix4<S> { unimplemented!() }

impl POrd<f32> for f32 {}
impl POrd<f64> for f64 {}

fn main() {
let x = 1.0;
let m : Matrix4<f32> = translate(x);
println!("m: {:?}", m);
}
Loading