Skip to content

Rollup of 18 pull requests #43800

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

Merged
merged 46 commits into from
Aug 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ba53f95
E0122: clarify wording
RalfJung Jul 12, 2017
5067ef2
fix line lengths
RalfJung Jul 12, 2017
5b30cc1
Detect relative urls in tidy check
ruuda Aug 3, 2017
0f924b8
add test
arshiamufti Aug 4, 2017
608863d
Only allow long relative urls after a link label
ruuda Aug 4, 2017
b298a58
Update String Deref to explain why using &String does not always work
natboehm Aug 4, 2017
94f7511
test MIR validation statements in closures
RalfJung Aug 5, 2017
970c780
Reexport all SyntaxExtension variants
oli-obk Aug 7, 2017
49310a9
Stop using URL shortener in docs
ollie27 Aug 7, 2017
2a62b91
Update explanation of deref coercion
natboehm Aug 7, 2017
43760a4
Encode proper spans in crate metadata.
ibabushkin Aug 8, 2017
6c0f2aa
fix assertion - trait object pointers don't have infinite fields
Gankra Aug 8, 2017
cf7f305
Ignore tests that fail on stage1
MaloJaffre Aug 8, 2017
40f5b30
Update solution to add using `&*` as well as `as_str()`
natboehm Aug 8, 2017
8ac4336
Improve headers linking
GuillaumeGomez Aug 8, 2017
fac6ce7
Fix trait name `Deref`
natboehm Aug 8, 2017
21a707e
explain that the example is indeed UB, but that's okay
RalfJung Aug 8, 2017
e5261c0
rustdoc: Fix broken CSS in search results
ollie27 Aug 9, 2017
445c08d
fix a typo
ubsan Aug 9, 2017
8c311e5
Fix typo in unicode char definition
mattico Aug 10, 2017
27d7e61
Fix typo corersponding -> corresponding
prisme60 Aug 10, 2017
645117f
Add missing links on File struct docs
GuillaumeGomez Aug 10, 2017
9e25984
Add missing links in ReadDir docs
GuillaumeGomez Aug 10, 2017
ac0ee51
Add missing links in io::Error docs
GuillaumeGomez Aug 10, 2017
592bdc3
Add missing links in io module docs
GuillaumeGomez Aug 10, 2017
972d67c
Add missing links for Error docs
GuillaumeGomez Aug 10, 2017
4b80d59
Fix broken links in Arc documentation
j-browne Aug 10, 2017
b617200
Improve enum variants display
GuillaumeGomez Aug 10, 2017
7a80cf1
Rollup merge of #43176 - RalfJung:explain, r=eddyb
GuillaumeGomez Aug 11, 2017
6432313
Rollup merge of #43632 - ruuda:allow-long-relative-urls, r=Mark-Simul…
GuillaumeGomez Aug 11, 2017
96c09f8
Rollup merge of #43650 - RalfJung:mir-validate, r=arielb1
GuillaumeGomez Aug 11, 2017
aebfe2b
Rollup merge of #43712 - oli-obk:cfg, r=arielb1
GuillaumeGomez Aug 11, 2017
e9d3909
Rollup merge of #43715 - ollie27:docs_long_link, r=QuietMisdreavus
GuillaumeGomez Aug 11, 2017
03abb9d
Rollup merge of #43721 - natboehm:patch-1, r=steveklabnik
GuillaumeGomez Aug 11, 2017
6047e93
Rollup merge of #43739 - ibabushkin:master, r=eddyb
GuillaumeGomez Aug 11, 2017
18238c7
Rollup merge of #43741 - Gankro:fix-assert, r=eddyb
GuillaumeGomez Aug 11, 2017
2ad3baa
Rollup merge of #43744 - MaloJaffre:stage1-test, r=Mark-Simulacrum
GuillaumeGomez Aug 11, 2017
42b0681
Rollup merge of #43747 - GuillaumeGomez:fix-css, r=QuietMisdreavus
GuillaumeGomez Aug 11, 2017
35947cf
Rollup merge of #43752 - arshiamufti:union-test, r=estebank
GuillaumeGomez Aug 11, 2017
6fac8dc
Rollup merge of #43760 - ollie27:rustdoc_search_css, r=GuillaumeGomez
GuillaumeGomez Aug 11, 2017
7fa572e
Rollup merge of #43773 - ubsan:patch-1, r=eddyb
GuillaumeGomez Aug 11, 2017
6af7b9d
Rollup merge of #43779 - mattico:fix-unicode-typo, r=aidanhs
GuillaumeGomez Aug 11, 2017
3e6e262
Rollup merge of #43783 - prisme60:prisme60-typo, r=Mark-Simulacrum
GuillaumeGomez Aug 11, 2017
4f5f3fa
Rollup merge of #43791 - GuillaumeGomez:file-docs, r=QuietMisdreavus
GuillaumeGomez Aug 11, 2017
77904aa
Rollup merge of #43793 - j-browne:master, r=steveklabnik
GuillaumeGomez Aug 11, 2017
742bba0
Rollup merge of #43795 - GuillaumeGomez:improve-variants-doc-style, r…
GuillaumeGomez Aug 11, 2017
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 src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
/// # Cloning references
///
/// Creating a new reference from an existing reference counted pointer is done using the
/// `Clone` trait implemented for [`Arc<T>`][`arc`] and [`Weak<T>`][`weak`].
/// `Clone` trait implemented for [`Arc<T>`][arc] and [`Weak<T>`][weak].
///
/// ```
/// use std::sync::Arc;
Expand Down
34 changes: 32 additions & 2 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ use boxed::Box;
/// # Deref
///
/// `String`s implement [`Deref`]`<Target=str>`, and so inherit all of [`str`]'s
/// methods. In addition, this means that you can pass a `String` to any
/// methods. In addition, this means that you can pass a `String` to a
/// function which takes a [`&str`] by using an ampersand (`&`):
///
/// ```
Expand All @@ -160,8 +160,38 @@ use boxed::Box;
///
/// This will create a [`&str`] from the `String` and pass it in. This
/// conversion is very inexpensive, and so generally, functions will accept
/// [`&str`]s as arguments unless they need a `String` for some specific reason.
/// [`&str`]s as arguments unless they need a `String` for some specific
/// reason.
///
/// In certain cases Rust doesn't have enough information to make this
/// conversion, known as `Deref` coercion. In the following example a string
/// slice `&'a str` implements the trait `TraitExample`, and the function
/// `example_func` takes anything that implements the trait. In this case Rust
/// would need to make two implicit conversions, which Rust doesn't have the
/// means to do. For that reason, the following example will not compile.
///
/// ```compile_fail,E0277
/// trait TraitExample {}
///
/// impl<'a> TraitExample for &'a str {}
///
/// fn example_func<A: TraitExample>(example_arg: A) {}
///
/// fn main() {
/// let example_string = String::from("example_string");
/// example_func(&example_string);
/// }
/// ```
///
/// There are two options that would work instead. The first would be to
/// change the line `example_func(&example_string);` to
/// `example_func(example_string.as_str());`, using the method `as_str()`
/// to explicitly extract the string slice containing the string. The second
/// way changes `example_func(&example_string);` to
/// `example_func(&*example_string);`. In this case we are dereferencing a
/// `String` to a `str`, then referencing the `str` back to `&str`. The
/// second way is more idiomatic, however both work to do the conversion
/// explicitly rather than relying on the implicit conversion.
///
/// # Representation
///
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2197,8 +2197,8 @@ impl<'a, 'tcx> TyLayout<'tcx> {
let tcx = cx.tcx();

