Warn,
"detects name collision with an existing but unstable method",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::Custom(
+ "once this associated item is added to the standard library, \
+ the ambiguity may cause an error or change in behavior!"
+ ),
reference: "issue #48919 <https://github.com/rust-lang/rust/issues/48919>",
// Note: this item represents future incompatibility of all unstable functions in the
// standard library, and thus should never be removed or changed to an error.
///
/// ### Example
///
- /// ```
+ /// ```rust
/// if let _ = 123 {
/// println!("always runs!");
/// }
Warn,
"reservation of a two-phased borrow conflicts with other shared borrows",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::Custom(
+ "this borrowing pattern was not meant to be accepted, \
+ and may become a hard error in the future"
+ ),
reference: "issue #59159 <https://github.com/rust-lang/rust/issues/59159>",
};
}
/// }
/// ```
///
- /// {{produces}}
+ /// This will produce:
+ ///
+ /// ```text
+ /// warning: formatting may not be suitable for sub-register argument
+ /// --> src/main.rs:7:19
+ /// |
+ /// 7 | asm!("mov {0}, {0}", in(reg) 0i16);
+ /// | ^^^ ^^^ ---- for this argument
+ /// |
+ /// = note: `#[warn(asm_sub_register)]` on by default
+ /// = help: use the `x` modifier to have the register formatted as `ax`
+ /// = help: or use the `r` modifier to keep the default formatting of `rax`
+ /// ```
///
/// ### Explanation
///
/// }
/// ```
///
- /// {{produces}}
+ /// This will produce:
+ ///
+ /// ```text
+ /// warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
+ /// --> src/main.rs:8:14
+ /// |
+ /// 8 | ".att_syntax",
+ /// | ^^^^^^^^^^^
+ /// |
+ /// = note: `#[warn(bad_asm_style)]` on by default
+ /// ```
///
/// ### Explanation
///
"undefined naked function ABI"
}
-declare_lint! {
- /// The `unsupported_naked_functions` lint detects naked function
- /// definitions that are unsupported but were previously accepted.
- ///
- /// ### Example
- ///
- /// ```rust
- /// #![feature(naked_functions)]
- ///
- /// #[naked]
- /// pub extern "C" fn f() -> u32 {
- /// 42
- /// }
- /// ```
- ///
- /// {{produces}}
- ///
- /// ### Explanation
- ///
- /// The naked functions must be defined using a single inline assembly
- /// block.
- ///
- /// The execution must never fall through past the end of the assembly
- /// code so the block must use `noreturn` option. The asm block can also
- /// use `att_syntax` option, but other options are not allowed.
- ///
- /// The asm block must not contain any operands other than `const` and
- /// `sym`. Additionally, naked function should specify a non-Rust ABI.
- ///
- /// Naked functions cannot be inlined. All forms of the `inline` attribute
- /// are prohibited.
- ///
- /// While other definitions of naked functions were previously accepted,
- /// they are unsupported and might not work reliably. This is a
- /// [future-incompatible] lint that will transition into hard error in
- /// the future.
- ///
- /// [future-incompatible]: ../index.md#future-incompatible-lints
- pub UNSUPPORTED_NAKED_FUNCTIONS,
- Warn,
- "unsupported naked function definitions",
- @future_incompatible = FutureIncompatibleInfo {
- reference: "issue #32408 <https://github.com/rust-lang/rust/issues/32408>",
- };
-}
-
declare_lint! {
/// The `ineffective_unstable_trait_impl` lint detects `#[unstable]` attributes which are not used.
///
/// ### Example
///
- /// ```compile_fail
+ /// ```rust,compile_fail
/// #![feature(staged_api)]
///
/// #[derive(Clone)]
};
}
+declare_lint! {
+ /// The `unexpected_cfgs` lint detects unexpected conditional compilation conditions.
+ ///
+ /// ### Example
+ ///
+ /// ```text
+ /// rustc --check-cfg 'names()'
+ /// ```
+ ///
+ /// ```rust,ignore (needs command line option)
+ /// #[cfg(widnows)]
+ /// fn foo() {}
+ /// ```
+ ///
+ /// This will produce:
+ ///
+ /// ```text
+ /// warning: unknown condition name used
+ /// --> lint_example.rs:1:7
+ /// |
+ /// 1 | #[cfg(widnows)]
+ /// | ^^^^^^^
+ /// |
+ /// = note: `#[warn(unexpected_cfgs)]` on by default
+ /// ```
+ ///
+ /// ### Explanation
+ ///
+ /// This lint is only active when a `--check-cfg='names(...)'` option has been passed
+ /// to the compiler and triggers whenever an unknown condition name or value is used.
+ /// The known condition include names or values passed in `--check-cfg`, `--cfg`, and some
+ /// well-knows names and values built into the compiler.
+ pub UNEXPECTED_CFGS,
+ Warn,
+ "detects unexpected names and values in `#[cfg]` conditions",
+}
+
declare_lint_pass! {
/// Does nothing as a lint pass, but registers some `Lint`s
/// that are used by other parts of the compiler.
UNINHABITED_STATIC,
FUNCTION_ITEM_REFERENCES,
USELESS_DEPRECATED,
- UNSUPPORTED_NAKED_FUNCTIONS,
MISSING_ABI,
INVALID_DOC_ATTRIBUTES,
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
DEREF_INTO_DYN_SUPERTRAIT,
DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
DUPLICATE_MACRO_ATTRIBUTES,
+ SUSPICIOUS_AUTO_TRAIT_IMPLS,
+ UNEXPECTED_CFGS,
]
}
/// fn foo() {}
/// ```
///
- /// {{produces}}
+ /// This will produce:
+ ///
+ /// ```text
+ /// warning: duplicated attribute
+ /// --> src/lib.rs:2:1
+ /// |
+ /// 2 | #[test]
+ /// | ^^^^^^^
+ /// |
+ /// = note: `#[warn(duplicate_macro_attributes)]` on by default
+ /// ```
///
/// ### Explanation
///
Warn,
"duplicated attribute"
}
+
+declare_lint! {
+ /// The `suspicious_auto_trait_impls` lint checks for potentially incorrect
+ /// implementations of auto traits.
+ ///
+ /// ### Example
+ ///
+ /// ```rust
+ /// struct Foo<T>(T);
+ ///
+ /// unsafe impl<T> Send for Foo<*const T> {}
+ /// ```
+ ///
+ /// {{produces}}
+ ///
+ /// ### Explanation
+ ///
+ /// A type can implement auto traits, e.g. `Send`, `Sync` and `Unpin`,
+ /// in two different ways: either by writing an explicit impl or if
+ /// all fields of the type implement that auto trait.
+ ///
+ /// The compiler disables the automatic implementation if an explicit one
+ /// exists for given type constructor. The exact rules governing this
+ /// are currently unsound and quite subtle and and will be modified in the future.
+ /// This change will cause the automatic implementation to be disabled in more
+ /// cases, potentially breaking some code.
+ pub SUSPICIOUS_AUTO_TRAIT_IMPLS,
+ Warn,
+ "the rules governing auto traits will change in the future",
+ @future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange,
+ reference: "issue #93367 <https://github.com/rust-lang/rust/issues/93367>",
+ };
+}