Skip to content

Commit c9010d6

Browse files
authored
Rollup merge of #74300 - lzutao:iterator-intra, r=jyn514
Use intra-doc links in core::iter module This will make core::iter doc depend less on std doc.
2 parents 6b2ccc7 + 5ffdd7c commit c9010d6

File tree

6 files changed

+40
-78
lines changed

6 files changed

+40
-78
lines changed

src/libcore/iter/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
//! ```
4040
//!
4141
//! An iterator has a method, [`next`], which when called, returns an
42-
//! [`Option`]`<Item>`. [`next`] will return `Some(Item)` as long as there
42+
//! [`Option`]`<Item>`. [`next`] will return [`Some(Item)`] as long as there
4343
//! are elements, and once they've all been exhausted, will return `None` to
4444
//! indicate that iteration is finished. Individual iterators may choose to
4545
//! resume iteration, and so calling [`next`] again may or may not eventually
46-
//! start returning `Some(Item)` again at some point (for example, see [`TryIter`]).
46+
//! start returning [`Some(Item)`] again at some point (for example, see [`TryIter`]).
4747
//!
4848
//! [`Iterator`]'s full definition includes a number of other methods as well,
4949
//! but they are default methods, built on top of [`next`], and so you get
@@ -53,9 +53,9 @@
5353
//! more complex forms of processing. See the [Adapters](#adapters) section
5454
//! below for more details.
5555
//!
56+
//! [`Some(Item)`]: Some
5657
//! [`Iterator`]: trait.Iterator.html
5758
//! [`next`]: trait.Iterator.html#tymethod.next
58-
//! [`Option`]: ../../std/option/enum.Option.html
5959
//! [`TryIter`]: ../../std/sync/mpsc/struct.TryIter.html
6060
//!
6161
//! # The three forms of iteration
@@ -72,9 +72,9 @@
7272
//! # Implementing Iterator
7373
//!
7474
//! Creating an iterator of your own involves two steps: creating a `struct` to
75-
//! hold the iterator's state, and then `impl`ementing [`Iterator`] for that
76-
//! `struct`. This is why there are so many `struct`s in this module: there is
77-
//! one for each iterator and iterator adapter.
75+
//! hold the iterator's state, and then implementing [`Iterator`] for that `struct`.
76+
//! This is why there are so many `struct`s in this module: there is one for
77+
//! each iterator and iterator adapter.
7878
//!
7979
//! Let's make an iterator named `Counter` which counts from `1` to `5`:
8080
//!