let ptr_field_type = |pointee: Ty<'tcx>| {
assert!(i < 2);
let slice = |element: Ty<'tcx>| {
assert!(i < 2);
if i == 0 {
tcx.mk_mut_ptr(element)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
Entry {
kind: EntryKind::Mod(self.lazy(&data)),
visibility: self.lazy(&ty::Visibility::from_hir(vis, id, tcx)),
span: self.lazy(&md.inner),
span: self.lazy(&tcx.def_span(def_id)),
attributes: self.encode_attributes(attrs),
children: self.lazy_seq(md.item_ids.iter().map(|item_id| {
tcx.hir.local_def_id(item_id.id).index
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1525,9 +1525,9 @@ static BAR: _ = "test"; // error, explicitly write out the type instead
"##,

E0122: r##"
An attempt was made to add a generic constraint to a type alias. While Rust will
allow this with a warning, it will not currently enforce the constraint.
Consider the example below:
An attempt was made to add a generic constraint to a type alias. This constraint
is entirely ignored. For backwards compatibility, Rust still allows this with a
warning. Consider the example below:

```
trait Foo{}
Expand Down
44 changes: 22 additions & 22 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2141,8 +2141,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,

if !types.is_empty() {
write!(w, "
<h2 id='associated-types' class='section-header'>
<a href='#associated-types'>Associated Types</a>
<h2 id='associated-types' class='small-section-header'>
Associated Types<a href='#associated-types' class='anchor'></a>
</h2>
<div class='methods'>
")?;
Expand All @@ -2154,8 +2154,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,

if !consts.is_empty() {
write!(w, "
<h2 id='associated-const' class='section-header'>
<a href='#associated-const'>Associated Constants</a>
<h2 id='associated-const' class='small-section-header'>
Associated Constants<a href='#associated-const' class='anchor'></a>
</h2>
<div class='methods'>
")?;
Expand All @@ -2168,8 +2168,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
// Output the documentation for each function individually
if !required.is_empty() {
write!(w, "
<h2 id='required-methods' class='section-header'>
<a href='#required-methods'>Required Methods</a>
<h2 id='required-methods' class='small-section-header'>
Required Methods<a href='#required-methods' class='anchor'></a>
</h2>
<div class='methods'>
")?;
Expand All @@ -2180,8 +2180,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
}
if !provided.is_empty() {
write!(w, "
<h2 id='provided-methods' class='section-header'>
<a href='#provided-methods'>Provided Methods</a>
<h2 id='provided-methods' class='small-section-header'>
Provided Methods<a href='#provided-methods' class='anchor'></a>
</h2>
<div class='methods'>
")?;
Expand All @@ -2196,8 +2196,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,

let cache = cache();
write!(w, "
<h2 id='implementors' class='section-header'>
<a href='#implementors'>Implementors</a>
<h2 id='implementors' class='small-section-header'>
Implementors<a href='#implementors' class='anchor'></a>
</h2>
<ul class='item-list' id='implementors-list'>
")?;
Expand Down Expand Up @@ -2436,8 +2436,8 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
}).peekable();
if let doctree::Plain = s.struct_type {
if fields.peek().is_some() {
write!(w, "<h2 id='fields' class='fields section-header'>
<a href='#fields'>Fields</a></h2>")?;
write!(w, "<h2 id='fields' class='fields small-section-header'>
Fields<a href='#fields' class='anchor'></a></h2>")?;
for (field, ty) in fields {
let id = derive_id(format!("{}.{}",
ItemType::StructField,
Expand Down Expand Up @@ -2485,8 +2485,8 @@ fn item_union(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
}
}).peekable();
if fields.peek().is_some() {
write!(w, "<h2 id='fields' class='fields section-header'>
<a href='#fields'>Fields</a></h2>")?;
write!(w, "<h2 id='fields' class='fields small-section-header'>
Fields<a href='#fields' class='anchor'></a></h2>")?;
for (field, ty) in fields {
write!(w, "<span id='{shortty}.{name}' class=\"{shortty}\"><code>{name}: {ty}</code>
</span>",
Expand Down Expand Up @@ -2558,8 +2558,8 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,

document(w, cx, it)?;
if !e.variants.is_empty() {
write!(w, "<h2 id='variants' class='variants section-header'>
<a href='#variants'>Variants</a></h2>\n")?;
write!(w, "<h2 id='variants' class='variants small-section-header'>
Variants<a href='#variants' class='anchor'></a></h2>\n")?;
for variant in &e.variants {
let id = derive_id(format!("{}.{}",
ItemType::Variant,
Expand Down Expand Up @@ -2831,16 +2831,16 @@ fn render_assoc_items(w: &mut fmt::Formatter,
let render_mode = match what {
AssocItemRender::All => {
write!(w, "
<h2 id='methods' class='section-header'>
<a href='#methods'>Methods</a>
<h2 id='methods' class='small-section-header'>
Methods<a href='#methods' class='anchor'></a>
</h2>
")?;
RenderMode::Normal
}
AssocItemRender::DerefFor { trait_, type_, deref_mut_ } => {
write!(w, "
<h2 id='deref-methods' class='section-header'>
<a href='#deref-methods'>Methods from {}&lt;Target = {}&gt;</a>
<h2 id='deref-methods' class='small-section-header'>
Methods from {}&lt;Target = {}&gt;<a href='#deref-methods' class='anchor'></a>
</h2>
", trait_, type_)?;
RenderMode::ForDeref { mut_: deref_mut_ }
Expand All @@ -2865,8 +2865,8 @@ fn render_assoc_items(w: &mut fmt::Formatter,
render_deref_methods(w, cx, impl_, containing_item, has_deref_mut)?;
}
write!(w, "
<h2 id='implementations' class='section-header'>
<a href='#implementations'>Trait Implementations</a>
<h2 id='implementations' class='small-section-header'>
Trait Implementations<a href='#implementations' class='anchor'></a>
</h2>
")?;
for i in &traits {
Expand Down
16 changes: 15 additions & 1 deletion src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,16 @@ a {
background: transparent;
}

.small-section-header:hover > .anchor {
display: initial;
}
.anchor {
display: none;
}
.anchor:after {
content: '\2002\00a7\2002';
}

.docblock a:hover, .docblock-short a:hover, .stability a {
text-decoration: underline;
}
Expand Down Expand Up @@ -677,6 +687,10 @@ span.since {
left: 0;
}

.variant + .toggle-wrapper + .docblock > p {
margin-top: 5px;
}

.variant + .toggle-wrapper > a {
margin-top: 5px;
}
Expand All @@ -695,7 +709,7 @@ span.since {
margin-bottom: 25px;
}

.enum .variant, .struct .structfield, .union .structfield {
#main > .variant, #main > .structfield {
display: block;
}

Expand Down
16 changes: 9 additions & 7 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use time::SystemTime;
/// A reference to an open file on the filesystem.
///
/// An instance of a `File` can be read and/or written depending on what options
/// it was opened with. Files also implement `Seek` to alter the logical cursor
/// it was opened with. Files also implement [`Seek`] to alter the logical cursor
/// that the file contains internally.
///
/// Files are automatically closed when they go out of scope.
Expand All @@ -48,7 +48,7 @@ use time::SystemTime;
/// # }
/// ```
///
/// Read the contents of a file into a `String`:
/// Read the contents of a file into a [`String`]:
///
/// ```no_run
/// use std::fs::File;
Expand Down Expand Up @@ -81,6 +81,8 @@ use time::SystemTime;
/// # }
/// ```
///
/// [`Seek`]: ../io/trait.Seek.html
/// [`String`]: ../string/struct.String.html
/// [`Read`]: ../io/trait.Read.html
/// [`BufReader<R>`]: ../io/struct.BufReader.html
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -104,19 +106,19 @@ pub struct Metadata(fs_imp::FileAttr);
/// Iterator over the entries in a directory.
///
/// This iterator is returned from the [`read_dir`] function of this module and
/// will yield instances of `io::Result<DirEntry>`. Through a [`DirEntry`]
/// will yield instances of [`io::Result`]`<`[`DirEntry`]`>`. Through a [`DirEntry`]
/// information like the entry's path and possibly other metadata can be
/// learned.
///
/// [`read_dir`]: fn.read_dir.html
/// [`DirEntry`]: struct.DirEntry.html
///
/// # Errors
///
/// This [`io::Result`] will be an `Err` if there's some sort of intermittent
/// This [`io::Result`] will be an [`Err`] if there's some sort of intermittent
/// IO error during iteration.
///
/// [`read_dir`]: fn.read_dir.html
/// [`DirEntry`]: struct.DirEntry.html
/// [`io::Result`]: ../io/type.Result.html
/// [`Err`]: ../result/enum.Result.html#variant.Err
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct ReadDir(fs_imp::ReadDir);
Expand Down
23 changes: 15 additions & 8 deletions src/libstd/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ use convert::From;
/// A specialized [`Result`](../result/enum.Result.html) type for I/O
/// operations.
///
/// This type is broadly used across `std::io` for any operation which may
/// This type is broadly used across [`std::io`] for any operation which may
/// produce an error.
///
/// This typedef is generally used to avoid writing out `io::Error` directly and
/// is otherwise a direct mapping to `Result`.
/// This typedef is generally used to avoid writing out [`io::Error`] directly and
/// is otherwise a direct mapping to [`Result`].
///
/// While usual Rust style is to import types directly, aliases of `Result`
/// often are not, to make it easier to distinguish between them. `Result` is
/// generally assumed to be `std::result::Result`, and so users of this alias
/// While usual Rust style is to import types directly, aliases of [`Result`]
/// often are not, to make it easier to distinguish between them. [`Result`] is
/// generally assumed to be [`std::result::Result`][`Result`], and so users of this alias
/// will generally use `io::Result` instead of shadowing the prelude's import
/// of `std::result::Result`.
/// of [`std::result::Result`][`Result`].
///
/// [`std::io`]: ../io/index.html
/// [`io::Error`]: ../io/struct.Error.html
/// [`Result`]: ../result/enum.Result.html
///
/// # Examples
///
Expand All @@ -47,13 +51,16 @@ use convert::From;
#[stable(feature = "rust1", since = "1.0.0")]
pub type Result<T> = result::Result<T, Error>;

/// The error type for I/O operations of the `Read`, `Write`, `Seek`, and
/// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and
/// associated traits.
///
/// Errors mostly originate from the underlying OS, but custom instances of
/// `Error` can be created with crafted error messages and a particular value of
/// [`ErrorKind`].
///
/// [`Read`]: ../io/trait.Read.html
/// [`Write`]: ../io/trait.Write.html
/// [`Seek`]: ../io/trait.Seek.html
/// [`ErrorKind`]: enum.ErrorKind.html
#[derive(Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
10 changes: 6 additions & 4 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//! you'll see a few different types of I/O throughout the documentation in
//! this module: [`File`]s, [`TcpStream`]s, and sometimes even [`Vec<T>`]s. For
//! example, [`Read`] adds a [`read`][`Read::read`] method, which we can use on
//! `File`s:
//! [`File`]s:
//!
//! ```
//! use std::io;
Expand Down Expand Up @@ -146,9 +146,9 @@
//! # }
//! ```
//!
//! Note that you cannot use the `?` operator in functions that do not return
//! a `Result<T, E>` (e.g. `main`). Instead, you can call `.unwrap()` or `match`
//! on the return value to catch any possible errors:
//! Note that you cannot use the [`?` operator] in functions that do not return
//! a [`Result<T, E>`][`Result`] (e.g. `main`). Instead, you can call [`.unwrap()`]
//! or `match` on the return value to catch any possible errors:
//!
//! ```
//! use std::io;
Expand Down Expand Up @@ -265,6 +265,8 @@
//! [`io::Result`]: type.Result.html
//! [`?` operator]: ../../book/first-edition/syntax-index.html
//! [`Read::read`]: trait.Read.html#tymethod.read
//! [`Result`]: ../result/enum.Result.html
//! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap

#![stable(feature = "rust1", since = "1.0.0")]

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ impl Ipv4Addr {
/// - test addresses used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24)
/// - the unspecified address (0.0.0.0)
///
/// [ipv4-sr]: http://goo.gl/RaZ7lg
/// [ipv4-sr]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
/// [`true`]: ../../std/primitive.bool.html
///
/// # Examples
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/ext/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ impl UnixListener {
/// Accepts a new incoming connection to this listener.
///
/// This function will block the calling thread until a new Unix connection
/// is established. When established, the corersponding [`UnixStream`] and
/// is established. When established, the corresponding [`UnixStream`] and
/// the remote peer's address will be returned.
///
/// [`UnixStream`]: ../../../../std/os/unix/net/struct.UnixStream.html
Expand Down
Loading