mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Auto merge of #5691 - flip1995:rustup, r=matthiaskrgr
Rustup changelog: none
This commit is contained in:
commit
67ec96c8f9
7 changed files with 28 additions and 10 deletions
3
.github/workflows/clippy_bors.yml
vendored
3
.github/workflows/clippy_bors.yml
vendored
|
@ -232,7 +232,8 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
integration:
|
integration:
|
||||||
- 'rust-lang/cargo'
|
- 'rust-lang/cargo'
|
||||||
- 'rust-lang/rls'
|
# FIXME: re-enable once fmt_macros is renamed in RLS
|
||||||
|
# - 'rust-lang/rls'
|
||||||
- 'rust-lang/chalk'
|
- 'rust-lang/chalk'
|
||||||
- 'rust-lang/rustfmt'
|
- 'rust-lang/rustfmt'
|
||||||
- 'Marwes/combine'
|
- 'Marwes/combine'
|
||||||
|
|
|
@ -95,7 +95,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FutureNotSend {
|
||||||
let trait_ref = trait_pred.to_poly_trait_ref();
|
let trait_ref = trait_pred.to_poly_trait_ref();
|
||||||
db.note(&*format!(
|
db.note(&*format!(
|
||||||
"`{}` doesn't implement `{}`",
|
"`{}` doesn't implement `{}`",
|
||||||
trait_ref.self_ty(),
|
trait_ref.skip_binder().self_ty(),
|
||||||
trait_ref.print_only_trait_path(),
|
trait_ref.print_only_trait_path(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
// FIXME: switch to something more ergonomic here, once available.
|
// FIXME: switch to something more ergonomic here, once available.
|
||||||
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
|
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
|
||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
extern crate fmt_macros;
|
|
||||||
#[allow(unused_extern_crates)]
|
|
||||||
extern crate rustc_ast;
|
extern crate rustc_ast;
|
||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
extern crate rustc_ast_pretty;
|
extern crate rustc_ast_pretty;
|
||||||
|
@ -48,6 +46,8 @@ extern crate rustc_mir;
|
||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
extern crate rustc_parse;
|
extern crate rustc_parse;
|
||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
|
extern crate rustc_parse_format;
|
||||||
|
#[allow(unused_extern_crates)]
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
extern crate rustc_span;
|
extern crate rustc_span;
|
||||||
|
|
|
@ -325,6 +325,11 @@ pub fn implements_trait<'a, 'tcx>(
|
||||||
trait_id: DefId,
|
trait_id: DefId,
|
||||||
ty_params: &[GenericArg<'tcx>],
|
ty_params: &[GenericArg<'tcx>],
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
// Do not check on infer_types to avoid panic in evaluate_obligation.
|
||||||
|
if ty.has_infer_types() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let ty = cx.tcx.erase_regions(&ty);
|
||||||
let ty_params = cx.tcx.mk_substs(ty_params.iter());
|
let ty_params = cx.tcx.mk_substs(ty_params.iter());
|
||||||
cx.tcx.type_implements_trait((trait_id, ty, ty_params, cx.param_env))
|
cx.tcx.type_implements_trait((trait_id, ty, ty_params, cx.param_env))
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,7 +369,7 @@ impl Write {
|
||||||
tts: &TokenStream,
|
tts: &TokenStream,
|
||||||
is_write: bool,
|
is_write: bool,
|
||||||
) -> (Option<StrLit>, Option<Expr>) {
|
) -> (Option<StrLit>, Option<Expr>) {
|
||||||
use fmt_macros::{
|
use rustc_parse_format::{
|
||||||
AlignUnknown, ArgumentImplicitlyIs, ArgumentIs, ArgumentNamed, CountImplied, FormatSpec, ParseMode, Parser,
|
AlignUnknown, ArgumentImplicitlyIs, ArgumentIs, ArgumentNamed, CountImplied, FormatSpec, ParseMode, Parser,
|
||||||
Piece,
|
Piece,
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@ fn or_fun_call() {
|
||||||
with_enum.unwrap_or(Enum::A(5));
|
with_enum.unwrap_or(Enum::A(5));
|
||||||
|
|
||||||
let with_const_fn = Some(Duration::from_secs(1));
|
let with_const_fn = Some(Duration::from_secs(1));
|
||||||
with_const_fn.unwrap_or(Duration::from_secs(5));
|
with_const_fn.unwrap_or_else(|| Duration::from_secs(5));
|
||||||
|
|
||||||
let with_constructor = Some(vec![1]);
|
let with_constructor = Some(vec![1]);
|
||||||
with_constructor.unwrap_or_else(make);
|
with_constructor.unwrap_or_else(make);
|
||||||
|
@ -94,7 +94,7 @@ fn test_or_with_ctors() {
|
||||||
|
|
||||||
let b = "b".to_string();
|
let b = "b".to_string();
|
||||||
let _ = Some(Bar("a".to_string(), Duration::from_secs(1)))
|
let _ = Some(Bar("a".to_string(), Duration::from_secs(1)))
|
||||||
.or(Some(Bar(b, Duration::from_secs(2))));
|
.or_else(|| Some(Bar(b, Duration::from_secs(2))));
|
||||||
|
|
||||||
let vec = vec!["foo"];
|
let vec = vec!["foo"];
|
||||||
let _ = opt.ok_or(vec.len());
|
let _ = opt.ok_or(vec.len());
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
|
error: use of `unwrap_or` followed by a function call
|
||||||
|
--> $DIR/or_fun_call.rs:32:19
|
||||||
|
|
|
||||||
|
LL | with_const_fn.unwrap_or(Duration::from_secs(5));
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Duration::from_secs(5))`
|
||||||
|
|
|
||||||
|
= note: `-D clippy::or-fun-call` implied by `-D warnings`
|
||||||
|
|
||||||
error: use of `unwrap_or` followed by a function call
|
error: use of `unwrap_or` followed by a function call
|
||||||
--> $DIR/or_fun_call.rs:35:22
|
--> $DIR/or_fun_call.rs:35:22
|
||||||
|
|
|
|
||||||
LL | with_constructor.unwrap_or(make());
|
LL | with_constructor.unwrap_or(make());
|
||||||
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
|
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
|
||||||
|
|
|
||||||
= note: `-D clippy::or-fun-call` implied by `-D warnings`
|
|
||||||
|
|
||||||
error: use of `unwrap_or` followed by a call to `new`
|
error: use of `unwrap_or` followed by a call to `new`
|
||||||
--> $DIR/or_fun_call.rs:38:5
|
--> $DIR/or_fun_call.rs:38:5
|
||||||
|
@ -78,5 +84,11 @@ error: use of `or` followed by a function call
|
||||||
LL | let _ = Some("a".to_string()).or(Some("b".to_string()));
|
LL | let _ = Some("a".to_string()).or(Some("b".to_string()));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some("b".to_string()))`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some("b".to_string()))`
|
||||||
|
|
||||||
error: aborting due to 13 previous errors
|
error: use of `or` followed by a function call
|
||||||
|
--> $DIR/or_fun_call.rs:97:10
|
||||||
|
|
|
||||||
|
LL | .or(Some(Bar(b, Duration::from_secs(2))));
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some(Bar(b, Duration::from_secs(2))))`
|
||||||
|
|
||||||
|
error: aborting due to 15 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue