Skip to content

Commit

Permalink
Auto merge of rust-lang#75476 - JohnTitor:rollup-ap1rqf1, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 11 pull requests

Successful merges:

 - rust-lang#75189 (Fix wasi::fs::OpenOptions to imply write when append is on)
 - rust-lang#75201 (Fix some Clippy warnings in librustc_serialize)
 - rust-lang#75372 (Fix suggestion to use lifetime in type and in assoc const)
 - rust-lang#75400 (Fix minor things in the `f32` primitive docs)
 - rust-lang#75449 (add regression test for rust-lang#74739 (mir const-prop bug))
 - rust-lang#75451 (Clean up E0751 explanation)
 - rust-lang#75455 (Use explicit path link in place for doc in time)
 - rust-lang#75457 (Remove some dead variants in LLVM FFI)
 - rust-lang#75466 (Move to intra doc links whenever possible within std/src/lib.rs)
 - rust-lang#75469 (Switch to intra-doc links in `std/io/mod.rs`)
 - rust-lang#75473 (Flip order of const & type)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Aug 13, 2020
2 parents 847ba83 + 76ac5d6 commit 9aa6cc0
Show file tree
Hide file tree
Showing 28 changed files with 464 additions and 217 deletions.
27 changes: 6 additions & 21 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ impl Initializer {
///
/// [`write`]: Self::write
/// [`flush`]: Self::flush
/// [`std::io`]: index.html
/// [`std::io`]: self
///
/// # Examples
///
Expand Down Expand Up @@ -1590,8 +1590,6 @@ pub trait Seek {
/// # Errors
///
/// Seeking to a negative offset is considered an error.
///
/// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start
#[stable(feature = "rust1", since = "1.0.0")]
fn seek(&mut self, pos: SeekFrom) -> Result<u64>;

Expand Down Expand Up @@ -1678,8 +1676,6 @@ pub trait Seek {
/// Enumeration of possible methods to seek within an I/O object.
///
/// It is used by the [`Seek`] trait.
///
/// [`Seek`]: trait.Seek.html
#[derive(Copy, PartialEq, Eq, Clone, Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub enum SeekFrom {
Expand Down Expand Up @@ -1759,11 +1755,9 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>) -> R
/// For example, [`File`] implements [`Read`], but not `BufRead`.
/// [`BufReader`] to the rescue!
///
/// [`BufReader`]: struct.BufReader.html
/// [`File`]: crate::fs::File
/// [`read_line`]: Self::read_line
/// [`lines`]: Self::lines
/// [`Read`]: trait.Read.html
///
/// ```no_run
/// use std::io::{self, BufReader};
Expand Down Expand Up @@ -1869,16 +1863,13 @@ pub trait BufRead: Read {
/// present in `buf` and its length will have been adjusted appropriately.
///
/// [`fill_buf`]: Self::fill_buf
/// [`ErrorKind::Interrupted`]: enum.ErrorKind.html#variant.Interrupted
///
/// # Examples
///
/// [`std::io::Cursor`][`Cursor`] is a type that implements `BufRead`. In
/// this example, we use [`Cursor`] to read all the bytes in a byte slice
/// in hyphen delimited segments:
///
/// [`Cursor`]: struct.Cursor.html
///
/// ```
/// use std::io::{self, BufRead};
///
Expand Down Expand Up @@ -1940,8 +1931,6 @@ pub trait BufRead: Read {
/// [`std::io::Cursor`][`Cursor`] is a type that implements `BufRead`. In
/// this example, we use [`Cursor`] to read all the lines in a byte slice:
///
/// [`Cursor`]: struct.Cursor.html
///
/// ```
/// use std::io::{self, BufRead};
///
Expand Down Expand Up @@ -1996,8 +1985,6 @@ pub trait BufRead: Read {
/// this example, we use [`Cursor`] to iterate over all hyphen delimited
/// segments in a byte slice
///
/// [`Cursor`]: struct.Cursor.html
///
/// ```
/// use std::io::{self, BufRead};
///
Expand Down Expand Up @@ -2046,8 +2033,6 @@ pub trait BufRead: Read {
/// # Errors
///
/// Each line of the iterator has the same error semantics as [`BufRead::read_line`].
///
/// [`BufRead::read_line`]: trait.BufRead.html#method.read_line
#[stable(feature = "rust1", since = "1.0.0")]
fn lines(self) -> Lines<Self>
where
Expand All @@ -2062,7 +2047,7 @@ pub trait BufRead: Read {
/// This struct is generally created by calling [`chain`] on a reader.
/// Please see the documentation of [`chain`] for more details.
///
/// [`chain`]: trait.Read.html#method.chain
/// [`chain`]: Read::chain
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Chain<T, U> {
first: T,
Expand Down Expand Up @@ -2204,7 +2189,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
/// This struct is generally created by calling [`take`] on a reader.
/// Please see the documentation of [`take`] for more details.
///
/// [`take`]: trait.Read.html#method.take
/// [`take`]: Read::take
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct Take<T> {
Expand Down Expand Up @@ -2403,7 +2388,7 @@ impl<T: BufRead> BufRead for Take<T> {
/// This struct is generally created by calling [`bytes`] on a reader.
/// Please see the documentation of [`bytes`] for more details.
///
/// [`bytes`]: trait.Read.html#method.bytes
/// [`bytes`]: Read::bytes
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct Bytes<R> {
Expand Down Expand Up @@ -2433,7 +2418,7 @@ impl<R: Read> Iterator for Bytes<R> {
/// This struct is generally created by calling [`split`] on a `BufRead`.
/// Please see the documentation of [`split`] for more details.
///
/// [`split`]: trait.BufRead.html#method.split
/// [`split`]: BufRead::split
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct Split<B> {
Expand Down Expand Up @@ -2465,7 +2450,7 @@ impl<B: BufRead> Iterator for Split<B> {
/// This struct is generally created by calling [`lines`] on a `BufRead`.
/// Please see the documentation of [`lines`] for more details.
///
/// [`lines`]: trait.BufRead.html#method.lines
/// [`lines`]: BufRead::lines
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
pub struct Lines<B> {
Expand Down
67 changes: 27 additions & 40 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//! * [`std::*` modules](#modules)
//! * [Primitive types](#primitives)
//! * [Standard macros](#macros)
//! * [The Rust Prelude](prelude/index.html)
//! * [The Rust Prelude]
//!
//! If this is your first time, the documentation for the standard library is
//! written to be casually perused. Clicking on interesting things should
Expand Down Expand Up @@ -63,8 +63,8 @@
//! So for example there is a [page for the primitive type
//! `i32`](primitive.i32.html) that lists all the methods that can be called on
//! 32-bit integers (very useful), and there is a [page for the module
//! `std::i32`](i32/index.html) that documents the constant values [`MIN`] and
//! [`MAX`](i32/constant.MAX.html) (rarely useful).
//! `std::i32`] that documents the constant values [`MIN`] and [`MAX`] (rarely
//! useful).
//!
//! Note the documentation for the primitives [`str`] and [`[T]`][slice] (also
//! called 'slice'). Many method calls on [`String`] and [`Vec<T>`] are actually
Expand Down Expand Up @@ -152,48 +152,35 @@
//! contains further primitive shared memory types, including [`atomic`] and
//! [`mpsc`], which contains the channel types for message passing.
//!
//! [I/O]: io/index.html
//! [`MIN`]: i32/constant.MIN.html
//! [TCP]: net/struct.TcpStream.html
//! [The Rust Prelude]: prelude/index.html
//! [UDP]: net/struct.UdpSocket.html
//! [`Arc`]: sync/struct.Arc.html
//! [owned slice]: boxed/index.html
//! [`Cell`]: cell/struct.Cell.html
//! [`FromStr`]: str/trait.FromStr.html
//! [`HashMap<K, V>`]: collections/struct.HashMap.html
//! [`Iterator`]: iter/trait.Iterator.html
//! [`Mutex`]: sync/struct.Mutex.html
//! [`Option<T>`]: option/enum.Option.html
//! [`Rc`]: rc/struct.Rc.html
//! [`RefCell`]: cell/struct.RefCell.html
//! [`Result<T, E>`]: result/enum.Result.html
//! [`String`]: string/struct.String.html
//! [`Vec<T>`]: vec/struct.Vec.html
//! [array]: primitive.array.html
//! [slice]: primitive.slice.html
//! [`atomic`]: sync/atomic/index.html
//! [`collections`]: collections/index.html
//! [I/O]: io
//! [`MIN`]: i32::MIN
//! [`MAX`]: i32::MAX
//! [page for the module `std::i32`]: crate::i32
//! [TCP]: net::TcpStream
//! [The Rust Prelude]: prelude
//! [UDP]: net::UdpSocket
//! [`Arc`]: sync::Arc
//! [owned slice]: boxed
//! [`Cell`]: cell::Cell
//! [`FromStr`]: str::FromStr
//! [`HashMap<K, V>`]: collections::HashMap
//! [`Mutex`]: sync::Mutex
//! [`Option<T>`]: option::Option
//! [`Rc`]: rc::Rc
//! [`RefCell`]: cell::RefCell
//! [`Result<T, E>`]: result::Result
//! [`Vec<T>`]: vec::Vec
//! [`atomic`]: sync::atomic
//! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
//! [`format!`]: macro.format.html
//! [`fs`]: fs/index.html
//! [`io`]: io/index.html
//! [`iter`]: iter/index.html
//! [`mpsc`]: sync/mpsc/index.html
//! [`net`]: net/index.html
//! [`option`]: option/index.html
//! [`result`]: result/index.html
//! [`std::cmp`]: cmp/index.html
//! [`std::slice`]: slice/index.html
//! [`str`]: primitive.str.html
//! [`sync`]: sync/index.html
//! [`thread`]: thread/index.html
//! [`mpsc`]: sync::mpsc
//! [`std::cmp`]: cmp
//! [`std::slice`]: slice
//! [`use std::env`]: env/index.html
//! [`use`]: ../book/ch07-02-defining-modules-to-control-scope-and-privacy.html
//! [crates.io]: https://crates.io
//! [deref-coercions]: ../book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods
//! [files]: fs/struct.File.html
//! [multithreading]: thread/index.html
//! [files]: fs::File
//! [multithreading]: thread
//! [other]: #what-is-in-the-standard-library-documentation
//! [primitive types]: ../book/ch03-02-data-types.html
//! [rust-discord]: https://discord.gg/rust-lang
Expand Down
8 changes: 3 additions & 5 deletions library/std/src/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ mod prim_tuple {}
///
/// This type can represent a wide range of decimal numbers, like `3.5`, `27`,
/// `-113.75`, `0.0078125`, `34359738368`, `0`, `-1`. So unlike integer types
/// (like `i32`), floating point types can represent non-integer numbers, too.
/// (such as `i32`), floating point types can represent non-integer numbers,
/// too.
///
/// However, being able to represent this wide range of numbers comes at the
/// cost of precision: floats can only represent some of the real numbers and
Expand All @@ -779,15 +780,12 @@ mod prim_tuple {}
/// often discard insignificant digits: `println!("{}", 1.0f32 / 5.0f32)` will
/// print `0.2`.
///
/// The precision is better for numbers near 0 and worse for large numbers. For
/// example, above 2<sup>24</sup>, not even all integers are representable.
///
/// Additionally, `f32` can represent a couple of special values:
///
/// - `-0`: this is just due to how floats are encoded. It is semantically
/// equivalent to `0` and `-0.0 == 0.0` results in `true`.
/// - [∞](#associatedconstant.INFINITY) and
/// [-∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// [∞](#associatedconstant.NEG_INFINITY): these result from calculations
/// like `1.0 / 0.0`.
/// - [NaN (not a number)](#associatedconstant.NAN): this value results from
/// calculations like `(-1.0).sqrt()`. NaN has some potentially unexpected
Expand Down
8 changes: 5 additions & 3 deletions library/std/src/sys/wasi/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub struct DirEntry {
pub struct OpenOptions {
read: bool,
write: bool,
append: bool,
dirflags: wasi::Lookupflags,
fdflags: wasi::Fdflags,
oflags: wasi::Oflags,
Expand Down Expand Up @@ -270,8 +271,9 @@ impl OpenOptions {
}
}

pub fn append(&mut self, set: bool) {
self.fdflag(wasi::FDFLAGS_APPEND, set);
pub fn append(&mut self, append: bool) {
self.append = append;
self.fdflag(wasi::FDFLAGS_APPEND, append);
}

pub fn dsync(&mut self, set: bool) {
Expand Down Expand Up @@ -321,7 +323,7 @@ impl OpenOptions {
base |= wasi::RIGHTS_FD_READ;
base |= wasi::RIGHTS_FD_READDIR;
}
if self.write {
if self.write || self.append {
base |= wasi::RIGHTS_FD_WRITE;
base |= wasi::RIGHTS_FD_DATASYNC;
base |= wasi::RIGHTS_FD_ALLOCATE;
Expand Down
8 changes: 2 additions & 6 deletions library/std/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ impl Add<Duration> for Instant {
/// # Panics
///
/// This function may panic if the resulting point in time cannot be represented by the
/// underlying data structure. See [`checked_add`] for a version without panic.
///
/// [`checked_add`]: Instant::checked_add
/// underlying data structure. See [`Instant::checked_add`] for a version without panic.
fn add(self, other: Duration) -> Instant {
self.checked_add(other).expect("overflow when adding duration to instant")
}
Expand Down Expand Up @@ -525,9 +523,7 @@ impl Add<Duration> for SystemTime {
/// # Panics
///
/// This function may panic if the resulting point in time cannot be represented by the
/// underlying data structure. See [`checked_add`] for a version without panic.
///
/// [`checked_add`]: SystemTime::checked_add
/// underlying data structure. See [`SystemTime::checked_add`] for a version without panic.
fn add(self, dur: Duration) -> SystemTime {
self.checked_add(dur).expect("overflow when adding duration to instant")
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_passes/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ fn validate_generic_param_order<'a>(
if sess.features_untracked().const_generics {
", then consts and types"
} else if sess.features_untracked().min_const_generics {
", then consts, then types"
", then types, then consts"
} else {
", then types"
},
Expand Down
1 change: 0 additions & 1 deletion src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,6 @@ pub unsafe fn with_llvm_pmb(
(llvm::CodeGenOptLevel::Default, ..) => {
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 225);
}
(llvm::CodeGenOptLevel::Other, ..) => bug!("CodeGenOptLevel::Other selected"),
}

f(builder);
Expand Down
16 changes: 0 additions & 16 deletions src/librustc_codegen_llvm/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,13 @@ impl AtomicOrdering {
#[derive(Copy, Clone)]
#[repr(C)]
pub enum SynchronizationScope {
// FIXME: figure out if this variant is needed at all.
#[allow(dead_code)]
Other,
SingleThread,
CrossThread,
}

impl SynchronizationScope {
pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
match sc {
rustc_codegen_ssa::common::SynchronizationScope::Other => SynchronizationScope::Other,
rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
SynchronizationScope::SingleThread
}
Expand All @@ -362,9 +358,6 @@ impl SynchronizationScope {
#[derive(Copy, Clone)]
#[repr(C)]
pub enum FileType {
// FIXME: figure out if this variant is needed at all.
#[allow(dead_code)]
Other,
AssemblyFile,
ObjectFile,
}
Expand All @@ -391,9 +384,6 @@ pub enum MetadataType {
#[derive(Copy, Clone)]
#[repr(C)]
pub enum AsmDialect {
// FIXME: figure out if this variant is needed at all.
#[allow(dead_code)]
Other,
Att,
Intel,
}
Expand All @@ -411,9 +401,6 @@ impl AsmDialect {
#[derive(Copy, Clone, PartialEq)]
#[repr(C)]
pub enum CodeGenOptLevel {
// FIXME: figure out if this variant is needed at all.
#[allow(dead_code)]
Other,
None,
Less,
Default,
Expand Down Expand Up @@ -513,9 +500,6 @@ pub enum DiagnosticLevel {
#[derive(Copy, Clone)]
#[repr(C)]
pub enum ArchiveKind {
// FIXME: figure out if this variant is needed at all.
#[allow(dead_code)]
Other,
K_GNU,
K_BSD,
K_DARWIN,
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_codegen_ssa/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ pub enum AtomicOrdering {
}

pub enum SynchronizationScope {
// FIXME: figure out if this variant is needed at all.
#[allow(dead_code)]
Other,
SingleThread,
CrossThread,
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_error_codes/error_codes/E0751.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Erroneous code example:
```compile_fail,E0751
trait MyTrait {}
impl MyTrait for i32 { }
impl !MyTrait for i32 { }
impl !MyTrait for i32 { } // error!
```

Negative implementations are a promise that the trait will never be
implemented for the given types.
Negative implementations are a promise that the trait will never be implemented
for the given types. Therefore, both cannot exists at the same time.
Loading

0 comments on commit 9aa6cc0

Please sign in to comment.