From 18d0c379048a59966c22af0b602c924498d517bb Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Mon, 1 Dec 2025 18:55:14 +0900 Subject: [PATCH 1/9] moved tests --- tests/ui/{issues/issue-3290.rs => box/self-assignment.rs} | 0 .../break-continue-in-loop-while-condition-1.rs} | 0 .../break-continue-in-loop-while-condition-1.stderr} | 0 .../break-continue-in-loop-while-condition-2.rs} | 0 .../break-continue-in-loop-while-condition-2.stderr} | 0 .../issue-3680.rs => match/match-option-result-mismatch.rs} | 0 .../match-option-result-mismatch.stderr} | 0 tests/ui/{issues/issue-3091.rs => numeric/ref-int.rs} | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{issues/issue-3290.rs => box/self-assignment.rs} (100%) rename tests/ui/{issues/issue-37576.rs => for-loop-while/break-continue-in-loop-while-condition-1.rs} (100%) rename tests/ui/{issues/issue-37576.stderr => for-loop-while/break-continue-in-loop-while-condition-1.stderr} (100%) rename tests/ui/{issues/issue-50802.rs => for-loop-while/break-continue-in-loop-while-condition-2.rs} (100%) rename tests/ui/{issues/issue-50802.stderr => for-loop-while/break-continue-in-loop-while-condition-2.stderr} (100%) rename tests/ui/{issues/issue-3680.rs => match/match-option-result-mismatch.rs} (100%) rename tests/ui/{issues/issue-3680.stderr => match/match-option-result-mismatch.stderr} (100%) rename tests/ui/{issues/issue-3091.rs => numeric/ref-int.rs} (100%) diff --git a/tests/ui/issues/issue-3290.rs b/tests/ui/box/self-assignment.rs similarity index 100% rename from tests/ui/issues/issue-3290.rs rename to tests/ui/box/self-assignment.rs diff --git a/tests/ui/issues/issue-37576.rs b/tests/ui/for-loop-while/break-continue-in-loop-while-condition-1.rs similarity index 100% rename from tests/ui/issues/issue-37576.rs rename to tests/ui/for-loop-while/break-continue-in-loop-while-condition-1.rs diff --git a/tests/ui/issues/issue-37576.stderr b/tests/ui/for-loop-while/break-continue-in-loop-while-condition-1.stderr similarity index 100% rename from tests/ui/issues/issue-37576.stderr rename to tests/ui/for-loop-while/break-continue-in-loop-while-condition-1.stderr diff --git a/tests/ui/issues/issue-50802.rs b/tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.rs similarity index 100% rename from tests/ui/issues/issue-50802.rs rename to tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.rs diff --git a/tests/ui/issues/issue-50802.stderr b/tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.stderr similarity index 100% rename from tests/ui/issues/issue-50802.stderr rename to tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.stderr diff --git a/tests/ui/issues/issue-3680.rs b/tests/ui/match/match-option-result-mismatch.rs similarity index 100% rename from tests/ui/issues/issue-3680.rs rename to tests/ui/match/match-option-result-mismatch.rs diff --git a/tests/ui/issues/issue-3680.stderr b/tests/ui/match/match-option-result-mismatch.stderr similarity index 100% rename from tests/ui/issues/issue-3680.stderr rename to tests/ui/match/match-option-result-mismatch.stderr diff --git a/tests/ui/issues/issue-3091.rs b/tests/ui/numeric/ref-int.rs similarity index 100% rename from tests/ui/issues/issue-3091.rs rename to tests/ui/numeric/ref-int.rs From bd2d4eb79e459487c80a98ccd7475253652e7b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Pu=C4=8Dil?= Date: Sat, 6 Dec 2025 18:09:29 +0100 Subject: [PATCH 2/9] rustc book: fix `*-pc-windows-msvc` link label in sidebar As far as I know, `*-unknown-windows-msvc` is not a thing. At least if I search for "unknown-windows-msvc" in the entire [rust-lang](https://github.com/rust-lang) organization (https://github.com/search?q=org%3Arust-lang+%22unknown-windows-msvc%22++&type=code&state=open), it gives only this occurrence and 3 other occurrences in https://github.com/rust-lang/lld, which was archived in 2019. I believe `*-pc-windows-msvc` is the correct replacement because that is the name of the page the link points to: https://github.com/rust-lang/rust/blob/ba86c0460b0233319e01fd789a42a7276eade805/src/doc/rustc/src/platform-support/windows-msvc.md?plain=1#L1 --- src/doc/rustc/src/SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index 3da3571c27184..832b5a69d47c4 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -130,7 +130,7 @@ - [\*-unknown-openbsd](platform-support/openbsd.md) - [\*-unknown-redox](platform-support/redox.md) - [\*-unknown-uefi](platform-support/unknown-uefi.md) - - [\*-unknown-windows-msvc](platform-support/windows-msvc.md) + - [\*-pc-windows-msvc](platform-support/windows-msvc.md) - [\*-uwp-windows-msvc](platform-support/uwp-windows-msvc.md) - [\*-wrs-vxworks](platform-support/vxworks.md) - [wasm32-wasip1](platform-support/wasm32-wasip1.md) From 234df83fe309fc4c3a5c3c87393110b1a5c8274d Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Sun, 28 Sep 2025 18:12:17 -0400 Subject: [PATCH 3/9] Add warn-by-default lint for visibility on `const _` declarations Add a warn-by-default `unused_visibility` lint for visibility qualifiers on `const _` declarations - e.g. `pub const _: () = ();`. These have no effect. --- .../rustc_ast_passes/src/ast_validation.rs | 15 +++++++++++-- compiler/rustc_lint/messages.ftl | 3 +++ compiler/rustc_lint/src/early/diagnostics.rs | 3 +++ compiler/rustc_lint/src/lib.rs | 1 + compiler/rustc_lint/src/lints.rs | 7 +++++++ compiler/rustc_lint_defs/src/builtin.rs | 21 +++++++++++++++++++ compiler/rustc_lint_defs/src/lib.rs | 1 + .../absolute_paths.no_short.stderr | 6 +++--- .../ui-toml/absolute_paths/absolute_paths.rs | 2 +- tests/ui/consts/promoted_const_call3.rs | 4 ++-- tests/ui/consts/ptr_is_null.rs | 10 ++++----- ...-dont-override-forbid-in-same-scope.stderr | 18 ++++++++++++++++ tests/ui/lint/outer-forbid.stderr | 18 ++++++++++++++++ tests/ui/lint/unused-visibilities.fixed | 12 +++++++++++ tests/ui/lint/unused-visibilities.rs | 12 +++++++++++ tests/ui/lint/unused-visibilities.stderr | 20 ++++++++++++++++++ tests/ui/traits/const-traits/call.rs | 2 +- 17 files changed, 141 insertions(+), 14 deletions(-) create mode 100644 tests/ui/lint/unused-visibilities.fixed create mode 100644 tests/ui/lint/unused-visibilities.rs create mode 100644 tests/ui/lint/unused-visibilities.stderr diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 2790916891a15..06a35e6919291 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -33,7 +33,7 @@ use rustc_session::Session; use rustc_session::lint::BuiltinLintDiag; use rustc_session::lint::builtin::{ DEPRECATED_WHERE_CLAUSE_LOCATION, MISSING_ABI, MISSING_UNSAFE_ON_EXTERN, - PATTERNS_IN_FNS_WITHOUT_BODY, + PATTERNS_IN_FNS_WITHOUT_BODY, UNUSED_VISIBILITIES, }; use rustc_session::parse::feature_err; use rustc_span::{Ident, Span, kw, sym}; @@ -1339,7 +1339,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } }); } - ItemKind::Const(box ConstItem { defaultness, rhs, .. }) => { + ItemKind::Const(box ConstItem { defaultness, ident, rhs, .. }) => { self.check_defaultness(item.span, *defaultness); if rhs.is_none() { self.dcx().emit_err(errors::ConstWithoutBody { @@ -1347,6 +1347,17 @@ impl<'a> Visitor<'a> for AstValidator<'a> { replace_span: self.ending_semi_or_hi(item.span), }); } + if ident.name == kw::Underscore + && !matches!(item.vis.kind, VisibilityKind::Inherited) + { + self.lint_buffer.buffer_lint( + UNUSED_VISIBILITIES, + item.id, + item.vis.span, + BuiltinLintDiag::UnusedVisibility(item.vis.span), + ) + } + visit::walk_item(self, item); } ItemKind::Static(box StaticItem { expr, safety, .. }) => { diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 1bcdda96e13a2..fac26b52176de 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -978,6 +978,9 @@ lint_unused_op = unused {$op} that must be used lint_unused_result = unused result of type `{$ty}` +lint_unused_visibilities = visibility qualifiers have no effect on `const _` declarations + .suggestion = remove the qualifier + lint_use_let_underscore_ignore_suggestion = use `let _ = ...` to ignore the expression or result lint_useless_ptr_null_checks_fn_ptr = function pointers are not nullable, so checking them for null will always return false diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index b654bc848ecfc..ff364e5f814ab 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -302,6 +302,9 @@ pub fn decorate_builtin_lint( BuiltinLintDiag::UnusedCrateDependency { extern_crate, local_crate } => { lints::UnusedCrateDependency { extern_crate, local_crate }.decorate_lint(diag) } + BuiltinLintDiag::UnusedVisibility(span) => { + lints::UnusedVisibility { span }.decorate_lint(diag) + } BuiltinLintDiag::AttributeLint(kind) => decorate_attribute_lint(sess, tcx, &kind, diag), } } diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index a5f9eabf89c4c..4e7a3e4051767 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -291,6 +291,7 @@ fn register_builtins(store: &mut LintStore) { "unused", UNUSED_IMPORTS, UNUSED_VARIABLES, + UNUSED_VISIBILITIES, UNUSED_ASSIGNMENTS, DEAD_CODE, UNUSED_MUT, diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 4f28d503af3c3..a10a5e7d5f26c 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3191,3 +3191,10 @@ pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion { #[suggestion_part(code = ")")] pub right: Span, } + +#[derive(LintDiagnostic)] +#[diag(lint_unused_visibilities)] +pub(crate) struct UnusedVisibility { + #[suggestion(style = "short", code = "", applicability = "machine-applicable")] + pub span: Span, +} diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 2f0333160f52b..e8bd8f8f70993 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -143,6 +143,7 @@ declare_lint_pass! { UNUSED_QUALIFICATIONS, UNUSED_UNSAFE, UNUSED_VARIABLES, + UNUSED_VISIBILITIES, USELESS_DEPRECATED, VARARGS_WITHOUT_PATTERN, WARNINGS, @@ -693,6 +694,26 @@ declare_lint! { "detect variables which are not used in any way" } +declare_lint! { + /// The `unused_visibilities` lint detects visibility qualifiers (like `pub`) + /// on a `const _` item. + /// + /// ### Example + /// + /// ```rust + /// pub const _: () = {}; + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// These qualifiers have no effect. + pub UNUSED_VISIBILITIES, + Warn, + "detect visibility qualifiers on `const _` items" +} + declare_lint! { /// The `unused_assignments` lint detects assignments that will never be read. /// diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 3c6e7d04a29dd..19ba27a27eafe 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -696,6 +696,7 @@ pub enum BuiltinLintDiag { extern_crate: Symbol, local_crate: Symbol, }, + UnusedVisibility(Span), AttributeLint(AttributeLintKind), } diff --git a/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.no_short.stderr b/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.no_short.stderr index 70d71f6c4ea16..c94b7777f3e9f 100644 --- a/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.no_short.stderr +++ b/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.no_short.stderr @@ -71,10 +71,10 @@ LL | impl core::fmt::Display for X | ^^^^^^^^^^^^^^^^^^ error: consider bringing this path into scope with the `use` keyword - --> tests/ui-toml/absolute_paths/absolute_paths.rs:113:14 + --> tests/ui-toml/absolute_paths/absolute_paths.rs:113:10 | -LL | pub const _: crate::S = { - | ^^^^^^^^ +LL | const _: crate::S = { + | ^^^^^^^^ error: consider bringing this path into scope with the `use` keyword --> tests/ui-toml/absolute_paths/absolute_paths.rs:114:9 diff --git a/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.rs b/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.rs index c024f2f513ced..a3982b8f6540d 100644 --- a/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.rs +++ b/src/tools/clippy/tests/ui-toml/absolute_paths/absolute_paths.rs @@ -110,7 +110,7 @@ mod m1 { } //~[no_short]v absolute_paths -pub const _: crate::S = { +const _: crate::S = { let crate::S = m1::S; //~[no_short] absolute_paths crate::m1::S diff --git a/tests/ui/consts/promoted_const_call3.rs b/tests/ui/consts/promoted_const_call3.rs index dc05a3b584424..82e9eac31d5cc 100644 --- a/tests/ui/consts/promoted_const_call3.rs +++ b/tests/ui/consts/promoted_const_call3.rs @@ -4,12 +4,12 @@ pub const C: () = { //~^ ERROR: destructor of `String` cannot be evaluated at compile-time }; -pub const _: () = { +const _: () = { let _: &'static _ = &id(&String::new()); //~^ ERROR: destructor of `String` cannot be evaluated at compile-time }; -pub const _: () = { +const _: () = { let _: &'static _ = &std::mem::ManuallyDrop::new(String::new()); //~^ ERROR: temporary value dropped while borrowed }; diff --git a/tests/ui/consts/ptr_is_null.rs b/tests/ui/consts/ptr_is_null.rs index 8b41f5718e8db..9f8a1697fd70e 100644 --- a/tests/ui/consts/ptr_is_null.rs +++ b/tests/ui/consts/ptr_is_null.rs @@ -5,12 +5,12 @@ const FOO: &usize = &42; -pub const _: () = assert!(!(FOO as *const usize).is_null()); +const _: () = assert!(!(FOO as *const usize).is_null()); -pub const _: () = assert!(!(42 as *const usize).is_null()); +const _: () = assert!(!(42 as *const usize).is_null()); -pub const _: () = assert!((0 as *const usize).is_null()); +const _: () = assert!((0 as *const usize).is_null()); -pub const _: () = assert!(std::ptr::null::().is_null()); +const _: () = assert!(std::ptr::null::().is_null()); -pub const _: () = assert!(!("foo" as *const str).is_null()); +const _: () = assert!(!("foo" as *const str).is_null()); diff --git a/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr b/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr index 77c8d1eab5845..506791fd17269 100644 --- a/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr +++ b/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr @@ -413,3 +413,21 @@ note: the lint level is defined here LL | #![forbid(forbidden_lint_groups)] | ^^^^^^^^^^^^^^^^^^^^^ +Future breakage diagnostic: +error: warn(unused) incompatible with previous forbid + --> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:22:13 + | +LL | #![forbid(unused)] + | ------ `forbid` level set here +LL | #![deny(unused)] +LL | #![warn(unused)] + | ^^^^^^ overruled by previous forbid + | + = 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 #81670 +note: the lint level is defined here + --> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:17:11 + | +LL | #![forbid(forbidden_lint_groups)] + | ^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/ui/lint/outer-forbid.stderr b/tests/ui/lint/outer-forbid.stderr index 64a1077462abe..7810ca223f8ad 100644 --- a/tests/ui/lint/outer-forbid.stderr +++ b/tests/ui/lint/outer-forbid.stderr @@ -453,3 +453,21 @@ note: the lint level is defined here LL | #![forbid(forbidden_lint_groups)] | ^^^^^^^^^^^^^^^^^^^^^ +Future breakage diagnostic: +error: allow(unused) incompatible with previous forbid + --> $DIR/outer-forbid.rs:25:9 + | +LL | #![forbid(unused, non_snake_case)] + | ------ `forbid` level set here +... +LL | #[allow(unused)] + | ^^^^^^ overruled by previous forbid + | + = 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 #81670 +note: the lint level is defined here + --> $DIR/outer-forbid.rs:18:11 + | +LL | #![forbid(forbidden_lint_groups)] + | ^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/ui/lint/unused-visibilities.fixed b/tests/ui/lint/unused-visibilities.fixed new file mode 100644 index 0000000000000..3dd7cde0c9e2a --- /dev/null +++ b/tests/ui/lint/unused-visibilities.fixed @@ -0,0 +1,12 @@ +//@ check-pass +//@ run-rustfix + +#![warn(unused_visibilities)] + + const _: () = {}; +//~^WARN visibility qualifiers have no effect on `const _` declarations + + const _: () = {}; +//~^WARN visibility qualifiers have no effect on `const _` declarations + +fn main() {} diff --git a/tests/ui/lint/unused-visibilities.rs b/tests/ui/lint/unused-visibilities.rs new file mode 100644 index 0000000000000..51bcd34599ad2 --- /dev/null +++ b/tests/ui/lint/unused-visibilities.rs @@ -0,0 +1,12 @@ +//@ check-pass +//@ run-rustfix + +#![warn(unused_visibilities)] + +pub const _: () = {}; +//~^WARN visibility qualifiers have no effect on `const _` declarations + +pub(self) const _: () = {}; +//~^WARN visibility qualifiers have no effect on `const _` declarations + +fn main() {} diff --git a/tests/ui/lint/unused-visibilities.stderr b/tests/ui/lint/unused-visibilities.stderr new file mode 100644 index 0000000000000..032e2821d9873 --- /dev/null +++ b/tests/ui/lint/unused-visibilities.stderr @@ -0,0 +1,20 @@ +warning: visibility qualifiers have no effect on `const _` declarations + --> $DIR/unused-visibilities.rs:6:1 + | +LL | pub const _: () = {}; + | ^^^ help: remove the qualifier + | +note: the lint level is defined here + --> $DIR/unused-visibilities.rs:4:9 + | +LL | #![warn(unused_visibilities)] + | ^^^^^^^^^^^^^^^^^^^ + +warning: visibility qualifiers have no effect on `const _` declarations + --> $DIR/unused-visibilities.rs:9:1 + | +LL | pub(self) const _: () = {}; + | ^^^^^^^^^ help: remove the qualifier + +warning: 2 warnings emitted + diff --git a/tests/ui/traits/const-traits/call.rs b/tests/ui/traits/const-traits/call.rs index b1080fe78bb5f..360c08e1b7fe9 100644 --- a/tests/ui/traits/const-traits/call.rs +++ b/tests/ui/traits/const-traits/call.rs @@ -3,7 +3,7 @@ #![feature(const_closures, const_trait_impl)] #![allow(incomplete_features)] -pub const _: () = { +const _: () = { assert!((const || true)()); //~^ ERROR }: [const] Fn()` is not satisfied }; From 4cc2f952e41ac4c3bbd0e5e8737238f06529fb7b Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Tue, 30 Sep 2025 10:05:20 -0400 Subject: [PATCH 4/9] Elaborate lint explanation --- compiler/rustc_lint_defs/src/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index e8bd8f8f70993..740530daf2bdb 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -708,7 +708,7 @@ declare_lint! { /// /// ### Explanation /// - /// These qualifiers have no effect. + /// These qualifiers have no effect, as `const _` items are unnameable. pub UNUSED_VISIBILITIES, Warn, "detect visibility qualifiers on `const _` items" From 6b5da2f17798a2232d793fc06daeb764a04b9386 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Wed, 3 Dec 2025 11:37:54 -0500 Subject: [PATCH 5/9] Don't warn when underscore is passed to macro --- compiler/rustc_ast_passes/src/ast_validation.rs | 1 + tests/ui/lint/unused-visibilities.fixed | 17 +++++++++++++++++ tests/ui/lint/unused-visibilities.rs | 17 +++++++++++++++++ tests/ui/lint/unused-visibilities.stderr | 13 ++++++++++++- 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 06a35e6919291..ddb19f5e79158 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -1349,6 +1349,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } if ident.name == kw::Underscore && !matches!(item.vis.kind, VisibilityKind::Inherited) + && ident.span.eq_ctxt(item.vis.span) { self.lint_buffer.buffer_lint( UNUSED_VISIBILITIES, diff --git a/tests/ui/lint/unused-visibilities.fixed b/tests/ui/lint/unused-visibilities.fixed index 3dd7cde0c9e2a..97c1a5c732497 100644 --- a/tests/ui/lint/unused-visibilities.fixed +++ b/tests/ui/lint/unused-visibilities.fixed @@ -9,4 +9,21 @@ const _: () = {}; //~^WARN visibility qualifiers have no effect on `const _` declarations +macro_rules! foo { + () => { + const _: () = {}; + //~^WARN visibility qualifiers have no effect on `const _` declarations + }; +} + +foo!(); + +macro_rules! bar { + ($tt:tt) => { + pub const $tt: () = {}; + }; +} + +bar!(_); + fn main() {} diff --git a/tests/ui/lint/unused-visibilities.rs b/tests/ui/lint/unused-visibilities.rs index 51bcd34599ad2..4bcbd1201e4ac 100644 --- a/tests/ui/lint/unused-visibilities.rs +++ b/tests/ui/lint/unused-visibilities.rs @@ -9,4 +9,21 @@ pub const _: () = {}; pub(self) const _: () = {}; //~^WARN visibility qualifiers have no effect on `const _` declarations +macro_rules! foo { + () => { + pub const _: () = {}; + //~^WARN visibility qualifiers have no effect on `const _` declarations + }; +} + +foo!(); + +macro_rules! bar { + ($tt:tt) => { + pub const $tt: () = {}; + }; +} + +bar!(_); + fn main() {} diff --git a/tests/ui/lint/unused-visibilities.stderr b/tests/ui/lint/unused-visibilities.stderr index 032e2821d9873..f70d654b30b1e 100644 --- a/tests/ui/lint/unused-visibilities.stderr +++ b/tests/ui/lint/unused-visibilities.stderr @@ -16,5 +16,16 @@ warning: visibility qualifiers have no effect on `const _` declarations LL | pub(self) const _: () = {}; | ^^^^^^^^^ help: remove the qualifier -warning: 2 warnings emitted +warning: visibility qualifiers have no effect on `const _` declarations + --> $DIR/unused-visibilities.rs:14:9 + | +LL | pub const _: () = {}; + | ^^^ help: remove the qualifier +... +LL | foo!(); + | ------ in this macro invocation + | + = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: 3 warnings emitted From 9e7200967eb051f1635e13196003c5d4d8c8ace0 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Fri, 5 Dec 2025 11:22:30 -0500 Subject: [PATCH 6/9] Add note to lint message --- compiler/rustc_lint/messages.ftl | 1 + compiler/rustc_lint/src/lints.rs | 1 + tests/ui/lint/unused-visibilities.stderr | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index fac26b52176de..5754bc9621a14 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -979,6 +979,7 @@ lint_unused_op = unused {$op} that must be used lint_unused_result = unused result of type `{$ty}` lint_unused_visibilities = visibility qualifiers have no effect on `const _` declarations + .note = there is no declared name for the qualifier to affect .suggestion = remove the qualifier lint_use_let_underscore_ignore_suggestion = use `let _ = ...` to ignore the expression or result diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index a10a5e7d5f26c..1bec316ce45a7 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3194,6 +3194,7 @@ pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion { #[derive(LintDiagnostic)] #[diag(lint_unused_visibilities)] +#[note] pub(crate) struct UnusedVisibility { #[suggestion(style = "short", code = "", applicability = "machine-applicable")] pub span: Span, diff --git a/tests/ui/lint/unused-visibilities.stderr b/tests/ui/lint/unused-visibilities.stderr index f70d654b30b1e..3aefb869dafd5 100644 --- a/tests/ui/lint/unused-visibilities.stderr +++ b/tests/ui/lint/unused-visibilities.stderr @@ -4,6 +4,7 @@ warning: visibility qualifiers have no effect on `const _` declarations LL | pub const _: () = {}; | ^^^ help: remove the qualifier | + = note: there is no declared name for the qualifier to affect note: the lint level is defined here --> $DIR/unused-visibilities.rs:4:9 | @@ -15,6 +16,8 @@ warning: visibility qualifiers have no effect on `const _` declarations | LL | pub(self) const _: () = {}; | ^^^^^^^^^ help: remove the qualifier + | + = note: there is no declared name for the qualifier to affect warning: visibility qualifiers have no effect on `const _` declarations --> $DIR/unused-visibilities.rs:14:9 @@ -25,6 +28,7 @@ LL | pub const _: () = {}; LL | foo!(); | ------ in this macro invocation | + = note: there is no declared name for the qualifier to affect = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) warning: 3 warnings emitted From 43fa060c38e06df99985007ecfff8b86c9fad7c5 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Sat, 6 Dec 2025 13:41:32 -0500 Subject: [PATCH 7/9] Expand lint note --- compiler/rustc_lint/messages.ftl | 2 +- tests/ui/lint/unused-visibilities.stderr | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 5754bc9621a14..bc1c246b8f03a 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -979,7 +979,7 @@ lint_unused_op = unused {$op} that must be used lint_unused_result = unused result of type `{$ty}` lint_unused_visibilities = visibility qualifiers have no effect on `const _` declarations - .note = there is no declared name for the qualifier to affect + .note = `const _` does not declare a name, so there is nothing for the qualifier to apply to .suggestion = remove the qualifier lint_use_let_underscore_ignore_suggestion = use `let _ = ...` to ignore the expression or result diff --git a/tests/ui/lint/unused-visibilities.stderr b/tests/ui/lint/unused-visibilities.stderr index 3aefb869dafd5..e5ff2a7fcae8d 100644 --- a/tests/ui/lint/unused-visibilities.stderr +++ b/tests/ui/lint/unused-visibilities.stderr @@ -4,7 +4,7 @@ warning: visibility qualifiers have no effect on `const _` declarations LL | pub const _: () = {}; | ^^^ help: remove the qualifier | - = note: there is no declared name for the qualifier to affect + = note: `const _` does not declare a name, so there is nothing for the qualifier to apply to note: the lint level is defined here --> $DIR/unused-visibilities.rs:4:9 | @@ -17,7 +17,7 @@ warning: visibility qualifiers have no effect on `const _` declarations LL | pub(self) const _: () = {}; | ^^^^^^^^^ help: remove the qualifier | - = note: there is no declared name for the qualifier to affect + = note: `const _` does not declare a name, so there is nothing for the qualifier to apply to warning: visibility qualifiers have no effect on `const _` declarations --> $DIR/unused-visibilities.rs:14:9 @@ -28,7 +28,7 @@ LL | pub const _: () = {}; LL | foo!(); | ------ in this macro invocation | - = note: there is no declared name for the qualifier to affect + = note: `const _` does not declare a name, so there is nothing for the qualifier to apply to = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) warning: 3 warnings emitted From 7fdf06693a92d9d781cb794ef5b20e564f8b3eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sat, 6 Dec 2025 22:02:23 +0100 Subject: [PATCH 8/9] Fix off-by-one staging output when testing the library --- src/bootstrap/src/core/build_steps/test.rs | 9 +++++++-- src/bootstrap/src/core/builder/cargo.rs | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 7e46b85ff9af3..eb3ea1ab51208 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2818,10 +2818,15 @@ fn run_cargo_test<'a>( builder: &Builder<'_>, ) -> bool { let compiler = cargo.compiler(); + let stage = match cargo.mode() { + Mode::Std => compiler.stage, + _ => compiler.stage + 1, + }; + let mut cargo = prepare_cargo_test(cargo, libtest_args, crates, target, builder); let _time = helpers::timeit(builder); - let _group = - description.into().and_then(|what| builder.msg_test(what, target, compiler.stage + 1)); + + let _group = description.into().and_then(|what| builder.msg_test(what, target, stage)); #[cfg(feature = "build-metrics")] builder.metrics.begin_test_suite( diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 093a754f1a4b7..2ca52c72e5ec7 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -98,6 +98,7 @@ pub struct Cargo { command: BootstrapCommand, args: Vec, compiler: Compiler, + mode: Mode, target: TargetSelection, rustflags: Rustflags, rustdocflags: Rustflags, @@ -141,6 +142,10 @@ impl Cargo { self.compiler } + pub fn mode(&self) -> Mode { + self.mode + } + pub fn into_cmd(self) -> BootstrapCommand { self.into() } @@ -1404,6 +1409,7 @@ impl Builder<'_> { command: cargo, args: vec![], compiler, + mode, target, rustflags, rustdocflags, From 79893a050eb5b4e3104dcef8781924b83b483a1e Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Mon, 1 Dec 2025 19:02:25 +0900 Subject: [PATCH 9/9] cleaned up some tests merged tests/ui/issues/issue-2951.rs with tests/ui/type/type-parameter-names.rs Merged tests/ui/for-loop-while/break-continue-in-loop-while-contiditoin-1.rs with tests/ui/for-loop-while/break-continue-in-loop-while-contiditoin-2.rs Removed tests/ui/issues/issue-2383.rs duplicated of library\alloc\src\collections\vec_deque\tests.rs Removed tests/ui/issues/issue-20714.rs duplicated of tests/ui/empty/empty-struct-unit-expr.rs Added comment to tests/ui/match/match-option-result-mismatch.rs, tests/ui/numeric/ref-int.rs, tests/ui/box/self-assignment.rs --- tests/ui/box/self-assignment.rs | 8 +++-- tests/ui/empty/empty-struct-unit-expr.rs | 3 +- tests/ui/empty/empty-struct-unit-expr.stderr | 10 +++--- ...reak-continue-in-loop-while-condition-2.rs | 8 ----- ...-continue-in-loop-while-condition-2.stderr | 9 ------ ...break-continue-in-loop-while-condition.rs} | 32 +++++++++++++++---- ...k-continue-in-loop-while-condition.stderr} | 32 +++++++++++-------- tests/ui/issues/issue-20714.rs | 5 --- tests/ui/issues/issue-20714.stderr | 20 ------------ tests/ui/issues/issue-2383.rs | 8 ----- tests/ui/issues/issue-2951.rs | 13 -------- tests/ui/issues/issue-2951.stderr | 20 ------------ .../ui/match/match-option-result-mismatch.rs | 7 ++-- .../match/match-option-result-mismatch.stderr | 7 ++-- tests/ui/numeric/ref-int.rs | 1 + tests/ui/type/type-parameter-names.rs | 18 ++++++++--- tests/ui/type/type-parameter-names.stderr | 21 ++++++++++-- 17 files changed, 100 insertions(+), 122 deletions(-) delete mode 100644 tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.rs delete mode 100644 tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.stderr rename tests/ui/for-loop-while/{break-continue-in-loop-while-condition-1.rs => break-continue-in-loop-while-condition.rs} (58%) rename tests/ui/for-loop-while/{break-continue-in-loop-while-condition-1.stderr => break-continue-in-loop-while-condition.stderr} (59%) delete mode 100644 tests/ui/issues/issue-20714.rs delete mode 100644 tests/ui/issues/issue-20714.stderr delete mode 100644 tests/ui/issues/issue-2383.rs delete mode 100644 tests/ui/issues/issue-2951.rs delete mode 100644 tests/ui/issues/issue-2951.stderr diff --git a/tests/ui/box/self-assignment.rs b/tests/ui/box/self-assignment.rs index 50c432288ce18..3689ddac5d109 100644 --- a/tests/ui/box/self-assignment.rs +++ b/tests/ui/box/self-assignment.rs @@ -1,8 +1,10 @@ //@ run-pass +//! regression test for + #![allow(dead_code)] pub fn main() { - let mut x: Box<_> = Box::new(3); - x = x; - assert_eq!(*x, 3); + let mut x: Box<_> = Box::new(3); + x = x; + assert_eq!(*x, 3); } diff --git a/tests/ui/empty/empty-struct-unit-expr.rs b/tests/ui/empty/empty-struct-unit-expr.rs index c71ea3bdce72c..5a0d57edb13da 100644 --- a/tests/ui/empty/empty-struct-unit-expr.rs +++ b/tests/ui/empty/empty-struct-unit-expr.rs @@ -1,4 +1,5 @@ // Can't use unit struct as constructor function +// related issue //@ aux-build:empty-struct.rs @@ -8,7 +9,7 @@ use empty_struct::*; struct Empty2; enum E { - Empty4 + Empty4, } fn main() { diff --git a/tests/ui/empty/empty-struct-unit-expr.stderr b/tests/ui/empty/empty-struct-unit-expr.stderr index e97209527fe34..511c144f926cf 100644 --- a/tests/ui/empty/empty-struct-unit-expr.stderr +++ b/tests/ui/empty/empty-struct-unit-expr.stderr @@ -1,5 +1,5 @@ error[E0618]: expected function, found struct `Empty2` - --> $DIR/empty-struct-unit-expr.rs:15:14 + --> $DIR/empty-struct-unit-expr.rs:16:14 | LL | struct Empty2; | ------------- struct `Empty2` defined here @@ -16,9 +16,9 @@ LL + let e2 = Empty2; | error[E0618]: expected function, found enum variant `E::Empty4` - --> $DIR/empty-struct-unit-expr.rs:16:14 + --> $DIR/empty-struct-unit-expr.rs:17:14 | -LL | Empty4 +LL | Empty4, | ------ enum variant `E::Empty4` defined here ... LL | let e4 = E::Empty4(); @@ -33,7 +33,7 @@ LL + let e4 = E::Empty4; | error[E0618]: expected function, found struct `XEmpty2` - --> $DIR/empty-struct-unit-expr.rs:18:15 + --> $DIR/empty-struct-unit-expr.rs:19:15 | LL | let xe2 = XEmpty2(); | ^^^^^^^-- @@ -47,7 +47,7 @@ LL + let xe2 = XEmpty2; | error[E0618]: expected function, found enum variant `XE::XEmpty4` - --> $DIR/empty-struct-unit-expr.rs:19:15 + --> $DIR/empty-struct-unit-expr.rs:20:15 | LL | let xe4 = XE::XEmpty4(); | ^^^^^^^^^^^-- diff --git a/tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.rs b/tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.rs deleted file mode 100644 index dece55968b6a6..0000000000000 --- a/tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.rs +++ /dev/null @@ -1,8 +0,0 @@ -#[allow(unreachable_code)] - -fn main() { - loop { - break while continue { //~ ERROR E0590 - } - } -} diff --git a/tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.stderr b/tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.stderr deleted file mode 100644 index e1b5ae3251206..0000000000000 --- a/tests/ui/for-loop-while/break-continue-in-loop-while-condition-2.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0590]: `break` or `continue` with no label in the condition of a `while` loop - --> $DIR/issue-50802.rs:5:21 - | -LL | break while continue { - | ^^^^^^^^ unlabeled `continue` in the condition of a `while` loop - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0590`. diff --git a/tests/ui/for-loop-while/break-continue-in-loop-while-condition-1.rs b/tests/ui/for-loop-while/break-continue-in-loop-while-condition.rs similarity index 58% rename from tests/ui/for-loop-while/break-continue-in-loop-while-condition-1.rs rename to tests/ui/for-loop-while/break-continue-in-loop-while-condition.rs index e7f933ab22ea7..d1fcb6dbb5371 100644 --- a/tests/ui/for-loop-while/break-continue-in-loop-while-condition-1.rs +++ b/tests/ui/for-loop-while/break-continue-in-loop-while-condition.rs @@ -1,3 +1,6 @@ +//! regression test for #37576, #50802 +//! Tests that using unlabeled `break` or `continue` within a loop or while's condition. + fn main() { 'test_1: while break 'test_1 {} while break {} @@ -7,9 +10,13 @@ fn main() { while let true = break {} //~^ ERROR `break` or `continue` with no label - loop { 'test_3: while break 'test_3 {} } - loop { while break {} } - //~^ ERROR `break` or `continue` with no label + loop { + 'test_3: while break 'test_3 {} + } + loop { + while break {} + //~^ ERROR `break` or `continue` with no label + } loop { 'test_4: while break 'test_4 {} @@ -29,9 +36,13 @@ fn main() { while let true = continue {} //~^ ERROR `break` or `continue` with no label - loop { 'test_7: while continue 'test_7 {} } - loop { while continue {} } - //~^ ERROR `break` or `continue` with no label + loop { + 'test_7: while continue 'test_7 {} + } + loop { + while continue {} + //~^ ERROR `break` or `continue` with no label + } loop { 'test_8: while continue 'test_8 {} @@ -42,4 +53,13 @@ fn main() { //~^ ERROR `break` or `continue` with no label continue; } + + 'test_9: loop { + break while continue 'test_9 {}; + } + loop { + break while continue { + //~^ ERROR `break` or `continue` with no label + }; + } } diff --git a/tests/ui/for-loop-while/break-continue-in-loop-while-condition-1.stderr b/tests/ui/for-loop-while/break-continue-in-loop-while-condition.stderr similarity index 59% rename from tests/ui/for-loop-while/break-continue-in-loop-while-condition-1.stderr rename to tests/ui/for-loop-while/break-continue-in-loop-while-condition.stderr index d19e1f45393a3..dac6dc2e30bc4 100644 --- a/tests/ui/for-loop-while/break-continue-in-loop-while-condition-1.stderr +++ b/tests/ui/for-loop-while/break-continue-in-loop-while-condition.stderr @@ -1,51 +1,57 @@ error[E0590]: `break` or `continue` with no label in the condition of a `while` loop - --> $DIR/issue-37576.rs:3:11 + --> $DIR/break-continue-in-loop-while-condition.rs:6:11 | LL | while break {} | ^^^^^ unlabeled `break` in the condition of a `while` loop error[E0590]: `break` or `continue` with no label in the condition of a `while` loop - --> $DIR/issue-37576.rs:7:22 + --> $DIR/break-continue-in-loop-while-condition.rs:10:22 | LL | while let true = break {} | ^^^^^ unlabeled `break` in the condition of a `while` loop error[E0590]: `break` or `continue` with no label in the condition of a `while` loop - --> $DIR/issue-37576.rs:11:18 + --> $DIR/break-continue-in-loop-while-condition.rs:17:15 | -LL | loop { while break {} } - | ^^^^^ unlabeled `break` in the condition of a `while` loop +LL | while break {} + | ^^^^^ unlabeled `break` in the condition of a `while` loop error[E0590]: `break` or `continue` with no label in the condition of a `while` loop - --> $DIR/issue-37576.rs:19:15 + --> $DIR/break-continue-in-loop-while-condition.rs:26:15 | LL | while break {} | ^^^^^ unlabeled `break` in the condition of a `while` loop error[E0590]: `break` or `continue` with no label in the condition of a `while` loop - --> $DIR/issue-37576.rs:25:11 + --> $DIR/break-continue-in-loop-while-condition.rs:32:11 | LL | while continue {} | ^^^^^^^^ unlabeled `continue` in the condition of a `while` loop error[E0590]: `break` or `continue` with no label in the condition of a `while` loop - --> $DIR/issue-37576.rs:29:22 + --> $DIR/break-continue-in-loop-while-condition.rs:36:22 | LL | while let true = continue {} | ^^^^^^^^ unlabeled `continue` in the condition of a `while` loop error[E0590]: `break` or `continue` with no label in the condition of a `while` loop - --> $DIR/issue-37576.rs:33:18 + --> $DIR/break-continue-in-loop-while-condition.rs:43:15 | -LL | loop { while continue {} } - | ^^^^^^^^ unlabeled `continue` in the condition of a `while` loop +LL | while continue {} + | ^^^^^^^^ unlabeled `continue` in the condition of a `while` loop error[E0590]: `break` or `continue` with no label in the condition of a `while` loop - --> $DIR/issue-37576.rs:41:15 + --> $DIR/break-continue-in-loop-while-condition.rs:52:15 | LL | while continue {} | ^^^^^^^^ unlabeled `continue` in the condition of a `while` loop -error: aborting due to 8 previous errors +error[E0590]: `break` or `continue` with no label in the condition of a `while` loop + --> $DIR/break-continue-in-loop-while-condition.rs:61:21 + | +LL | break while continue { + | ^^^^^^^^ unlabeled `continue` in the condition of a `while` loop + +error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0590`. diff --git a/tests/ui/issues/issue-20714.rs b/tests/ui/issues/issue-20714.rs deleted file mode 100644 index 3aa39bb7388fa..0000000000000 --- a/tests/ui/issues/issue-20714.rs +++ /dev/null @@ -1,5 +0,0 @@ -struct G; - -fn main() { - let g = G(); //~ ERROR: expected function, found struct `G` -} diff --git a/tests/ui/issues/issue-20714.stderr b/tests/ui/issues/issue-20714.stderr deleted file mode 100644 index f537a01582b6b..0000000000000 --- a/tests/ui/issues/issue-20714.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0618]: expected function, found struct `G` - --> $DIR/issue-20714.rs:4:13 - | -LL | struct G; - | -------- struct `G` defined here -... -LL | let g = G(); - | ^-- - | | - | call expression requires function - | -help: `G` is a unit struct, and does not take parentheses to be constructed - | -LL - let g = G(); -LL + let g = G; - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0618`. diff --git a/tests/ui/issues/issue-2383.rs b/tests/ui/issues/issue-2383.rs deleted file mode 100644 index 5d60018ae673b..0000000000000 --- a/tests/ui/issues/issue-2383.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass - -use std::collections::VecDeque; - -pub fn main() { - let mut q = VecDeque::new(); - q.push_front(10); -} diff --git a/tests/ui/issues/issue-2951.rs b/tests/ui/issues/issue-2951.rs deleted file mode 100644 index e28516fa30730..0000000000000 --- a/tests/ui/issues/issue-2951.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ dont-require-annotations: NOTE - -fn foo(x: T, y: U) { - let mut xx = x; - xx = y; - //~^ ERROR mismatched types - //~| NOTE expected type parameter `T`, found type parameter `U` - //~| NOTE expected type parameter `T` - //~| NOTE found type parameter `U` -} - -fn main() { -} diff --git a/tests/ui/issues/issue-2951.stderr b/tests/ui/issues/issue-2951.stderr deleted file mode 100644 index d4b45935bf9a6..0000000000000 --- a/tests/ui/issues/issue-2951.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-2951.rs:5:10 - | -LL | fn foo(x: T, y: U) { - | - - found type parameter - | | - | expected type parameter -LL | let mut xx = x; - | - expected due to this value -LL | xx = y; - | ^ expected type parameter `T`, found type parameter `U` - | - = note: expected type parameter `T` - found type parameter `U` - = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound - = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/match/match-option-result-mismatch.rs b/tests/ui/match/match-option-result-mismatch.rs index 7fdc6e179e47a..e7c185cf09b82 100644 --- a/tests/ui/match/match-option-result-mismatch.rs +++ b/tests/ui/match/match-option-result-mismatch.rs @@ -1,6 +1,9 @@ +//! regression test for + fn main() { - match None { //~ NOTE this expression has type `Option<_>` - Err(_) => () + match None { + //~^ NOTE this expression has type `Option<_>` + Err(_) => (), //~^ ERROR mismatched types //~| NOTE expected enum `Option<_>` //~| NOTE found enum `Result<_, _>` diff --git a/tests/ui/match/match-option-result-mismatch.stderr b/tests/ui/match/match-option-result-mismatch.stderr index 2a757b44dc834..212d322fe2d96 100644 --- a/tests/ui/match/match-option-result-mismatch.stderr +++ b/tests/ui/match/match-option-result-mismatch.stderr @@ -1,16 +1,17 @@ error[E0308]: mismatched types - --> $DIR/issue-3680.rs:3:9 + --> $DIR/match-option-result-mismatch.rs:6:9 | LL | match None { | ---- this expression has type `Option<_>` -LL | Err(_) => () +LL | +LL | Err(_) => (), | ^^^^^^ expected `Option<_>`, found `Result<_, _>` | = note: expected enum `Option<_>` found enum `Result<_, _>` help: try wrapping the pattern in `Some` | -LL | Some(Err(_)) => () +LL | Some(Err(_)) => (), | +++++ + error: aborting due to 1 previous error diff --git a/tests/ui/numeric/ref-int.rs b/tests/ui/numeric/ref-int.rs index a4f9b3718446a..da4f4fc070828 100644 --- a/tests/ui/numeric/ref-int.rs +++ b/tests/ui/numeric/ref-int.rs @@ -1,4 +1,5 @@ //@ run-pass +//! regression test for pub fn main() { let x = 1; diff --git a/tests/ui/type/type-parameter-names.rs b/tests/ui/type/type-parameter-names.rs index fbd1885f543fe..0b427314f1333 100644 --- a/tests/ui/type/type-parameter-names.rs +++ b/tests/ui/type/type-parameter-names.rs @@ -1,14 +1,24 @@ // Test that we print out the names of type parameters correctly in // our error messages. +// related issue //@ dont-require-annotations: NOTE fn foo(x: Foo) -> Bar { x -//~^ ERROR mismatched types -//~| NOTE expected type parameter `Bar`, found type parameter `Foo` -//~| NOTE expected type parameter `Bar` -//~| NOTE found type parameter `Foo` + //~^ ERROR mismatched types + //~| NOTE expected type parameter `Bar`, found type parameter `Foo` + //~| NOTE expected type parameter `Bar` + //~| NOTE found type parameter `Foo` +} + +fn bar(x: Foo, y: Bar) { + let mut xx = x; + xx = y; + //~^ ERROR mismatched types + //~| NOTE expected type parameter `Foo`, found type parameter `Bar` + //~| NOTE expected type parameter `Foo` + //~| NOTE found type parameter `Bar` } fn main() {} diff --git a/tests/ui/type/type-parameter-names.stderr b/tests/ui/type/type-parameter-names.stderr index 795a260688c4b..f84449ef0d367 100644 --- a/tests/ui/type/type-parameter-names.stderr +++ b/tests/ui/type/type-parameter-names.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-parameter-names.rs:7:5 + --> $DIR/type-parameter-names.rs:8:5 | LL | fn foo(x: Foo) -> Bar { | --- --- --- expected `Bar` because of return type @@ -15,6 +15,23 @@ LL | x = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters = note: the caller chooses a type for `Bar` which can be different from `Foo` -error: aborting due to 1 previous error +error[E0308]: mismatched types + --> $DIR/type-parameter-names.rs:17:10 + | +LL | fn bar(x: Foo, y: Bar) { + | --- --- found type parameter + | | + | expected type parameter +LL | let mut xx = x; + | - expected due to this value +LL | xx = y; + | ^ expected type parameter `Foo`, found type parameter `Bar` + | + = note: expected type parameter `Foo` + found type parameter `Bar` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`.