src/libcore/iter/traits/accum.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use crate::ops::{Add, Mul};
99
/// [`FromIterator`] this trait should rarely be called directly and instead
1010
/// interacted with through [`Iterator::sum`].
1111
///
12-
/// [`sum`]: ../../std/iter/trait.Sum.html#tymethod.sum
13-
/// [`FromIterator`]: ../../std/iter/trait.FromIterator.html
14-
/// [`Iterator::sum`]: ../../std/iter/trait.Iterator.html#method.sum
12+
/// [`sum`]: #tymethod.sum
13+
/// [`FromIterator`]: crate::iter::FromIterator
14+
/// [`Iterator::sum`]: crate::iter::Iterator::sum
1515
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
1616
pub trait Sum<A = Self>: Sized {
1717
/// Method which takes an iterator and generates `Self` from the elements by
@@ -28,9 +28,9 @@ pub trait Sum<A = Self>: Sized {
2828
/// [`FromIterator`] this trait should rarely be called directly and instead
2929
/// interacted with through [`Iterator::product`].
3030
///
31-
/// [`product`]: ../../std/iter/trait.Product.html#tymethod.product
32-
/// [`FromIterator`]: ../../std/iter/trait.FromIterator.html
33-
/// [`Iterator::product`]: ../../std/iter/trait.Iterator.html#method.product
31+
/// [`product`]: #tymethod.product
32+
/// [`FromIterator`]: crate::iter::FromIterator
33+
/// [`Iterator::product`]: crate::iter::Iterator::product
3434
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
3535
pub trait Product<A = Self>: Sized {
3636
/// Method which takes an iterator and generates `Self` from the elements by

src/libcore/iter/traits/double_ended.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ pub trait DoubleEndedIterator: Iterator {
106106
/// `nth_back()` will return [`None`] if `n` is greater than or equal to the length of the
107107
/// iterator.
108108
///
109-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
110-
/// [`nth`]: ../../std/iter/trait.Iterator.html#method.nth
109+
/// [`nth`]: crate::iter::Iterator::nth
111110
///
112111
/// # Examples
113112
///
@@ -274,8 +273,7 @@ pub trait DoubleEndedIterator: Iterator {
274273
/// argument is a double reference. You can see this effect in the
275274
/// examples below, with `&&x`.
276275
///
277-
/// [`Some(element)`]: ../../std/option/enum.Option.html#variant.Some
278-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
276+
/// [`Some(element)`]: Some
279277
///
280278
/// # Examples
281279
///

src/libcore/iter/traits/iterator.rs

+21-56
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ pub trait Iterator {
106106
/// again may or may not eventually start returning [`Some(Item)`] again at some
107107
/// point.
108108
///
109-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
110-
/// [`Some(Item)`]: ../../std/option/enum.Option.html#variant.Some
109+
/// [`Some(Item)`]: Some
111110
///
112111
/// # Examples
113112
///
@@ -160,9 +159,7 @@ pub trait Iterator {
160159
/// The default implementation returns `(0, `[`None`]`)` which is correct for any
161160
/// iterator.
162161
///
163-
/// [`usize`]: ../../std/primitive.usize.html
164-
/// [`Option`]: ../../std/option/enum.Option.html
165-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
162+
/// [`usize`]: type@usize
166163
///
167164
/// # Examples
168165
///
@@ -214,8 +211,6 @@ pub trait Iterator {
214211
/// called at least once even if the iterator does not have any elements.
215212
///
216213
/// [`next`]: #tymethod.next
217-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
218-
/// [`Some`]: ../../std/option/enum.Option.html#variant.Some
219214
///
220215
/// # Overflow Behavior
221216
///
@@ -229,7 +224,7 @@ pub trait Iterator {
229224
/// This function might panic if the iterator has more than [`usize::MAX`]
230225
/// elements.
231226
///
232-
/// [`usize::MAX`]: ../../std/usize/constant.MAX.html
227+
/// [`usize::MAX`]: crate::usize::MAX
233228
///
234229
/// # Examples
235230
///
@@ -263,8 +258,6 @@ pub trait Iterator {
263258
/// doing so, it keeps track of the current element. After [`None`] is
264259
/// returned, `last()` will then return the last element it saw.
265260
///
266-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
267-
///
268261
/// # Examples
269262
///
270263
/// Basic usage:
@@ -303,8 +296,6 @@ pub trait Iterator {
303296
/// `nth()` will return [`None`] if `n` is greater than or equal to the length of the
304297
/// iterator.
305298
///
306-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
307-
///
308299
/// # Examples
309300
///
310301
/// Basic usage:
@@ -537,9 +528,8 @@ pub trait Iterator {
537528
/// assert_eq!((2, 'o'), zipper[2]);
538529
/// ```
539530
///
540-
/// [`enumerate`]: trait.Iterator.html#method.enumerate
541-
/// [`next`]: ../../std/iter/trait.Iterator.html#tymethod.next
542-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
531+
/// [`enumerate`]: #method.enumerate
532+
/// [`next`]: #tymethod.next
543533
#[inline]
544534
#[stable(feature = "rust1", since = "1.0.0")]
545535
fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter>
@@ -568,7 +558,7 @@ pub trait Iterator {
568558
/// more idiomatic to use [`for`] than `map()`.
569559
///
570560
/// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
571-
/// [`FnMut`]: ../../std/ops/trait.FnMut.html
561+
/// [`FnMut`]: crate::ops::FnMut
572562
///
573563
/// # Examples
574564
///
@@ -777,9 +767,7 @@ pub trait Iterator {
777767
/// assert_eq!(iter.next(), None);
778768
/// ```
779769
///
780-
/// [`Option<T>`]: ../../std/option/enum.Option.html
781-
/// [`Some`]: ../../std/option/enum.Option.html#variant.Some
782-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
770+
/// [`Option<T>`]: Option
783771
#[inline]
784772
#[stable(feature = "rust1", since = "1.0.0")]
785773
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
@@ -812,8 +800,8 @@ pub trait Iterator {
812800
/// The returned iterator might panic if the to-be-returned index would
813801
/// overflow a [`usize`].
814802
///
815-
/// [`usize::MAX`]: ../../std/usize/constant.MAX.html
816-
/// [`usize`]: ../../std/primitive.usize.html
803+
/// [`usize`]: type@usize
804+
/// [`usize::MAX`]: crate::usize::MAX
817805
/// [`zip`]: #method.zip
818806
///
819807
/// # Examples
@@ -849,8 +837,8 @@ pub trait Iterator {
849837
/// anything other than fetching the next value) of the [`next`] method
850838
/// will occur.
851839
///
852-
/// [`peek`]: struct.Peekable.html#method.peek
853-
/// [`next`]: ../../std/iter/trait.Iterator.html#tymethod.next
840+
/// [`peek`]: crate::iter::Peekable::peek
841+
/// [`next`]: #tymethod.next
854842
///
855843
/// # Examples
856844
///
@@ -1116,8 +1104,6 @@ pub trait Iterator {
11161104
/// It is also not specified what this iterator returns after the first` None` is returned.
11171105
/// If you need fused iterator, use [`fuse`].
11181106
///
1119-
/// [`Some`]: ../../std/option/enum.Option.html#variant.Some
1120-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
11211107
/// [`fuse`]: #method.fuse
11221108
#[inline]
11231109
#[unstable(feature = "iter_map_while", reason = "recently added", issue = "68537")]
@@ -1216,8 +1202,6 @@ pub trait Iterator {
12161202
/// iterator and the return value from the closure, an [`Option`], is
12171203
/// yielded by the iterator.
12181204
///
1219-
/// [`Option`]: ../../std/option/enum.Option.html
1220-
///
12211205
/// # Examples
12221206
///
12231207
/// Basic usage:
@@ -1366,8 +1350,7 @@ pub trait Iterator {
13661350
/// [`Some(T)`] again. `fuse()` adapts an iterator, ensuring that after a
13671351
/// [`None`] is given, it will always return [`None`] forever.
13681352
///
1369-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
1370-
/// [`Some(T)`]: ../../std/option/enum.Option.html#variant.Some
1353+
/// [`Some(T)`]: Some
13711354
///
13721355
/// # Examples
13731356
///
@@ -1658,10 +1641,9 @@ pub trait Iterator {
16581641
/// assert_eq!(Ok(vec![1, 3]), result);
16591642
/// ```
16601643
///
1661-
/// [`iter`]: ../../std/iter/trait.Iterator.html#tymethod.next
1644+
/// [`iter`]: #tymethod.next
16621645
/// [`String`]: ../../std/string/struct.String.html
1663-
/// [`char`]: ../../std/primitive.char.html
1664-
/// [`Result`]: ../../std/result/enum.Result.html
1646+
/// [`char`]: type@char
16651647
#[inline]
16661648
#[stable(feature = "rust1", since = "1.0.0")]
16671649
#[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]
@@ -2184,8 +2166,7 @@ pub trait Iterator {
21842166
/// argument is a double reference. You can see this effect in the
21852167
/// examples below, with `&&x`.
21862168
///
2187-
/// [`Some(element)`]: ../../std/option/enum.Option.html#variant.Some
2188-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
2169+
/// [`Some(element)`]: Some
21892170
///
21902171
/// # Examples
21912172
///
@@ -2331,9 +2312,8 @@ pub trait Iterator {
23312312
/// This function might panic if the iterator has more than `usize::MAX`
23322313
/// non-matching elements.
23332314
///
2334-
/// [`Some(index)`]: ../../std/option/enum.Option.html#variant.Some
2335-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
2336-
/// [`usize::MAX`]: ../../std/usize/constant.MAX.html
2315+
/// [`Some(index)`]: Some
2316+
/// [`usize::MAX`]: crate::usize::MAX
23372317
///
23382318
/// # Examples
23392319
///
@@ -2394,8 +2374,7 @@ pub trait Iterator {
23942374
/// `rposition()` is short-circuiting; in other words, it will stop
23952375
/// processing as soon as it finds a `true`.
23962376
///
2397-
/// [`Some(index)`]: ../../std/option/enum.Option.html#variant.Some
2398-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
2377+
/// [`Some(index)`]: Some
23992378
///
24002379
/// # Examples
24012380
///
@@ -2449,8 +2428,6 @@ pub trait Iterator {
24492428
/// If several elements are equally maximum, the last element is
24502429
/// returned. If the iterator is empty, [`None`] is returned.
24512430
///
2452-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
2453-
///
24542431
/// # Examples
24552432
///
24562433
/// Basic usage:
@@ -2477,8 +2454,6 @@ pub trait Iterator {
24772454
/// If several elements are equally minimum, the first element is
24782455
/// returned. If the iterator is empty, [`None`] is returned.
24792456
///
2480-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
2481-
///
24822457
/// # Examples
24832458
///
24842459
/// Basic usage:
@@ -2506,8 +2481,6 @@ pub trait Iterator {
25062481
/// If several elements are equally maximum, the last element is
25072482
/// returned. If the iterator is empty, [`None`] is returned.
25082483
///
2509-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
2510-
///
25112484
/// # Examples
25122485
///
25132486
/// ```
@@ -2541,8 +2514,6 @@ pub trait Iterator {
25412514
/// If several elements are equally maximum, the last element is
25422515
/// returned. If the iterator is empty, [`None`] is returned.
25432516
///
2544-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
2545-
///
25462517
/// # Examples
25472518
///
25482519
/// ```
@@ -2570,8 +2541,6 @@ pub trait Iterator {
25702541
/// If several elements are equally minimum, the first element is
25712542
/// returned. If the iterator is empty, [`None`] is returned.
25722543
///
2573-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
2574-
///
25752544
/// # Examples
25762545
///
25772546
/// ```
@@ -2605,8 +2574,6 @@ pub trait Iterator {
26052574
/// If several elements are equally minimum, the first element is
26062575
/// returned. If the iterator is empty, [`None`] is returned.
26072576
///
2608-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
2609-
///
26102577
/// # Examples
26112578
///
26122579
/// ```
@@ -2747,7 +2714,7 @@ pub trait Iterator {
27472714
/// This is useful when you have an iterator over `&T`, but you need an
27482715
/// iterator over `T`.
27492716
///
2750-
/// [`clone`]: ../../std/clone/trait.Clone.html#tymethod.clone
2717+
/// [`clone`]: crate::clone::Clone::clone
27512718
///
27522719
/// # Examples
27532720
///
@@ -2779,8 +2746,6 @@ pub trait Iterator {
27792746
/// from the beginning. After iterating again, it will start at the
27802747
/// beginning again. And again. And again. Forever.
27812748
///
2782-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
2783-
///
27842749
/// # Examples
27852750
///
27862751
/// Basic usage:
@@ -3233,7 +3198,7 @@ pub trait Iterator {
32333198
/// assert!(![0.0, 1.0, f32::NAN].iter().is_sorted_by(|a, b| a.partial_cmp(b)));
32343199
/// ```
32353200
///
3236-
/// [`is_sorted`]: trait.Iterator.html#method.is_sorted
3201+
/// [`is_sorted`]: #method.is_sorted
32373202
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
32383203
fn is_sorted_by<F>(mut self, mut compare: F) -> bool
32393204
where
@@ -3262,7 +3227,7 @@ pub trait Iterator {
32623227
/// the elements, as determined by `f`. Apart from that, it's equivalent to [`is_sorted`]; see
32633228
/// its documentation for more information.
32643229
///
3265-
/// [`is_sorted`]: trait.Iterator.html#method.is_sorted
3230+
/// [`is_sorted`]: #method.is_sorted
32663231
///
32673232
/// # Examples
32683233
///

src/libcore/iter/traits/marker.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
/// on the iterator. If the iterator is already fused, the additional [`Fuse`]
1010
/// wrapper will be a no-op with no performance penalty.
1111
///
12-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
13-
/// [`Iterator::fuse`]: ../../std/iter/trait.Iterator.html#method.fuse
14-
/// [`Fuse`]: ../../std/iter/struct.Fuse.html
12+
/// [`Iterator::fuse`]: crate::iter::Iterator::fuse
13+
/// [`Fuse`]: crate::iter::Fuse
1514
#[stable(feature = "fused", since = "1.26.0")]
1615
#[rustc_unsafe_specialization_marker]
1716
pub trait FusedIterator: Iterator {}
@@ -35,9 +34,8 @@ impl<I: FusedIterator + ?Sized> FusedIterator for &mut I {}
3534
/// This trait must only be implemented when the contract is upheld.
3635
/// Consumers of this trait must inspect [`.size_hint`]’s upper bound.
3736
///
38-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
39-
/// [`usize::MAX`]: ../../std/usize/constant.MAX.html
40-
/// [`.size_hint`]: ../../std/iter/trait.Iterator.html#method.size_hint
37+
/// [`usize::MAX`]: crate::usize::MAX
38+
/// [`.size_hint`]: crate::iter::Iterator::size_hint
4139
#[unstable(feature = "trusted_len", issue = "37572")]
4240
#[rustc_unsafe_specialization_marker]
4341
pub unsafe trait TrustedLen: Iterator {}

src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
#![feature(slice_ptr_get)]
152152
#![feature(no_niche)] // rust-lang/rust#68303
153153
#![feature(unsafe_block_in_unsafe_fn)]
154+
#![deny(intra_doc_link_resolution_failure)]
154155
#![deny(unsafe_op_in_unsafe_fn)]
155156

156157
#[prelude_import]

0 commit comments

Comments
 (0)