mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Do not lint main function in must_use_candidates
Marking the `main` function as `#[must_use]` is nonsensical, as it is not really supposed to be called anyway.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
use clippy_utils::source::snippet_indent;
|
||||
use clippy_utils::ty::is_must_use_ty;
|
||||
use clippy_utils::visitors::for_each_expr_without_closures;
|
||||
use clippy_utils::{return_ty, trait_ref_of_method};
|
||||
use clippy_utils::{is_entrypoint_fn, return_ty, trait_ref_of_method};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::find_attr;
|
||||
use rustc_span::Symbol;
|
||||
@@ -211,6 +211,7 @@ fn check_must_use_candidate<'tcx>(
|
||||
|| !cx.effective_visibilities.is_exported(item_id.def_id)
|
||||
|| is_must_use_ty(cx, return_ty(cx, item_id))
|
||||
|| item_span.from_expansion()
|
||||
|| is_entrypoint_fn(cx, item_id.def_id.to_def_id())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ pub extern "C" fn unmangled(i: bool) -> bool {
|
||||
!i
|
||||
}
|
||||
|
||||
fn main() {
|
||||
pub fn main() -> std::process::ExitCode {
|
||||
assert_eq!(1, pure(1));
|
||||
std::process::ExitCode::SUCCESS
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ pub extern "C" fn unmangled(i: bool) -> bool {
|
||||
!i
|
||||
}
|
||||
|
||||
fn main() {
|
||||
pub fn main() -> std::process::ExitCode {
|
||||
assert_eq!(1, pure(1));
|
||||
std::process::ExitCode::SUCCESS
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user