Skip to content

Commit 9aa6cc0

Browse files
committed
Auto merge of rust-lang#75476 - JohnTitor:rollup-ap1rqf1, r=JohnTitor
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
2 parents 847ba83 + 76ac5d6 commit 9aa6cc0

28 files changed

+464
-217
lines changed

library/std/src/io/mod.rs

+6-21
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ impl Initializer {
12121212
///
12131213
/// [`write`]: Self::write
12141214
/// [`flush`]: Self::flush
1215-
/// [`std::io`]: index.html
1215+
/// [`std::io`]: self
12161216
///
12171217
/// # Examples
12181218
///
@@ -1590,8 +1590,6 @@ pub trait Seek {
15901590
/// # Errors
15911591
///
15921592
/// Seeking to a negative offset is considered an error.
1593-
///
1594-
/// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start
15951593
#[stable(feature = "rust1", since = "1.0.0")]
15961594
fn seek(&mut self, pos: SeekFrom) -> Result<u64>;
15971595

@@ -1678,8 +1676,6 @@ pub trait Seek {
16781676
/// Enumeration of possible methods to seek within an I/O object.
16791677
///
16801678
/// It is used by the [`Seek`] trait.
1681-
///
1682-
/// [`Seek`]: trait.Seek.html
16831679
#[derive(Copy, PartialEq, Eq, Clone, Debug)]
16841680
#[stable(feature = "rust1", since = "1.0.0")]
16851681
pub enum SeekFrom {
@@ -1759,11 +1755,9 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>) -> R
17591755
/// For example, [`File`] implements [`Read`], but not `BufRead`.
17601756
/// [`BufReader`] to the rescue!
17611757
///
1762-
/// [`BufReader`]: struct.BufReader.html
17631758
/// [`File`]: crate::fs::File
17641759
/// [`read_line`]: Self::read_line
17651760
/// [`lines`]: Self::lines
1766-
/// [`Read`]: trait.Read.html
17671761
///
17681762
/// ```no_run
17691763
/// use std::io::{self, BufReader};
@@ -1869,16 +1863,13 @@ pub trait BufRead: Read {
18691863
/// present in `buf` and its length will have been adjusted appropriately.
18701864
///
18711865
/// [`fill_buf`]: Self::fill_buf
1872-
/// [`ErrorKind::Interrupted`]: enum.ErrorKind.html#variant.Interrupted
18731866
///
18741867
/// # Examples
18751868
///
18761869
/// [`std::io::Cursor`][`Cursor`] is a type that implements `BufRead`. In
18771870
/// this example, we use [`Cursor`] to read all the bytes in a byte slice
18781871
/// in hyphen delimited segments:
18791872
///
1880-
/// [`Cursor`]: struct.Cursor.html
1881-
///
18821873
/// ```
18831874
/// use std::io::{self, BufRead};
18841875
///
@@ -1940,8 +1931,6 @@ pub trait BufRead: Read {
19401931
/// [`std::io::Cursor`][`Cursor`] is a type that implements `BufRead`. In
19411932
/// this example, we use [`Cursor`] to read all the lines in a byte slice:
19421933
///
1943-
/// [`Cursor`]: struct.Cursor.html
1944-
///
19451934
/// ```
19461935
/// use std::io::{self, BufRead};
19471936
///
@@ -1996,8 +1985,6 @@ pub trait BufRead: Read {
19961985
/// this example, we use [`Cursor`] to iterate over all hyphen delimited
19971986
/// segments in a byte slice
19981987
///
1999-
/// [`Cursor`]: struct.Cursor.html
2000-
///
20011988
/// ```
20021989
/// use std::io::{self, BufRead};
20031990
///
@@ -2046,8 +2033,6 @@ pub trait BufRead: Read {
20462033
/// # Errors
20472034
///
20482035
/// Each line of the iterator has the same error semantics as [`BufRead::read_line`].
2049-
///
2050-
/// [`BufRead::read_line`]: trait.BufRead.html#method.read_line
20512036
#[stable(feature = "rust1", since = "1.0.0")]
20522037
fn lines(self) -> Lines<Self>
20532038
where
@@ -2062,7 +2047,7 @@ pub trait BufRead: Read {
20622047
/// This struct is generally created by calling [`chain`] on a reader.
20632048
/// Please see the documentation of [`chain`] for more details.
20642049
///
2065-
/// [`chain`]: trait.Read.html#method.chain
2050+
/// [`chain`]: Read::chain
20662051
#[stable(feature = "rust1", since = "1.0.0")]
20672052
pub struct Chain<T, U> {
20682053
first: T,
@@ -2204,7 +2189,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
22042189
/// This struct is generally created by calling [`take`] on a reader.
22052190
/// Please see the documentation of [`take`] for more details.
22062191
///
2207-
/// [`take`]: trait.Read.html#method.take
2192+
/// [`take`]: Read::take
22082193
#[stable(feature = "rust1", since = "1.0.0")]
22092194
#[derive(Debug)]
22102195
pub struct Take<T> {
@@ -2403,7 +2388,7 @@ impl<T: BufRead> BufRead for Take<T> {
24032388
/// This struct is generally created by calling [`bytes`] on a reader.
24042389
/// Please see the documentation of [`bytes`] for more details.
24052390
///
2406-
/// [`bytes`]: trait.Read.html#method.bytes
2391+
/// [`bytes`]: Read::bytes
24072392
#[stable(feature = "rust1", since = "1.0.0")]
24082393
#[derive(Debug)]
24092394
pub struct Bytes<R> {
@@ -2433,7 +2418,7 @@ impl<R: Read> Iterator for Bytes<R> {
24332418
/// This struct is generally created by calling [`split`] on a `BufRead`.
24342419
/// Please see the documentation of [`split`] for more details.
24352420
///
2436-
/// [`split`]: trait.BufRead.html#method.split
2421+
/// [`split`]: BufRead::split
24372422
#[stable(feature = "rust1", since = "1.0.0")]
24382423
#[derive(Debug)]
24392424
pub struct Split<B> {
@@ -2465,7 +2450,7 @@ impl<B: BufRead> Iterator for Split<B> {
24652450
/// This struct is generally created by calling [`lines`] on a `BufRead`.
24662451
/// Please see the documentation of [`lines`] for more details.
24672452
///
2468-
/// [`lines`]: trait.BufRead.html#method.lines
2453+
/// [`lines`]: BufRead::lines
24692454
#[stable(feature = "rust1", since = "1.0.0")]
24702455
#[derive(Debug)]
24712456
pub struct Lines<B> {

library/std/src/lib.rs

+27-40
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
//! * [`std::*` modules](#modules)
2323
//! * [Primitive types](#primitives)
2424
//! * [Standard macros](#macros)
25-
//! * [The Rust Prelude](prelude/index.html)
25+
//! * [The Rust Prelude]
2626
//!
2727
//! If this is your first time, the documentation for the standard library is
2828
//! written to be casually perused. Clicking on interesting things should
@@ -63,8 +63,8 @@
6363
//! So for example there is a [page for the primitive type
6464
//! `i32`](primitive.i32.html) that lists all the methods that can be called on
6565
//! 32-bit integers (very useful), and there is a [page for the module
66-
//! `std::i32`](i32/index.html) that documents the constant values [`MIN`] and
67-
//! [`MAX`](i32/constant.MAX.html) (rarely useful).
66+
//! `std::i32`] that documents the constant values [`MIN`] and [`MAX`] (rarely
67+
//! useful).
6868
//!
6969
//! Note the documentation for the primitives [`str`] and [`[T]`][slice] (also
7070
//! called 'slice'). Many method calls on [`String`] and [`Vec<T>`] are actually
@@ -152,48 +152,35 @@
152152
//! contains further primitive shared memory types, including [`atomic`] and
153153
//! [`mpsc`], which contains the channel types for message passing.
154154
//!
155-
//! [I/O]: io/index.html
156-
//! [`MIN`]: i32/constant.MIN.html
157-
//! [TCP]: net/struct.TcpStream.html
158-
//! [The Rust Prelude]: prelude/index.html
159-
//! [UDP]: net/struct.UdpSocket.html
160-
//! [`Arc`]: sync/struct.Arc.html
161-
//! [owned slice]: boxed/index.html
162-
//! [`Cell`]: cell/struct.Cell.html
163-
//! [`FromStr`]: str/trait.FromStr.html
164-
//! [`HashMap<K, V>`]: collections/struct.HashMap.html
165-
//! [`Iterator`]: iter/trait.Iterator.html
166-
//! [`Mutex`]: sync/struct.Mutex.html
167-
//! [`Option<T>`]: option/enum.Option.html
168-
//! [`Rc`]: rc/struct.Rc.html
169-
//! [`RefCell`]: cell/struct.RefCell.html
170-
//! [`Result<T, E>`]: result/enum.Result.html
171-
//! [`String`]: string/struct.String.html
172-
//! [`Vec<T>`]: vec/struct.Vec.html
173-
//! [array]: primitive.array.html
174-
//! [slice]: primitive.slice.html
175-
//! [`atomic`]: sync/atomic/index.html
176-
//! [`collections`]: collections/index.html
155+
//! [I/O]: io
156+
//! [`MIN`]: i32::MIN
157+
//! [`MAX`]: i32::MAX
158+
//! [page for the module `std::i32`]: crate::i32
159+
//! [TCP]: net::TcpStream
160+
//! [The Rust Prelude]: prelude
161+
//! [UDP]: net::UdpSocket
162+
//! [`Arc`]: sync::Arc
163+
//! [owned slice]: boxed
164+
//! [`Cell`]: cell::Cell
165+
//! [`FromStr`]: str::FromStr
166+
//! [`HashMap<K, V>`]: collections::HashMap
167+
//! [`Mutex`]: sync::Mutex
168+
//! [`Option<T>`]: option::Option
169+
//! [`Rc`]: rc::Rc
170+
//! [`RefCell`]: cell::RefCell
171+
//! [`Result<T, E>`]: result::Result
172+
//! [`Vec<T>`]: vec::Vec
173+
//! [`atomic`]: sync::atomic
177174
//! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
178-
//! [`format!`]: macro.format.html
179-
//! [`fs`]: fs/index.html
180-
//! [`io`]: io/index.html
181-
//! [`iter`]: iter/index.html
182-
//! [`mpsc`]: sync/mpsc/index.html
183-
//! [`net`]: net/index.html
184-
//! [`option`]: option/index.html
185-
//! [`result`]: result/index.html
186-
//! [`std::cmp`]: cmp/index.html
187-
//! [`std::slice`]: slice/index.html
188-
//! [`str`]: primitive.str.html
189-
//! [`sync`]: sync/index.html
190-
//! [`thread`]: thread/index.html
175+
//! [`mpsc`]: sync::mpsc
176+
//! [`std::cmp`]: cmp
177+
//! [`std::slice`]: slice
191178
//! [`use std::env`]: env/index.html
192179
//! [`use`]: ../book/ch07-02-defining-modules-to-control-scope-and-privacy.html
193180
//! [crates.io]: https://crates.io
194181
//! [deref-coercions]: ../book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods
195-
//! [files]: fs/struct.File.html
196-
//! [multithreading]: thread/index.html
182+
//! [files]: fs::File
183+
//! [multithreading]: thread
197184
//! [other]: #what-is-in-the-standard-library-documentation
198185
//! [primitive types]: ../book/ch03-02-data-types.html
199186
//! [rust-discord]: https://discord.gg/rust-lang

library/std/src/primitive_docs.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,8 @@ mod prim_tuple {}
768768
///
769769
/// This type can represent a wide range of decimal numbers, like `3.5`, `27`,
770770
/// `-113.75`, `0.0078125`, `34359738368`, `0`, `-1`. So unlike integer types
771-
/// (like `i32`), floating point types can represent non-integer numbers, too.
771+
/// (such as `i32`), floating point types can represent non-integer numbers,
772+
/// too.
772773
///
773774
/// However, being able to represent this wide range of numbers comes at the
774775
/// cost of precision: floats can only represent some of the real numbers and
@@ -779,15 +780,12 @@ mod prim_tuple {}
779780
/// often discard insignificant digits: `println!("{}", 1.0f32 / 5.0f32)` will
780781
/// print `0.2`.
781782
///
782-
/// The precision is better for numbers near 0 and worse for large numbers. For
783-
/// example, above 2<sup>24</sup>, not even all integers are representable.
784-
///
785783
/// Additionally, `f32` can represent a couple of special values:
786784
///
787785
/// - `-0`: this is just due to how floats are encoded. It is semantically
788786
/// equivalent to `0` and `-0.0 == 0.0` results in `true`.
789787
/// - [∞](#associatedconstant.INFINITY) and
790-
/// [-∞](#associatedconstant.NEG_INFINITY): these result from calculations
788+
/// [∞](#associatedconstant.NEG_INFINITY): these result from calculations
791789
/// like `1.0 / 0.0`.
792790
/// - [NaN (not a number)](#associatedconstant.NAN): this value results from
793791
/// calculations like `(-1.0).sqrt()`. NaN has some potentially unexpected

library/std/src/sys/wasi/fs.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub struct DirEntry {
4646
pub struct OpenOptions {
4747
read: bool,
4848
write: bool,
49+
append: bool,
4950
dirflags: wasi::Lookupflags,
5051
fdflags: wasi::Fdflags,
5152
oflags: wasi::Oflags,
@@ -270,8 +271,9 @@ impl OpenOptions {
270271
}
271272
}
272273

273-
pub fn append(&mut self, set: bool) {
274-
self.fdflag(wasi::FDFLAGS_APPEND, set);
274+
pub fn append(&mut self, append: bool) {
275+
self.append = append;
276+
self.fdflag(wasi::FDFLAGS_APPEND, append);
275277
}
276278

277279
pub fn dsync(&mut self, set: bool) {
@@ -321,7 +323,7 @@ impl OpenOptions {
321323
base |= wasi::RIGHTS_FD_READ;
322324
base |= wasi::RIGHTS_FD_READDIR;
323325
}
324-
if self.write {
326+
if self.write || self.append {
325327
base |= wasi::RIGHTS_FD_WRITE;
326328
base |= wasi::RIGHTS_FD_DATASYNC;
327329
base |= wasi::RIGHTS_FD_ALLOCATE;

library/std/src/time.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,7 @@ impl Add<Duration> for Instant {
359359
/// # Panics
360360
///
361361
/// This function may panic if the resulting point in time cannot be represented by the
362-
/// underlying data structure. See [`checked_add`] for a version without panic.
363-
///
364-
/// [`checked_add`]: Instant::checked_add
362+
/// underlying data structure. See [`Instant::checked_add`] for a version without panic.
365363
fn add(self, other: Duration) -> Instant {
366364
self.checked_add(other).expect("overflow when adding duration to instant")
367365
}
@@ -525,9 +523,7 @@ impl Add<Duration> for SystemTime {
525523
/// # Panics
526524
///
527525
/// This function may panic if the resulting point in time cannot be represented by the
528-
/// underlying data structure. See [`checked_add`] for a version without panic.
529-
///
530-
/// [`checked_add`]: SystemTime::checked_add
526+
/// underlying data structure. See [`SystemTime::checked_add`] for a version without panic.
531527
fn add(self, dur: Duration) -> SystemTime {
532528
self.checked_add(dur).expect("overflow when adding duration to instant")
533529
}

src/librustc_ast_passes/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ fn validate_generic_param_order<'a>(
777777
if sess.features_untracked().const_generics {
778778
", then consts and types"
779779
} else if sess.features_untracked().min_const_generics {
780-
", then consts, then types"
780+
", then types, then consts"
781781
} else {
782782
", then types"
783783
},

src/librustc_codegen_llvm/back/write.rs

-1
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,6 @@ pub unsafe fn with_llvm_pmb(
975975
(llvm::CodeGenOptLevel::Default, ..) => {
976976
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 225);
977977
}
978-
(llvm::CodeGenOptLevel::Other, ..) => bug!("CodeGenOptLevel::Other selected"),
979978
}
980979

981980
f(builder);

src/librustc_codegen_llvm/llvm/ffi.rs

-16
Original file line numberDiff line numberDiff line change
@@ -337,17 +337,13 @@ impl AtomicOrdering {
337337
#[derive(Copy, Clone)]
338338
#[repr(C)]
339339
pub enum SynchronizationScope {
340-
// FIXME: figure out if this variant is needed at all.
341-
#[allow(dead_code)]
342-
Other,
343340
SingleThread,
344341
CrossThread,
345342
}
346343

347344
impl SynchronizationScope {
348345
pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
349346
match sc {
350-
rustc_codegen_ssa::common::SynchronizationScope::Other => SynchronizationScope::Other,
351347
rustc_codegen_ssa::common::SynchronizationScope::SingleThread => {
352348
SynchronizationScope::SingleThread
353349
}
@@ -362,9 +358,6 @@ impl SynchronizationScope {
362358
#[derive(Copy, Clone)]
363359
#[repr(C)]
364360
pub enum FileType {
365-
// FIXME: figure out if this variant is needed at all.
366-
#[allow(dead_code)]
367-
Other,
368361
AssemblyFile,
369362
ObjectFile,
370363
}
@@ -391,9 +384,6 @@ pub enum MetadataType {
391384
#[derive(Copy, Clone)]
392385
#[repr(C)]
393386
pub enum AsmDialect {
394-
// FIXME: figure out if this variant is needed at all.
395-
#[allow(dead_code)]
396-
Other,
397387
Att,
398388
Intel,
399389
}
@@ -411,9 +401,6 @@ impl AsmDialect {
411401
#[derive(Copy, Clone, PartialEq)]
412402
#[repr(C)]
413403
pub enum CodeGenOptLevel {
414-
// FIXME: figure out if this variant is needed at all.
415-
#[allow(dead_code)]
416-
Other,
417404
None,
418405
Less,
419406
Default,
@@ -513,9 +500,6 @@ pub enum DiagnosticLevel {
513500
#[derive(Copy, Clone)]
514501
#[repr(C)]
515502
pub enum ArchiveKind {
516-
// FIXME: figure out if this variant is needed at all.
517-
#[allow(dead_code)]
518-
Other,
519503
K_GNU,
520504
K_BSD,
521505
K_DARWIN,

src/librustc_codegen_ssa/common.rs

-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ pub enum AtomicOrdering {
7272
}
7373

7474
pub enum SynchronizationScope {
75-
// FIXME: figure out if this variant is needed at all.
76-
#[allow(dead_code)]
77-
Other,
7875
SingleThread,
7976
CrossThread,
8077
}

src/librustc_error_codes/error_codes/E0751.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Erroneous code example:
55
```compile_fail,E0751
66
trait MyTrait {}
77
impl MyTrait for i32 { }
8-
impl !MyTrait for i32 { }
8+
impl !MyTrait for i32 { } // error!
99
```
1010

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

0 commit comments

Comments
 (0)