mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 21:53:23 +00:00
Auto merge of #8134 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
This commit is contained in:
commit
23d11428de
32 changed files with 144 additions and 161 deletions
|
@ -65,6 +65,7 @@ declare_clippy_lint! {
|
|||
/// ```rust,no_run
|
||||
/// # #![feature(asm)]
|
||||
/// # unsafe { let ptr = "".as_ptr();
|
||||
/// # use std::arch::asm;
|
||||
/// asm!("lea {}, [{}]", lateout(reg) _, in(reg) ptr);
|
||||
/// # }
|
||||
/// ```
|
||||
|
@ -72,6 +73,7 @@ declare_clippy_lint! {
|
|||
/// ```rust,no_run
|
||||
/// # #![feature(asm)]
|
||||
/// # unsafe { let ptr = "".as_ptr();
|
||||
/// # use std::arch::asm;
|
||||
/// asm!("lea ({}), {}", in(reg) ptr, lateout(reg) _, options(att_syntax));
|
||||
/// # }
|
||||
/// ```
|
||||
|
@ -102,6 +104,7 @@ declare_clippy_lint! {
|
|||
/// ```rust,no_run
|
||||
/// # #![feature(asm)]
|
||||
/// # unsafe { let ptr = "".as_ptr();
|
||||
/// # use std::arch::asm;
|
||||
/// asm!("lea ({}), {}", in(reg) ptr, lateout(reg) _, options(att_syntax));
|
||||
/// # }
|
||||
/// ```
|
||||
|
@ -109,6 +112,7 @@ declare_clippy_lint! {
|
|||
/// ```rust,no_run
|
||||
/// # #![feature(asm)]
|
||||
/// # unsafe { let ptr = "".as_ptr();
|
||||
/// # use std::arch::asm;
|
||||
/// asm!("lea {}, [{}]", lateout(reg) _, in(reg) ptr);
|
||||
/// # }
|
||||
/// ```
|
||||
|
|
|
@ -42,7 +42,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
|
|||
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
|
||||
if_chain! {
|
||||
if let ExprKind::MethodCall(count, _, [count_recv], _) = expr.kind;
|
||||
if count.ident.name == sym!(count);
|
||||
if count.ident.name == sym::count;
|
||||
if let ExprKind::MethodCall(filter, _, [filter_recv, filter_arg], _) = count_recv.kind;
|
||||
if filter.ident.name == sym!(filter);
|
||||
if let ExprKind::Closure(_, _, body_id, _, _) = filter_arg.kind;
|
||||
|
|
|
@ -68,8 +68,8 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
|
|||
let mut is_future = false;
|
||||
for &(p, _span) in preds {
|
||||
let p = p.subst(cx.tcx, subst);
|
||||
if let Some(trait_ref) = p.to_opt_poly_trait_ref() {
|
||||
if Some(trait_ref.value.def_id()) == cx.tcx.lang_items().future_trait() {
|
||||
if let Some(trait_pred) = p.to_opt_poly_trait_pred() {
|
||||
if Some(trait_pred.skip_binder().trait_ref.def_id) == cx.tcx.lang_items().future_trait() {
|
||||
is_future = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#![feature(box_patterns)]
|
||||
#![feature(drain_filter)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(once_cell)]
|
||||
#![feature(rustc_private)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
|
|
@ -13,7 +13,6 @@ use clippy_utils::{
|
|||
strip_pat_refs,
|
||||
};
|
||||
use clippy_utils::{paths, search_same, SpanlessEq, SpanlessHash};
|
||||
use core::array;
|
||||
use core::iter::{once, ExactSizeIterator};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::{Attribute, LitKind};
|
||||
|
@ -1314,7 +1313,7 @@ fn check_match_like_matches<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>)
|
|||
return find_matches_sugg(
|
||||
cx,
|
||||
let_expr,
|
||||
array::IntoIter::new([(&[][..], Some(let_pat), if_then, None), (&[][..], None, if_else, None)]),
|
||||
IntoIterator::into_iter([(&[][..], Some(let_pat), if_then, None), (&[][..], None, if_else, None)]),
|
||||
expr,
|
||||
true,
|
||||
);
|
||||
|
|
|
@ -204,7 +204,7 @@ fn parse_iter_usage(
|
|||
match e.kind {
|
||||
ExprKind::Call(
|
||||
Expr {
|
||||
kind: ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, _)),
|
||||
kind: ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, ..)),
|
||||
..
|
||||
},
|
||||
_,
|
||||
|
|
|
@ -155,8 +155,14 @@ fn assignment_suggestions<'tcx>(
|
|||
}
|
||||
|
||||
let suggestions = assignments
|
||||
.into_iter()
|
||||
.map(|assignment| Some((assignment.span, snippet_opt(cx, assignment.rhs_span)?)))
|
||||
.iter()
|
||||
.map(|assignment| Some((assignment.span.until(assignment.rhs_span), String::new())))
|
||||
.chain(assignments.iter().map(|assignment| {
|
||||
Some((
|
||||
assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi()),
|
||||
String::new(),
|
||||
))
|
||||
}))
|
||||
.collect::<Option<Vec<(Span, String)>>>()?;
|
||||
|
||||
let applicability = if suggestions.len() > 1 {
|
||||
|
|
|
@ -105,7 +105,7 @@ fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
|
|||
};
|
||||
if let ExprKind::Match(inner_expr_with_q, _, MatchSource::TryDesugar) = &arg.kind;
|
||||
if let ExprKind::Call(called, [inner_expr]) = &inner_expr_with_q.kind;
|
||||
if let ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, _)) = &called.kind;
|
||||
if let ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, ..)) = &called.kind;
|
||||
if expr.span.ctxt() == inner_expr.span.ctxt();
|
||||
let expr_ty = cx.typeck_results().expr_ty(expr);
|
||||
let inner_ty = cx.typeck_results().expr_ty(inner_expr);
|
||||
|
|
|
@ -15,7 +15,7 @@ use rustc_middle::mir::{
|
|||
Mutability,
|
||||
};
|
||||
use rustc_middle::ty::{self, fold::TypeVisitor, Ty, TyCtxt};
|
||||
use rustc_mir_dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, ResultsCursor};
|
||||
use rustc_mir_dataflow::{Analysis, AnalysisDomain, CallReturnPlaces, GenKill, GenKillAnalysis, ResultsCursor};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::{BytePos, Span};
|
||||
use rustc_span::sym;
|
||||
|
@ -500,11 +500,9 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeStorageLive {
|
|||
|
||||
fn call_return_effect(
|
||||
&self,
|
||||
_in_out: &mut impl GenKill<Self::Idx>,
|
||||
_trans: &mut impl GenKill<Self::Idx>,
|
||||
_block: mir::BasicBlock,
|
||||
_func: &mir::Operand<'tcx>,
|
||||
_args: &[mir::Operand<'tcx>],
|
||||
_return_place: mir::Place<'tcx>,
|
||||
_return_places: CallReturnPlaces<'_, 'tcx>,
|
||||
) {
|
||||
// Nothing to do when a call returns successfully
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ impl<'tcx> LateLintPass<'tcx> for StringLitAsBytes {
|
|||
if method_names[0] == sym!(as_bytes);
|
||||
|
||||
// Check for slicer
|
||||
if let ExprKind::Struct(QPath::LangItem(LangItem::Range, _), _, _) = right.kind;
|
||||
if let ExprKind::Struct(QPath::LangItem(LangItem::Range, ..), _, _) = right.kind;
|
||||
|
||||
then {
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
|
|
|
@ -65,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for TryErr {
|
|||
if let ExprKind::Match(match_arg, _, MatchSource::TryDesugar) = expr.kind;
|
||||
if let ExprKind::Call(match_fun, try_args) = match_arg.kind;
|
||||
if let ExprKind::Path(ref match_fun_path) = match_fun.kind;
|
||||
if matches!(match_fun_path, QPath::LangItem(LangItem::TryTraitBranch, _));
|
||||
if matches!(match_fun_path, QPath::LangItem(LangItem::TryTraitBranch, ..));
|
||||
if let Some(try_arg) = try_args.get(0);
|
||||
if let ExprKind::Call(err_fun, err_args) = try_arg.kind;
|
||||
if let Some(err_arg) = err_args.get(0);
|
||||
|
|
|
@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedIoAmount {
|
|||
if let hir::ExprKind::Call(func, [ref arg_0, ..]) = res.kind {
|
||||
if matches!(
|
||||
func.kind,
|
||||
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::TryTraitBranch, _))
|
||||
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::TryTraitBranch, ..))
|
||||
) {
|
||||
check_map_error(cx, arg_0, expr);
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn qpath(&self, qpath: &Binding<&QPath<'_>>) {
|
||||
if let QPath::LangItem(lang_item, _) = *qpath.value {
|
||||
if let QPath::LangItem(lang_item, ..) = *qpath.value {
|
||||
out!("if matches!({qpath}, QPath::LangItem(LangItem::{lang_item:?}, _));");
|
||||
} else {
|
||||
out!("if match_qpath({qpath}, &[{}]);", path_to_string(qpath.value));
|
||||
|
|
|
@ -218,7 +218,7 @@ impl<'a> Range<'a> {
|
|||
hir::ExprKind::Call(path, args)
|
||||
if matches!(
|
||||
path.kind,
|
||||
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, _))
|
||||
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, ..))
|
||||
) =>
|
||||
{
|
||||
Some(Range {
|
||||
|
@ -228,27 +228,27 @@ impl<'a> Range<'a> {
|
|||
})
|
||||
},
|
||||
hir::ExprKind::Struct(path, fields, None) => match &path {
|
||||
hir::QPath::LangItem(hir::LangItem::RangeFull, _) => Some(Range {
|
||||
hir::QPath::LangItem(hir::LangItem::RangeFull, ..) => Some(Range {
|
||||
start: None,
|
||||
end: None,
|
||||
limits: ast::RangeLimits::HalfOpen,
|
||||
}),
|
||||
hir::QPath::LangItem(hir::LangItem::RangeFrom, _) => Some(Range {
|
||||
hir::QPath::LangItem(hir::LangItem::RangeFrom, ..) => Some(Range {
|
||||
start: Some(get_field("start", fields)?),
|
||||
end: None,
|
||||
limits: ast::RangeLimits::HalfOpen,
|
||||
}),
|
||||
hir::QPath::LangItem(hir::LangItem::Range, _) => Some(Range {
|
||||
hir::QPath::LangItem(hir::LangItem::Range, ..) => Some(Range {
|
||||
start: Some(get_field("start", fields)?),
|
||||
end: Some(get_field("end", fields)?),
|
||||
limits: ast::RangeLimits::HalfOpen,
|
||||
}),
|
||||
hir::QPath::LangItem(hir::LangItem::RangeToInclusive, _) => Some(Range {
|
||||
hir::QPath::LangItem(hir::LangItem::RangeToInclusive, ..) => Some(Range {
|
||||
start: None,
|
||||
end: Some(get_field("end", fields)?),
|
||||
limits: ast::RangeLimits::Closed,
|
||||
}),
|
||||
hir::QPath::LangItem(hir::LangItem::RangeTo, _) => Some(Range {
|
||||
hir::QPath::LangItem(hir::LangItem::RangeTo, ..) => Some(Range {
|
||||
start: None,
|
||||
end: Some(get_field("end", fields)?),
|
||||
limits: ast::RangeLimits::HalfOpen,
|
||||
|
|
|
@ -348,7 +348,7 @@ impl HirEqInterExpr<'_, '_, '_> {
|
|||
(&QPath::TypeRelative(lty, lseg), &QPath::TypeRelative(rty, rseg)) => {
|
||||
self.eq_ty(lty, rty) && self.eq_path_segment(lseg, rseg)
|
||||
},
|
||||
(&QPath::LangItem(llang_item, _), &QPath::LangItem(rlang_item, _)) => llang_item == rlang_item,
|
||||
(&QPath::LangItem(llang_item, ..), &QPath::LangItem(rlang_item, ..)) => llang_item == rlang_item,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#![feature(box_patterns)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(rustc_private)]
|
||||
#![feature(control_flow_enum)]
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[toolchain]
|
||||
channel = "nightly-2021-12-02"
|
||||
channel = "nightly-2021-12-17"
|
||||
components = ["cargo", "llvm-tools-preview", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
// only-x86_64
|
||||
// ignore-aarch64
|
||||
|
||||
#![feature(asm)]
|
||||
|
||||
#[warn(clippy::inline_asm_x86_intel_syntax)]
|
||||
mod warn_intel {
|
||||
pub(super) unsafe fn use_asm() {
|
||||
use std::arch::asm;
|
||||
asm!("");
|
||||
asm!("", options());
|
||||
asm!("", options(nostack));
|
||||
|
@ -17,6 +16,7 @@ mod warn_intel {
|
|||
#[warn(clippy::inline_asm_x86_att_syntax)]
|
||||
mod warn_att {
|
||||
pub(super) unsafe fn use_asm() {
|
||||
use std::arch::asm;
|
||||
asm!("");
|
||||
asm!("", options());
|
||||
asm!("", options(nostack));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: Intel x86 assembly syntax used
|
||||
--> $DIR/asm_syntax.rs:9:9
|
||||
--> $DIR/asm_syntax.rs:8:9
|
||||
|
|
||||
LL | asm!("");
|
||||
| ^^^^^^^^
|
||||
|
@ -8,7 +8,7 @@ LL | asm!("");
|
|||
= help: use AT&T x86 assembly syntax
|
||||
|
||||
error: Intel x86 assembly syntax used
|
||||
--> $DIR/asm_syntax.rs:10:9
|
||||
--> $DIR/asm_syntax.rs:9:9
|
||||
|
|
||||
LL | asm!("", options());
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -16,7 +16,7 @@ LL | asm!("", options());
|
|||
= help: use AT&T x86 assembly syntax
|
||||
|
||||
error: Intel x86 assembly syntax used
|
||||
--> $DIR/asm_syntax.rs:11:9
|
||||
--> $DIR/asm_syntax.rs:10:9
|
||||
|
|
||||
LL | asm!("", options(nostack));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -1,14 +1,3 @@
|
|||
error[E0658]: destructuring assignments are unstable
|
||||
--> $DIR/ice-6250.rs:12:25
|
||||
|
|
||||
LL | Some(reference) = cache.data.get(key) {
|
||||
| --------------- ^
|
||||
| |
|
||||
| cannot assign to this expression
|
||||
|
|
||||
= note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information
|
||||
= help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable
|
||||
|
||||
error[E0601]: `main` function not found in crate `ice_6250`
|
||||
--> $DIR/ice-6250.rs:4:1
|
||||
|
|
||||
|
@ -41,7 +30,7 @@ error[E0308]: mismatched types
|
|||
LL | Some(reference) = cache.data.get(key) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0601, E0658.
|
||||
Some errors have detailed explanations: E0308, E0601.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)]
|
||||
#![warn(clippy::map_entry)]
|
||||
#![feature(asm)]
|
||||
|
||||
use std::arch::asm;
|
||||
use std::collections::HashMap;
|
||||
use std::hash::Hash;
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)]
|
||||
#![warn(clippy::map_entry)]
|
||||
#![feature(asm)]
|
||||
|
||||
use std::arch::asm;
|
||||
use std::collections::HashMap;
|
||||
use std::hash::Hash;
|
||||
|
||||
|
|
|
@ -6,22 +6,22 @@ LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool {
|
|||
|
|
||||
= note: `-D clippy::future-not-send` implied by `-D warnings`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/future_not_send.rs:8:5
|
||||
--> $DIR/future_not_send.rs:8:19
|
||||
|
|
||||
LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool {
|
||||
| -- has type `std::rc::Rc<[u8]>` which is not `Send`
|
||||
LL | async { true }.await
|
||||
| ^^^^^^^^^^^^^^^^^^^^ await occurs here, with `rc` maybe used later
|
||||
| ^^^^^^ await occurs here, with `rc` maybe used later
|
||||
LL | }
|
||||
| - `rc` is later dropped here
|
||||
= note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/future_not_send.rs:8:5
|
||||
--> $DIR/future_not_send.rs:8:19
|
||||
|
|
||||
LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool {
|
||||
| ---- has type `&std::cell::Cell<usize>` which is not `Send`
|
||||
LL | async { true }.await
|
||||
| ^^^^^^^^^^^^^^^^^^^^ await occurs here, with `cell` maybe used later
|
||||
| ^^^^^^ await occurs here, with `cell` maybe used later
|
||||
LL | }
|
||||
| - `cell` is later dropped here
|
||||
= note: `std::cell::Cell<usize>` doesn't implement `std::marker::Sync`
|
||||
|
@ -33,12 +33,12 @@ LL | pub async fn public_future(rc: Rc<[u8]>) {
|
|||
| ^ future returned by `public_future` is not `Send`
|
||||
|
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/future_not_send.rs:12:5
|
||||
--> $DIR/future_not_send.rs:12:19
|
||||
|
|
||||
LL | pub async fn public_future(rc: Rc<[u8]>) {
|
||||
| -- has type `std::rc::Rc<[u8]>` which is not `Send`
|
||||
LL | async { true }.await;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ await occurs here, with `rc` maybe used later
|
||||
| ^^^^^^ await occurs here, with `rc` maybe used later
|
||||
LL | }
|
||||
| - `rc` is later dropped here
|
||||
= note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send`
|
||||
|
@ -82,12 +82,12 @@ LL | async fn private_future(&self) -> usize {
|
|||
| ^^^^^ future returned by `private_future` is not `Send`
|
||||
|
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/future_not_send.rs:35:9
|
||||
--> $DIR/future_not_send.rs:35:23
|
||||
|
|
||||
LL | async fn private_future(&self) -> usize {
|
||||
| ----- has type `&Dummy` which is not `Send`
|
||||
LL | async { true }.await;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ await occurs here, with `&self` maybe used later
|
||||
| ^^^^^^ await occurs here, with `&self` maybe used later
|
||||
LL | self.rc.len()
|
||||
LL | }
|
||||
| - `&self` is later dropped here
|
||||
|
@ -100,12 +100,12 @@ LL | pub async fn public_future(&self) {
|
|||
| ^ future returned by `public_future` is not `Send`
|
||||
|
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/future_not_send.rs:40:9
|
||||
--> $DIR/future_not_send.rs:40:30
|
||||
|
|
||||
LL | pub async fn public_future(&self) {
|
||||
| ----- has type `&Dummy` which is not `Send`
|
||||
LL | self.private_future().await;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs here, with `&self` maybe used later
|
||||
| ^^^^^^ await occurs here, with `&self` maybe used later
|
||||
LL | }
|
||||
| - `&self` is later dropped here
|
||||
= note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync`
|
||||
|
@ -117,12 +117,12 @@ LL | async fn generic_future<T>(t: T) -> T
|
|||
| ^ future returned by `generic_future` is not `Send`
|
||||
|
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/future_not_send.rs:54:5
|
||||
--> $DIR/future_not_send.rs:54:19
|
||||
|
|
||||
LL | let rt = &t;
|
||||
| -- has type `&T` which is not `Send`
|
||||
LL | async { true }.await;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ await occurs here, with `rt` maybe used later
|
||||
| ^^^^^^ await occurs here, with `rt` maybe used later
|
||||
LL | t
|
||||
LL | }
|
||||
| - `rt` is later dropped here
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
// When denying at the crate level, be sure to not get random warnings from the
|
||||
// injected intrinsics by the compiler.
|
||||
#![allow(dead_code)]
|
||||
#![feature(global_asm)]
|
||||
//! Some garbage docs for the crate here
|
||||
#![doc = "More garbage"]
|
||||
|
||||
use std::arch::global_asm;
|
||||
|
||||
type Typedef = String;
|
||||
pub type PubTypedef = String;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: missing documentation for a type alias
|
||||
--> $DIR/missing-doc.rs:9:1
|
||||
--> $DIR/missing-doc.rs:10:1
|
||||
|
|
||||
LL | type Typedef = String;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -7,37 +7,37 @@ LL | type Typedef = String;
|
|||
= note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings`
|
||||
|
||||
error: missing documentation for a type alias
|
||||
--> $DIR/missing-doc.rs:10:1
|
||||
--> $DIR/missing-doc.rs:11:1
|
||||
|
|
||||
LL | pub type PubTypedef = String;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a module
|
||||
--> $DIR/missing-doc.rs:12:1
|
||||
--> $DIR/missing-doc.rs:13:1
|
||||
|
|
||||
LL | mod module_no_dox {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a module
|
||||
--> $DIR/missing-doc.rs:13:1
|
||||
--> $DIR/missing-doc.rs:14:1
|
||||
|
|
||||
LL | pub mod pub_module_no_dox {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a function
|
||||
--> $DIR/missing-doc.rs:17:1
|
||||
--> $DIR/missing-doc.rs:18:1
|
||||
|
|
||||
LL | pub fn foo2() {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a function
|
||||
--> $DIR/missing-doc.rs:18:1
|
||||
--> $DIR/missing-doc.rs:19:1
|
||||
|
|
||||
LL | fn foo3() {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for an enum
|
||||
--> $DIR/missing-doc.rs:32:1
|
||||
--> $DIR/missing-doc.rs:33:1
|
||||
|
|
||||
LL | / enum Baz {
|
||||
LL | | BazA { a: isize, b: isize },
|
||||
|
@ -46,31 +46,31 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: missing documentation for a variant
|
||||
--> $DIR/missing-doc.rs:33:5
|
||||
--> $DIR/missing-doc.rs:34:5
|
||||
|
|
||||
LL | BazA { a: isize, b: isize },
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a struct field
|
||||
--> $DIR/missing-doc.rs:33:12
|
||||
--> $DIR/missing-doc.rs:34:12
|
||||
|
|
||||
LL | BazA { a: isize, b: isize },
|
||||
| ^^^^^^^^
|
||||
|
||||
error: missing documentation for a struct field
|
||||
--> $DIR/missing-doc.rs:33:22
|
||||
--> $DIR/missing-doc.rs:34:22
|
||||
|
|
||||
LL | BazA { a: isize, b: isize },
|
||||
| ^^^^^^^^
|
||||
|
||||
error: missing documentation for a variant
|
||||
--> $DIR/missing-doc.rs:34:5
|
||||
--> $DIR/missing-doc.rs:35:5
|
||||
|
|
||||
LL | BarB,
|
||||
| ^^^^
|
||||
|
||||
error: missing documentation for an enum
|
||||
--> $DIR/missing-doc.rs:37:1
|
||||
--> $DIR/missing-doc.rs:38:1
|
||||
|
|
||||
LL | / pub enum PubBaz {
|
||||
LL | | PubBazA { a: isize },
|
||||
|
@ -78,43 +78,43 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: missing documentation for a variant
|
||||
--> $DIR/missing-doc.rs:38:5
|
||||
--> $DIR/missing-doc.rs:39:5
|
||||
|
|
||||
LL | PubBazA { a: isize },
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a struct field
|
||||
--> $DIR/missing-doc.rs:38:15
|
||||
--> $DIR/missing-doc.rs:39:15
|
||||
|
|
||||
LL | PubBazA { a: isize },
|
||||
| ^^^^^^^^
|
||||
|
||||
error: missing documentation for a constant
|
||||
--> $DIR/missing-doc.rs:58:1
|
||||
--> $DIR/missing-doc.rs:59:1
|
||||
|
|
||||
LL | const FOO: u32 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a constant
|
||||
--> $DIR/missing-doc.rs:65:1
|
||||
--> $DIR/missing-doc.rs:66:1
|
||||
|
|
||||
LL | pub const FOO4: u32 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a static
|
||||
--> $DIR/missing-doc.rs:67:1
|
||||
--> $DIR/missing-doc.rs:68:1
|
||||
|
|
||||
LL | static BAR: u32 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a static
|
||||
--> $DIR/missing-doc.rs:74:1
|
||||
--> $DIR/missing-doc.rs:75:1
|
||||
|
|
||||
LL | pub static BAR4: u32 = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a module
|
||||
--> $DIR/missing-doc.rs:76:1
|
||||
--> $DIR/missing-doc.rs:77:1
|
||||
|
|
||||
LL | / mod internal_impl {
|
||||
LL | | /// dox
|
||||
|
@ -126,31 +126,31 @@ LL | | }
|
|||
| |_^
|
||||
|
||||
error: missing documentation for a function
|
||||
--> $DIR/missing-doc.rs:79:5
|
||||
--> $DIR/missing-doc.rs:80:5
|
||||
|
|
||||
LL | pub fn undocumented1() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a function
|
||||
--> $DIR/missing-doc.rs:80:5
|
||||
--> $DIR/missing-doc.rs:81:5
|
||||
|
|
||||
LL | pub fn undocumented2() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a function
|
||||
--> $DIR/missing-doc.rs:81:5
|
||||
--> $DIR/missing-doc.rs:82:5
|
||||
|
|
||||
LL | fn undocumented3() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a function
|
||||
--> $DIR/missing-doc.rs:86:9
|
||||
--> $DIR/missing-doc.rs:87:9
|
||||
|
|
||||
LL | pub fn also_undocumented1() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a function
|
||||
--> $DIR/missing-doc.rs:87:9
|
||||
--> $DIR/missing-doc.rs:88:9
|
||||
|
|
||||
LL | fn also_undocumented2() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -39,6 +39,19 @@ fn main() {
|
|||
e = format!("{}", c);
|
||||
}
|
||||
|
||||
let f;
|
||||
match 1 {
|
||||
1 => f = "three",
|
||||
_ => return,
|
||||
}; // has semi
|
||||
|
||||
let g: usize;
|
||||
if true {
|
||||
g = 5;
|
||||
} else {
|
||||
panic!();
|
||||
}
|
||||
|
||||
println!("{}", a);
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,43 @@ LL | };
|
|||
| +
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init.rs:50:5
|
||||
--> $DIR/needless_late_init.rs:42:5
|
||||
|
|
||||
LL | let f;
|
||||
| ^^^^^^
|
||||
|
|
||||
help: declare `f` here
|
||||
|
|
||||
LL | let f = match 1 {
|
||||
| +++++++
|
||||
help: remove the assignments from the `match` arms
|
||||
|
|
||||
LL - 1 => f = "three",
|
||||
LL + 1 => "three",
|
||||
|
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init.rs:48:5
|
||||
|
|
||||
LL | let g: usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
help: declare `g` here
|
||||
|
|
||||
LL | let g: usize = if true {
|
||||
| ++++++++++++++
|
||||
help: remove the assignments from the branches
|
||||
|
|
||||
LL - g = 5;
|
||||
LL + 5
|
||||
|
|
||||
help: add a semicolon after the `if` expression
|
||||
|
|
||||
LL | };
|
||||
| +
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init.rs:63:5
|
||||
|
|
||||
LL | let a;
|
||||
| ^^^^^^
|
||||
|
@ -126,7 +162,7 @@ LL | };
|
|||
| +
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init.rs:67:5
|
||||
--> $DIR/needless_late_init.rs:80:5
|
||||
|
|
||||
LL | let a;
|
||||
| ^^^^^^
|
||||
|
@ -146,5 +182,5 @@ help: add a semicolon after the `match` expression
|
|||
LL | };
|
||||
| +
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
|
|
@ -19,19 +19,6 @@ fn main() {
|
|||
e = 2;
|
||||
|
||||
|
||||
let f = match 1 {
|
||||
1 => "three",
|
||||
_ => return,
|
||||
}; // has semi
|
||||
|
||||
|
||||
let g: usize = if true {
|
||||
5
|
||||
} else {
|
||||
panic!();
|
||||
};
|
||||
|
||||
|
||||
let h = format!("{}", e);
|
||||
|
||||
println!("{}", a);
|
||||
|
|
|
@ -18,19 +18,6 @@ fn main() {
|
|||
e = 1;
|
||||
e = 2;
|
||||
|
||||
let f;
|
||||
match 1 {
|
||||
1 => f = "three",
|
||||
_ => return,
|
||||
}; // has semi
|
||||
|
||||
let g: usize;
|
||||
if true {
|
||||
g = 5;
|
||||
} else {
|
||||
panic!();
|
||||
}
|
||||
|
||||
let h;
|
||||
h = format!("{}", e);
|
||||
|
||||
|
|
|
@ -57,40 +57,6 @@ LL | let mut e = 1;
|
|||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init_fixable.rs:21:5
|
||||
|
|
||||
LL | let f;
|
||||
| ^^^^^^
|
||||
|
|
||||
help: declare `f` here
|
||||
|
|
||||
LL | let f = match 1 {
|
||||
| +++++++
|
||||
help: remove the assignments from the `match` arms
|
||||
|
|
||||
LL | 1 => "three",
|
||||
| ~~~~~~~
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init_fixable.rs:27:5
|
||||
|
|
||||
LL | let g: usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
help: declare `g` here
|
||||
|
|
||||
LL | let g: usize = if true {
|
||||
| ++++++++++++++
|
||||
help: remove the assignments from the branches
|
||||
|
|
||||
LL | 5
|
||||
|
|
||||
help: add a semicolon after the `if` expression
|
||||
|
|
||||
LL | };
|
||||
| +
|
||||
|
||||
error: unneeded late initalization
|
||||
--> $DIR/needless_late_init_fixable.rs:34:5
|
||||
|
|
||||
LL | let h;
|
||||
| ^^^^^^
|
||||
|
|
||||
|
@ -99,5 +65,5 @@ help: declare `h` here
|
|||
LL | let h = format!("{}", e);
|
||||
| ~~~~~
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#![warn(clippy::trailing_empty_array)]
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
// Do lint:
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
|
||||
--> $DIR/trailing_empty_array.rs:6:1
|
||||
--> $DIR/trailing_empty_array.rs:5:1
|
||||
|
|
||||
LL | / struct RarelyUseful {
|
||||
LL | | field: i32,
|
||||
|
@ -11,7 +11,7 @@ LL | | }
|
|||
= help: consider annotating `RarelyUseful` with `#[repr(C)]` or another `repr` attribute
|
||||
|
||||
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
|
||||
--> $DIR/trailing_empty_array.rs:11:1
|
||||
--> $DIR/trailing_empty_array.rs:10:1
|
||||
|
|
||||
LL | / struct OnlyField {
|
||||
LL | | first_and_last: [usize; 0],
|
||||
|
@ -21,7 +21,7 @@ LL | | }
|
|||
= help: consider annotating `OnlyField` with `#[repr(C)]` or another `repr` attribute
|
||||
|
||||
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
|
||||
--> $DIR/trailing_empty_array.rs:15:1
|
||||
--> $DIR/trailing_empty_array.rs:14:1
|
||||
|
|
||||
LL | / struct GenericArrayType<T> {
|
||||
LL | | field: i32,
|
||||
|
@ -32,7 +32,7 @@ LL | | }
|
|||
= help: consider annotating `GenericArrayType` with `#[repr(C)]` or another `repr` attribute
|
||||
|
||||
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
|
||||
--> $DIR/trailing_empty_array.rs:21:1
|
||||
--> $DIR/trailing_empty_array.rs:20:1
|
||||
|
|
||||
LL | / struct OnlyAnotherAttribute {
|
||||
LL | | field: i32,
|
||||
|
@ -43,7 +43,7 @@ LL | | }
|
|||
= help: consider annotating `OnlyAnotherAttribute` with `#[repr(C)]` or another `repr` attribute
|
||||
|
||||
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
|
||||
--> $DIR/trailing_empty_array.rs:27:1
|
||||
--> $DIR/trailing_empty_array.rs:26:1
|
||||
|
|
||||
LL | / struct OnlyADeriveAttribute {
|
||||
LL | | field: i32,
|
||||
|
@ -54,7 +54,7 @@ LL | | }
|
|||
= help: consider annotating `OnlyADeriveAttribute` with `#[repr(C)]` or another `repr` attribute
|
||||
|
||||
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
|
||||
--> $DIR/trailing_empty_array.rs:33:1
|
||||
--> $DIR/trailing_empty_array.rs:32:1
|
||||
|
|
||||
LL | / struct ZeroSizedWithConst {
|
||||
LL | | field: i32,
|
||||
|
@ -65,7 +65,7 @@ LL | | }
|
|||
= help: consider annotating `ZeroSizedWithConst` with `#[repr(C)]` or another `repr` attribute
|
||||
|
||||
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
|
||||
--> $DIR/trailing_empty_array.rs:42:1
|
||||
--> $DIR/trailing_empty_array.rs:41:1
|
||||
|
|
||||
LL | / struct ZeroSizedWithConstFunction {
|
||||
LL | | field: i32,
|
||||
|
@ -76,7 +76,7 @@ LL | | }
|
|||
= help: consider annotating `ZeroSizedWithConstFunction` with `#[repr(C)]` or another `repr` attribute
|
||||
|
||||
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
|
||||
--> $DIR/trailing_empty_array.rs:50:1
|
||||
--> $DIR/trailing_empty_array.rs:49:1
|
||||
|
|
||||
LL | / struct ZeroSizedWithConstFunction2 {
|
||||
LL | | field: i32,
|
||||
|
@ -87,7 +87,7 @@ LL | | }
|
|||
= help: consider annotating `ZeroSizedWithConstFunction2` with `#[repr(C)]` or another `repr` attribute
|
||||
|
||||
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
|
||||
--> $DIR/trailing_empty_array.rs:55:1
|
||||
--> $DIR/trailing_empty_array.rs:54:1
|
||||
|
|
||||
LL | struct ZeroSizedArrayWrapper([usize; 0]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -95,7 +95,7 @@ LL | struct ZeroSizedArrayWrapper([usize; 0]);
|
|||
= help: consider annotating `ZeroSizedArrayWrapper` with `#[repr(C)]` or another `repr` attribute
|
||||
|
||||
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
|
||||
--> $DIR/trailing_empty_array.rs:57:1
|
||||
--> $DIR/trailing_empty_array.rs:56:1
|
||||
|
|
||||
LL | struct TupleStruct(i32, [usize; 0]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -103,7 +103,7 @@ LL | struct TupleStruct(i32, [usize; 0]);
|
|||
= help: consider annotating `TupleStruct` with `#[repr(C)]` or another `repr` attribute
|
||||
|
||||
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
|
||||
--> $DIR/trailing_empty_array.rs:59:1
|
||||
--> $DIR/trailing_empty_array.rs:58:1
|
||||
|
|
||||
LL | / struct LotsOfFields {
|
||||
LL | | f1: u32,
|
||||
|
|
Loading…
Reference in a new issue