Skip to content

Commit

Permalink
Rollup merge of rust-lang#86277 - jsha:remove-must-use, r=Manishearth
Browse files Browse the repository at this point in the history
Remove must_use from ALLOWED_ATTRIBUTES

This is a fairly common attribute on methods, but is not something you need to know when reading the method docs - the purpose of the attribute is for the compiler to tell you about it if you forget to use a value.

Removing reclaims some valuable space in the summary of methods, particularly when the attribute has a long string value.

As discussed in rust-lang#84309. Partially addresses rust-lang#81482.

r? ``@Manishearth``
  • Loading branch information
Dylan-DPC committed Jun 14, 2021
2 parents 8373c01 + 74e8e7b commit 0282fe0
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 50 deletions.
10 changes: 2 additions & 8 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,14 +965,8 @@ fn render_assoc_item(
}
}

const ALLOWED_ATTRIBUTES: &[Symbol] = &[
sym::export_name,
sym::link_section,
sym::must_use,
sym::no_mangle,
sym::repr,
sym::non_exhaustive,
];
const ALLOWED_ATTRIBUTES: &[Symbol] =
&[sym::export_name, sym::link_section, sym::no_mangle, sym::repr, sym::non_exhaustive];

fn attributes(it: &clean::Item) -> Vec<String> {
it.attrs
Expand Down
8 changes: 0 additions & 8 deletions src/test/rustdoc/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ pub extern "C" fn f() {}
#[export_name = "bar"]
pub extern "C" fn g() {}

// @matches foo/enum.Foo.html '//*[@class="rust enum"]' \
// '#\[repr\(i64\)\]\n#\[must_use\]'
#[repr(i64)]
#[must_use]
pub enum Foo {
Bar,
}

// @has foo/struct.Repr.html '//*[@class="docblock type-decl"]' '#[repr(C, align(8))]'
#[repr(C, align(8))]
pub struct Repr;
3 changes: 1 addition & 2 deletions src/test/rustdoc/cap-lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// therefore should not concern itself with the lints.
#[deny(warnings)]

// @has cap_lints/struct.Foo.html //pre '#[must_use]'
#[must_use]
// @has cap_lints/struct.Foo.html //* 'Struct Foo'
pub struct Foo {
field: i32,
}
11 changes: 0 additions & 11 deletions src/test/rustdoc/must-use.rs

This file was deleted.

21 changes: 0 additions & 21 deletions src/test/rustdoc/trait-attributes.rs

This file was deleted.

0 comments on commit 0282fe0

Please sign in to comment.