From ffbc40ff0607026f20618ba648d92426fea17962 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sat, 10 Jul 2021 21:24:13 +0800 Subject: [PATCH 1/7] rustdoc: show count of item contents when hidden --- src/librustdoc/html/render/print_item.rs | 46 +++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index eeac9d1a9db76..6a74c4ec306cc 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1,6 +1,7 @@ use clean::AttributesExt; use std::cmp::Ordering; +use std::fmt; use rustc_data_structures::fx::FxHashMap; use rustc_hir as hir; @@ -155,7 +156,7 @@ fn should_hide_fields(n_fields: usize) -> bool { n_fields > 12 } -fn toggle_open(w: &mut Buffer, text: &str) { +fn toggle_open(w: &mut Buffer, text: impl fmt::Display) { write!( w, "
\ @@ -481,6 +482,9 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra let consts = t.items.iter().filter(|m| m.is_associated_const()).collect::>(); let required = t.items.iter().filter(|m| m.is_ty_method()).collect::>(); let provided = t.items.iter().filter(|m| m.is_method()).collect::>(); + let count_types = types.len(); + let count_consts = consts.len(); + let count_methods = required.len() + provided.len(); // Output the trait definition wrap_into_docblock(w, |w| { @@ -511,9 +515,12 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra let mut toggle = false; // If there are too many associated types, hide _everything_ - if should_hide_fields(types.len()) { + if should_hide_fields(count_types) { toggle = true; - toggle_open(w, "associated items"); + toggle_open( + w, + format_args!("{} associated items", count_types + count_consts + count_methods), + ); } for t in &types { render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait, cx); @@ -523,9 +530,18 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra // We also do this if the types + consts is large because otherwise we could // render a bunch of types and _then_ a bunch of consts just because both were // _just_ under the limit - if !toggle && should_hide_fields(types.len() + consts.len()) { + if !toggle && should_hide_fields(count_types + count_consts) { toggle = true; - toggle_open(w, "associated constants and methods"); + toggle_open( + w, + format_args!( + "{} associated constant{} and {} method{}", + count_consts, + pluralize(count_consts), + count_methods, + pluralize(count_methods), + ), + ); } if !types.is_empty() && !consts.is_empty() { w.write_str("\n"); @@ -534,9 +550,9 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait, cx); w.write_str(";\n"); } - if !toggle && should_hide_fields(required.len() + provided.len()) { + if !toggle && should_hide_fields(count_methods) { toggle = true; - toggle_open(w, "methods"); + toggle_open(w, format_args!("{} methods", count_methods)); } if !consts.is_empty() && !required.is_empty() { w.write_str("\n"); @@ -924,9 +940,10 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum w.write_str(" {}"); } else { w.write_str(" {\n"); - let toggle = should_hide_fields(e.variants.len()); + let count_variants = e.variants.len(); + let toggle = should_hide_fields(count_variants); if toggle { - toggle_open(w, "variants"); + toggle_open(w, format_args!("{} variants", count_variants)); } for v in &e.variants { w.write_str(" "); @@ -1003,7 +1020,8 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum use crate::clean::Variant; if let clean::VariantItem(Variant::Struct(ref s)) = *variant.kind { - toggle_open(w, "fields"); + let count_fields = s.fields.len(); + toggle_open(w, format_args!("{} field{}", count_fields, pluralize(count_fields))); let variant_id = cx.derive_id(format!( "{}.{}.fields", ItemType::Variant, @@ -1376,7 +1394,7 @@ fn render_union( fields.iter().filter(|f| matches!(*f.kind, clean::StructFieldItem(..))).count(); let toggle = should_hide_fields(count_fields); if toggle { - toggle_open(w, "fields"); + toggle_open(w, format_args!("{} fields", count_fields)); } for field in fields { @@ -1432,7 +1450,7 @@ fn render_struct( let has_visible_fields = count_fields > 0; let toggle = should_hide_fields(count_fields); if toggle { - toggle_open(w, "fields"); + toggle_open(w, format_args!("{} fields", count_fields)); } for field in fields { if let clean::StructFieldItem(ref ty) = *field.kind { @@ -1609,3 +1627,7 @@ fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) { writeln!(w, ""); } + +fn pluralize(count: usize) -> &'static str { + if count > 1 { "s" } else { "" } +} From 2b518acc6f9da564d3024e46746ac85b47abdaa2 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 11 Jul 2021 10:42:21 +0800 Subject: [PATCH 2/7] rustdoc: test count of item contents when hidden --- src/test/rustdoc/toggle-item-contents.rs | 45 ++++++++++++++++++++---- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/src/test/rustdoc/toggle-item-contents.rs b/src/test/rustdoc/toggle-item-contents.rs index 6e3c0b4c681f7..167858b6065f9 100644 --- a/src/test/rustdoc/toggle-item-contents.rs +++ b/src/test/rustdoc/toggle-item-contents.rs @@ -9,7 +9,7 @@ pub struct PubStruct { // @has 'toggle_item_contents/struct.BigPubStruct.html' // @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1 -// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show fields' +// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 13 fields' pub struct BigPubStruct { pub a: usize, pub b: usize, @@ -28,7 +28,7 @@ pub struct BigPubStruct { // @has 'toggle_item_contents/union.BigUnion.html' // @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1 -// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show fields' +// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 13 fields' pub union BigUnion { pub a: usize, pub b: usize, @@ -63,7 +63,7 @@ pub struct PrivStruct { // @has 'toggle_item_contents/enum.Enum.html' // @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1 -// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show fields' +// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 2 fields' pub enum Enum { A, B, C, D { @@ -72,9 +72,19 @@ pub enum Enum { } } +// @has 'toggle_item_contents/enum.EnumStructVariant.html' +// @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1 +// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 1 field' +pub enum EnumStructVariant { + A, B, C, + D { + a: u8, + } +} + // @has 'toggle_item_contents/enum.LargeEnum.html' // @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1 -// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show variants' +// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 13 variants' pub enum LargeEnum { A, B, C, D, E, F(u8), G, H, I, J, K, L, M } @@ -90,7 +100,7 @@ pub trait Trait { // @has 'toggle_item_contents/trait.GinormousTrait.html' // @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1 -// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show associated items' +// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 16 associated items' pub trait GinormousTrait { type A; type B; @@ -113,7 +123,7 @@ pub trait GinormousTrait { // @has 'toggle_item_contents/trait.HugeTrait.html' // @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1 -// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show associated constants and methods' +// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 12 associated constants and 2 methods' pub trait HugeTrait { type A; const M: usize = 1; @@ -133,9 +143,30 @@ pub trait HugeTrait { fn bar(); } +// @has 'toggle_item_contents/trait.GiganticTrait.html' +// @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1 +// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 1 associated constant and 1 method' +pub trait GiganticTrait { + type A; + type B; + type C; + type D; + type E; + type F; + type G; + type H; + type I; + type J; + type K; + type L; + const M: usize = 1; + #[must_use] + fn foo(); +} + // @has 'toggle_item_contents/trait.BigTrait.html' // @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1 -// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show methods' +// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 14 methods' pub trait BigTrait { type A; #[must_use] From 76ab8a6b107060aa09ec5dc0901d29502bda8497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 19 Jul 2021 17:07:21 +0300 Subject: [PATCH 3/7] :arrow_up: rust-analyzer --- src/tools/rust-analyzer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer index fe00358888a24..ea105f9396a9d 160000 --- a/src/tools/rust-analyzer +++ b/src/tools/rust-analyzer @@ -1 +1 @@ -Subproject commit fe00358888a24c64878abc15f09b0e60e16db9d6 +Subproject commit ea105f9396a9dab68e71efb06016b7c76c83ba7c From 07e11e849586c30540dfd784f56438dc7af11900 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 7 Feb 2021 21:50:56 +0000 Subject: [PATCH 4/7] docs: GlobalAlloc: completely replace example with one that works Since this is an example, this could really do with some review from someone familiar with unsafe stuff ! I made the example no longer `no_run` since it works for me. Fixes #81847 Signed-off-by: Ian Jackson Co-authored-by: Amanieu d'Antras --- library/core/src/alloc/global.rs | 67 ++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/library/core/src/alloc/global.rs b/library/core/src/alloc/global.rs index 6dcc110f1539c..a8e76c2982d22 100644 --- a/library/core/src/alloc/global.rs +++ b/library/core/src/alloc/global.rs @@ -20,24 +20,69 @@ use crate::ptr; /// /// # Example /// -/// ```no_run -/// use std::alloc::{GlobalAlloc, Layout, alloc}; +/// ``` +/// use std::alloc::{GlobalAlloc, Layout}; +/// use std::cell::UnsafeCell; /// use std::ptr::null_mut; +/// use std::sync::atomic::{ +/// AtomicUsize, +/// Ordering::{Acquire, SeqCst}, +/// }; /// -/// struct MyAllocator; -/// -/// unsafe impl GlobalAlloc for MyAllocator { -/// unsafe fn alloc(&self, _layout: Layout) -> *mut u8 { null_mut() } -/// unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {} +/// const ARENA_SIZE: usize = 128 * 1024; +/// #[repr(C, align(131072))] // 131072 == ARENA_SIZE. +/// struct SimpleAllocator { +/// arena: UnsafeCell<[u8; ARENA_SIZE]>, +/// remaining: AtomicUsize, // we allocate from the top, counting down /// } /// /// #[global_allocator] -/// static A: MyAllocator = MyAllocator; +/// static ALLOCATOR: SimpleAllocator = SimpleAllocator { +/// arena: UnsafeCell::new([0x55; ARENA_SIZE]), +/// remaining: AtomicUsize::new(ARENA_SIZE), +/// }; /// -/// fn main() { -/// unsafe { -/// assert!(alloc(Layout::new::()).is_null()) +/// unsafe impl Sync for SimpleAllocator {} +/// +/// unsafe impl GlobalAlloc for SimpleAllocator { +/// unsafe fn alloc(&self, layout: Layout) -> *mut u8 { +/// let size = layout.size(); +/// let align = layout.align(); +/// +/// // `Layout` contract forbids making a `Layout` with align=0, or align not power of 2. +/// // So we can safely use a mask to ensure alignment without worrying about UB. +/// let align_mask_to_round_down = !(align - 1); +/// +/// if align > ARENA_SIZE { +/// // align may be > size ! +/// return null_mut(); +/// } +/// +/// let mut allocated = 0; +/// if self +/// .remaining +/// .fetch_update(SeqCst, SeqCst, |mut remaining| { +/// if size > remaining { +/// return None; +/// } +/// remaining -= size; +/// remaining &= align_mask_to_round_down; +/// allocated = remaining; +/// Some(remaining) +/// }) +/// .is_err() +/// { +/// return null_mut(); +/// }; +/// (self.arena.get() as *mut u8).add(allocated) /// } +/// unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {} +/// } +/// +/// fn main() { +/// let _s = format!("allocating a string!"); +/// let currently = ALLOCATOR.remaining.load(Acquire); +/// println!("allocated so far: {}", ARENA_SIZE - currently); /// } /// ``` /// From f4981b4aedac1d9f750dc28bd7524b3ac4bb9b25 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 20 Jul 2021 16:08:41 -0700 Subject: [PATCH 5/7] Update cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 27277d966b3cf..4e143fd131e0c 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 27277d966b3cfa454d6dea7f724cb961c036251c +Subproject commit 4e143fd131e0c16cefd008456e974236ca54e62e From 03d7001564d140a3607a77fe02a5b1aaca0031d6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 21 Jul 2021 12:37:59 +0100 Subject: [PATCH 6/7] docs: GlobalAlloc: Make example only require 4096-aligned static Alignments > 4k are not supported, https://github.com/rust-lang/rust/issues/70022 https://github.com/rust-lang/rust/issues/70144 Signed-off-by: Ian Jackson --- library/core/src/alloc/global.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/core/src/alloc/global.rs b/library/core/src/alloc/global.rs index a8e76c2982d22..0a098c8e2d986 100644 --- a/library/core/src/alloc/global.rs +++ b/library/core/src/alloc/global.rs @@ -30,7 +30,8 @@ use crate::ptr; /// }; /// /// const ARENA_SIZE: usize = 128 * 1024; -/// #[repr(C, align(131072))] // 131072 == ARENA_SIZE. +/// const MAX_SUPPORTED_ALIGN: usize = 4096; +/// #[repr(C, align(4096))] // 4096 == MAX_SUPPORTED_ALIGN /// struct SimpleAllocator { /// arena: UnsafeCell<[u8; ARENA_SIZE]>, /// remaining: AtomicUsize, // we allocate from the top, counting down @@ -53,8 +54,7 @@ use crate::ptr; /// // So we can safely use a mask to ensure alignment without worrying about UB. /// let align_mask_to_round_down = !(align - 1); /// -/// if align > ARENA_SIZE { -/// // align may be > size ! +/// if align > MAX_SUPPORTED_ALIGN { /// return null_mut(); /// } /// From 800c5f9202ca5309bbe372bbb8f2d6f1c29e59a5 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Wed, 21 Jul 2021 15:40:52 +0200 Subject: [PATCH 7/7] Rename force-warns to force-warn --- compiler/rustc_lint/src/context.rs | 2 +- compiler/rustc_lint_defs/src/lib.rs | 2 +- compiler/rustc_middle/src/lint.rs | 2 +- compiler/rustc_session/src/config.rs | 6 +++--- .../src/compiler-flags/{force-warns.md => force-warn.md} | 6 +++--- src/librustdoc/lib.rs | 4 ++-- src/test/run-make/unstable-flag-required/Makefile | 2 +- .../{force-warns.stderr => force-warn.stderr} | 2 +- src/test/ui/lint/cli-lint-override.force_warn_deny.stderr | 2 +- src/test/ui/lint/cli-lint-override.rs | 2 +- src/test/ui/lint/cli-unknown-force-warn.rs | 4 ++-- src/test/ui/lint/cli-unknown-force-warn.stderr | 6 +++--- .../ui/lint/force-warn/force-allowed-by-default-lint.rs | 2 +- .../ui/lint/force-warn/force-allowed-by-default-lint.stderr | 2 +- .../lint/force-warn/force-allowed-deny-by-default-lint.rs | 2 +- .../force-warn/force-allowed-deny-by-default-lint.stderr | 2 +- src/test/ui/lint/force-warn/force-allowed-warning.rs | 2 +- src/test/ui/lint/force-warn/force-allowed-warning.stderr | 2 +- src/test/ui/lint/force-warn/force-deny-by-default-lint.rs | 2 +- .../ui/lint/force-warn/force-deny-by-default-lint.stderr | 2 +- .../ui/lint/force-warn/force-lint-allow-all-warnings.rs | 2 +- .../ui/lint/force-warn/force-lint-allow-all-warnings.stderr | 2 +- .../lint/force-warn/force-lint-group-allow-all-warnings.rs | 2 +- .../force-warn/force-lint-group-allow-all-warnings.stderr | 2 +- src/test/ui/lint/force-warn/force-lint-in-allowed-group.rs | 2 +- .../ui/lint/force-warn/force-lint-in-allowed-group.stderr | 2 +- ...rns-cap-lints-allow.rs => force-warn-cap-lints-allow.rs} | 2 +- ...lints-allow.stderr => force-warn-cap-lints-allow.stderr} | 4 ++-- src/test/ui/lint/force-warn/force-warn-cap-lints-warn.rs | 2 +- .../ui/lint/force-warn/force-warn-cap-lints-warn.stderr | 2 +- .../ui/lint/force-warn/force-warn-group-allow-warning.rs | 2 +- .../lint/force-warn/force-warn-group-allow-warning.stderr | 2 +- src/test/ui/lint/force-warn/force-warn-group.rs | 2 +- src/test/ui/lint/force-warn/force-warn-group.stderr | 2 +- 34 files changed, 43 insertions(+), 43 deletions(-) rename src/doc/unstable-book/src/compiler-flags/{force-warns.md => force-warn.md} (70%) rename src/test/run-make/unstable-flag-required/{force-warns.stderr => force-warn.stderr} (65%) rename src/test/ui/lint/force-warn/{force-warns-cap-lints-allow.rs => force-warn-cap-lints-allow.rs} (69%) rename src/test/ui/lint/force-warn/{force-warns-cap-lints-allow.stderr => force-warn-cap-lints-allow.stderr} (76%) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index c16d46efb8863..f448acd24fc55 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -370,7 +370,7 @@ impl LintStore { match level { Level::Allow => "-A", Level::Warn => "-W", - Level::ForceWarn => "--force-warns", + Level::ForceWarn => "--force-warn", Level::Deny => "-D", Level::Forbid => "-F", }, diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 4d85bf6b499d9..4190e769976e9 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -64,7 +64,7 @@ impl Level { match self { Level::Allow => "allow", Level::Warn => "warn", - Level::ForceWarn => "force-warns", + Level::ForceWarn => "force-warn", Level::Deny => "deny", Level::Forbid => "forbid", } diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 848e60fe1342e..6ad68877235dc 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -288,7 +288,7 @@ pub fn struct_lint_level<'s, 'd>( Level::Deny => "-D", Level::Forbid => "-F", Level::Allow => "-A", - Level::ForceWarn => "--force-warns", + Level::ForceWarn => "--force-warn", }; let hyphen_case_lint_name = name.replace("_", "-"); if lint_flag_val.as_str() == name { diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 9e5a38b8dc0b1..2d7f5f9b321d1 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1101,7 +1101,7 @@ pub fn rustc_short_optgroups() -> Vec { ), opt::multi_s( "", - "force-warns", + "force-warn", "Specifiy lints that should warn even if \ they are allowed somewhere else", "LINT", @@ -1175,11 +1175,11 @@ pub fn get_cmd_lint_options( let mut lint_opts_with_position = vec![]; let mut describe_lints = false; - if !debugging_opts.unstable_options && matches.opt_present("force-warns") { + if !debugging_opts.unstable_options && matches.opt_present("force-warn") { early_error( error_format, "the `-Z unstable-options` flag must also be passed to enable \ - the flag `--force-warns=lints`", + the flag `--force-warn=lints`", ); } diff --git a/src/doc/unstable-book/src/compiler-flags/force-warns.md b/src/doc/unstable-book/src/compiler-flags/force-warn.md similarity index 70% rename from src/doc/unstable-book/src/compiler-flags/force-warns.md rename to src/doc/unstable-book/src/compiler-flags/force-warn.md index 0a205be096c00..052de0f379e7f 100644 --- a/src/doc/unstable-book/src/compiler-flags/force-warns.md +++ b/src/doc/unstable-book/src/compiler-flags/force-warn.md @@ -1,10 +1,10 @@ -# `force-warns` +# `force-warn` The tracking issue for this feature is: [#85512](https://github.com/rust-lang/rust/issues/85512). ------------------------ -This feature allows you to cause any lint to produce a warning even if the lint has a different level by default or another level is set somewhere else. For instance, the `force-warns` option can be used to make a lint (e.g., `dead_code`) produce a warning even if that lint is allowed in code with `#![allow(dead_code)]`. +This feature allows you to cause any lint to produce a warning even if the lint has a different level by default or another level is set somewhere else. For instance, the `force-warn` option can be used to make a lint (e.g., `dead_code`) produce a warning even if that lint is allowed in code with `#![allow(dead_code)]`. ## Example @@ -18,4 +18,4 @@ fn dead_function() {} fn main() {} ``` -We can force a warning to be produced by providing `--force-warns dead_code` to rustc. +We can force a warning to be produced by providing `--force-warn dead_code` to rustc. diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 19deaa11388d8..fa755777584f3 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -511,10 +511,10 @@ fn opts() -> Vec { "LEVEL", ) }), - unstable("force-warns", |o| { + unstable("force-warn", |o| { o.optopt( "", - "force-warns", + "force-warn", "Lints that will warn even if allowed somewhere else", "LINTS", ) diff --git a/src/test/run-make/unstable-flag-required/Makefile b/src/test/run-make/unstable-flag-required/Makefile index aa20d6aa4bf27..a9aad54162f11 100644 --- a/src/test/run-make/unstable-flag-required/Makefile +++ b/src/test/run-make/unstable-flag-required/Makefile @@ -2,4 +2,4 @@ all: $(RUSTDOC) --output-format=json x.html 2>&1 | diff - output-format-json.stderr - $(RUSTC) --force-warns dead_code x.rs 2>&1 | diff - force-warns.stderr + $(RUSTC) --force-warn dead_code x.rs 2>&1 | diff - force-warn.stderr diff --git a/src/test/run-make/unstable-flag-required/force-warns.stderr b/src/test/run-make/unstable-flag-required/force-warn.stderr similarity index 65% rename from src/test/run-make/unstable-flag-required/force-warns.stderr rename to src/test/run-make/unstable-flag-required/force-warn.stderr index e0936196a116f..1b70dc83bdb15 100644 --- a/src/test/run-make/unstable-flag-required/force-warns.stderr +++ b/src/test/run-make/unstable-flag-required/force-warn.stderr @@ -1,2 +1,2 @@ -error: the `-Z unstable-options` flag must also be passed to enable the flag `--force-warns=lints` +error: the `-Z unstable-options` flag must also be passed to enable the flag `--force-warn=lints` diff --git a/src/test/ui/lint/cli-lint-override.force_warn_deny.stderr b/src/test/ui/lint/cli-lint-override.force_warn_deny.stderr index 50c58ea6e151a..74e7823e1ffc1 100644 --- a/src/test/ui/lint/cli-lint-override.force_warn_deny.stderr +++ b/src/test/ui/lint/cli-lint-override.force_warn_deny.stderr @@ -4,7 +4,7 @@ warning: extern declarations without an explicit ABI are deprecated LL | extern fn foo() {} | ^^^^^^^^^^^^^^^ ABI should be specified here | - = note: requested on the command line with `--force-warns missing-abi` + = note: requested on the command line with `--force-warn missing-abi` = help: the default ABI is C warning: 1 warning emitted diff --git a/src/test/ui/lint/cli-lint-override.rs b/src/test/ui/lint/cli-lint-override.rs index 6814c15e65686..a0a96d01be3f5 100644 --- a/src/test/ui/lint/cli-lint-override.rs +++ b/src/test/ui/lint/cli-lint-override.rs @@ -5,7 +5,7 @@ // //[warn_deny] compile-flags: --warn missing_abi --deny missing_abi //[forbid_warn] compile-flags: --warn missing_abi --forbid missing_abi -//[force_warn_deny] compile-flags: -Z unstable-options --force-warns missing_abi --allow missing_abi +//[force_warn_deny] compile-flags: -Z unstable-options --force-warn missing_abi --allow missing_abi //[force_warn_deny] check-pass diff --git a/src/test/ui/lint/cli-unknown-force-warn.rs b/src/test/ui/lint/cli-unknown-force-warn.rs index 201161296baf4..55544cc73781a 100644 --- a/src/test/ui/lint/cli-unknown-force-warn.rs +++ b/src/test/ui/lint/cli-unknown-force-warn.rs @@ -1,7 +1,7 @@ // Checks that rustc correctly errors when passed an invalid lint with -// `--force-warns`. This is a regression test for issue #86958. +// `--force-warn`. This is a regression test for issue #86958. // -// compile-flags: -Z unstable-options --force-warns foo-qux +// compile-flags: -Z unstable-options --force-warn foo-qux // error-pattern: unknown lint: `foo_qux` fn main() {} diff --git a/src/test/ui/lint/cli-unknown-force-warn.stderr b/src/test/ui/lint/cli-unknown-force-warn.stderr index 3a9aebb996c93..4367c3b4500d5 100644 --- a/src/test/ui/lint/cli-unknown-force-warn.stderr +++ b/src/test/ui/lint/cli-unknown-force-warn.stderr @@ -1,14 +1,14 @@ error[E0602]: unknown lint: `foo_qux` | - = note: requested on the command line with `--force-warns foo_qux` + = note: requested on the command line with `--force-warn foo_qux` error[E0602]: unknown lint: `foo_qux` | - = note: requested on the command line with `--force-warns foo_qux` + = note: requested on the command line with `--force-warn foo_qux` error[E0602]: unknown lint: `foo_qux` | - = note: requested on the command line with `--force-warns foo_qux` + = note: requested on the command line with `--force-warn foo_qux` error: aborting due to 3 previous errors diff --git a/src/test/ui/lint/force-warn/force-allowed-by-default-lint.rs b/src/test/ui/lint/force-warn/force-allowed-by-default-lint.rs index 0a3e20b4f7d66..4799429ea2c69 100644 --- a/src/test/ui/lint/force-warn/force-allowed-by-default-lint.rs +++ b/src/test/ui/lint/force-warn/force-allowed-by-default-lint.rs @@ -1,4 +1,4 @@ -// compile-flags: --force-warns elided_lifetimes_in_paths -Zunstable-options +// compile-flags: --force-warn elided_lifetimes_in_paths -Zunstable-options // check-pass struct Foo<'a> { diff --git a/src/test/ui/lint/force-warn/force-allowed-by-default-lint.stderr b/src/test/ui/lint/force-warn/force-allowed-by-default-lint.stderr index 37c61e614f3e3..05513de81d1c8 100644 --- a/src/test/ui/lint/force-warn/force-allowed-by-default-lint.stderr +++ b/src/test/ui/lint/force-warn/force-allowed-by-default-lint.stderr @@ -4,7 +4,7 @@ warning: hidden lifetime parameters in types are deprecated LL | fn foo(x: &Foo) {} | ^^^- help: indicate the anonymous lifetime: `<'_>` | - = note: requested on the command line with `--force-warns elided-lifetimes-in-paths` + = note: requested on the command line with `--force-warn elided-lifetimes-in-paths` warning: 1 warning emitted diff --git a/src/test/ui/lint/force-warn/force-allowed-deny-by-default-lint.rs b/src/test/ui/lint/force-warn/force-allowed-deny-by-default-lint.rs index 0abc49137269d..d066feba86984 100644 --- a/src/test/ui/lint/force-warn/force-allowed-deny-by-default-lint.rs +++ b/src/test/ui/lint/force-warn/force-allowed-deny-by-default-lint.rs @@ -1,4 +1,4 @@ -// compile-flags: --force-warns const_err -Zunstable-options +// compile-flags: --force-warn const_err -Zunstable-options // check-pass #![allow(const_err)] diff --git a/src/test/ui/lint/force-warn/force-allowed-deny-by-default-lint.stderr b/src/test/ui/lint/force-warn/force-allowed-deny-by-default-lint.stderr index 56b2f0236a5d3..dd4f88a3b533e 100644 --- a/src/test/ui/lint/force-warn/force-allowed-deny-by-default-lint.stderr +++ b/src/test/ui/lint/force-warn/force-allowed-deny-by-default-lint.stderr @@ -6,7 +6,7 @@ LL | const C: i32 = 1 / 0; | | | attempt to divide `1_i32` by zero | - = note: requested on the command line with `--force-warns const-err` + = note: requested on the command line with `--force-warn const-err` = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 diff --git a/src/test/ui/lint/force-warn/force-allowed-warning.rs b/src/test/ui/lint/force-warn/force-allowed-warning.rs index bac0e4f8f8e86..280de5064720a 100644 --- a/src/test/ui/lint/force-warn/force-allowed-warning.rs +++ b/src/test/ui/lint/force-warn/force-allowed-warning.rs @@ -1,4 +1,4 @@ -// compile-flags: --force-warns dead_code -Zunstable-options +// compile-flags: --force-warn dead_code -Zunstable-options // check-pass #![allow(dead_code)] diff --git a/src/test/ui/lint/force-warn/force-allowed-warning.stderr b/src/test/ui/lint/force-warn/force-allowed-warning.stderr index 7eb980a129708..fced147254e82 100644 --- a/src/test/ui/lint/force-warn/force-allowed-warning.stderr +++ b/src/test/ui/lint/force-warn/force-allowed-warning.stderr @@ -4,7 +4,7 @@ warning: function is never used: `dead_function` LL | fn dead_function() {} | ^^^^^^^^^^^^^ | - = note: requested on the command line with `--force-warns dead-code` + = note: requested on the command line with `--force-warn dead-code` warning: 1 warning emitted diff --git a/src/test/ui/lint/force-warn/force-deny-by-default-lint.rs b/src/test/ui/lint/force-warn/force-deny-by-default-lint.rs index e721760ab2da0..8331df02da763 100644 --- a/src/test/ui/lint/force-warn/force-deny-by-default-lint.rs +++ b/src/test/ui/lint/force-warn/force-deny-by-default-lint.rs @@ -1,4 +1,4 @@ -// compile-flags: --force-warns const_err -Zunstable-options +// compile-flags: --force-warn const_err -Zunstable-options // check-pass const C: i32 = 1 / 0; diff --git a/src/test/ui/lint/force-warn/force-deny-by-default-lint.stderr b/src/test/ui/lint/force-warn/force-deny-by-default-lint.stderr index 8b9bb5a74cfc1..68cd3a392f583 100644 --- a/src/test/ui/lint/force-warn/force-deny-by-default-lint.stderr +++ b/src/test/ui/lint/force-warn/force-deny-by-default-lint.stderr @@ -6,7 +6,7 @@ LL | const C: i32 = 1 / 0; | | | attempt to divide `1_i32` by zero | - = note: requested on the command line with `--force-warns const-err` + = note: requested on the command line with `--force-warn const-err` = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 diff --git a/src/test/ui/lint/force-warn/force-lint-allow-all-warnings.rs b/src/test/ui/lint/force-warn/force-lint-allow-all-warnings.rs index 0dc1ce28ac4f5..0e8a65a41173d 100644 --- a/src/test/ui/lint/force-warn/force-lint-allow-all-warnings.rs +++ b/src/test/ui/lint/force-warn/force-lint-allow-all-warnings.rs @@ -1,4 +1,4 @@ -// compile-flags: --force-warns dead_code -Zunstable-options +// compile-flags: --force-warn dead_code -Zunstable-options // check-pass #![allow(warnings)] diff --git a/src/test/ui/lint/force-warn/force-lint-allow-all-warnings.stderr b/src/test/ui/lint/force-warn/force-lint-allow-all-warnings.stderr index ebdb022f2a20b..3305f2c02834d 100644 --- a/src/test/ui/lint/force-warn/force-lint-allow-all-warnings.stderr +++ b/src/test/ui/lint/force-warn/force-lint-allow-all-warnings.stderr @@ -4,7 +4,7 @@ warning: function is never used: `dead_function` LL | fn dead_function() {} | ^^^^^^^^^^^^^ | - = note: requested on the command line with `--force-warns dead-code` + = note: requested on the command line with `--force-warn dead-code` warning: 1 warning emitted diff --git a/src/test/ui/lint/force-warn/force-lint-group-allow-all-warnings.rs b/src/test/ui/lint/force-warn/force-lint-group-allow-all-warnings.rs index 4f637c7fefa2b..aaca59a2a2aab 100644 --- a/src/test/ui/lint/force-warn/force-lint-group-allow-all-warnings.rs +++ b/src/test/ui/lint/force-warn/force-lint-group-allow-all-warnings.rs @@ -1,4 +1,4 @@ -// compile-flags: --force-warns nonstandard_style -Zunstable-options +// compile-flags: --force-warn nonstandard_style -Zunstable-options // check-pass #![allow(warnings)] diff --git a/src/test/ui/lint/force-warn/force-lint-group-allow-all-warnings.stderr b/src/test/ui/lint/force-warn/force-lint-group-allow-all-warnings.stderr index 7429e77fe83e1..065a8f6a556a0 100644 --- a/src/test/ui/lint/force-warn/force-lint-group-allow-all-warnings.stderr +++ b/src/test/ui/lint/force-warn/force-lint-group-allow-all-warnings.stderr @@ -4,7 +4,7 @@ warning: function `FUNCTION` should have a snake case name LL | pub fn FUNCTION() {} | ^^^^^^^^ help: convert the identifier to snake case: `function` | - = note: `--force-warns non-snake-case` implied by `--force-warns nonstandard-style` + = note: `--force-warn non-snake-case` implied by `--force-warn nonstandard-style` warning: 1 warning emitted diff --git a/src/test/ui/lint/force-warn/force-lint-in-allowed-group.rs b/src/test/ui/lint/force-warn/force-lint-in-allowed-group.rs index b4c2c505aa560..d8447bd238244 100644 --- a/src/test/ui/lint/force-warn/force-lint-in-allowed-group.rs +++ b/src/test/ui/lint/force-warn/force-lint-in-allowed-group.rs @@ -1,4 +1,4 @@ -// compile-flags: --force-warns bare_trait_objects -Zunstable-options +// compile-flags: --force-warn bare_trait_objects -Zunstable-options // check-pass #![allow(rust_2018_idioms)] diff --git a/src/test/ui/lint/force-warn/force-lint-in-allowed-group.stderr b/src/test/ui/lint/force-warn/force-lint-in-allowed-group.stderr index 4f7bba6bba1c9..185c0e8e3d0eb 100644 --- a/src/test/ui/lint/force-warn/force-lint-in-allowed-group.stderr +++ b/src/test/ui/lint/force-warn/force-lint-in-allowed-group.stderr @@ -4,7 +4,7 @@ warning: trait objects without an explicit `dyn` are deprecated LL | pub fn function(_x: Box) {} | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` | - = note: requested on the command line with `--force-warns bare-trait-objects` + = note: requested on the command line with `--force-warn bare-trait-objects` = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see issue #80165 diff --git a/src/test/ui/lint/force-warn/force-warns-cap-lints-allow.rs b/src/test/ui/lint/force-warn/force-warn-cap-lints-allow.rs similarity index 69% rename from src/test/ui/lint/force-warn/force-warns-cap-lints-allow.rs rename to src/test/ui/lint/force-warn/force-warn-cap-lints-allow.rs index e364897ec4ecb..e10d161e7c62b 100644 --- a/src/test/ui/lint/force-warn/force-warns-cap-lints-allow.rs +++ b/src/test/ui/lint/force-warn/force-warn-cap-lints-allow.rs @@ -1,4 +1,4 @@ -// compile-flags: --cap-lints allow --force-warns bare_trait_objects -Zunstable-options +// compile-flags: --cap-lints allow --force-warn bare_trait_objects -Zunstable-options // check-pass pub trait SomeTrait {} diff --git a/src/test/ui/lint/force-warn/force-warns-cap-lints-allow.stderr b/src/test/ui/lint/force-warn/force-warn-cap-lints-allow.stderr similarity index 76% rename from src/test/ui/lint/force-warn/force-warns-cap-lints-allow.stderr rename to src/test/ui/lint/force-warn/force-warn-cap-lints-allow.stderr index 21532024f1c4a..a89970587751d 100644 --- a/src/test/ui/lint/force-warn/force-warns-cap-lints-allow.stderr +++ b/src/test/ui/lint/force-warn/force-warn-cap-lints-allow.stderr @@ -1,10 +1,10 @@ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/force-warns-cap-lints-allow.rs:6:25 + --> $DIR/force-warn-cap-lints-allow.rs:6:25 | LL | pub fn function(_x: Box) {} | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` | - = note: requested on the command line with `--force-warns bare-trait-objects` + = note: requested on the command line with `--force-warn bare-trait-objects` = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see issue #80165 diff --git a/src/test/ui/lint/force-warn/force-warn-cap-lints-warn.rs b/src/test/ui/lint/force-warn/force-warn-cap-lints-warn.rs index bcfe6e5a5bd6e..4afc0868608d3 100644 --- a/src/test/ui/lint/force-warn/force-warn-cap-lints-warn.rs +++ b/src/test/ui/lint/force-warn/force-warn-cap-lints-warn.rs @@ -1,4 +1,4 @@ -// compile-flags: --cap-lints warn --force-warns rust-2021-compatibility -Zunstable-options +// compile-flags: --cap-lints warn --force-warn rust-2021-compatibility -Zunstable-options // check-pass #![allow(ellipsis_inclusive_range_patterns)] diff --git a/src/test/ui/lint/force-warn/force-warn-cap-lints-warn.stderr b/src/test/ui/lint/force-warn/force-warn-cap-lints-warn.stderr index 07e786ce7d266..1d5f88086c5c4 100644 --- a/src/test/ui/lint/force-warn/force-warn-cap-lints-warn.stderr +++ b/src/test/ui/lint/force-warn/force-warn-cap-lints-warn.stderr @@ -4,7 +4,7 @@ warning: `...` range patterns are deprecated LL | 0...100 => true, | ^^^ help: use `..=` for an inclusive range | - = note: `--force-warns ellipsis-inclusive-range-patterns` implied by `--force-warns rust-2021-compatibility` + = note: `--force-warn ellipsis-inclusive-range-patterns` implied by `--force-warn rust-2021-compatibility` = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see issue #80165 diff --git a/src/test/ui/lint/force-warn/force-warn-group-allow-warning.rs b/src/test/ui/lint/force-warn/force-warn-group-allow-warning.rs index 83a1c078f062f..193ba2b6f0da5 100644 --- a/src/test/ui/lint/force-warn/force-warn-group-allow-warning.rs +++ b/src/test/ui/lint/force-warn/force-warn-group-allow-warning.rs @@ -1,4 +1,4 @@ -// compile-flags: --force-warns rust-2018-idioms -Zunstable-options +// compile-flags: --force-warn rust-2018-idioms -Zunstable-options // check-pass #![allow(bare_trait_objects)] diff --git a/src/test/ui/lint/force-warn/force-warn-group-allow-warning.stderr b/src/test/ui/lint/force-warn/force-warn-group-allow-warning.stderr index 65de6c9e287f0..d242ef266b8d1 100644 --- a/src/test/ui/lint/force-warn/force-warn-group-allow-warning.stderr +++ b/src/test/ui/lint/force-warn/force-warn-group-allow-warning.stderr @@ -4,7 +4,7 @@ warning: trait objects without an explicit `dyn` are deprecated LL | pub fn function(_x: Box) {} | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` | - = note: `--force-warns bare-trait-objects` implied by `--force-warns rust-2018-idioms` + = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see issue #80165 diff --git a/src/test/ui/lint/force-warn/force-warn-group.rs b/src/test/ui/lint/force-warn/force-warn-group.rs index 5e5fda973d54e..0198610b78e10 100644 --- a/src/test/ui/lint/force-warn/force-warn-group.rs +++ b/src/test/ui/lint/force-warn/force-warn-group.rs @@ -1,4 +1,4 @@ -// compile-flags: --force-warns rust_2018_idioms -Zunstable-options +// compile-flags: --force-warn rust_2018_idioms -Zunstable-options // check-pass #![allow(rust_2018_idioms)] diff --git a/src/test/ui/lint/force-warn/force-warn-group.stderr b/src/test/ui/lint/force-warn/force-warn-group.stderr index fd3397c916a6d..180dff880a658 100644 --- a/src/test/ui/lint/force-warn/force-warn-group.stderr +++ b/src/test/ui/lint/force-warn/force-warn-group.stderr @@ -4,7 +4,7 @@ warning: trait objects without an explicit `dyn` are deprecated LL | pub fn function(_x: Box) {} | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` | - = note: `--force-warns bare-trait-objects` implied by `--force-warns rust-2018-idioms` + = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see issue #80165