about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-06-07 12:55:08 +0000
committerbors <bors@rust-lang.org>2020-06-07 12:55:08 +0000
commit67ec96c8f97ae810f72ccc08c8bf0c371ff11305 (patch)
tree70d219f25692cbf37078482832a03e905461fe8a
parent5699672b5b69e829a8a51fc339e65f8c057bdf9e (diff)
parentd9aa26a14dca32e0c4f2718ad1d3322f0de1674d (diff)
downloadrust-67ec96c8f97ae810f72ccc08c8bf0c371ff11305.tar.gz
rust-67ec96c8f97ae810f72ccc08c8bf0c371ff11305.zip
Auto merge of #5691 - flip1995:rustup, r=matthiaskrgr
Rustup

changelog: none
-rw-r--r--.github/workflows/clippy_bors.yml3
-rw-r--r--clippy_lints/src/future_not_send.rs2
-rw-r--r--clippy_lints/src/lib.rs4
-rw-r--r--clippy_lints/src/utils/mod.rs5
-rw-r--r--clippy_lints/src/write.rs2
-rw-r--r--tests/ui/or_fun_call.fixed4
-rw-r--r--tests/ui/or_fun_call.stderr18
7 files changed, 28 insertions, 10 deletions
diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml
index 3958ba01246..0c80394f03e 100644
--- a/.github/workflows/clippy_bors.yml
+++ b/.github/workflows/clippy_bors.yml
@@ -232,7 +232,8 @@ jobs:
       matrix:
         integration:
         - 'rust-lang/cargo'
-        - 'rust-lang/rls'
+        # FIXME: re-enable once fmt_macros is renamed in RLS
+        # - 'rust-lang/rls'
         - 'rust-lang/chalk'
         - 'rust-lang/rustfmt'
         - 'Marwes/combine'
diff --git a/clippy_lints/src/future_not_send.rs b/clippy_lints/src/future_not_send.rs
index 0a02aa7533c..17dd3cd5493 100644
--- a/clippy_lints/src/future_not_send.rs
+++ b/clippy_lints/src/future_not_send.rs
@@ -95,7 +95,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FutureNotSend {
                                         let trait_ref = trait_pred.to_poly_trait_ref();
                                         db.note(&*format!(
                                             "`{}` doesn't implement `{}`",
-                                            trait_ref.self_ty(),
+                                            trait_ref.skip_binder().self_ty(),
                                             trait_ref.print_only_trait_path(),
                                         ));
                                     }
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 7e9a52fe69f..6f8923b2660 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -16,8 +16,6 @@
 // FIXME: switch to something more ergonomic here, once available.
 // (Currently there is no way to opt into sysroot crates without `extern crate`.)
 #[allow(unused_extern_crates)]
-extern crate fmt_macros;
-#[allow(unused_extern_crates)]
 extern crate rustc_ast;
 #[allow(unused_extern_crates)]
 extern crate rustc_ast_pretty;
@@ -48,6 +46,8 @@ extern crate rustc_mir;
 #[allow(unused_extern_crates)]
 extern crate rustc_parse;
 #[allow(unused_extern_crates)]
+extern crate rustc_parse_format;
+#[allow(unused_extern_crates)]
 extern crate rustc_session;
 #[allow(unused_extern_crates)]
 extern crate rustc_span;
diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs
index 9a6750c51ab..06638e7187b 100644
--- a/clippy_lints/src/utils/mod.rs
+++ b/clippy_lints/src/utils/mod.rs
@@ -325,6 +325,11 @@ pub fn implements_trait<'a, 'tcx>(
     trait_id: DefId,
     ty_params: &[GenericArg<'tcx>],
 ) -> 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());
     cx.tcx.type_implements_trait((trait_id, ty, ty_params, cx.param_env))
 }
diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs
index 22ce484b24e..732f4b28e06 100644
--- a/clippy_lints/src/write.rs
+++ b/clippy_lints/src/write.rs
@@ -369,7 +369,7 @@ impl Write {
         tts: &TokenStream,
         is_write: bool,
     ) -> (Option<StrLit>, Option<Expr>) {
-        use fmt_macros::{
+        use rustc_parse_format::{
             AlignUnknown, ArgumentImplicitlyIs, ArgumentIs, ArgumentNamed, CountImplied, FormatSpec, ParseMode, Parser,
             Piece,
         };
diff --git a/tests/ui/or_fun_call.fixed b/tests/ui/or_fun_call.fixed
index 7bb08797ef3..2045ffdb5f0 100644
--- a/tests/ui/or_fun_call.fixed
+++ b/tests/ui/or_fun_call.fixed
@@ -29,7 +29,7 @@ fn or_fun_call() {
     with_enum.unwrap_or(Enum::A(5));
 
     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]);
     with_constructor.unwrap_or_else(make);
@@ -94,7 +94,7 @@ fn test_or_with_ctors() {
 
     let b = "b".to_string();
     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 _ = opt.ok_or(vec.len());
diff --git a/tests/ui/or_fun_call.stderr b/tests/ui/or_fun_call.stderr
index 96d55771e6c..bc5978b538f 100644
--- a/tests/ui/or_fun_call.stderr
+++ b/tests/ui/or_fun_call.stderr
@@ -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
   --> $DIR/or_fun_call.rs:35:22
    |
 LL |     with_constructor.unwrap_or(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`
   --> $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()));
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^ 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