Skip to content

Commit b07ef61

Browse files
committed
Fix code that uses doc comments nested in fns
1 parent 6bed383 commit b07ef61

10 files changed

Lines changed: 43 additions & 39 deletions

File tree

library/compiler-builtins/compiler-builtins/src/mem/impls.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ pub unsafe fn copy_forward(mut dest: *mut u8, mut src: *const u8, mut n: usize)
183183
// dest_usize does not matter any more
184184
}
185185

186-
/// `n` is in units of bytes, but must be a multiple of the word size and must not be 0.
187-
/// `src` *must not* be `usize`-aligned.
186+
// `n` is in units of bytes, but must be a multiple of the word size and must not be 0.
187+
// `src` *must not* be `usize`-aligned.
188188
#[cfg(mem_unaligned)]
189189
#[inline(always)]
190190
unsafe fn copy_forward_misaligned_words(dest: *mut u8, src: *const u8, n: usize) {
@@ -299,8 +299,8 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, mut n: usize) {
299299
*dest_usize = reassembled;
300300
}
301301

302-
/// `n` is in units of bytes, but must be a multiple of the word size and must not be 0.
303-
/// `src` *must not* be `usize`-aligned.
302+
// `n` is in units of bytes, but must be a multiple of the word size and must not be 0.
303+
// `src` *must not* be `usize`-aligned.
304304
#[cfg(mem_unaligned)]
305305
#[inline(always)]
306306
unsafe fn copy_backward_misaligned_words(dest: *mut u8, src: *const u8, n: usize) {

library/compiler-builtins/libm/src/math/support/feature_detect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ macro_rules! select_once {
5252

5353
type Func = unsafe fn($($arg: $ArgTy),*) -> $RetTy;
5454

55-
/// Stores a pointer that is immediately jumped to. By default it is an init function
56-
/// that sets FUNC to something else.
55+
// Stores a pointer that is immediately jumped to. By default it is an init function
56+
// that sets FUNC to something else.
5757
static FUNC: AtomicPtr<()> = AtomicPtr::new((initializer as Func) as *mut ());
5858

59-
/// Run once to set the function that will be used for all subsequent calls.
59+
// Run once to set the function that will be used for all subsequent calls.
6060
fn initializer($($arg: $ArgTy),*) -> $RetTy {
6161
// Select an implementation, ensuring a 'static lifetime.
6262
let fn_ptr: Func = $init();

library/core/src/escape.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ const fn escape_ascii<const N: usize>(byte: u8) -> ([ascii::Char; N], Range<u8>)
8080

8181
#[cfg(not(feature = "optimize_for_size"))]
8282
{
83-
/// Lookup table helps us determine how to display character.
84-
///
85-
/// Since ASCII characters will always be 7 bits, we can exploit this to store the 8th bit to
86-
/// indicate whether the result is escaped or unescaped.
87-
///
88-
/// We additionally use 0x80 (escaped NUL character) to indicate hex-escaped bytes, since
89-
/// escaped NUL will not occur.
83+
// Lookup table helps us determine how to display character.
84+
//
85+
// Since ASCII characters will always be 7 bits, we can exploit this to store the 8th bit to
86+
// indicate whether the result is escaped or unescaped.
87+
//
88+
// We additionally use 0x80 (escaped NUL character) to indicate hex-escaped bytes, since
89+
// escaped NUL will not occur.
9090
const LOOKUP: [u8; 256] = {
9191
let mut arr = [0; 256];
9292
let mut idx = 0;

library/core/src/ptr/mod.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,22 +2251,22 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
22512251
unchecked_shr, unchecked_sub, wrapping_add, wrapping_mul, wrapping_sub,
22522252
};
22532253

2254-
/// Calculate multiplicative modular inverse of `x` modulo `m`.
2255-
///
2256-
/// This implementation is tailored for `align_offset` and has following preconditions:
2257-
///
2258-
/// * `m` is a power-of-two;
2259-
/// * `x < m`; (if `x ≥ m`, pass in `x % m` instead)
2260-
///
2261-
/// Implementation of this function shall not panic. Ever.
2254+
// Calculate multiplicative modular inverse of `x` modulo `m`.
2255+
//
2256+
// This implementation is tailored for `align_offset` and has following preconditions:
2257+
//
2258+
// * `m` is a power-of-two;
2259+
// * `x < m`; (if `x ≥ m`, pass in `x % m` instead)
2260+
//
2261+
// Implementation of this function shall not panic. Ever.
22622262
#[inline]
22632263
const unsafe fn mod_inv(x: usize, m: usize) -> usize {
2264-
/// Multiplicative modular inverse table modulo 2⁴ = 16.
2265-
///
2266-
/// Note, that this table does not contain values where inverse does not exist (i.e., for
2267-
/// `0⁻¹ mod 16`, `2⁻¹ mod 16`, etc.)
2264+
// Multiplicative modular inverse table modulo 2⁴ = 16.
2265+
//
2266+
// Note, that this table does not contain values where inverse does not exist (i.e., for
2267+
// `0⁻¹ mod 16`, `2⁻¹ mod 16`, etc.)
22682268
const INV_TABLE_MOD_16: [u8; 8] = [1, 11, 13, 7, 9, 3, 5, 15];
2269-
/// Modulo for which the `INV_TABLE_MOD_16` is intended.
2269+
// Modulo for which the `INV_TABLE_MOD_16` is intended.
22702270
const INV_TABLE_MOD: usize = 16;
22712271

22722272
// SAFETY: `m` is required to be a power-of-two, hence non-zero.

library/core/src/slice/ascii.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ const fn is_ascii(s: &[u8]) -> bool {
463463
if const {
464464
is_ascii_simple(s)
465465
} else {
466-
/// Returns `true` if any byte in the word `v` is nonascii (>= 128). Snarfed
467-
/// from `../str/mod.rs`, which does something similar for utf8 validation.
466+
// Returns `true` if any byte in the word `v` is nonascii (>= 128). Snarfed
467+
// from `../str/mod.rs`, which does something similar for utf8 validation.
468468
const fn contains_nonascii(v: usize) -> bool {
469469
const NONASCII_MASK: usize = usize::repeat_u8(0x80);
470470
(NONASCII_MASK & v) != 0

tests/rustdoc-ui/crate-reference-in-block-module.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ check-pass
2+
#![allow(unused_doc_comments)]
23
fn main() {
34
/// [](crate)
45
struct X;

tests/rustdoc-ui/impl-fn-nesting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Ensure that rustdoc gives errors for trait impls inside function bodies that don't resolve.
22
// See https://github.com/rust-lang/rust/pull/73566
3+
#![allow(unused_doc_comments)]
34
pub struct ValidType;
45
pub trait ValidTrait {}
56
pub trait NeedsBody {

tests/rustdoc-ui/impl-fn-nesting.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
error: cannot find macro `unknown_macro` in this scope
2-
--> $DIR/impl-fn-nesting.rs:32:13
2+
--> $DIR/impl-fn-nesting.rs:33:13
33
|
44
LL | unknown_macro!();
55
| ^^^^^^^^^^^^^
66

77
error[E0405]: cannot find trait `UnknownBound` in this scope
8-
--> $DIR/impl-fn-nesting.rs:11:13
8+
--> $DIR/impl-fn-nesting.rs:12:13
99
|
1010
LL | pub fn f<B: UnknownBound>(a: UnknownType, b: B) {
1111
| ^^^^^^^^^^^^ not found in this scope
1212

1313
error[E0425]: cannot find type `UnknownType` in this scope
14-
--> $DIR/impl-fn-nesting.rs:11:30
14+
--> $DIR/impl-fn-nesting.rs:12:30
1515
|
1616
LL | pub fn f<B: UnknownBound>(a: UnknownType, b: B) {
1717
| ^^^^^^^^^^^ not found in this scope
1818

1919
error[E0405]: cannot find trait `UnknownTrait` in this scope
20-
--> $DIR/impl-fn-nesting.rs:14:10
20+
--> $DIR/impl-fn-nesting.rs:15:10
2121
|
2222
LL | impl UnknownTrait for ValidType {}
2323
| ^^^^^^^^^^^^ not found in this scope
2424

2525
error[E0405]: cannot find trait `UnknownTrait` in this scope
26-
--> $DIR/impl-fn-nesting.rs:15:27
26+
--> $DIR/impl-fn-nesting.rs:16:27
2727
|
2828
LL | impl<T: UnknownBound> UnknownTrait for T {}
2929
| ^^^^^^^^^^^^ not found in this scope
3030

3131
error[E0405]: cannot find trait `UnknownBound` in this scope
32-
--> $DIR/impl-fn-nesting.rs:15:13
32+
--> $DIR/impl-fn-nesting.rs:16:13
3333
|
3434
LL | impl<T: UnknownBound> UnknownTrait for T {}
3535
| ^^^^^^^^^^^^ not found in this scope
3636

3737
error[E0425]: cannot find type `UnknownType` in this scope
38-
--> $DIR/impl-fn-nesting.rs:18:25
38+
--> $DIR/impl-fn-nesting.rs:19:25
3939
|
4040
LL | impl ValidTrait for UnknownType {}
4141
| ^^^^^^^^^^^ not found in this scope
4242

4343
error[E0405]: cannot find trait `UnknownBound` in this scope
44-
--> $DIR/impl-fn-nesting.rs:20:53
44+
--> $DIR/impl-fn-nesting.rs:21:53
4545
|
4646
LL | impl ValidTrait for ValidType where ValidTrait: UnknownBound {}
4747
| ^^^^^^^^^^^^ not found in this scope
4848

4949
error[E0425]: cannot find type `UnknownType` in this scope
50-
--> $DIR/impl-fn-nesting.rs:25:21
50+
--> $DIR/impl-fn-nesting.rs:26:21
5151
|
5252
LL | type Item = UnknownType;
5353
| ^^^^^^^^^^^ not found in this scope
5454

5555
error[E0425]: cannot find type `UnknownType` in this scope
56-
--> $DIR/impl-fn-nesting.rs:44:37
56+
--> $DIR/impl-fn-nesting.rs:45:37
5757
|
5858
LL | pub fn doubly_nested(c: UnknownType) {
5959
| ^^^^^^^^^^^ not found in this scope

tests/ui/macros/macro-literal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ run-pass
2+
#![allow(unused_doc_comments)]
23

34
macro_rules! mtester {
45
($l:literal) => {

tests/ui/macros/macro-nested_expr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#![feature(decl_macro)]
55
#![allow(dead_code)]
6+
#![allow(unused_doc_comments)]
67

78
pub macro m($inner_str:expr) {
89
#[doc = $inner_str]

0 commit comments

Comments
 (0)