about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-05-23 14:22:25 +0000
committerbors <bors@rust-lang.org>2020-05-23 14:22:25 +0000
commit02c25b359e667d2eba0da4d9e75408d675b7a4d5 (patch)
treeef2245fe4d7b10975abaad601c5684c05ec08dea
parent0f0d70055530bdbf3f0acb7b8ad25aa4a6ad8ea9 (diff)
parent9021f241691751a2d66165763b506eb1638cbfa9 (diff)
downloadrust-02c25b359e667d2eba0da4d9e75408d675b7a4d5.tar.gz
rust-02c25b359e667d2eba0da4d9e75408d675b7a4d5.zip
Auto merge of #72468 - Elinvynia:backport, r=Mark-Simulacrum
[beta] Rollup backports

This includes:
* Fail if I/O error occurs during testing #72089
* Fix hang in lexical_region_resolve #72087
* Fix E0284 to not use incorrect wording #71960
* Bump pulldown-cmark #71682
-rw-r--r--Cargo.lock8
-rw-r--r--src/librustc_infer/infer/lexical_region_resolve/mod.rs20
-rw-r--r--src/librustc_trait_selection/traits/error_reporting/mod.rs20
-rw-r--r--src/test/ui/associated-types/associated-types-overridden-binding.stderr12
-rw-r--r--src/test/ui/issues/issue-12028.stderr6
-rw-r--r--src/test/ui/issues/issue-69455.rs30
-rw-r--r--src/test/ui/issues/issue-69455.stderr9
-rw-r--r--src/test/ui/issues/issue-69683.rs32
-rw-r--r--src/test/ui/issues/issue-69683.stderr9
-rw-r--r--src/test/ui/issues/issue-71584.rs5
-rw-r--r--src/test/ui/issues/issue-71584.stderr9
-rw-r--r--src/test/ui/regions/issue-72051-member-region-hang.rs7
-rw-r--r--src/tools/compiletest/src/main.rs5
13 files changed, 148 insertions, 24 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 85a94b4f599..3456b65e190 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -487,7 +487,7 @@ dependencies = [
  "if_chain",
  "itertools 0.9.0",
  "lazy_static 1.4.0",
- "pulldown-cmark 0.7.0",
+ "pulldown-cmark 0.7.1",
  "quine-mc_cluskey",
  "regex-syntax",
  "semver",
@@ -2657,9 +2657,9 @@ dependencies = [
 
 [[package]]
 name = "pulldown-cmark"
-version = "0.7.0"
+version = "0.7.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c2d7fd131800e0d63df52aff46201acaab70b431a4a1ec6f0343fe8e64f35a4"
+checksum = "3e142c3b8f49d2200605ee6ba0b1d757310e9e7a72afe78c36ee2ef67300ee00"
 dependencies = [
  "bitflags",
  "memchr",
@@ -4355,7 +4355,7 @@ version = "0.0.0"
 dependencies = [
  "itertools 0.8.0",
  "minifier",
- "pulldown-cmark 0.7.0",
+ "pulldown-cmark 0.7.1",
  "rustc-rayon",
  "serde",
  "serde_json",
diff --git a/src/librustc_infer/infer/lexical_region_resolve/mod.rs b/src/librustc_infer/infer/lexical_region_resolve/mod.rs
index c8d35774978..6954a9bc977 100644
--- a/src/librustc_infer/infer/lexical_region_resolve/mod.rs
+++ b/src/librustc_infer/infer/lexical_region_resolve/mod.rs
@@ -325,8 +325,21 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
             }
         }
 
-        debug!("enforce_member_constraint: final least choice = {:?}", least_choice);
-        if least_choice != member_lower_bound {
+        // (#72087) Different `ty::Regions` can be known to be equal, for
+        // example, we know that `'a` and `'static` are equal in a function
+        // with a parameter of type `&'static &'a ()`.
+        //
+        // When we have two equal regions like this `expansion` will use
+        // `lub_concrete_regions` to pick a canonical representative. The same
+        // choice is needed here so that we don't end up in a cycle of
+        // `expansion` changing the region one way and the code here changing
+        // it back.
+        let lub = self.lub_concrete_regions(least_choice, member_lower_bound);
+        debug!(
+            "enforce_member_constraint: final least choice = {:?}\nlub = {:?}",
+            least_choice, lub
+        );
+        if lub != member_lower_bound {
             *var_values.value_mut(member_vid) = VarValue::Value(least_choice);
             true
         } else {
@@ -578,8 +591,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
                 self.tcx().mk_region(ReScope(lub))
             }
 
-            (&ReEarlyBound(_), &ReEarlyBound(_) | &ReFree(_))
-            | (&ReFree(_), &ReEarlyBound(_) | &ReFree(_)) => {
+            (&ReEarlyBound(_) | &ReFree(_), &ReEarlyBound(_) | &ReFree(_)) => {
                 self.region_rels.lub_free_regions(a, b)
             }
 
diff --git a/src/librustc_trait_selection/traits/error_reporting/mod.rs b/src/librustc_trait_selection/traits/error_reporting/mod.rs
index 74cf06d5468..cdb410a1017 100644
--- a/src/librustc_trait_selection/traits/error_reporting/mod.rs
+++ b/src/librustc_trait_selection/traits/error_reporting/mod.rs
@@ -1482,12 +1482,26 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
             ty::Predicate::Projection(ref data) => {
                 let trait_ref = data.to_poly_trait_ref(self.tcx);
                 let self_ty = trait_ref.self_ty();
+                let ty = data.skip_binder().ty;
                 if predicate.references_error() {
                     return;
                 }
-                let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0284);
-                err.note(&format!("cannot satisfy `{}`", predicate));
-                err
+                if self_ty.needs_infer() && ty.needs_infer() {
+                    // We do this for the `foo.collect()?` case to produce a suggestion.
+                    let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0284);
+                    err.note(&format!("cannot satisfy `{}`", predicate));
+                    err
+                } else {
+                    let mut err = struct_span_err!(
+                        self.tcx.sess,
+                        span,
+                        E0284,
+                        "type annotations needed: cannot satisfy `{}`",
+                        predicate,
+                    );
+                    err.span_label(span, &format!("cannot satisfy `{}`", predicate));
+                    err
+                }
             }
 
             _ => {
diff --git a/src/test/ui/associated-types/associated-types-overridden-binding.stderr b/src/test/ui/associated-types/associated-types-overridden-binding.stderr
index 3aed85645ae..b8321ce5b25 100644
--- a/src/test/ui/associated-types/associated-types-overridden-binding.stderr
+++ b/src/test/ui/associated-types/associated-types-overridden-binding.stderr
@@ -1,22 +1,18 @@
-error[E0284]: type annotations needed
+error[E0284]: type annotations needed: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
   --> $DIR/associated-types-overridden-binding.rs:4:12
    |
 LL | trait Foo: Iterator<Item = i32> {}
    |                     ---------- required by this bound in `Foo`
 LL | trait Bar: Foo<Item = u32> {}
-   |            ^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
-   |
-   = note: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
+   |            ^^^^^^^^^^^^^^^ cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
 
-error[E0284]: type annotations needed
+error[E0284]: type annotations needed: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
   --> $DIR/associated-types-overridden-binding.rs:7:21
    |
 LL | trait I32Iterator = Iterator<Item = i32>;
    |                              ---------- required by this bound in `I32Iterator`
 LL | trait U32Iterator = I32Iterator<Item = u32>;
-   |                     ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
-   |
-   = note: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
+   |                     ^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/issues/issue-12028.stderr b/src/test/ui/issues/issue-12028.stderr
index 434c5de2874..30cb7a1df80 100644
--- a/src/test/ui/issues/issue-12028.stderr
+++ b/src/test/ui/issues/issue-12028.stderr
@@ -1,10 +1,8 @@
-error[E0284]: type annotations needed
+error[E0284]: type annotations needed: cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S`
   --> $DIR/issue-12028.rs:27:14
    |
 LL |         self.input_stream(&mut stream);
-   |              ^^^^^^^^^^^^ cannot infer type for type parameter `H` declared on the trait `StreamHash`
-   |
-   = note: cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S`
+   |              ^^^^^^^^^^^^ cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-69455.rs b/src/test/ui/issues/issue-69455.rs
new file mode 100644
index 00000000000..f1935ae2534
--- /dev/null
+++ b/src/test/ui/issues/issue-69455.rs
@@ -0,0 +1,30 @@
+// Regression test for #69455: projection predicate was not satisfied.
+// Compiler should indicate the correct location of the
+// unsatisfied projection predicate
+
+pub trait Test<Rhs = Self> {
+    type Output;
+
+    fn test(self, rhs: Rhs) -> Self::Output;
+}
+
+impl Test<u32> for u64 {
+    type Output = u64;
+
+    fn test(self, other: u32) -> u64 {
+        self + (other as u64)
+    }
+}
+
+impl Test<u64> for u64 {
+    type Output = u64;
+
+    fn test(self, other: u64) -> u64 {
+        (self + other) as u64
+    }
+}
+
+fn main() {
+    let xs: Vec<u64> = vec![1, 2, 3];
+    println!("{}", 23u64.test(xs.iter().sum())); //~ ERROR: type annotations needed
+}
diff --git a/src/test/ui/issues/issue-69455.stderr b/src/test/ui/issues/issue-69455.stderr
new file mode 100644
index 00000000000..430bbcabf83
--- /dev/null
+++ b/src/test/ui/issues/issue-69455.stderr
@@ -0,0 +1,9 @@
+error[E0284]: type annotations needed: cannot satisfy `<u64 as Test<_>>::Output == _`
+  --> $DIR/issue-69455.rs:29:26
+   |
+LL |     println!("{}", 23u64.test(xs.iter().sum()));
+   |                          ^^^^ cannot satisfy `<u64 as Test<_>>::Output == _`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0284`.
diff --git a/src/test/ui/issues/issue-69683.rs b/src/test/ui/issues/issue-69683.rs
new file mode 100644
index 00000000000..cc7f1fa0f55
--- /dev/null
+++ b/src/test/ui/issues/issue-69683.rs
@@ -0,0 +1,32 @@
+pub trait Element<S> {
+    type Array;
+}
+
+impl<T> Element<()> for T {
+    type Array = T;
+}
+
+impl<T: Element<S>, S> Element<[S; 3]> for T {
+    type Array = [T::Array; 3];
+}
+
+trait Foo<I>
+where
+    u8: Element<I>,
+{
+    fn foo(self, x: <u8 as Element<I>>::Array);
+}
+
+impl<I> Foo<I> for u16
+where
+    u8: Element<I>,
+{
+    fn foo(self, _: <u8 as Element<I>>::Array) {}
+}
+
+fn main() {
+    let b: [u8; 3] = [0u8; 3];
+
+    0u16.foo(b); //~ ERROR type annotations needed
+    //<u16 as Foo<[(); 3]>>::foo(0u16, b);
+}
diff --git a/src/test/ui/issues/issue-69683.stderr b/src/test/ui/issues/issue-69683.stderr
new file mode 100644
index 00000000000..776370331a4
--- /dev/null
+++ b/src/test/ui/issues/issue-69683.stderr
@@ -0,0 +1,9 @@
+error[E0284]: type annotations needed: cannot satisfy `<u8 as Element<_>>::Array == [u8; 3]`
+  --> $DIR/issue-69683.rs:30:10
+   |
+LL |     0u16.foo(b);
+   |          ^^^ cannot satisfy `<u8 as Element<_>>::Array == [u8; 3]`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0284`.
diff --git a/src/test/ui/issues/issue-71584.rs b/src/test/ui/issues/issue-71584.rs
new file mode 100644
index 00000000000..c96cd598f0c
--- /dev/null
+++ b/src/test/ui/issues/issue-71584.rs
@@ -0,0 +1,5 @@
+fn main() {
+    let n: u32 = 1;
+    let mut d: u64 = 2;
+    d = d % n.into(); //~ ERROR type annotations needed
+}
diff --git a/src/test/ui/issues/issue-71584.stderr b/src/test/ui/issues/issue-71584.stderr
new file mode 100644
index 00000000000..c162d338a93
--- /dev/null
+++ b/src/test/ui/issues/issue-71584.stderr
@@ -0,0 +1,9 @@
+error[E0284]: type annotations needed: cannot satisfy `<u64 as std::ops::Rem<_>>::Output == u64`
+  --> $DIR/issue-71584.rs:4:11
+   |
+LL |     d = d % n.into();
+   |           ^ cannot satisfy `<u64 as std::ops::Rem<_>>::Output == u64`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0284`.
diff --git a/src/test/ui/regions/issue-72051-member-region-hang.rs b/src/test/ui/regions/issue-72051-member-region-hang.rs
new file mode 100644
index 00000000000..b7340b79d68
--- /dev/null
+++ b/src/test/ui/regions/issue-72051-member-region-hang.rs
@@ -0,0 +1,7 @@
+// Regression test for #72051, hang when resolving regions.
+
+// check-pass
+// edition:2018
+
+pub async fn query<'a>(_: &(), _: &(), _: (&(dyn std::any::Any + 'a),) ) {}
+fn main() {}
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index 028483b7d95..890d2f26272 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -347,7 +347,10 @@ pub fn run_tests(config: Config) {
         Ok(true) => {}
         Ok(false) => panic!("Some tests failed"),
         Err(e) => {
-            println!("I/O failure during tests: {:?}", e);
+            // We don't know if tests passed or not, but if there was an error
+            // during testing we don't want to just suceeed (we may not have
+            // tested something), so fail.
+            panic!("I/O failure during tests: {:?}", e);
         }
     }
 }