Skip to content
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

Rollup of 15 pull requests #35898

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b9762f8
Update E0033 to the new error format
munyari Aug 8, 2016
80beeb3
Add additional error note
munyari Aug 11, 2016
a37e90a
Make E0033 tests fit in 100 cols
munyari Aug 14, 2016
481b0f3
Improve Path and PathBuf docs
GuillaumeGomez Aug 18, 2016
2c190ad
Update block codes' flags
GuillaumeGomez Aug 19, 2016
f551674
Add new error code tests
GuillaumeGomez Aug 19, 2016
5d02b03
New format for E0426
tvladyslav Aug 19, 2016
f796112
Fix typos in unix/rwlock.rs
apasel422 Aug 20, 2016
825fd11
replace `Rem` example with something more evocative
matthew-piziak Aug 20, 2016
ff44f08
Update E0424 to the new error format
kyrias Aug 20, 2016
1dfc5db
replace `Index` example with something more evocative of indexing
matthew-piziak Aug 20, 2016
f4d55e1
Indicate where `core::result::IntoIter` is created.
frewsxcv Aug 20, 2016
738b91e
Update lib.rs
shyamsundarb-arch Aug 21, 2016
8b18e78
replace `println!` statements with `assert!`ions in `std::ptr` examples
matthew-piziak Aug 21, 2016
18445cd
Fix "Furthermore" Typo in String Docs
CryZe Aug 21, 2016
5310d11
add example for `Rc::would_unwrap`
matthew-piziak Aug 21, 2016
17f9937
rustc: Fix outdated comment
petrochenkov Aug 21, 2016
4b6477f
Minor type in CONTRIBUTING.md
alevy Aug 22, 2016
cdb4af8
Remove E0455 test (for now)
GuillaumeGomez Aug 22, 2016
e606055
Rollup merge of #35526 - munyari:e0033, r=jonathandturner
Aug 22, 2016
e6ab353
Rollup merge of #35786 - GuillaumeGomez:paths_doc, r=jonathandturner
Aug 22, 2016
f7f5602
Rollup merge of #35824 - GuillaumeGomez:err_codes, r=jonathandturner
Aug 22, 2016
9bd2dfd
Rollup merge of #35835 - crypto-universe:E0426, r=jonathandturner
Aug 22, 2016
ddaf109
Rollup merge of #35841 - kyrias:new-error-E0424, r=GuillaumeGomez
Aug 22, 2016
0838334
Rollup merge of #35842 - apasel422:typo, r=GuillaumeGomez
Aug 22, 2016
ca86803
Rollup merge of #35845 - frewsxcv:result-into-iter, r=GuillaumeGomez
Aug 22, 2016
631fe3b
Rollup merge of #35858 - shyaamsundhar:patch-1, r=GuillaumeGomez
Aug 22, 2016
deed0a8
Rollup merge of #35861 - matthew-piziak:rem-example, r=GuillaumeGomez
Aug 22, 2016
4bb6c06
Rollup merge of #35864 - matthew-piziak:index-example, r=GuillaumeGomez
Aug 22, 2016
53a11e3
Rollup merge of #35878 - matthew-piziak:ptr-assertions, r=GuillaumeGomez
Aug 22, 2016
e5d4f5d
Rollup merge of #35879 - CryZe:patch-2, r=apasel422
Aug 22, 2016
b0a50c5
Rollup merge of #35881 - matthew-piziak:rc-would-unwrap-example, r=Gu…
Aug 22, 2016
ff999c2
Rollup merge of #35882 - petrochenkov:patch-2, r=eddyb
Aug 22, 2016
1e5d804
Rollup merge of #35889 - alevy:patch-1, r=GuillaumeGomez
Aug 22, 2016
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ To find documentation-related issues, sort by the [A-docs label][adocs].
In many cases, you don't need a full `make doc`. You can use `rustdoc` directly
to check small fixes. For example, `rustdoc src/doc/reference.md` will render
reference to `doc/reference.html`. The CSS might be messed up, but you can
verify that HTML is right.
verify that the HTML is right.

## Issue Triage

Expand Down
17 changes: 17 additions & 0 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,23 @@ impl<T> Rc<T> {
}

