Qualify panic! as core::panic! in non-built-in core macros#78343
Qualify panic! as core::panic! in non-built-in core macros#78343bors merged 2 commits intorust-lang:masterfrom
panic! as core::panic! in non-built-in core macros#78343Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
|
I would like to write a test for this, but I'm not sure where to put it. Where are library compiletests put? |
|
Tested locally and it seems to work. stderr (compiling)warning: unreachable statement
--> issue-78333.rs:5:5
|
4 | ::std::todo!();
| --------------- any code following this expression is unreachable
5 | ::std::unimplemented!();
| ^^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement
|
= note: `#[warn(unreachable_code)]` on by default
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
warning: 1 warning emittedstderr (running) |
|
|
Seems fine to me, and actually with @m-ou-se's recent changes the two macros are now more similar than before. |
|
For all cases of the form The other cases in this PR are of the form However, two important notes:
assert!(1 + 1 == 3, 123); // ok with std, error with core
assert!(1 + 1 == 3, &String::from("hello")); // ok with core, error with stdI think it's fine to merge this PR as is, and fix |
I doubt this was ever intended to work, and even for people using |
I'm all for just breaking I'll turn my notes about this into an RFC today (and also add something about |
For
Okay, great. :) (But some of this will likely require further data, in particular for |
The proposed steps include this PR and the problem it solves. See the second to last step under 'Proposed solution'. |
|
I'm going to r? @m-ou-se here, I'm not sure what the right path is -- would need to think about it -- but you seem to have a better handle on it than I :) |
|
Yeah, this is much more complicated than I thought! |
panic! with $crate:: in core macrospanic! as core::panic!
|
Now that you're also updating |
|
Yeah, I think I'll have to adjust the code if we're going to go forward with updating error[E0308]: mismatched types
--> /Users/nlroscoemeow/rust/src/test/ui/macros/assert-macro-owned.rs:6:20
|
LL | assert!(false, "test-assert-owned".to_string());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected `&str`, found struct `String`
| help: consider borrowing here: `&"test-assert-owned".to_string()` |
|
Yup. But we can still use this to do a crater run. Curious to see if anything other than this unit test fails. @bors try |
|
⌛ Trying commit 3fd3d0e53589340759a75a5ea28c858c21860484 with merge d17e02cd82564103b338f152142ccfe1a9b9fbc0... |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
⌛ Testing commit 0510fd3 with merge 82ed431104bc6c77c7a15da62fd70d557634db25... |
|
Note to whoever writes the relnotes for this: You can no longer 'intercept' |
|
💔 Test failed - checks-actions |
|
It seems like Clippy tests need to be blessed? |
How come the output changed? Shouldn't it stay the same as before? |
|
I'm not fully sure; it seems like Clippy is picking up on more things now? |
|
@m-ou-se Also see the discussion on Zulip. |
|
Don't bless the tests, just allow the lint in the affected test files. Those files aren't meant for testing this lint anyway. The patch to apply: diff --git a/tests/ui/logic_bug.rs b/tests/ui/logic_bug.rs
index b4163d776..a01c6ef99 100644
--- a/src/tools/clippy/tests/ui/logic_bug.rs
+++ b/src/tools/clippy/tests/ui/logic_bug.rs
@@ -1,4 +1,4 @@
-#![allow(unused, clippy::many_single_char_names)]
+#![allow(unused, clippy::many_single_char_names, clippy::diverging_sub_expression)]
#![warn(clippy::logic_bug)]
fn main() {
diff --git a/tests/ui/nonminimal_bool.rs b/tests/ui/nonminimal_bool.rs
index 7ea154cb9..971be2627 100644
--- a/src/tools/clippy/tests/ui/nonminimal_bool.rs
+++ b/src/tools/clippy/tests/ui/nonminimal_bool.rs
@@ -1,4 +1,4 @@
-#![allow(unused, clippy::many_single_char_names)]
+#![allow(unused, clippy::many_single_char_names, clippy::diverging_sub_expression)]
#![warn(clippy::nonminimal_bool)]
fn main() {
diff --git a/tests/ui/nonminimal_bool_methods.rs b/tests/ui/nonminimal_bool_methods.rs
index 4de48cd08..907587402 100644
--- a/src/tools/clippy/tests/ui/nonminimal_bool_methods.rs
+++ b/src/tools/clippy/tests/ui/nonminimal_bool_methods.rs
@@ -1,4 +1,4 @@
-#![allow(unused, clippy::many_single_char_names)]
+#![allow(unused, clippy::many_single_char_names, clippy::diverging_sub_expression)]
#![warn(clippy::nonminimal_bool)]
fn methods_with_negation() {
diff --git a/tests/ui/wildcard_enum_match_arm.fixed b/tests/ui/wildcard_enum_match_arm.fixed
index 4f8754a93..b1e5742b7 100644
--- a/src/tools/clippy/tests/ui/wildcard_enum_match_arm.fixed
+++ b/src/tools/clippy/tests/ui/wildcard_enum_match_arm.fixed
@@ -7,7 +7,7 @@
dead_code,
clippy::single_match,
clippy::wildcard_in_or_patterns,
- clippy::unnested_or_patterns
+ clippy::unnested_or_patterns, clippy::diverging_sub_expression
)]
use std::io::ErrorKind;
diff --git a/tests/ui/wildcard_enum_match_arm.rs b/tests/ui/wildcard_enum_match_arm.rs
index 5e66644ce..cd3ec3ea8 100644
--- a/src/tools/clippy/tests/ui/wildcard_enum_match_arm.rs
+++ b/src/tools/clippy/tests/ui/wildcard_enum_match_arm.rs
@@ -7,7 +7,7 @@
dead_code,
clippy::single_match,
clippy::wildcard_in_or_patterns,
- clippy::unnested_or_patterns
+ clippy::unnested_or_patterns, clippy::diverging_sub_expression
)]
use std::io::ErrorKind; |
|
Thanks for providing that patch :) |
|
Rebased. |
|
CI should pass now. |
|
Squashed. |
Otherwise code like this
#![no_implicit_prelude]
fn main() {
::std::todo!();
::std::unimplemented!();
}
will fail to compile, which is unfortunate and presumably unintended.
This changes many invocations of `panic!` in a `macro_rules!` definition
to invocations of `$crate::panic!`, which makes the invocations hygienic.
Note that this does not make the built-in macro `assert!` hygienic.
* Switch a couple links over to intra-doc links * Clean up some formatting/typography
|
@bors r+ 🎉 |
|
📌 Commit d8b1d51 has been approved by |
|
☀️ Test successful - checks-actions |
|
🎉 Thanks for making this happen, @camelid! |
Fixes #78333.
Otherwise code like this
will fail to compile, which is unfortunate and presumably unintended.
This changes many invocations of
panic!in amacro_rules!definitionto invocations of
$crate::panic!, which makes the invocations hygienic.Note that this does not make the built-in macro
assert!hygienic.