diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6093577078181..4e6cd6c9782a9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 2beb652aa017a..3a158240c3a26 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -263,6 +263,23 @@ impl Rc { } /// 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")] diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 788c838cd3fc8..a7dc2875320b7 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -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. diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 3a2d6c8bcf7d6..9980b689ad47c 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -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 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")] @@ -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 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 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}`"] diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 925cdfec900db..8cb485872b3f3 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -128,7 +128,9 @@ pub unsafe fn replace(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")] @@ -178,7 +180,7 @@ pub unsafe fn read_and_drop(dest: *mut T) -> T { /// /// unsafe { /// std::ptr::write(y, z); -/// println!("{}", std::ptr::read(y)); +/// assert_eq!(std::ptr::read(y), 12); /// } /// ``` #[inline] @@ -220,7 +222,9 @@ pub unsafe fn write(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")] @@ -266,7 +270,7 @@ pub unsafe fn read_volatile(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] diff --git a/src/libcore/result.rs b/src/libcore/result.rs index c7ca70fc1622d..870d667fb468f 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -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 { inner: Option } diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 478f662d0962a..189150d426463 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -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, diff --git a/src/librustc_metadata/diagnostics.rs b/src/librustc_metadata/diagnostics.rs index ae9f500c5de59..099ec62b38de7 100644 --- a/src/librustc_metadata/diagnostics.rs +++ b/src/librustc_metadata/diagnostics.rs @@ -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 ``` @@ -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 ``` @@ -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` ``` @@ -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"` ``` @@ -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` diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 0c0582edcc051..ff3dee88a3795 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -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, @@ -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 } => { @@ -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, @@ -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(); diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index af24a7b51176c..52073359c0fd9 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -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", 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 } } diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index b78db24e44b70..ed821983b7087 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1511,8 +1511,11 @@ pub fn remove_dir_all>(path: P) -> io::Result<()> { /// Returns an iterator over the entries within a directory. /// -/// The iterator will yield instances of `io::Result`. 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 /// diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 2d19561139b58..66efe017655fd 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -986,11 +986,16 @@ impl<'a> cmp::Ord for Components<'a> { // Basic types and traits //////////////////////////////////////////////////////////////////////////////// -/// An owned, mutable path (akin to `String`). +/// An owned, mutable path (akin to [`String`]). /// -/// This type provides methods like `push` and `set_extension` that mutate the -/// path in place. It also implements `Deref` to `Path`, meaning that all -/// methods on `Path` slices are available on `PathBuf` values as well. +/// This type provides methods like [`push`] and [`set_extension`] that mutate +/// the path in place. It also implements [`Deref`] to [`Path`], meaning that +/// all methods on [`Path`] slices are available on `PathBuf` values as well. +/// +/// [`String`]: ../string/struct.String.html +/// [`Path`]: struct.Path.html +/// [`push`]: struct.PathBuf.html#method.push +/// [`set_extension`]: struct.PathBuf.html#method.set_extension /// /// More details about the overall approach can be found in /// the module documentation. @@ -1017,12 +1022,31 @@ impl PathBuf { } /// Allocates an empty `PathBuf`. + /// + /// # Examples + /// + /// ``` + /// use std::path::PathBuf; + /// + /// let path = PathBuf::new(); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn new() -> PathBuf { PathBuf { inner: OsString::new() } } - /// Coerces to a `Path` slice. + /// Coerces to a [`Path`] slice. + /// + /// [`Path`]: struct.Path.html + /// + /// # Examples + /// + /// ``` + /// use std::path::{Path, PathBuf}; + /// + /// let p = PathBuf::from("/test"); + /// assert_eq!(Path::new("/test"), p.as_path()); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn as_path(&self) -> &Path { self @@ -1087,10 +1111,26 @@ impl PathBuf { self.inner.push(path); } - /// Truncate `self` to `self.parent()`. + /// Truncate `self` to [`self.parent()`]. /// - /// Returns false and does nothing if `self.file_name()` is `None`. + /// Returns false and does nothing if [`self.file_name()`] is `None`. /// Otherwise, returns `true`. + /// + /// [`self.parent()`]: struct.PathBuf.html#method.parent + /// [`self.file_name()`]: struct.PathBuf.html#method.file_name + /// + /// # Examples + /// + /// ``` + /// use std::path::{Path, PathBuf}; + /// + /// let mut p = PathBuf::from("/test/test.rs"); + /// + /// p.pop(); + /// assert_eq!(Path::new("/test"), p.as_path()); + /// p.pop(); + /// assert_eq!(Path::new("/"), p.as_path()); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn pop(&mut self) -> bool { match self.parent().map(|p| p.as_u8_slice().len()) { @@ -1102,11 +1142,13 @@ impl PathBuf { } } - /// Updates `self.file_name()` to `file_name`. + /// Updates [`self.file_name()`] to `file_name`. /// /// If `self.file_name()` was `None`, this is equivalent to pushing /// `file_name`. /// + /// [`self.file_name()`]: struct.PathBuf.html#method.file_name + /// /// # Examples /// /// ``` @@ -1133,12 +1175,29 @@ impl PathBuf { self.push(file_name); } - /// Updates `self.extension()` to `extension`. + /// Updates [`self.extension()`] to `extension`. + /// + /// If [`self.file_name()`] is `None`, does nothing and returns `false`. + /// + /// Otherwise, returns `true`; if [`self.extension()`] is `None`, the + /// extension is added; otherwise it is replaced. + /// + /// [`self.file_name()`]: struct.PathBuf.html#method.file_name + /// [`self.extension()`]: struct.PathBuf.html#method.extension + /// + /// # Examples + /// + /// ``` + /// use std::path::{Path, PathBuf}; /// - /// If `self.file_name()` is `None`, does nothing and returns `false`. + /// let mut p = PathBuf::from("/feel/the"); /// - /// Otherwise, returns `true`; if `self.extension()` is `None`, the extension - /// is added; otherwise it is replaced. + /// p.set_extension("force"); + /// assert_eq!(Path::new("/feel/the.force"), p.as_path()); + /// + /// p.set_extension("dark_side"); + /// assert_eq!(Path::new("/feel/the.dark_side"), p.as_path()); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn set_extension>(&mut self, extension: S) -> bool { self._set_extension(extension.as_ref()) @@ -1163,7 +1222,18 @@ impl PathBuf { true } - /// Consumes the `PathBuf`, yielding its internal `OsString` storage. + /// Consumes the `PathBuf`, yielding its internal [`OsString`] storage. + /// + /// [`OsString`]: ../ffi/struct.OsString.html + /// + /// # Examples + /// + /// ``` + /// use std::path::PathBuf; + /// + /// let p = PathBuf::from("/the/head"); + /// let os_str = p.into_os_string(); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn into_os_string(self) -> OsString { self.inner @@ -1301,7 +1371,7 @@ impl Into for PathBuf { } } -/// A slice of a path (akin to `str`). +/// A slice of a path (akin to [`str`]). /// /// This type supports a number of operations for inspecting a path, including /// breaking the path into its components (separated by `/` or `\`, depending on @@ -1310,7 +1380,10 @@ impl Into for PathBuf { /// the module documentation. /// /// This is an *unsized* type, meaning that it must always be used behind a -/// pointer like `&` or `Box`. +/// pointer like `&` or [`Box`]. +/// +/// [`str`]: ../primitive.str.html +/// [`Box`]: ../boxed/struct.Box.html /// /// # Examples /// @@ -1372,7 +1445,9 @@ impl Path { unsafe { mem::transmute(s.as_ref()) } } - /// Yields the underlying `OsStr` slice. + /// Yields the underlying [`OsStr`] slice. + /// + /// [`OsStr`]: ../ffi/struct.OsStr.html /// /// # Examples /// @@ -1387,10 +1462,12 @@ impl Path { &self.inner } - /// Yields a `&str` slice if the `Path` is valid unicode. + /// Yields a [`&str`] slice if the `Path` is valid unicode. /// /// This conversion may entail doing a check for UTF-8 validity. /// + /// [`&str`]: ../primitive.str.html + /// /// # Examples /// /// ``` @@ -1404,10 +1481,12 @@ impl Path { self.inner.to_str() } - /// Converts a `Path` to a `Cow`. + /// Converts a `Path` to a [`Cow`]. /// /// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER. /// + /// [`Cow`]: ../borrow/enum.Cow.html + /// /// # Examples /// /// ``` @@ -1421,7 +1500,9 @@ impl Path { self.inner.to_string_lossy() } - /// Converts a `Path` to an owned `PathBuf`. + /// Converts a `Path` to an owned [`PathBuf`]. + /// + /// [`PathBuf`]: struct.PathBuf.html /// /// # Examples /// @@ -1569,6 +1650,18 @@ impl Path { /// /// If `base` is not a prefix of `self` (i.e. `starts_with` /// returns `false`), returns `Err`. + /// + /// # Examples + /// + /// ``` + /// use std::path::Path; + /// + /// let path = Path::new("/test/haha/foo.txt"); + /// + /// assert_eq!(path.strip_prefix("/test"), Ok(Path::new("haha/foo.txt"))); + /// assert_eq!(path.strip_prefix("test").is_ok(), false); + /// assert_eq!(path.strip_prefix("/haha").is_ok(), false); + /// ``` #[stable(since = "1.7.0", feature = "path_strip_prefix")] pub fn strip_prefix<'a, P: ?Sized>(&'a self, base: &'a P) -> Result<&'a Path, StripPrefixError> @@ -1630,7 +1723,9 @@ impl Path { iter_after(self.components().rev(), child.components().rev()).is_some() } - /// Extracts the stem (non-extension) portion of `self.file_name()`. + /// Extracts the stem (non-extension) portion of [`self.file_name()`]. + /// + /// [`self.file_name()`]: struct.Path.html#method.file_name /// /// The stem is: /// @@ -1653,7 +1748,9 @@ impl Path { self.file_name().map(split_file_at_dot).and_then(|(before, after)| before.or(after)) } - /// Extracts the extension of `self.file_name()`, if possible. + /// Extracts the extension of [`self.file_name()`], if possible. + /// + /// [`self.file_name()`]: struct.Path.html#method.file_name /// /// The extension is: /// @@ -1676,9 +1773,12 @@ impl Path { self.file_name().map(split_file_at_dot).and_then(|(before, after)| before.and(after)) } - /// Creates an owned `PathBuf` with `path` adjoined to `self`. + /// Creates an owned [`PathBuf`] with `path` adjoined to `self`. + /// + /// See [`PathBuf::push`] for more details on what it means to adjoin a path. /// - /// See `PathBuf::push` for more details on what it means to adjoin a path. + /// [`PathBuf`]: struct.PathBuf.html + /// [`PathBuf::push`]: struct.PathBuf.html#method.push /// /// # Examples /// @@ -1698,9 +1798,12 @@ impl Path { buf } - /// Creates an owned `PathBuf` like `self` but with the given file name. + /// Creates an owned [`PathBuf`] like `self` but with the given file name. /// - /// See `PathBuf::set_file_name` for more details. + /// See [`PathBuf::set_file_name`] for more details. + /// + /// [`PathBuf`]: struct.PathBuf.html + /// [`PathBuf::set_file_name`]: struct.PathBuf.html#method.set_file_name /// /// # Examples /// @@ -1721,9 +1824,12 @@ impl Path { buf } - /// Creates an owned `PathBuf` like `self` but with the given extension. + /// Creates an owned [`PathBuf`] like `self` but with the given extension. + /// + /// See [`PathBuf::set_extension`] for more details. /// - /// See `PathBuf::set_extension` for more details. + /// [`PathBuf`]: struct.PathBuf.html + /// [`PathBuf::set_extension`]: struct.PathBuf.html#method.set_extension /// /// # Examples /// @@ -1771,7 +1877,9 @@ impl Path { } } - /// Produce an iterator over the path's components viewed as `OsStr` slices. + /// Produce an iterator over the path's components viewed as [`OsStr`] slices. + /// + /// [`OsStr`]: ffi/struct.OsStr.html /// /// # Examples /// @@ -1790,9 +1898,11 @@ impl Path { Iter { inner: self.components() } } - /// Returns an object that implements `Display` for safely printing paths + /// Returns an object that implements [`Display`] for safely printing paths /// that may contain non-Unicode data. /// + /// [`Display`]: fmt/trait.Display.html + /// /// # Examples /// /// ``` @@ -1854,11 +1964,13 @@ impl Path { /// Returns an iterator over the entries within a directory. /// - /// The iterator will yield instances of `io::Result`. 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. /// /// This is an alias to [`fs::read_dir`]. /// + /// [`io::Result<`]: ../io/type.Result.html + /// [`DirEntry`]: ../fs/struct.DirEntry.html /// [`fs::read_dir`]: ../fs/fn.read_dir.html #[stable(feature = "path_ext", since = "1.5.0")] pub fn read_dir(&self) -> io::Result { diff --git a/src/libstd/sys/unix/rwlock.rs b/src/libstd/sys/unix/rwlock.rs index 08aeb5fb8ccde..c754d5b8359a9 100644 --- a/src/libstd/sys/unix/rwlock.rs +++ b/src/libstd/sys/unix/rwlock.rs @@ -45,10 +45,10 @@ impl RWLock { // We roughly maintain the deadlocking behavior by panicking to ensure // that this lock acquisition does not succeed. // - // We also check whether there this lock is already write locked. This + // We also check whether this lock is already write locked. This // is only possible if it was write locked by the current thread and // the implementation allows recursive locking. The POSIX standard - // doesn't require recursivly locking a rwlock to deadlock, but we can't + // doesn't require recursively locking a rwlock to deadlock, but we can't // allow that because it could lead to aliasing issues. if r == libc::EAGAIN { panic!("rwlock maximum reader count exceeded"); diff --git a/src/test/compile-fail/E0033.rs b/src/test/compile-fail/E0033.rs index 946600013f33d..d320bcd4d0f55 100644 --- a/src/test/compile-fail/E0033.rs +++ b/src/test/compile-fail/E0033.rs @@ -13,7 +13,13 @@ trait SomeTrait { } fn main() { - let trait_obj: &SomeTrait = SomeTrait; //~ ERROR E0425 - //~^ ERROR E0038 - let &invalid = trait_obj; //~ ERROR E0033 + let trait_obj: &SomeTrait = SomeTrait; + //~^ ERROR E0425 + //~| ERROR E0038 + //~| method `foo` has no receiver + //~| NOTE the trait `SomeTrait` cannot be made into an object + + let &invalid = trait_obj; + //~^ ERROR E0033 + //~| NOTE type `&SomeTrait` cannot be dereferenced } diff --git a/src/test/compile-fail/E0424.rs b/src/test/compile-fail/E0424.rs index 445d0c5f3edc0..911007113d3d6 100644 --- a/src/test/compile-fail/E0424.rs +++ b/src/test/compile-fail/E0424.rs @@ -14,7 +14,10 @@ impl Foo { fn bar(self) {} fn foo() { - self.bar(); //~ ERROR E0424 + self.bar(); + //~^ ERROR `self` is not available in a static method [E0424] + //~| NOTE not available in static method + //~| NOTE maybe a `self` argument is missing? } } diff --git a/src/test/compile-fail/E0426.rs b/src/test/compile-fail/E0426.rs index 2eb4c2d3b5e04..be21421cb0781 100644 --- a/src/test/compile-fail/E0426.rs +++ b/src/test/compile-fail/E0426.rs @@ -10,6 +10,8 @@ fn main () { loop { - break 'a; //~ ERROR E0426 + break 'a; + //~^ ERROR E0426 + //~| NOTE undeclared label `'a` } } diff --git a/src/test/compile-fail/E0435.rs b/src/test/compile-fail/E0435.rs index f6cba15a0bff8..f687633d34d86 100644 --- a/src/test/compile-fail/E0435.rs +++ b/src/test/compile-fail/E0435.rs @@ -11,4 +11,5 @@ fn main () { let foo = 42u32; const FOO : u32 = foo; //~ ERROR E0435 + //~| NOTE non-constant used with constant } diff --git a/src/test/compile-fail/E0437.rs b/src/test/compile-fail/E0437.rs index 7440a82773e7a..62ee8dc346492 100644 --- a/src/test/compile-fail/E0437.rs +++ b/src/test/compile-fail/E0437.rs @@ -12,6 +12,7 @@ trait Foo {} impl Foo for i32 { type Bar = bool; //~ ERROR E0437 + //~| NOTE not a member of trait `Foo` } fn main () { diff --git a/src/test/compile-fail/E0438.rs b/src/test/compile-fail/E0438.rs index b3d453072049e..f549d62aebfea 100644 --- a/src/test/compile-fail/E0438.rs +++ b/src/test/compile-fail/E0438.rs @@ -14,6 +14,7 @@ trait Foo {} impl Foo for i32 { const BAR: bool = true; //~ ERROR E0438 + //~| NOTE not a member of trait `Foo` } fn main () { diff --git a/src/test/compile-fail/E0441.rs b/src/test/compile-fail/E0441.rs new file mode 100644 index 0000000000000..967ff64327235 --- /dev/null +++ b/src/test/compile-fail/E0441.rs @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd)] +#![feature(platform_intrinsics)] + +#[repr(simd)] +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); + +extern "platform-intrinsic" { + fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8; //~ ERROR E0441 +} + +fn main() {} diff --git a/src/test/compile-fail/E0442.rs b/src/test/compile-fail/E0442.rs new file mode 100644 index 0000000000000..ddd927054be1d --- /dev/null +++ b/src/test/compile-fail/E0442.rs @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd)] +#![feature(platform_intrinsics)] + +#[repr(simd)] +struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, + i8, i8, i8, i8, i8, i8, i8, i8); +#[repr(simd)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +struct i64x2(i64, i64); + +extern "platform-intrinsic" { + fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; + //~^ ERROR E0442 + //~| ERROR E0442 + //~| ERROR E0442 +} + +fn main() {} diff --git a/src/test/compile-fail/E0443.rs b/src/test/compile-fail/E0443.rs new file mode 100644 index 0000000000000..24d1ee01dd46e --- /dev/null +++ b/src/test/compile-fail/E0443.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd)] +#![feature(platform_intrinsics)] + +#[repr(simd)] +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); +#[repr(simd)] +struct i64x8(i64, i64, i64, i64, i64, i64, i64, i64); + +extern "platform-intrinsic" { + fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; //~ ERROR E0443 +} + +fn main() {} diff --git a/src/test/compile-fail/E0444.rs b/src/test/compile-fail/E0444.rs new file mode 100644 index 0000000000000..a424a3ca20ec0 --- /dev/null +++ b/src/test/compile-fail/E0444.rs @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd)] +#![feature(platform_intrinsics)] + +#[repr(simd)] +struct f64x2(f64, f64); + +extern "platform-intrinsic" { + fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444 +} + +fn main() {} diff --git a/src/test/compile-fail/E0445.rs b/src/test/compile-fail/E0445.rs new file mode 100644 index 0000000000000..6b360c60a0f90 --- /dev/null +++ b/src/test/compile-fail/E0445.rs @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { + fn dummy(&self) { } +} + +pub trait Bar : Foo {} //~ ERROR E0445 +pub struct Bar2(pub T); //~ ERROR E0445 +pub fn foo (t: T) {} //~ ERROR E0445 + +fn main() {} diff --git a/src/test/compile-fail/E0446.rs b/src/test/compile-fail/E0446.rs new file mode 100644 index 0000000000000..c576661828471 --- /dev/null +++ b/src/test/compile-fail/E0446.rs @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod Foo { + struct Bar(u32); + + pub fn bar() -> Bar { //~ ERROR E0446 + Bar(0) + } +} + +fn main() {} diff --git a/src/test/compile-fail/E0449.rs b/src/test/compile-fail/E0449.rs new file mode 100644 index 0000000000000..ac365db33e5cd --- /dev/null +++ b/src/test/compile-fail/E0449.rs @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Bar; + +trait Foo { + fn foo(); +} + +pub impl Bar {} //~ ERROR E0449 + +pub impl Foo for Bar { //~ ERROR E0449 + pub fn foo() {} //~ ERROR E0449 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0450.rs b/src/test/compile-fail/E0450.rs new file mode 100644 index 0000000000000..3d76cb9377316 --- /dev/null +++ b/src/test/compile-fail/E0450.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod Bar { + pub struct Foo(isize); +} + +fn main() { + let f = Bar::Foo(0); //~ ERROR E0450 +} diff --git a/src/test/compile-fail/E0451.rs b/src/test/compile-fail/E0451.rs new file mode 100644 index 0000000000000..9e4a8713a33e0 --- /dev/null +++ b/src/test/compile-fail/E0451.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod Bar { + pub struct Foo { + pub a: isize, + b: isize, + } +} + +fn main() { + let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451 +} diff --git a/src/test/compile-fail/E0452.rs b/src/test/compile-fail/E0452.rs new file mode 100644 index 0000000000000..1665bbdd4c2c1 --- /dev/null +++ b/src/test/compile-fail/E0452.rs @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(foo = "")] //~ ERROR E0452 + +fn main() { +} diff --git a/src/test/compile-fail/E0453.rs b/src/test/compile-fail/E0453.rs new file mode 100644 index 0000000000000..629b373cd7f12 --- /dev/null +++ b/src/test/compile-fail/E0453.rs @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![forbid(non_snake_case)] + +#[allow(non_snake_case)] //~ ERROR E0453 +fn main() { +} diff --git a/src/test/compile-fail/E0454.rs b/src/test/compile-fail/E0454.rs new file mode 100644 index 0000000000000..1439c3133d9ca --- /dev/null +++ b/src/test/compile-fail/E0454.rs @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(name = "")] extern {} //~ ERROR E0454 + +fn main() { +} diff --git a/src/test/compile-fail/E0458.rs b/src/test/compile-fail/E0458.rs new file mode 100644 index 0000000000000..21bedc6b84c2b --- /dev/null +++ b/src/test/compile-fail/E0458.rs @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458 + //~^ ERROR E0459 + +fn main() { +} diff --git a/src/test/compile-fail/E0459.rs b/src/test/compile-fail/E0459.rs new file mode 100644 index 0000000000000..dc7ac714f2239 --- /dev/null +++ b/src/test/compile-fail/E0459.rs @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(kind = "dylib")] extern {} //~ ERROR E0459 + +fn main() { +} diff --git a/src/test/compile-fail/E0463.rs b/src/test/compile-fail/E0463.rs new file mode 100644 index 0000000000000..3eff107365af1 --- /dev/null +++ b/src/test/compile-fail/E0463.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(plugin)] +#![plugin(cookie_monster)] //~ ERROR E0463 +extern crate cake_is_a_lie; + +fn main() { +} diff --git a/src/test/compile-fail/issue-2356.rs b/src/test/compile-fail/issue-2356.rs index d7ec1ed67397f..da92161967dbd 100644 --- a/src/test/compile-fail/issue-2356.rs +++ b/src/test/compile-fail/issue-2356.rs @@ -59,7 +59,9 @@ impl cat { impl cat { fn meow() { if self.whiskers > 3 { - //~^ ERROR: `self` is not available in a static method. Maybe a `self` argument is missing? + //~^ ERROR `self` is not available in a static method [E0424] + //~| NOTE not available in static method + //~| NOTE maybe a `self` argument is missing? println!("MEOW"); } }