/// Checks if `Rc::try_unwrap` would return `Ok`.
///
/// # Examples
///
/// ```
/// #![feature(rc_would_unwrap)]
///
/// use std::rc::Rc;
///
/// let x = Rc::new(3);
/// assert!(Rc::would_unwrap(&x));
/// assert_eq!(Rc::try_unwrap(x), Ok(3));
///
/// let x = Rc::new(4);
/// let _y = x.clone();
/// assert!(!Rc::would_unwrap(&x));
/// assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4)));
/// ```
#[unstable(feature = "rc_would_unwrap",
reason = "just added for niche usecase",
issue = "28356")]
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ use boxed::Box;
/// [`OsString`]: ../../std/ffi/struct.OsString.html
///
/// Indexing is intended to be a constant-time operation, but UTF-8 encoding
/// does not allow us to do this. Furtheremore, it's not clear what sort of
/// does not allow us to do this. Furthermore, it's not clear what sort of
/// thing the index should return: a byte, a codepoint, or a grapheme cluster.
/// The [`as_bytes()`] and [`chars()`] methods return iterators over the first
/// two, respectively.
Expand Down
72 changes: 48 additions & 24 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,26 +486,34 @@ div_impl_float! { f32 f64 }
///
/// # Examples
///
/// A trivial implementation of `Rem`. When `Foo % Foo` happens, it ends up
/// calling `rem`, and therefore, `main` prints `Remainder-ing!`.
/// This example implements `Rem` on a `SplitSlice` object. After `Rem` is
/// implemented, one can use the `%` operator to find out what the remaining
/// elements of the slice would be after splitting it into equal slices of a
/// given length.
///
/// ```
/// use std::ops::Rem;
///
/// struct Foo;
/// #[derive(PartialEq, Debug)]
/// struct SplitSlice<'a, T: 'a> {
/// slice: &'a [T],
/// }
///
/// impl Rem for Foo {
/// type Output = Foo;
/// impl<'a, T> Rem<usize> for SplitSlice<'a, T> {
/// type Output = SplitSlice<'a, T>;
///
/// fn rem(self, _rhs: Foo) -> Foo {
/// println!("Remainder-ing!");
/// self
/// fn rem(self, modulus: usize) -> Self {
/// let len = self.slice.len();
/// let rem = len % modulus;
/// let start = len - rem;
/// SplitSlice {slice: &self.slice[start..]}
/// }
/// }
///
/// fn main() {
/// Foo % Foo;
/// }
/// // If we were to divide &[0, 1, 2, 3, 4, 5, 6, 7] into slices of size 3,
/// // the remainder would be &[6, 7]
/// assert_eq!(SplitSlice { slice: &[0, 1, 2, 3, 4, 5, 6, 7] } % 3,
/// SplitSlice { slice: &[6, 7] });
/// ```
#[lang = "rem"]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1490,28 +1498,44 @@ shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
///
/// # Examples
///
/// A trivial implementation of `Index`. When `Foo[Bar]` happens, it ends up
/// calling `index`, and therefore, `main` prints `Indexing!`.
/// This example implements `Index` on a read-only `NucleotideCount` container,
/// enabling individual counts to be retrieved with index syntax.
///
/// ```
/// use std::ops::Index;
///
/// #[derive(Copy, Clone)]
/// struct Foo;
/// struct Bar;
/// enum Nucleotide {
/// A,
/// C,
/// G,
/// T,
/// }
///
/// impl Index<Bar> for Foo {
/// type Output = Foo;
/// struct NucleotideCount {
/// a: usize,
/// c: usize,
/// g: usize,
/// t: usize,
/// }
///
/// fn index<'a>(&'a self, _index: Bar) -> &'a Foo {
/// println!("Indexing!");
/// self
/// impl Index<Nucleotide> for NucleotideCount {
/// type Output = usize;
///
/// fn index(&self, nucleotide: Nucleotide) -> &usize {
/// match nucleotide {
/// Nucleotide::A => &self.a,
/// Nucleotide::C => &self.c,
/// Nucleotide::G => &self.g,
/// Nucleotide::T => &self.t,
/// }
/// }
/// }
///
/// fn main() {
/// Foo[Bar];
/// }
/// let nucleotide_count = NucleotideCount {a: 14, c: 9, g: 10, t: 12};
/// assert_eq!(nucleotide_count[Nucleotide::A], 14);
/// assert_eq!(nucleotide_count[Nucleotide::C], 9);
/// assert_eq!(nucleotide_count[Nucleotide::G], 10);
/// assert_eq!(nucleotide_count[Nucleotide::T], 12);
/// ```
#[lang = "index"]
#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
Expand Down
12 changes: 8 additions & 4 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
/// let x = 12;
/// let y = &x as *const i32;
///
/// unsafe { println!("{}", std::ptr::read(y)); }
/// unsafe {
/// assert_eq!(std::ptr::read(y), 12);
/// }
/// ```
#[inline(always)]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -178,7 +180,7 @@ pub unsafe fn read_and_drop<T>(dest: *mut T) -> T {
///
/// unsafe {
/// std::ptr::write(y, z);
/// println!("{}", std::ptr::read(y));
/// assert_eq!(std::ptr::read(y), 12);
/// }
/// ```
#[inline]
Expand Down Expand Up @@ -220,7 +222,9 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
/// let x = 12;
/// let y = &x as *const i32;
///
/// unsafe { println!("{}", std::ptr::read_volatile(y)); }
/// unsafe {
/// assert_eq!(std::ptr::read_volatile(y), 12);
/// }
/// ```
#[inline]
#[stable(feature = "volatile", since = "1.9.0")]
Expand Down Expand Up @@ -266,7 +270,7 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
///
/// unsafe {
/// std::ptr::write_volatile(y, z);
/// println!("{}", std::ptr::read_volatile(y));
/// assert_eq!(std::ptr::read_volatile(y), 12);
/// }
/// ```
#[inline]
Expand Down
8 changes: 7 additions & 1 deletion src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,13 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for IterMut<'a, T> {}

