未验证 提交 7e95290c 编写于 作者: Y Yuki Okushi 提交者: GitHub

Rollup merge of #86717 - rylev:rename, r=nikomatsakis

Rename some Rust 2021 lints to better names

Based on conversation in https://github.com/rust-lang/rust/issues/85894.

Rename a bunch of Rust 2021 related lints:

Lints that are officially renamed because they are already in beta or stable:
* `disjoint_capture_migration` => `rust_2021_incompatible_closure_captures`
* `or_patterns_back_compat` => `rust_2021_incompatible_or_patterns`
* `non_fmt_panic` => `non_fmt_panics`

Lints that are renamed but don't require any back -compat work since they aren't yet in stable:
* `future_prelude_collision` => `rust_2021_prelude_collisions`
* `reserved_prefix` => `rust_2021_token_prefixes`

Lints that have been discussed but that I did not rename:
* ~`non_fmt_panic` and `bare_trait_object`: is making this plural worth the headache we might cause users?~
* `array_into_iter`: I'm unsure of a good name and whether bothering users with a name change is worth it.

r? `@nikomatsakis`
...@@ -18,7 +18,9 @@ ...@@ -18,7 +18,9 @@
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_feature::Features; use rustc_feature::Features;
use rustc_lint_defs::builtin::{OR_PATTERNS_BACK_COMPAT, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS}; use rustc_lint_defs::builtin::{
RUST_2021_INCOMPATIBLE_OR_PATTERNS, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
};
use rustc_lint_defs::BuiltinLintDiagnostics; use rustc_lint_defs::BuiltinLintDiagnostics;
use rustc_parse::parser::Parser; use rustc_parse::parser::Parser;
use rustc_session::parse::ParseSess; use rustc_session::parse::ParseSess;
...@@ -975,7 +977,7 @@ fn check_matcher_core( ...@@ -975,7 +977,7 @@ fn check_matcher_core(
Some(NonterminalKind::PatParam { inferred: false }), Some(NonterminalKind::PatParam { inferred: false }),
)); ));
sess.buffer_lint_with_diagnostic( sess.buffer_lint_with_diagnostic(
&OR_PATTERNS_BACK_COMPAT, &RUST_2021_INCOMPATIBLE_OR_PATTERNS,
span, span,
ast::CRATE_NODE_ID, ast::CRATE_NODE_ID,
"the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro", "the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro",
......
...@@ -325,6 +325,9 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { ...@@ -325,6 +325,9 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
store.register_renamed("redundant_semicolon", "redundant_semicolons"); store.register_renamed("redundant_semicolon", "redundant_semicolons");
store.register_renamed("overlapping_patterns", "overlapping_range_endpoints"); store.register_renamed("overlapping_patterns", "overlapping_range_endpoints");
store.register_renamed("safe_packed_borrows", "unaligned_references"); store.register_renamed("safe_packed_borrows", "unaligned_references");
store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures");
store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns");
store.register_renamed("non_fmt_panic", "non_fmt_panics");
// These were moved to tool lints, but rustc still sees them when compiling normally, before // These were moved to tool lints, but rustc still sees them when compiling normally, before
// tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use // tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
use rustc_span::{hygiene, sym, symbol::kw, symbol::SymbolStr, InnerSpan, Span, Symbol}; use rustc_span::{hygiene, sym, symbol::kw, symbol::SymbolStr, InnerSpan, Span, Symbol};
declare_lint! { declare_lint! {
/// The `non_fmt_panic` lint detects `panic!(..)` invocations where the first /// The `non_fmt_panics` lint detects `panic!(..)` invocations where the first
/// argument is not a formatting string. /// argument is not a formatting string.
/// ///
/// ### Example /// ### Example
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
/// an `i32` as message. /// an `i32` as message.
/// ///
/// Rust 2021 always interprets the first argument as format string. /// Rust 2021 always interprets the first argument as format string.
NON_FMT_PANIC, NON_FMT_PANICS,
Warn, Warn,
"detect single-argument panic!() invocations in which the argument is not a format string", "detect single-argument panic!() invocations in which the argument is not a format string",
@future_incompatible = FutureIncompatibleInfo { @future_incompatible = FutureIncompatibleInfo {
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
report_in_external_macro report_in_external_macro
} }
declare_lint_pass!(NonPanicFmt => [NON_FMT_PANIC]); declare_lint_pass!(NonPanicFmt => [NON_FMT_PANICS]);
impl<'tcx> LateLintPass<'tcx> for NonPanicFmt { impl<'tcx> LateLintPass<'tcx> for NonPanicFmt {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
...@@ -91,7 +91,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc ...@@ -91,7 +91,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
arg_span = expn.call_site; arg_span = expn.call_site;
} }
cx.struct_span_lint(NON_FMT_PANIC, arg_span, |lint| { cx.struct_span_lint(NON_FMT_PANICS, arg_span, |lint| {
let mut l = lint.build("panic message is not a string literal"); let mut l = lint.build("panic message is not a string literal");
l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021"); l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021");
l.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>"); l.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>");
...@@ -174,7 +174,7 @@ fn check_panic_str<'tcx>( ...@@ -174,7 +174,7 @@ fn check_panic_str<'tcx>(
[] => vec![fmt_span], [] => vec![fmt_span],
v => v.iter().map(|span| fmt_span.from_inner(*span)).collect(), v => v.iter().map(|span| fmt_span.from_inner(*span)).collect(),
}; };
cx.struct_span_lint(NON_FMT_PANIC, arg_spans, |lint| { cx.struct_span_lint(NON_FMT_PANICS, arg_spans, |lint| {
let mut l = lint.build(match n_arguments { let mut l = lint.build(match n_arguments {
1 => "panic message contains an unused formatting placeholder", 1 => "panic message contains an unused formatting placeholder",
_ => "panic message contains unused formatting placeholders", _ => "panic message contains unused formatting placeholders",
...@@ -208,7 +208,7 @@ fn check_panic_str<'tcx>( ...@@ -208,7 +208,7 @@ fn check_panic_str<'tcx>(
Some(v) if v.len() == 1 => "panic message contains a brace", Some(v) if v.len() == 1 => "panic message contains a brace",
_ => "panic message contains braces", _ => "panic message contains braces",
}; };
cx.struct_span_lint(NON_FMT_PANIC, brace_spans.unwrap_or_else(|| vec![span]), |lint| { cx.struct_span_lint(NON_FMT_PANICS, brace_spans.unwrap_or_else(|| vec![span]), |lint| {
let mut l = lint.build(msg); let mut l = lint.build(msg);
l.note("this message is not used as a format string, but will be in Rust 2021"); l.note("this message is not used as a format string, but will be in Rust 2021");
if span.contains(arg.span) { if span.contains(arg.span) {
......
...@@ -2967,13 +2967,13 @@ ...@@ -2967,13 +2967,13 @@
MISSING_ABI, MISSING_ABI,
INVALID_DOC_ATTRIBUTES, INVALID_DOC_ATTRIBUTES,
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
DISJOINT_CAPTURE_MIGRATION, RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
LEGACY_DERIVE_HELPERS, LEGACY_DERIVE_HELPERS,
PROC_MACRO_BACK_COMPAT, PROC_MACRO_BACK_COMPAT,
OR_PATTERNS_BACK_COMPAT, RUST_2021_INCOMPATIBLE_OR_PATTERNS,
LARGE_ASSIGNMENTS, LARGE_ASSIGNMENTS,
FUTURE_PRELUDE_COLLISION, RUST_2021_PRELUDE_COLLISIONS,
RESERVED_PREFIX, RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
UNSUPPORTED_CALLING_CONVENTIONS, UNSUPPORTED_CALLING_CONVENTIONS,
] ]
} }
...@@ -3002,7 +3002,7 @@ ...@@ -3002,7 +3002,7 @@
} }
declare_lint! { declare_lint! {
/// The `disjoint_capture_migration` lint detects variables that aren't completely /// The `rust_2021_incompatible_closure_captures` lint detects variables that aren't completely
/// captured in Rust 2021 and affect the Drop order of at least one path starting at this variable. /// captured in Rust 2021 and affect the Drop order of at least one path starting at this variable.
/// It can also detect when a variable implements a trait, but one of its field does not and /// It can also detect when a variable implements a trait, but one of its field does not and
/// the field is captured by a closure and used with the assumption that said field implements /// the field is captured by a closure and used with the assumption that said field implements
...@@ -3011,7 +3011,7 @@ ...@@ -3011,7 +3011,7 @@
/// ### Example of drop reorder /// ### Example of drop reorder
/// ///
/// ```rust,compile_fail /// ```rust,compile_fail
/// # #![deny(disjoint_capture_migration)] /// # #![deny(rust_2021_incompatible_closure_captures)]
/// # #![allow(unused)] /// # #![allow(unused)]
/// struct FancyInteger(i32); /// struct FancyInteger(i32);
/// ///
...@@ -3046,7 +3046,7 @@ ...@@ -3046,7 +3046,7 @@
/// ### Example of auto-trait /// ### Example of auto-trait
/// ///
/// ```rust,compile_fail /// ```rust,compile_fail
/// #![deny(disjoint_capture_migration)] /// #![deny(rust_2021_incompatible_closure_captures)]
/// use std::thread; /// use std::thread;
/// ///
/// struct Pointer(*mut i32); /// struct Pointer(*mut i32);
...@@ -3068,7 +3068,7 @@ ...@@ -3068,7 +3068,7 @@
/// In the above example, only `fptr.0` is captured in Rust 2021. /// In the above example, only `fptr.0` is captured in Rust 2021.
/// The field is of type *mut i32 which doesn't implement Send, making the code invalid as the /// The field is of type *mut i32 which doesn't implement Send, making the code invalid as the
/// field cannot be sent between thread safely. /// field cannot be sent between thread safely.
pub DISJOINT_CAPTURE_MIGRATION, pub RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
Allow, Allow,
"detects closures affected by Rust 2021 changes", "detects closures affected by Rust 2021 changes",
@future_incompatible = FutureIncompatibleInfo { @future_incompatible = FutureIncompatibleInfo {
...@@ -3183,12 +3183,12 @@ ...@@ -3183,12 +3183,12 @@
} }
declare_lint! { declare_lint! {
/// The `or_patterns_back_compat` lint detects usage of old versions of or-patterns. /// The `rust_2021_incompatible_or_patterns` lint detects usage of old versions of or-patterns.
/// ///
/// ### Example /// ### Example
/// ///
/// ```rust,compile_fail /// ```rust,compile_fail
/// #![deny(or_patterns_back_compat)] /// #![deny(rust_2021_incompatible_or_patterns)]
/// macro_rules! match_any { /// macro_rules! match_any {
/// ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { /// ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
/// match $expr { /// match $expr {
...@@ -3211,7 +3211,7 @@ ...@@ -3211,7 +3211,7 @@
/// ### Explanation /// ### Explanation
/// ///
/// In Rust 2021, the pat matcher will match new patterns, which include the | character. /// In Rust 2021, the pat matcher will match new patterns, which include the | character.
pub OR_PATTERNS_BACK_COMPAT, pub RUST_2021_INCOMPATIBLE_OR_PATTERNS,
Allow, Allow,
"detects usage of old versions of or-patterns", "detects usage of old versions of or-patterns",
@future_incompatible = FutureIncompatibleInfo { @future_incompatible = FutureIncompatibleInfo {
...@@ -3221,13 +3221,13 @@ ...@@ -3221,13 +3221,13 @@
} }
declare_lint! { declare_lint! {
/// The `future_prelude_collision` lint detects the usage of trait methods which are ambiguous /// The `rust_2021_prelude_collisions` lint detects the usage of trait methods which are ambiguous
/// with traits added to the prelude in future editions. /// with traits added to the prelude in future editions.
/// ///
/// ### Example /// ### Example
/// ///
/// ```rust,compile_fail /// ```rust,compile_fail
/// #![deny(future_prelude_collision)] /// #![deny(rust_2021_prelude_collisions)]
/// ///
/// trait Foo { /// trait Foo {
/// fn try_into(self) -> Result<String, !>; /// fn try_into(self) -> Result<String, !>;
...@@ -3259,7 +3259,7 @@ ...@@ -3259,7 +3259,7 @@
/// is called directly on a type. /// is called directly on a type.
/// ///
/// [prelude changes]: https://blog.rust-lang.org/inside-rust/2021/03/04/planning-rust-2021.html#prelude-changes /// [prelude changes]: https://blog.rust-lang.org/inside-rust/2021/03/04/planning-rust-2021.html#prelude-changes
pub FUTURE_PRELUDE_COLLISION, pub RUST_2021_PRELUDE_COLLISIONS,
Allow, Allow,
"detects the usage of trait methods which are ambiguous with traits added to the \ "detects the usage of trait methods which are ambiguous with traits added to the \
prelude in future editions", prelude in future editions",
...@@ -3270,13 +3270,13 @@ ...@@ -3270,13 +3270,13 @@
} }
declare_lint! { declare_lint! {
/// The `reserved_prefix` lint detects identifiers that will be parsed as a /// The `rust_2021_prefixes_incompatible_syntax` lint detects identifiers that will be parsed as a
/// prefix instead in Rust 2021. /// prefix instead in Rust 2021.
/// ///
/// ### Example /// ### Example
/// ///
/// ```rust,compile_fail /// ```rust,compile_fail
/// #![deny(reserved_prefix)] /// #![deny(rust_2021_prefixes_incompatible_syntax)]
/// ///
/// macro_rules! m { /// macro_rules! m {
/// (z $x:expr) => (); /// (z $x:expr) => ();
...@@ -3295,7 +3295,7 @@ ...@@ -3295,7 +3295,7 @@
/// ///
/// This lint suggests to add whitespace between the `z` and `"hey"` tokens /// This lint suggests to add whitespace between the `z` and `"hey"` tokens
/// to keep them separated in Rust 2021. /// to keep them separated in Rust 2021.
pub RESERVED_PREFIX, pub RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
Allow, Allow,
"identifiers that will be parsed as a prefix in Rust 2021", "identifiers that will be parsed as a prefix in Rust 2021",
@future_incompatible = FutureIncompatibleInfo { @future_incompatible = FutureIncompatibleInfo {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
use rustc_errors::{error_code, Applicability, DiagnosticBuilder, FatalError, PResult}; use rustc_errors::{error_code, Applicability, DiagnosticBuilder, FatalError, PResult};
use rustc_lexer::unescape::{self, Mode}; use rustc_lexer::unescape::{self, Mode};
use rustc_lexer::{Base, DocStyle, RawStrError}; use rustc_lexer::{Base, DocStyle, RawStrError};
use rustc_session::lint::builtin::RESERVED_PREFIX; use rustc_session::lint::builtin::RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX;
use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::lint::BuiltinLintDiagnostics;
use rustc_session::parse::ParseSess; use rustc_session::parse::ParseSess;
use rustc_span::symbol::{sym, Symbol}; use rustc_span::symbol::{sym, Symbol};
...@@ -526,7 +526,7 @@ fn report_unknown_prefix(&self, start: BytePos) { ...@@ -526,7 +526,7 @@ fn report_unknown_prefix(&self, start: BytePos) {
} else { } else {
// Before Rust 2021, only emit a lint for migration. // Before Rust 2021, only emit a lint for migration.
self.sess.buffer_lint_with_diagnostic( self.sess.buffer_lint_with_diagnostic(
&RESERVED_PREFIX, &RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
prefix_span, prefix_span,
ast::CRATE_NODE_ID, ast::CRATE_NODE_ID,
&msg, &msg,
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
use rustc_errors::Applicability; use rustc_errors::Applicability;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_middle::ty::{Ref, Ty}; use rustc_middle::ty::{Ref, Ty};
use rustc_session::lint::builtin::FUTURE_PRELUDE_COLLISION; use rustc_session::lint::builtin::RUST_2021_PRELUDE_COLLISIONS;
use rustc_span::symbol::kw::Underscore; use rustc_span::symbol::kw::Underscore;
use rustc_span::symbol::{sym, Ident}; use rustc_span::symbol::{sym, Ident};
use rustc_span::Span; use rustc_span::Span;
...@@ -67,7 +67,7 @@ pub(super) fn lint_dot_call_from_2018( ...@@ -67,7 +67,7 @@ pub(super) fn lint_dot_call_from_2018(
// Inherent impls only require not relying on autoref and autoderef in order to // Inherent impls only require not relying on autoref and autoderef in order to
// ensure that the trait implementation won't be used // ensure that the trait implementation won't be used
self.tcx.struct_span_lint_hir( self.tcx.struct_span_lint_hir(
FUTURE_PRELUDE_COLLISION, RUST_2021_PRELUDE_COLLISIONS,
self_expr.hir_id, self_expr.hir_id,
self_expr.span, self_expr.span,
|lint| { |lint| {
...@@ -128,7 +128,7 @@ pub(super) fn lint_dot_call_from_2018( ...@@ -128,7 +128,7 @@ pub(super) fn lint_dot_call_from_2018(
// trait implementations require full disambiguation to not clash with the new prelude // trait implementations require full disambiguation to not clash with the new prelude
// additions (i.e. convert from dot-call to fully-qualified call) // additions (i.e. convert from dot-call to fully-qualified call)
self.tcx.struct_span_lint_hir( self.tcx.struct_span_lint_hir(
FUTURE_PRELUDE_COLLISION, RUST_2021_PRELUDE_COLLISIONS,
call_expr.hir_id, call_expr.hir_id,
call_expr.span, call_expr.span,
|lint| { |lint| {
...@@ -212,7 +212,7 @@ pub(super) fn lint_fully_qualified_call_from_2018( ...@@ -212,7 +212,7 @@ pub(super) fn lint_fully_qualified_call_from_2018(
return; return;
} }
self.tcx.struct_span_lint_hir(FUTURE_PRELUDE_COLLISION, expr_id, span, |lint| { self.tcx.struct_span_lint_hir(RUST_2021_PRELUDE_COLLISIONS, expr_id, span, |lint| {
// "type" refers to either a type or, more likely, a trait from which // "type" refers to either a type or, more likely, a trait from which
// the associated function or method is from. // the associated function or method is from.
let trait_path = self.trait_path_or_bare_name(span, expr_id, pick.item.container.id()); let trait_path = self.trait_path_or_bare_name(span, expr_id, pick.item.container.id());
......
...@@ -173,7 +173,7 @@ fn analyze_closure( ...@@ -173,7 +173,7 @@ fn analyze_closure(
let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id); let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
if should_do_disjoint_capture_migration_analysis(self.tcx, closure_hir_id) { if should_do_rust_2021_incompatible_closure_captures_analysis(self.tcx, closure_hir_id) {
self.perform_2229_migration_anaysis(closure_def_id, body_id, capture_clause, span); self.perform_2229_migration_anaysis(closure_def_id, body_id, capture_clause, span);
} }
...@@ -505,7 +505,7 @@ fn perform_2229_migration_anaysis( ...@@ -505,7 +505,7 @@ fn perform_2229_migration_anaysis(
let local_def_id = closure_def_id.expect_local(); let local_def_id = closure_def_id.expect_local();
let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id); let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
self.tcx.struct_span_lint_hir( self.tcx.struct_span_lint_hir(
lint::builtin::DISJOINT_CAPTURE_MIGRATION, lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
closure_hir_id, closure_hir_id,
span, span,
|lint| { |lint| {
...@@ -1829,8 +1829,12 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol { ...@@ -1829,8 +1829,12 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol {
tcx.hir().name(var_hir_id) tcx.hir().name(var_hir_id)
} }
fn should_do_disjoint_capture_migration_analysis(tcx: TyCtxt<'_>, closure_id: hir::HirId) -> bool { fn should_do_rust_2021_incompatible_closure_captures_analysis(
let (level, _) = tcx.lint_level_at_node(lint::builtin::DISJOINT_CAPTURE_MIGRATION, closure_id); tcx: TyCtxt<'_>,
closure_id: hir::HirId,
) -> bool {
let (level, _) =
tcx.lint_level_at_node(lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_id);
!matches!(level, lint::Level::Allow) !matches!(level, lint::Level::Allow)
} }
......
...@@ -164,7 +164,8 @@ ...@@ -164,7 +164,8 @@
#![feature(no_niche)] // rust-lang/rust#68303 #![feature(no_niche)] // rust-lang/rust#68303
#![feature(no_coverage)] // rust-lang/rust#84605 #![feature(no_coverage)] // rust-lang/rust#84605
#![deny(unsafe_op_in_unsafe_fn)] #![deny(unsafe_op_in_unsafe_fn)]
#![deny(or_patterns_back_compat)] #![cfg_attr(bootstrap, deny(or_patterns_back_compat))]
#![cfg_attr(not(bootstrap), deny(rust_2021_incompatible_or_patterns))]
// allow using `core::` in intra-doc links // allow using `core::` in intra-doc links
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
use std::thread; use std::thread;
/* Test Send Trait Migration */ /* Test Send Trait Migration */
struct SendPointer (*mut i32); struct SendPointer(*mut i32);
unsafe impl Send for SendPointer {} unsafe impl Send for SendPointer {}
fn test_send_trait() { fn test_send_trait() {
...@@ -18,8 +18,8 @@ fn test_send_trait() { ...@@ -18,8 +18,8 @@ fn test_send_trait() {
} }
/* Test Sync Trait Migration */ /* Test Sync Trait Migration */
struct CustomInt (*mut i32); struct CustomInt(*mut i32);
struct SyncPointer (CustomInt); struct SyncPointer(CustomInt);
unsafe impl Sync for SyncPointer {} unsafe impl Sync for SyncPointer {}
unsafe impl Send for CustomInt {} unsafe impl Send for CustomInt {}
...@@ -38,7 +38,7 @@ fn test_sync_trait() { ...@@ -38,7 +38,7 @@ fn test_sync_trait() {
struct S(String); struct S(String);
struct T(i32); struct T(i32);
struct U(S,T); struct U(S, T);
impl Clone for U { impl Clone for U {
fn clone(&self) -> Self { fn clone(&self) -> Self {
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
use std::thread; use std::thread;
/* Test Send Trait Migration */ /* Test Send Trait Migration */
struct SendPointer (*mut i32); struct SendPointer(*mut i32);
unsafe impl Send for SendPointer {} unsafe impl Send for SendPointer {}
fn test_send_trait() { fn test_send_trait() {
...@@ -18,8 +18,8 @@ fn test_send_trait() { ...@@ -18,8 +18,8 @@ fn test_send_trait() {
} }
/* Test Sync Trait Migration */ /* Test Sync Trait Migration */
struct CustomInt (*mut i32); struct CustomInt(*mut i32);
struct SyncPointer (CustomInt); struct SyncPointer(CustomInt);
unsafe impl Sync for SyncPointer {} unsafe impl Sync for SyncPointer {}
unsafe impl Send for CustomInt {} unsafe impl Send for CustomInt {}
...@@ -38,7 +38,7 @@ fn test_sync_trait() { ...@@ -38,7 +38,7 @@ fn test_sync_trait() {
struct S(String); struct S(String);
struct T(i32); struct T(i32);
struct U(S,T); struct U(S, T);
impl Clone for U { impl Clone for U {
fn clone(&self) -> Self { fn clone(&self) -> Self {
......
...@@ -12,8 +12,8 @@ LL | | }); ...@@ -12,8 +12,8 @@ LL | | });
note: the lint level is defined here note: the lint level is defined here
--> $DIR/auto_traits.rs:2:9 --> $DIR/auto_traits.rs:2:9
| |
LL | #![deny(disjoint_capture_migration)] LL | #![deny(rust_2021_incompatible_closure_captures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
help: add a dummy let to cause `fptr` to be fully captured help: add a dummy let to cause `fptr` to be fully captured
| |
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here //~^ NOTE: the lint level is defined here
// Test cases for types that implement a insignificant drop (stlib defined) // Test cases for types that implement a insignificant drop (stlib defined)
...@@ -13,9 +13,9 @@ fn test1_all_need_migration() { ...@@ -13,9 +13,9 @@ fn test1_all_need_migration() {
let t2 = (String::new(), String::new()); let t2 = (String::new(), String::new());
let c = || { let _ = (&t, &t1, &t2); let c = || { let _ = (&t, &t1, &t2);
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
let _t = t.0; let _t = t.0;
let _t1 = t1.0; let _t1 = t1.0;
...@@ -33,9 +33,9 @@ fn test2_only_precise_paths_need_migration() { ...@@ -33,9 +33,9 @@ fn test2_only_precise_paths_need_migration() {
let t2 = (String::new(), String::new()); let t2 = (String::new(), String::new());
let c = || { let _ = (&t, &t1); let c = || { let _ = (&t, &t1);
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
let _t = t.0; let _t = t.0;
let _t1 = t1.0; let _t1 = t1.0;
let _t2 = t2; let _t2 = t2;
...@@ -50,9 +50,9 @@ fn test3_only_by_value_need_migration() { ...@@ -50,9 +50,9 @@ fn test3_only_by_value_need_migration() {
let t = (String::new(), String::new()); let t = (String::new(), String::new());
let t1 = (String::new(), String::new()); let t1 = (String::new(), String::new());
let c = || { let _ = &t; let c = || { let _ = &t;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
println!("{}", t1.1); println!("{}", t1.1);
}; };
...@@ -69,9 +69,9 @@ fn test4_only_non_copy_types_need_migration() { ...@@ -69,9 +69,9 @@ fn test4_only_non_copy_types_need_migration() {
let t1 = (0i32, 0i32); let t1 = (0i32, 0i32);
let c = || { let _ = &t; let c = || { let _ = &t;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
let _t1 = t1.0; let _t1 = t1.0;
}; };
...@@ -88,9 +88,9 @@ fn test5_only_drop_types_need_migration() { ...@@ -88,9 +88,9 @@ fn test5_only_drop_types_need_migration() {
let s = S(0i32, 0i32); let s = S(0i32, 0i32);
let c = || { let _ = &t; let c = || { let _ = &t;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
let _s = s.0; let _s = s.0;
}; };
...@@ -104,9 +104,9 @@ fn test6_move_closures_non_copy_types_might_need_migration() { ...@@ -104,9 +104,9 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
let t = (String::new(), String::new()); let t = (String::new(), String::new());
let t1 = (String::new(), String::new()); let t1 = (String::new(), String::new());
let c = move || { let _ = (&t1, &t); let c = move || { let _ = (&t1, &t);
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
println!("{} {}", t1.1, t.1); println!("{} {}", t1.1, t.1);
}; };
...@@ -120,9 +120,9 @@ fn test7_drop_non_drop_aggregate_need_migration() { ...@@ -120,9 +120,9 @@ fn test7_drop_non_drop_aggregate_need_migration() {
let t = (String::new(), String::new(), 0i32); let t = (String::new(), String::new(), 0i32);
let c = || { let _ = &t; let c = || { let _ = &t;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
}; };
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here //~^ NOTE: the lint level is defined here
// Test cases for types that implement a insignificant drop (stlib defined) // Test cases for types that implement a insignificant drop (stlib defined)
...@@ -13,9 +13,9 @@ fn test1_all_need_migration() { ...@@ -13,9 +13,9 @@ fn test1_all_need_migration() {
let t2 = (String::new(), String::new()); let t2 = (String::new(), String::new());
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
let _t = t.0; let _t = t.0;
let _t1 = t1.0; let _t1 = t1.0;
...@@ -33,9 +33,9 @@ fn test2_only_precise_paths_need_migration() { ...@@ -33,9 +33,9 @@ fn test2_only_precise_paths_need_migration() {
let t2 = (String::new(), String::new()); let t2 = (String::new(), String::new());
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
let _t = t.0; let _t = t.0;
let _t1 = t1.0; let _t1 = t1.0;
let _t2 = t2; let _t2 = t2;
...@@ -50,9 +50,9 @@ fn test3_only_by_value_need_migration() { ...@@ -50,9 +50,9 @@ fn test3_only_by_value_need_migration() {
let t = (String::new(), String::new()); let t = (String::new(), String::new());
let t1 = (String::new(), String::new()); let t1 = (String::new(), String::new());
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
println!("{}", t1.1); println!("{}", t1.1);
}; };
...@@ -69,9 +69,9 @@ fn test4_only_non_copy_types_need_migration() { ...@@ -69,9 +69,9 @@ fn test4_only_non_copy_types_need_migration() {
let t1 = (0i32, 0i32); let t1 = (0i32, 0i32);
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
let _t1 = t1.0; let _t1 = t1.0;
}; };
...@@ -88,9 +88,9 @@ fn test5_only_drop_types_need_migration() { ...@@ -88,9 +88,9 @@ fn test5_only_drop_types_need_migration() {
let s = S(0i32, 0i32); let s = S(0i32, 0i32);
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
let _s = s.0; let _s = s.0;
}; };
...@@ -104,9 +104,9 @@ fn test6_move_closures_non_copy_types_might_need_migration() { ...@@ -104,9 +104,9 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
let t = (String::new(), String::new()); let t = (String::new(), String::new());
let t1 = (String::new(), String::new()); let t1 = (String::new(), String::new());
let c = move || { let c = move || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
println!("{} {}", t1.1, t.1); println!("{} {}", t1.1, t.1);
}; };
...@@ -120,9 +120,9 @@ fn test7_drop_non_drop_aggregate_need_migration() { ...@@ -120,9 +120,9 @@ fn test7_drop_non_drop_aggregate_need_migration() {
let t = (String::new(), String::new(), 0i32); let t = (String::new(), String::new(), 0i32);
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
}; };
......
...@@ -14,8 +14,8 @@ LL | | }; ...@@ -14,8 +14,8 @@ LL | | };
note: the lint level is defined here note: the lint level is defined here
--> $DIR/insignificant_drop.rs:3:9 --> $DIR/insignificant_drop.rs:3:9
| |
LL | #![deny(disjoint_capture_migration)] LL | #![deny(rust_2021_incompatible_closure_captures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
| |
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here //~^ NOTE: the lint level is defined here
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(unused)] #![allow(unused)]
...@@ -36,9 +35,9 @@ fn significant_drop_needs_migration() { ...@@ -36,9 +35,9 @@ fn significant_drop_needs_migration() {
let t = (SigDrop {}, SigDrop {}); let t = (SigDrop {}, SigDrop {});
let c = || { let _ = &t; let c = || { let _ = &t;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
}; };
...@@ -54,9 +53,9 @@ fn generic_struct_with_significant_drop_needs_migration() { ...@@ -54,9 +53,9 @@ fn generic_struct_with_significant_drop_needs_migration() {
// move is used to force i32 to be copied instead of being a ref // move is used to force i32 to be copied instead of being a ref
let c = move || { let _ = &t; let c = move || { let _ = &t;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.1; let _t = t.1;
}; };
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here //~^ NOTE: the lint level is defined here
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(unused)] #![allow(unused)]
...@@ -36,9 +35,9 @@ fn significant_drop_needs_migration() { ...@@ -36,9 +35,9 @@ fn significant_drop_needs_migration() {
let t = (SigDrop {}, SigDrop {}); let t = (SigDrop {}, SigDrop {});
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
}; };
...@@ -54,9 +53,9 @@ fn generic_struct_with_significant_drop_needs_migration() { ...@@ -54,9 +53,9 @@ fn generic_struct_with_significant_drop_needs_migration() {
// move is used to force i32 to be copied instead of being a ref // move is used to force i32 to be copied instead of being a ref
let c = move || { let c = move || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.1; let _t = t.1;
}; };
......
error: drop order will change in Rust 2021 error: drop order will change in Rust 2021
--> $DIR/insignificant_drop_attr_migrations.rs:38:13 --> $DIR/insignificant_drop_attr_migrations.rs:37:13
| |
LL | let c = || { LL | let c = || {
| _____________^ | _____________^
...@@ -13,8 +13,8 @@ LL | | }; ...@@ -13,8 +13,8 @@ LL | | };
note: the lint level is defined here note: the lint level is defined here
--> $DIR/insignificant_drop_attr_migrations.rs:3:9 --> $DIR/insignificant_drop_attr_migrations.rs:3:9
| |
LL | #![deny(disjoint_capture_migration)] LL | #![deny(rust_2021_incompatible_closure_captures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
help: add a dummy let to cause `t` to be fully captured help: add a dummy let to cause `t` to be fully captured
| |
...@@ -27,7 +27,7 @@ LL | }; ...@@ -27,7 +27,7 @@ LL | };
| |
error: drop order will change in Rust 2021 error: drop order will change in Rust 2021
--> $DIR/insignificant_drop_attr_migrations.rs:56:13 --> $DIR/insignificant_drop_attr_migrations.rs:55:13
| |
LL | let c = move || { LL | let c = move || {
| _____________^ | _____________^
......
// run-pass // run-pass
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(unused)] #![allow(unused)]
......
// run-pass // run-pass
#![warn(disjoint_capture_migration)] #![warn(rust_2021_incompatible_closure_captures)]
fn main() { fn main() {
if let a = "" { if let a = "" {
//~^ WARNING: irrefutable `if let` pattern //~^ WARNING: irrefutable `if let` pattern
drop(|_: ()| drop(a)); drop(|_: ()| drop(a));
} }
} }
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here //~^ NOTE: the lint level is defined here
// Test the two possible cases for automated migartion using rustfix // Test the two possible cases for automated migartion using rustfix
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here //~^ NOTE: the lint level is defined here
// Test the two possible cases for automated migartion using rustfix // Test the two possible cases for automated migartion using rustfix
......
...@@ -13,8 +13,8 @@ LL | | }; ...@@ -13,8 +13,8 @@ LL | | };
note: the lint level is defined here note: the lint level is defined here
--> $DIR/migrations_rustfix.rs:2:9 --> $DIR/migrations_rustfix.rs:2:9
| |
LL | #![deny(disjoint_capture_migration)] LL | #![deny(rust_2021_incompatible_closure_captures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
help: add a dummy let to cause `t` to be fully captured help: add a dummy let to cause `t` to be fully captured
| |
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
// ignore-wasm32-bare compiled with panic=abort by default // ignore-wasm32-bare compiled with panic=abort by default
#![feature(fn_traits)] #![feature(fn_traits)]
#![feature(never_type)] #![feature(never_type)]
use std::panic; use std::panic;
fn foo_diverges() -> ! { panic!() } fn foo_diverges() -> ! {
panic!()
}
fn assert_panics<F>(f: F) where F: FnOnce() { fn assert_panics<F>(f: F)
where
F: FnOnce(),
{
let f = panic::AssertUnwindSafe(f); let f = panic::AssertUnwindSafe(f);
let result = panic::catch_unwind(move || { let _ = &f; let result = panic::catch_unwind(move || { let _ = &f;
//~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation //~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation
...@@ -23,7 +27,8 @@ fn assert_panics<F>(f: F) where F: FnOnce() { ...@@ -23,7 +27,8 @@ fn assert_panics<F>(f: F) where F: FnOnce() {
} }
fn test_fn_ptr_panic<T>(mut t: T) fn test_fn_ptr_panic<T>(mut t: T)
where T: Fn() -> ! where
T: Fn() -> !,
{ {
let as_fn = <T as Fn<()>>::call; let as_fn = <T as Fn<()>>::call;
assert_panics(|| as_fn(&t, ())); assert_panics(|| as_fn(&t, ()));
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
// ignore-wasm32-bare compiled with panic=abort by default // ignore-wasm32-bare compiled with panic=abort by default
#![feature(fn_traits)] #![feature(fn_traits)]
#![feature(never_type)] #![feature(never_type)]
use std::panic; use std::panic;
fn foo_diverges() -> ! { panic!() } fn foo_diverges() -> ! {
panic!()
}
fn assert_panics<F>(f: F) where F: FnOnce() { fn assert_panics<F>(f: F)
where
F: FnOnce(),
{
let f = panic::AssertUnwindSafe(f); let f = panic::AssertUnwindSafe(f);
let result = panic::catch_unwind(move || { let result = panic::catch_unwind(move || {
//~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation //~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation
...@@ -23,7 +27,8 @@ fn assert_panics<F>(f: F) where F: FnOnce() { ...@@ -23,7 +27,8 @@ fn assert_panics<F>(f: F) where F: FnOnce() {
} }
fn test_fn_ptr_panic<T>(mut t: T) fn test_fn_ptr_panic<T>(mut t: T)
where T: Fn() -> ! where
T: Fn() -> !,
{ {
let as_fn = <T as Fn<()>>::call; let as_fn = <T as Fn<()>>::call;
assert_panics(|| as_fn(&t, ())); assert_panics(|| as_fn(&t, ()));
......
error: `UnwindSafe`, `RefUnwindSafe` trait implementation will change in Rust 2021 error: `UnwindSafe`, `RefUnwindSafe` trait implementation will change in Rust 2021
--> $DIR/mir_calls_to_shims.rs:15:38 --> $DIR/mir_calls_to_shims.rs:19:38
| |
LL | let result = panic::catch_unwind(move || { LL | let result = panic::catch_unwind(move || {
| ______________________________________^ | ______________________________________^
...@@ -12,8 +12,8 @@ LL | | }); ...@@ -12,8 +12,8 @@ LL | | });
note: the lint level is defined here note: the lint level is defined here
--> $DIR/mir_calls_to_shims.rs:3:9 --> $DIR/mir_calls_to_shims.rs:3:9
| |
LL | #![deny(disjoint_capture_migration)] LL | #![deny(rust_2021_incompatible_closure_captures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
help: add a dummy let to cause `f` to be fully captured help: add a dummy let to cause `f` to be fully captured
| |
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// Set of test cases that don't need migrations // Set of test cases that don't need migrations
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
// Copy types as copied by the closure instead of being moved into the closure // Copy types as copied by the closure instead of being moved into the closure
// Therefore their drop order isn't tied to the closure and won't be requiring any // Therefore their drop order isn't tied to the closure and won't be requiring any
...@@ -53,7 +52,6 @@ fn test4_insignificant_drop_non_drop_aggregate() { ...@@ -53,7 +52,6 @@ fn test4_insignificant_drop_non_drop_aggregate() {
c(); c();
} }
struct Foo(i32); struct Foo(i32);
impl Drop for Foo { impl Drop for Foo {
fn drop(&mut self) { fn drop(&mut self) {
...@@ -80,5 +78,4 @@ fn main() { ...@@ -80,5 +78,4 @@ fn main() {
test3_only_copy_types_move_closure(); test3_only_copy_types_move_closure();
test4_insignificant_drop_non_drop_aggregate(); test4_insignificant_drop_non_drop_aggregate();
test5_significant_drop_non_drop_aggregate(); test5_significant_drop_non_drop_aggregate();
} }
// check-pass
// Ensure that the old name for `rust_2021_incompatible_closure_captures` is still
// accepted by the compiler
#![allow(disjoint_capture_migration)]
//~^ WARN lint `disjoint_capture_migration` has been renamed
fn main() {}
warning: lint `disjoint_capture_migration` has been renamed to `rust_2021_incompatible_closure_captures`
--> $DIR/old_name.rs:6:10
|
LL | #![allow(disjoint_capture_migration)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rust_2021_incompatible_closure_captures`
|
= note: `#[warn(renamed_and_removed_lints)]` on by default
warning: 1 warning emitted
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
#[derive(Debug)] #[derive(Debug)]
struct Foo(i32); struct Foo(i32);
...@@ -17,8 +17,8 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() { ...@@ -17,8 +17,8 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {
let t = ConstainsDropField(Foo(10), Foo(20)); let t = ConstainsDropField(Foo(10), Foo(20));
let c = || { let _ = &t; let c = || { let _ = &t;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
let _t = &t.1; let _t = &t.1;
}; };
...@@ -28,8 +28,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() { ...@@ -28,8 +28,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {
struct S; struct S;
impl Drop for S { impl Drop for S {
fn drop(&mut self) { fn drop(&mut self) {}
}
} }
struct T(S, S); struct T(S, S);
...@@ -40,8 +39,8 @@ fn test_precise_analysis_long_path_missing() { ...@@ -40,8 +39,8 @@ fn test_precise_analysis_long_path_missing() {
let u = U(T(S, S), T(S, S)); let u = U(T(S, S), T(S, S));
let c = || { let _ = &u; let c = || { let _ = &u;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| HELP: add a dummy let to cause `u` to be fully captured //~| HELP: add a dummy let to cause `u` to be fully captured
let _x = u.0.0; let _x = u.0.0;
let _x = u.0.1; let _x = u.0.1;
let _x = u.1.0; let _x = u.1.0;
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
#[derive(Debug)] #[derive(Debug)]
struct Foo(i32); struct Foo(i32);
...@@ -17,8 +17,8 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() { ...@@ -17,8 +17,8 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {
let t = ConstainsDropField(Foo(10), Foo(20)); let t = ConstainsDropField(Foo(10), Foo(20));
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
let _t = &t.1; let _t = &t.1;
}; };
...@@ -28,8 +28,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() { ...@@ -28,8 +28,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {
struct S; struct S;
impl Drop for S { impl Drop for S {
fn drop(&mut self) { fn drop(&mut self) {}
}
} }
struct T(S, S); struct T(S, S);
...@@ -40,8 +39,8 @@ fn test_precise_analysis_long_path_missing() { ...@@ -40,8 +39,8 @@ fn test_precise_analysis_long_path_missing() {
let u = U(T(S, S), T(S, S)); let u = U(T(S, S), T(S, S));
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| HELP: add a dummy let to cause `u` to be fully captured //~| HELP: add a dummy let to cause `u` to be fully captured
let _x = u.0.0; let _x = u.0.0;
let _x = u.0.1; let _x = u.0.1;
let _x = u.1.0; let _x = u.1.0;
......
...@@ -13,8 +13,8 @@ LL | | }; ...@@ -13,8 +13,8 @@ LL | | };
note: the lint level is defined here note: the lint level is defined here
--> $DIR/precise.rs:3:9 --> $DIR/precise.rs:3:9
| |
LL | #![deny(disjoint_capture_migration)] LL | #![deny(rust_2021_incompatible_closure_captures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
help: add a dummy let to cause `t` to be fully captured help: add a dummy let to cause `t` to be fully captured
| |
...@@ -27,7 +27,7 @@ LL | }; ...@@ -27,7 +27,7 @@ LL | };
| |
error: drop order will change in Rust 2021 error: drop order will change in Rust 2021
--> $DIR/precise.rs:42:13 --> $DIR/precise.rs:41:13
| |
LL | let c = || { LL | let c = || {
| _____________^ | _____________^
......
// run-pass // run-pass
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
#[derive(Debug)] #[derive(Debug)]
struct Foo(i32); struct Foo(i32);
...@@ -73,8 +73,7 @@ fn test_precise_analysis_parent_captured_2() { ...@@ -73,8 +73,7 @@ fn test_precise_analysis_parent_captured_2() {
struct S; struct S;
impl Drop for S { impl Drop for S {
fn drop(&mut self) { fn drop(&mut self) {}
}
} }
struct T(S, S); struct T(S, S);
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here //~^ NOTE: the lint level is defined here
// Test cases for types that implement a significant drop (user defined) // Test cases for types that implement a significant drop (user defined)
...@@ -23,9 +23,9 @@ fn test1_all_need_migration() { ...@@ -23,9 +23,9 @@ fn test1_all_need_migration() {
let t2 = (Foo(0), Foo(0)); let t2 = (Foo(0), Foo(0));
let c = || { let _ = (&t, &t1, &t2); let c = || { let _ = (&t, &t1, &t2);
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
let _t = t.0; let _t = t.0;
let _t1 = t1.0; let _t1 = t1.0;
let _t2 = t2.0; let _t2 = t2.0;
...@@ -42,9 +42,9 @@ fn test2_only_precise_paths_need_migration() { ...@@ -42,9 +42,9 @@ fn test2_only_precise_paths_need_migration() {
let t2 = (Foo(0), Foo(0)); let t2 = (Foo(0), Foo(0));
let c = || { let _ = (&t, &t1); let c = || { let _ = (&t, &t1);
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
let _t = t.0; let _t = t.0;
let _t1 = t1.0; let _t1 = t1.0;
let _t2 = t2; let _t2 = t2;
...@@ -59,9 +59,9 @@ fn test3_only_by_value_need_migration() { ...@@ -59,9 +59,9 @@ fn test3_only_by_value_need_migration() {
let t = (Foo(0), Foo(0)); let t = (Foo(0), Foo(0));
let t1 = (Foo(0), Foo(0)); let t1 = (Foo(0), Foo(0));
let c = || { let _ = &t; let c = || { let _ = &t;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
println!("{:?}", t1.1); println!("{:?}", t1.1);
}; };
...@@ -77,9 +77,9 @@ fn test4_type_contains_drop_need_migration() { ...@@ -77,9 +77,9 @@ fn test4_type_contains_drop_need_migration() {
let t = ConstainsDropField(Foo(0), Foo(0)); let t = ConstainsDropField(Foo(0), Foo(0));
let c = || { let _ = &t; let c = || { let _ = &t;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
}; };
...@@ -93,9 +93,9 @@ fn test5_drop_non_drop_aggregate_need_migration() { ...@@ -93,9 +93,9 @@ fn test5_drop_non_drop_aggregate_need_migration() {
let t = (Foo(0), Foo(0), 0i32); let t = (Foo(0), Foo(0), 0i32);
let c = || { let _ = &t; let c = || { let _ = &t;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
}; };
...@@ -107,9 +107,9 @@ fn test6_significant_insignificant_drop_aggregate_need_migration() { ...@@ -107,9 +107,9 @@ fn test6_significant_insignificant_drop_aggregate_need_migration() {
let t = (Foo(0), String::new()); let t = (Foo(0), String::new());
let c = || { let _ = &t; let c = || { let _ = &t;
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.1; let _t = t.1;
}; };
...@@ -123,9 +123,9 @@ fn test7_move_closures_non_copy_types_might_need_migration() { ...@@ -123,9 +123,9 @@ fn test7_move_closures_non_copy_types_might_need_migration() {
let t1 = (Foo(0), Foo(0), Foo(0)); let t1 = (Foo(0), Foo(0), Foo(0));
let c = move || { let _ = (&t1, &t); let c = move || { let _ = (&t1, &t);
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
println!("{:?} {:?}", t1.1, t.1); println!("{:?} {:?}", t1.1, t.1);
}; };
......
// run-rustfix // run-rustfix
#![deny(disjoint_capture_migration)] #![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here //~^ NOTE: the lint level is defined here
// Test cases for types that implement a significant drop (user defined) // Test cases for types that implement a significant drop (user defined)
...@@ -23,9 +23,9 @@ fn test1_all_need_migration() { ...@@ -23,9 +23,9 @@ fn test1_all_need_migration() {
let t2 = (Foo(0), Foo(0)); let t2 = (Foo(0), Foo(0));
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured //~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
let _t = t.0; let _t = t.0;
let _t1 = t1.0; let _t1 = t1.0;
let _t2 = t2.0; let _t2 = t2.0;
...@@ -42,9 +42,9 @@ fn test2_only_precise_paths_need_migration() { ...@@ -42,9 +42,9 @@ fn test2_only_precise_paths_need_migration() {
let t2 = (Foo(0), Foo(0)); let t2 = (Foo(0), Foo(0));
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured //~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
let _t = t.0; let _t = t.0;
let _t1 = t1.0; let _t1 = t1.0;
let _t2 = t2; let _t2 = t2;
...@@ -59,9 +59,9 @@ fn test3_only_by_value_need_migration() { ...@@ -59,9 +59,9 @@ fn test3_only_by_value_need_migration() {
let t = (Foo(0), Foo(0)); let t = (Foo(0), Foo(0));
let t1 = (Foo(0), Foo(0)); let t1 = (Foo(0), Foo(0));
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
println!("{:?}", t1.1); println!("{:?}", t1.1);
}; };
...@@ -77,9 +77,9 @@ fn test4_type_contains_drop_need_migration() { ...@@ -77,9 +77,9 @@ fn test4_type_contains_drop_need_migration() {
let t = ConstainsDropField(Foo(0), Foo(0)); let t = ConstainsDropField(Foo(0), Foo(0));
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
}; };
...@@ -93,9 +93,9 @@ fn test5_drop_non_drop_aggregate_need_migration() { ...@@ -93,9 +93,9 @@ fn test5_drop_non_drop_aggregate_need_migration() {
let t = (Foo(0), Foo(0), 0i32); let t = (Foo(0), Foo(0), 0i32);
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0; let _t = t.0;
}; };
...@@ -107,9 +107,9 @@ fn test6_significant_insignificant_drop_aggregate_need_migration() { ...@@ -107,9 +107,9 @@ fn test6_significant_insignificant_drop_aggregate_need_migration() {
let t = (Foo(0), String::new()); let t = (Foo(0), String::new());
let c = || { let c = || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured //~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.1; let _t = t.1;
}; };
...@@ -123,9 +123,9 @@ fn test7_move_closures_non_copy_types_might_need_migration() { ...@@ -123,9 +123,9 @@ fn test7_move_closures_non_copy_types_might_need_migration() {
let t1 = (Foo(0), Foo(0), Foo(0)); let t1 = (Foo(0), Foo(0), Foo(0));
let c = move || { let c = move || {
//~^ ERROR: drop order //~^ ERROR: drop order
//~| NOTE: for more information, see //~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured //~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
println!("{:?} {:?}", t1.1, t.1); println!("{:?} {:?}", t1.1, t.1);
}; };
......
...@@ -14,8 +14,8 @@ LL | | }; ...@@ -14,8 +14,8 @@ LL | | };
note: the lint level is defined here note: the lint level is defined here
--> $DIR/significant_drop.rs:2:9 --> $DIR/significant_drop.rs:2:9
| |
LL | #![deny(disjoint_capture_migration)] LL | #![deny(rust_2021_incompatible_closure_captures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html> = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
| |
......
#![feature(const_panic)] #![feature(const_panic)]
#![allow(non_fmt_panic)] #![allow(non_fmt_panics)]
#![crate_type = "lib"] #![crate_type = "lib"]
const MSG: &str = "hello"; const MSG: &str = "hello";
......
...@@ -16,13 +16,13 @@ fn main() { ...@@ -16,13 +16,13 @@ fn main() {
fn named_argument_takes_precedence_to_captured() { fn named_argument_takes_precedence_to_captured() {
let foo = "captured"; let foo = "captured";
let s = format!("{foo}", foo="named"); let s = format!("{foo}", foo = "named");
assert_eq!(&s, "named"); assert_eq!(&s, "named");
let s = format!("{foo}-{foo}-{foo}", foo="named"); let s = format!("{foo}-{foo}-{foo}", foo = "named");
assert_eq!(&s, "named-named-named"); assert_eq!(&s, "named-named-named");
let s = format!("{}-{bar}-{foo}", "positional", bar="named"); let s = format!("{}-{bar}-{foo}", "positional", bar = "named");
assert_eq!(&s, "positional-named-captured"); assert_eq!(&s, "positional-named-captured");
} }
...@@ -42,10 +42,11 @@ fn panic_with_single_argument_does_not_get_formatted() { ...@@ -42,10 +42,11 @@ fn panic_with_single_argument_does_not_get_formatted() {
// RFC #2795 suggests that this may need to change so that captured arguments are formatted. // RFC #2795 suggests that this may need to change so that captured arguments are formatted.
// For stability reasons this will need to part of an edition change. // For stability reasons this will need to part of an edition change.
#[allow(non_fmt_panic)] #[allow(non_fmt_panics)]
let msg = std::panic::catch_unwind(|| { let msg = std::panic::catch_unwind(|| {
panic!("{foo}"); panic!("{foo}");
}).unwrap_err(); })
.unwrap_err();
assert_eq!(msg.downcast_ref::<&str>(), Some(&"{foo}")) assert_eq!(msg.downcast_ref::<&str>(), Some(&"{foo}"))
} }
...@@ -55,8 +56,9 @@ fn panic_with_multiple_arguments_is_formatted() { ...@@ -55,8 +56,9 @@ fn panic_with_multiple_arguments_is_formatted() {
let foo = "captured"; let foo = "captured";
let msg = std::panic::catch_unwind(|| { let msg = std::panic::catch_unwind(|| {
panic!("{}-{bar}-{foo}", "positional", bar="named"); panic!("{}-{bar}-{foo}", "positional", bar = "named");
}).unwrap_err(); })
.unwrap_err();
assert_eq!(msg.downcast_ref::<String>(), Some(&"positional-named-captured".to_string())) assert_eq!(msg.downcast_ref::<String>(), Some(&"positional-named-captured".to_string()))
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// error-pattern:panicked at 'test-assert-owned' // error-pattern:panicked at 'test-assert-owned'
// ignore-emscripten no processes // ignore-emscripten no processes
#![allow(non_fmt_panic)] #![allow(non_fmt_panics)]
fn main() { fn main() {
assert!(false, "test-assert-owned".to_string()); assert!(false, "test-assert-owned".to_string());
......
...@@ -14,11 +14,12 @@ ...@@ -14,11 +14,12 @@
// revisions: std core // revisions: std core
// ignore-wasm32-bare compiled with panic=abort by default // ignore-wasm32-bare compiled with panic=abort by default
#![cfg_attr(core, no_std)] #![cfg_attr(core, no_std)]
#[cfg(std)] use std::fmt; #[cfg(core)]
#[cfg(core)] use core::fmt; use core::fmt;
#[cfg(std)]
use std::fmt;
// an easy mistake in the implementation of 'assert!' // an easy mistake in the implementation of 'assert!'
// would cause this to say "explicit panic" // would cause this to say "explicit panic"
...@@ -57,7 +58,7 @@ fn writeln_1arg() { ...@@ -57,7 +58,7 @@ fn writeln_1arg() {
// //
// (Example: Issue #48042) // (Example: Issue #48042)
#[test] #[test]
#[allow(non_fmt_panic)] #[allow(non_fmt_panics)]
fn to_format_or_not_to_format() { fn to_format_or_not_to_format() {
// ("{}" is the easiest string to test because if this gets // ("{}" is the easiest string to test because if this gets
// sent to format_args!, it'll simply fail to compile. // sent to format_args!, it'll simply fail to compile.
...@@ -80,13 +81,17 @@ fn to_format_or_not_to_format() { ...@@ -80,13 +81,17 @@ fn to_format_or_not_to_format() {
// format!("{}",); // see check-fail // format!("{}",); // see check-fail
// format_args!("{}",); // see check-fail // format_args!("{}",); // see check-fail
if falsum() { panic!("{}",); } if falsum() {
panic!("{}",);
}
// print!("{}",); // see check-fail // print!("{}",); // see check-fail
// println!("{}",); // see check-fail // println!("{}",); // see check-fail
// unimplemented!("{}",); // see check-fail // unimplemented!("{}",); // see check-fail
if falsum() { unreachable!("{}",); } if falsum() {
unreachable!("{}",);
}
// write!(&mut stdout, "{}",); // see check-fail // write!(&mut stdout, "{}",); // see check-fail
// writeln!(&mut stdout, "{}",); // see check-fail // writeln!(&mut stdout, "{}",); // see check-fail
......
// run-rustfix // run-rustfix
// aux-build:or-pattern.rs // aux-build:or-pattern.rs
#![deny(or_patterns_back_compat)] #![deny(rust_2021_incompatible_or_patterns)]
#![allow(unused_macros)] #![allow(unused_macros)]
#[macro_use] #[macro_use]
......
// run-rustfix // run-rustfix
// aux-build:or-pattern.rs // aux-build:or-pattern.rs
#![deny(or_patterns_back_compat)] #![deny(rust_2021_incompatible_or_patterns)]
#![allow(unused_macros)] #![allow(unused_macros)]
#[macro_use] #[macro_use]
......
...@@ -7,8 +7,8 @@ LL | macro_rules! foo { ($x:pat | $y:pat) => {} } ...@@ -7,8 +7,8 @@ LL | macro_rules! foo { ($x:pat | $y:pat) => {} }
note: the lint level is defined here note: the lint level is defined here
--> $DIR/macro-or-patterns-back-compat.rs:4:9 --> $DIR/macro-or-patterns-back-compat.rs:4:9
| |
LL | #![deny(or_patterns_back_compat)] LL | #![deny(rust_2021_incompatible_or_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869> = note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869>
......
...@@ -4,7 +4,7 @@ warning: panic message contains a brace ...@@ -4,7 +4,7 @@ warning: panic message contains a brace
LL | panic!("here's a brace: {"); LL | panic!("here's a brace: {");
| ^ | ^
| |
= note: `#[warn(non_fmt_panic)]` on by default = note: `#[warn(non_fmt_panics)]` on by default
= note: this message is not used as a format string, but will be in Rust 2021 = note: this message is not used as a format string, but will be in Rust 2021
help: add a "{}" format string to use the message literally help: add a "{}" format string to use the message literally
| |
......
#![allow(unused_assignments)] #![allow(unused_assignments)]
#![allow(unused_variables)] #![allow(unused_variables)]
#![allow(non_fmt_panic)] #![allow(non_fmt_panics)]
// run-fail // run-fail
// error-pattern:wooooo // error-pattern:wooooo
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// error-pattern:panicked at 'Box<dyn Any>' // error-pattern:panicked at 'Box<dyn Any>'
// ignore-emscripten no processes // ignore-emscripten no processes
#![allow(non_fmt_panic)] #![allow(non_fmt_panics)]
fn main() { fn main() {
panic!(Box::new(612_i64)); panic!(Box::new(612_i64));
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// ignore-emscripten no processes // ignore-emscripten no processes
#![feature(box_syntax)] #![feature(box_syntax)]
#![allow(non_fmt_panic)] #![allow(non_fmt_panics)]
fn main() { fn main() {
panic!(box 413 as Box<dyn std::any::Any + Send>); panic!(box 413 as Box<dyn std::any::Any + Send>);
......
// run-rustfix // run-rustfix
// edition:2018 // edition:2018
// check-pass // check-pass
#![warn(future_prelude_collision)] #![warn(rust_2021_prelude_collisions)]
#![allow(dead_code)] #![allow(dead_code)]
#![allow(unused_imports)] #![allow(unused_imports)]
......
// run-rustfix // run-rustfix
// edition:2018 // edition:2018
// check-pass // check-pass
#![warn(future_prelude_collision)] #![warn(rust_2021_prelude_collisions)]
#![allow(dead_code)] #![allow(dead_code)]
#![allow(unused_imports)] #![allow(unused_imports)]
......
...@@ -7,8 +7,8 @@ LL | let _: u32 = 3u8.try_into().unwrap(); ...@@ -7,8 +7,8 @@ LL | let _: u32 = 3u8.try_into().unwrap();
note: the lint level is defined here note: the lint level is defined here
--> $DIR/future-prelude-collision-imported.rs:4:9 --> $DIR/future-prelude-collision-imported.rs:4:9
| |
LL | #![warn(future_prelude_collision)] LL | #![warn(rust_2021_prelude_collisions)]
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684>
......
// edition:2018 // edition:2018
#![warn(future_prelude_collision)] #![warn(rust_2021_prelude_collisions)]
#![allow(dead_code)] #![allow(dead_code)]
#![allow(unused_imports)] #![allow(unused_imports)]
......
// edition:2018 // edition:2018
// check-pass // check-pass
#![allow(unused)] #![allow(unused)]
#![deny(future_prelude_collision)] #![deny(rust_2021_prelude_collisions)]
struct S; struct S;
impl S { impl S {
fn try_into(self) -> S { S } fn try_into(self) -> S {
S
}
} }
// See https://github.com/rust-lang/rust/issues/86633 // See https://github.com/rust-lang/rust/issues/86633
......
// run-rustfix // run-rustfix
// edition:2018 // edition:2018
// check-pass // check-pass
#![warn(future_prelude_collision)] #![warn(rust_2021_prelude_collisions)]
trait TryIntoU32 { trait TryIntoU32 {
fn try_into(self) -> Result<u32, ()>; fn try_into(self) -> Result<u32, ()>;
......
// run-rustfix // run-rustfix
// edition:2018 // edition:2018
// check-pass // check-pass
#![warn(future_prelude_collision)] #![warn(rust_2021_prelude_collisions)]
trait TryIntoU32 { trait TryIntoU32 {
fn try_into(self) -> Result<u32, ()>; fn try_into(self) -> Result<u32, ()>;
......
...@@ -7,8 +7,8 @@ LL | let _: u32 = 3u8.try_into().unwrap(); ...@@ -7,8 +7,8 @@ LL | let _: u32 = 3u8.try_into().unwrap();
note: the lint level is defined here note: the lint level is defined here
--> $DIR/future-prelude-collision.rs:4:9 --> $DIR/future-prelude-collision.rs:4:9
| |
LL | #![warn(future_prelude_collision)] LL | #![warn(rust_2021_prelude_collisions)]
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684>
......
// check-pass // check-pass
// run-rustfix // run-rustfix
// edition 2018 // edition 2018
#![warn(future_prelude_collision)] #![warn(rust_2021_prelude_collisions)]
trait MyTrait<A> { trait MyTrait<A> {
fn from_iter(x: Option<A>); fn from_iter(x: Option<A>);
......
// check-pass // check-pass
// run-rustfix // run-rustfix
// edition 2018 // edition 2018
#![warn(future_prelude_collision)] #![warn(rust_2021_prelude_collisions)]
trait MyTrait<A> { trait MyTrait<A> {
fn from_iter(x: Option<A>); fn from_iter(x: Option<A>);
......
...@@ -7,8 +7,8 @@ LL | <Vec<i32>>::from_iter(None); ...@@ -7,8 +7,8 @@ LL | <Vec<i32>>::from_iter(None);
note: the lint level is defined here note: the lint level is defined here
--> $DIR/generic-type-collision.rs:4:9 --> $DIR/generic-type-collision.rs:4:9
| |
LL | #![warn(future_prelude_collision)] LL | #![warn(rust_2021_prelude_collisions)]
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// run-rustfix // run-rustfix
// edition:2018 // edition:2018
#![warn(future_prelude_collision)] #![warn(rust_2021_prelude_collisions)]
trait TryIntoU32 { trait TryIntoU32 {
fn try_into(&self) -> Result<u32, ()>; fn try_into(&self) -> Result<u32, ()>;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// run-rustfix // run-rustfix
// edition:2018 // edition:2018
#![warn(future_prelude_collision)] #![warn(rust_2021_prelude_collisions)]
trait TryIntoU32 { trait TryIntoU32 {
fn try_into(&self) -> Result<u32, ()>; fn try_into(&self) -> Result<u32, ()>;
......
...@@ -7,8 +7,8 @@ LL | get_dyn_trait().try_into().unwrap() ...@@ -7,8 +7,8 @@ LL | get_dyn_trait().try_into().unwrap()
note: the lint level is defined here note: the lint level is defined here
--> $DIR/inherent-dyn-collision.rs:8:9 --> $DIR/inherent-dyn-collision.rs:8:9
| |
LL | #![warn(future_prelude_collision)] LL | #![warn(rust_2021_prelude_collisions)]
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684> = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// //
// check-pass // check-pass
#![deny(future_prelude_collision)] #![deny(rust_2021_prelude_collisions)]
pub struct MySeq {} pub struct MySeq {}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// run-rustfix // run-rustfix
// compile-flags: -Z unstable-options --edition 2018 // compile-flags: -Z unstable-options --edition 2018
#![warn(reserved_prefix)] #![warn(rust_2021_prefixes_incompatible_syntax)]
macro_rules! m2 { macro_rules! m2 {
($a:tt $b:tt) => {}; ($a:tt $b:tt) => {};
...@@ -14,16 +14,16 @@ macro_rules! m3 { ...@@ -14,16 +14,16 @@ macro_rules! m3 {
fn main() { fn main() {
m2!(z "hey"); m2!(z "hey");
//~^ WARNING prefix `z` is unknown [reserved_prefix] //~^ WARNING prefix `z` is unknown [rust_2021_prefixes_incompatible_syntax]
//~| WARNING hard error in Rust 2021 //~| WARNING hard error in Rust 2021
m2!(prefix "hey"); m2!(prefix "hey");
//~^ WARNING prefix `prefix` is unknown [reserved_prefix] //~^ WARNING prefix `prefix` is unknown [rust_2021_prefixes_incompatible_syntax]
//~| WARNING hard error in Rust 2021 //~| WARNING hard error in Rust 2021
m3!(hey #123); m3!(hey #123);
//~^ WARNING prefix `hey` is unknown [reserved_prefix] //~^ WARNING prefix `hey` is unknown [rust_2021_prefixes_incompatible_syntax]
//~| WARNING hard error in Rust 2021 //~| WARNING hard error in Rust 2021
m3!(hey #hey); m3!(hey #hey);
//~^ WARNING prefix `hey` is unknown [reserved_prefix] //~^ WARNING prefix `hey` is unknown [rust_2021_prefixes_incompatible_syntax]
//~| WARNING hard error in Rust 2021 //~| WARNING hard error in Rust 2021
} }
...@@ -33,6 +33,6 @@ macro_rules! quote { ...@@ -33,6 +33,6 @@ macro_rules! quote {
quote! { quote! {
#name = #kind #value #name = #kind #value
//~^ WARNING prefix `kind` is unknown [reserved_prefix] //~^ WARNING prefix `kind` is unknown [rust_2021_prefixes_incompatible_syntax]
//~| WARNING hard error in Rust 2021 //~| WARNING hard error in Rust 2021
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// run-rustfix // run-rustfix
// compile-flags: -Z unstable-options --edition 2018 // compile-flags: -Z unstable-options --edition 2018
#![warn(reserved_prefix)] #![warn(rust_2021_prefixes_incompatible_syntax)]
macro_rules! m2 { macro_rules! m2 {
($a:tt $b:tt) => {}; ($a:tt $b:tt) => {};
...@@ -14,16 +14,16 @@ ...@@ -14,16 +14,16 @@
fn main() { fn main() {
m2!(z"hey"); m2!(z"hey");
//~^ WARNING prefix `z` is unknown [reserved_prefix] //~^ WARNING prefix `z` is unknown [rust_2021_prefixes_incompatible_syntax]
//~| WARNING hard error in Rust 2021 //~| WARNING hard error in Rust 2021
m2!(prefix"hey"); m2!(prefix"hey");
//~^ WARNING prefix `prefix` is unknown [reserved_prefix] //~^ WARNING prefix `prefix` is unknown [rust_2021_prefixes_incompatible_syntax]
//~| WARNING hard error in Rust 2021 //~| WARNING hard error in Rust 2021
m3!(hey#123); m3!(hey#123);
//~^ WARNING prefix `hey` is unknown [reserved_prefix] //~^ WARNING prefix `hey` is unknown [rust_2021_prefixes_incompatible_syntax]
//~| WARNING hard error in Rust 2021 //~| WARNING hard error in Rust 2021
m3!(hey#hey); m3!(hey#hey);
//~^ WARNING prefix `hey` is unknown [reserved_prefix] //~^ WARNING prefix `hey` is unknown [rust_2021_prefixes_incompatible_syntax]
//~| WARNING hard error in Rust 2021 //~| WARNING hard error in Rust 2021
} }
...@@ -33,6 +33,6 @@ fn main() { ...@@ -33,6 +33,6 @@ fn main() {
quote! { quote! {
#name = #kind#value #name = #kind#value
//~^ WARNING prefix `kind` is unknown [reserved_prefix] //~^ WARNING prefix `kind` is unknown [rust_2021_prefixes_incompatible_syntax]
//~| WARNING hard error in Rust 2021 //~| WARNING hard error in Rust 2021
} }
...@@ -7,8 +7,8 @@ LL | m2!(z"hey"); ...@@ -7,8 +7,8 @@ LL | m2!(z"hey");
note: the lint level is defined here note: the lint level is defined here
--> $DIR/reserved-prefixes-migration.rs:5:9 --> $DIR/reserved-prefixes-migration.rs:5:9
| |
LL | #![warn(reserved_prefix)] LL | #![warn(rust_2021_prefixes_incompatible_syntax)]
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see issue #84978 <https://github.com/rust-lang/rust/issues/84978> = note: for more information, see issue #84978 <https://github.com/rust-lang/rust/issues/84978>
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021 help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
......
...@@ -592,7 +592,7 @@ Released 2021-02-11 ...@@ -592,7 +592,7 @@ Released 2021-02-11
* Previously deprecated [`str_to_string`] and [`string_to_string`] have been un-deprecated * Previously deprecated [`str_to_string`] and [`string_to_string`] have been un-deprecated
as `restriction` lints [#6333](https://github.com/rust-lang/rust-clippy/pull/6333) as `restriction` lints [#6333](https://github.com/rust-lang/rust-clippy/pull/6333)
* Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panic` * Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panics`
[#6351](https://github.com/rust-lang/rust-clippy/pull/6351) [#6351](https://github.com/rust-lang/rust-clippy/pull/6351)
* Move [`map_err_ignore`] to `restriction` * Move [`map_err_ignore`] to `restriction`
[#6416](https://github.com/rust-lang/rust-clippy/pull/6416) [#6416](https://github.com/rust-lang/rust-clippy/pull/6416)
......
...@@ -2171,7 +2171,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) { ...@@ -2171,7 +2171,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
ls.register_renamed("clippy::unused_label", "unused_labels"); ls.register_renamed("clippy::unused_label", "unused_labels");
ls.register_renamed("clippy::drop_bounds", "drop_bounds"); ls.register_renamed("clippy::drop_bounds", "drop_bounds");
ls.register_renamed("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr"); ls.register_renamed("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr");
ls.register_renamed("clippy::panic_params", "non_fmt_panic"); ls.register_renamed("clippy::panic_params", "non_fmt_panics");
ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints"); ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints");
} }
......
#![allow(non_fmt_panic)] #![allow(non_fmt_panics)]
macro_rules! assert_const { macro_rules! assert_const {
($len:expr) => { ($len:expr) => {
......
...@@ -60,11 +60,11 @@ error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cs ...@@ -60,11 +60,11 @@ error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cs
LL | #[warn(clippy::temporary_cstring_as_ptr)] LL | #[warn(clippy::temporary_cstring_as_ptr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr`
error: lint `clippy::panic_params` has been renamed to `non_fmt_panic` error: lint `clippy::panic_params` has been renamed to `non_fmt_panics`
--> $DIR/deprecated.rs:11:8 --> $DIR/deprecated.rs:11:8
| |
LL | #[warn(clippy::panic_params)] LL | #[warn(clippy::panic_params)]
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panic` | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics`
error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints` error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints`
--> $DIR/deprecated.rs:12:8 --> $DIR/deprecated.rs:12:8
......
...@@ -467,7 +467,9 @@ fn lint_name(line: &str) -> Result<String, &'static str> { ...@@ -467,7 +467,9 @@ fn lint_name(line: &str) -> Result<String, &'static str> {
return Err("lint name should end with comma"); return Err("lint name should end with comma");
} }
let name = &name[..name.len() - 1]; let name = &name[..name.len() - 1];
if !name.chars().all(|ch| ch.is_uppercase() || ch == '_') || name.is_empty() { if !name.chars().all(|ch| ch.is_uppercase() || ch.is_ascii_digit() || ch == '_')
|| name.is_empty()
{
return Err("lint name did not have expected format"); return Err("lint name did not have expected format");
} }
Ok(name.to_lowercase().to_string()) Ok(name.to_lowercase().to_string())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册