/// An iterator over the value in a `Ok` variant of a `Result`.
/// An iterator over the value in a `Ok` variant of a `Result`. This struct is
/// created by the [`into_iter`] method on [`Result`][`Result`] (provided by
/// the [`IntoIterator`] trait).
///
/// [`Result`]: struct.Result.html
/// [`into_iter`]: ../../std/iter/trait.IntoIterator.html#tymethod.into_iter
/// [`IntoIterator`]: ../../std/iter/trait.IntoIterator.html
#[derive(Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<T> { inner: Option<T> }
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ use syntax::ast::NodeId;
pub enum AccessLevel {
// Exported items + items participating in various kinds of public interfaces,
// but not directly nameable. For example, if function `fn f() -> T {...}` is
// public, then type `T` is exported. Its values can be obtained by other crates
// even if the type itseld is not nameable.
// FIXME: Mostly unimplemented. Only `type` aliases export items currently.
// public, then type `T` is reachable. Its values can be obtained by other crates
// even if the type itself is not nameable.
Reachable,
// Public items + items accessible to other crates with help of `pub use` reexports
Exported,
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_metadata/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ register_long_diagnostics! {
E0454: r##"
A link name was given with an empty name. Erroneous code example:

```
```compile_fail,E0454
#[link(name = "")] extern {} // error: #[link(name = "")] given with empty name
```

Expand All @@ -32,7 +32,7 @@ as frameworks are specific to that operating system.

Erroneous code example:

```compile_fail"
```compile_fail,E0455
#[link(name = "FooCoreServices", kind = "framework")] extern {}
// OS used to compile is Linux for example
```
Expand All @@ -50,7 +50,7 @@ See more: https://doc.rust-lang.org/book/conditional-compilation.html
E0458: r##"
An unknown "kind" was specified for a link attribute. Erroneous code example:

```
```compile_fail,E0458
#[link(kind = "wonderful_unicorn")] extern {}
// error: unknown kind: `wonderful_unicorn`
```
Expand All @@ -64,7 +64,7 @@ Please specify a valid "kind" value, from one of the following:
E0459: r##"
A link was used without a name parameter. Erroneous code example:

```
```compile_fail,E0459
#[link(kind = "dylib")] extern {}
// error: #[link(...)] specified without `name = "foo"`
```
Expand All @@ -80,7 +80,7 @@ you want. Example:
E0463: r##"
A plugin/crate was declared but cannot be found. Erroneous code example:

```
```compile_fail,E0463
#![feature(plugin)]
#![plugin(cookie_monster)] // error: can't find crate for `cookie_monster`
extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`
Expand Down
38 changes: 24 additions & 14 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,20 +251,24 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
err
}
ResolutionError::TypeNotMemberOfTrait(type_, trait_) => {
struct_span_err!(resolver.session,
let mut err = struct_span_err!(resolver.session,
span,
E0437,
"type `{}` is not a member of trait `{}`",
type_,
trait_)
trait_);
err.span_label(span, &format!("not a member of trait `Foo`"));
err
}
ResolutionError::ConstNotMemberOfTrait(const_, trait_) => {
struct_span_err!(resolver.session,
let mut err = struct_span_err!(resolver.session,
span,
E0438,
"const `{}` is not a member of trait `{}`",
const_,
trait_)
trait_);
err.span_label(span, &format!("not a member of trait `Foo`"));
err
}
ResolutionError::VariableNotBoundInPattern(variable_name, from, to) => {
struct_span_err!(resolver.session,
Expand Down Expand Up @@ -344,11 +348,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
path_name)
}
ResolutionError::SelfNotAvailableInStaticMethod => {
struct_span_err!(resolver.session,
let mut err = struct_span_err!(resolver.session,
span,
E0424,
"`self` is not available in a static method. Maybe a `self` \
argument is missing?")
"`self` is not available in a static method");
err.span_label(span, &format!("not available in static method"));
err.note(&format!("maybe a `self` argument is missing?"));
err
}
ResolutionError::UnresolvedName { path, message: msg, context, is_static_method,
is_field, def } => {
Expand Down Expand Up @@ -390,11 +396,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
err
}
ResolutionError::UndeclaredLabel(name) => {
struct_span_err!(resolver.session,
span,
E0426,
"use of undeclared label `{}`",
name)
let mut err = struct_span_err!(resolver.session,
span,
E0426,
"use of undeclared label `{}`",
name);
err.span_label(span, &format!("undeclared label `{}`",&name));
err
}
ResolutionError::SelfImportsOnlyAllowedWithin => {
struct_span_err!(resolver.session,
Expand Down Expand Up @@ -438,10 +446,12 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
closure form instead")
}
ResolutionError::AttemptToUseNonConstantValueInConstant => {
struct_span_err!(resolver.session,
let mut err = struct_span_err!(resolver.session,
span,
E0435,
"attempt to use a non-constant value in a constant")
"attempt to use a non-constant value in a constant");
err.span_label(span, &format!("non-constant used with constant"));
err
}
ResolutionError::BindingShadowsSomethingUnacceptable(what_binding, name, binding) => {
let shadows_what = PathResolution::new(binding.def().unwrap()).kind_name();
Expand Down
8 changes: 5 additions & 3 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if let ty::TyTrait(..) = mt.ty.sty {
// This is "x = SomeTrait" being reduced from
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
span_err!(self.tcx.sess, span, E0033,
"type `{}` cannot be dereferenced",
self.ty_to_string(expected));
let type_str = self.ty_to_string(expected);
struct_span_err!(self.tcx.sess, span, E0033,
"type `{}` cannot be dereferenced", type_str)
.span_label(span, &format!("type `{}` cannot be dereferenced", type_str))
.emit();
return false
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1511,8 +1511,11 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {

/// Returns an iterator over the entries within a directory.
///
/// The iterator will yield instances of `io::Result<DirEntry>`. New errors may
/// be encountered after an iterator is initially constructed.
/// The iterator will yield instances of [`io::Result<`][`DirEntry`]`>`.
/// New errors may be encountered after an iterator is initially constructed.
///
/// [`io::Result<`]: ../io/type.Result.html
/// [`DirEntry`]: ../fs/struct.DirEntry.html
///
/// # Platform-specific behavior
///
Expand Down
Loading