Skip to content

Commit 02c25b3

Browse files
committed
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
2 parents 0f0d700 + 9021f24 commit 02c25b3

File tree

13 files changed

+148
-24
lines changed

13 files changed

+148
-24
lines changed

Cargo.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ dependencies = [
487487
"if_chain",
488488
"itertools 0.9.0",
489489
"lazy_static 1.4.0",
490-
"pulldown-cmark 0.7.0",
490+
"pulldown-cmark 0.7.1",
491491
"quine-mc_cluskey",
492492
"regex-syntax",
493493
"semver",
@@ -2657,9 +2657,9 @@ dependencies = [
26572657

26582658
[[package]]
26592659
name = "pulldown-cmark"
2660-
version = "0.7.0"
2660+
version = "0.7.1"
26612661
source = "registry+https://github.com/rust-lang/crates.io-index"
2662-
checksum = "2c2d7fd131800e0d63df52aff46201acaab70b431a4a1ec6f0343fe8e64f35a4"
2662+
checksum = "3e142c3b8f49d2200605ee6ba0b1d757310e9e7a72afe78c36ee2ef67300ee00"
26632663
dependencies = [
26642664
"bitflags",
26652665
"memchr",
@@ -4355,7 +4355,7 @@ version = "0.0.0"
43554355
dependencies = [
43564356
"itertools 0.8.0",
43574357
"minifier",
4358-
"pulldown-cmark 0.7.0",
4358+
"pulldown-cmark 0.7.1",
43594359
"rustc-rayon",
43604360
"serde",
43614361
"serde_json",

src/librustc_infer/infer/lexical_region_resolve/mod.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,21 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
325325
}
326326
}
327327

328-
debug!("enforce_member_constraint: final least choice = {:?}", least_choice);
329-
if least_choice != member_lower_bound {
328+
// (#72087) Different `ty::Regions` can be known to be equal, for
329+
// example, we know that `'a` and `'static` are equal in a function
330+
// with a parameter of type `&'static &'a ()`.
331+
//
332+
// When we have two equal regions like this `expansion` will use
333+
// `lub_concrete_regions` to pick a canonical representative. The same
334+
// choice is needed here so that we don't end up in a cycle of
335+
// `expansion` changing the region one way and the code here changing
336+
// it back.
337+
let lub = self.lub_concrete_regions(least_choice, member_lower_bound);
338+
debug!(
339+
"enforce_member_constraint: final least choice = {:?}\nlub = {:?}",
340+
least_choice, lub
341+
);
342+
if lub != member_lower_bound {
330343
*var_values.value_mut(member_vid) = VarValue::Value(least_choice);
331344
true
332345
} else {
@@ -578,8 +591,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
578591
self.tcx().mk_region(ReScope(lub))
579592
}
580593

581-
(&ReEarlyBound(_), &ReEarlyBound(_) | &ReFree(_))
582-
| (&ReFree(_), &ReEarlyBound(_) | &ReFree(_)) => {
594+
(&ReEarlyBound(_) | &ReFree(_), &ReEarlyBound(_) | &ReFree(_)) => {
583595
self.region_rels.lub_free_regions(a, b)
584596
}
585597

src/librustc_trait_selection/traits/error_reporting/mod.rs

+17-3
Original file line numberDiff line numberDiff line change
@@ -1482,12 +1482,26 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
14821482
ty::Predicate::Projection(ref data) => {
14831483
let trait_ref = data.to_poly_trait_ref(self.tcx);
14841484
let self_ty = trait_ref.self_ty();
1485+
let ty = data.skip_binder().ty;
14851486
if predicate.references_error() {
14861487
return;
14871488
}
1488-
let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0284);
1489-
err.note(&format!("cannot satisfy `{}`", predicate));
1490-
err
1489+
if self_ty.needs_infer() && ty.needs_infer() {
1490+
// We do this for the `foo.collect()?` case to produce a suggestion.
1491+
let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0284);
1492+
err.note(&format!("cannot satisfy `{}`", predicate));
1493+
err
1494+
} else {
1495+
let mut err = struct_span_err!(
1496+
self.tcx.sess,
1497+
span,
1498+
E0284,
1499+
"type annotations needed: cannot satisfy `{}`",
1500+
predicate,
1501+
);
1502+
err.span_label(span, &format!("cannot satisfy `{}`", predicate));
1503+
err
1504+
}
14911505
}
14921506

14931507
_ => {

src/test/ui/associated-types/associated-types-overridden-binding.stderr

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
error[E0284]: type annotations needed
1+
error[E0284]: type annotations needed: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
22
--> $DIR/associated-types-overridden-binding.rs:4:12
33
|
44
LL | trait Foo: Iterator<Item = i32> {}
55
| ---------- required by this bound in `Foo`
66
LL | trait Bar: Foo<Item = u32> {}
7-
| ^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
8-
|
9-
= note: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
7+
| ^^^^^^^^^^^^^^^ cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
108

11-
error[E0284]: type annotations needed
9+
error[E0284]: type annotations needed: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
1210
--> $DIR/associated-types-overridden-binding.rs:7:21
1311
|
1412
LL | trait I32Iterator = Iterator<Item = i32>;
1513
| ---------- required by this bound in `I32Iterator`
1614
LL | trait U32Iterator = I32Iterator<Item = u32>;
17-
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
18-
|
19-
= note: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
15+
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
2016

2117
error: aborting due to 2 previous errors
2218

src/test/ui/issues/issue-12028.stderr

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
error[E0284]: type annotations needed
1+
error[E0284]: type annotations needed: cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S`
22
--> $DIR/issue-12028.rs:27:14
33
|
44
LL | self.input_stream(&mut stream);
5-
| ^^^^^^^^^^^^ cannot infer type for type parameter `H` declared on the trait `StreamHash`
6-
|
7-
= note: cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S`
5+
| ^^^^^^^^^^^^ cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S`
86

97
error: aborting due to previous error
108

src/test/ui/issues/issue-69455.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Regression test for #69455: projection predicate was not satisfied.
2+
// Compiler should indicate the correct location of the
3+
// unsatisfied projection predicate
4+
5+
pub trait Test<Rhs = Self> {
6+
type Output;
7+
8+
fn test(self, rhs: Rhs) -> Self::Output;
9+
}
10+
11+
impl Test<u32> for u64 {
12+
type Output = u64;
13+
14+
fn test(self, other: u32) -> u64 {
15+
self + (other as u64)
16+
}
17+
}
18+
19+
impl Test<u64> for u64 {
20+
type Output = u64;
21+
22+
fn test(self, other: u64) -> u64 {
23+
(self + other) as u64
24+
}
25+
}
26+
27+
fn main() {
28+
let xs: Vec<u64> = vec![1, 2, 3];
29+
println!("{}", 23u64.test(xs.iter().sum())); //~ ERROR: type annotations needed
30+
}

src/test/ui/issues/issue-69455.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0284]: type annotations needed: cannot satisfy `<u64 as Test<_>>::Output == _`
2+
--> $DIR/issue-69455.rs:29:26
3+
|
4+
LL | println!("{}", 23u64.test(xs.iter().sum()));
5+
| ^^^^ cannot satisfy `<u64 as Test<_>>::Output == _`
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0284`.

src/test/ui/issues/issue-69683.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
pub trait Element<S> {
2+
type Array;
3+
}
4+
5+
impl<T> Element<()> for T {
6+
type Array = T;
7+
}
8+
9+
impl<T: Element<S>, S> Element<[S; 3]> for T {
10+
type Array = [T::Array; 3];
11+
}
12+
13+
trait Foo<I>
14+
where
15+
u8: Element<I>,
16+
{
17+
fn foo(self, x: <u8 as Element<I>>::Array);
18+
}
19+
20+
impl<I> Foo<I> for u16
21+
where
22+
u8: Element<I>,
23+
{
24+
fn foo(self, _: <u8 as Element<I>>::Array) {}
25+
}
26+
27+
fn main() {
28+
let b: [u8; 3] = [0u8; 3];
29+
30+
0u16.foo(b); //~ ERROR type annotations needed
31+
//<u16 as Foo<[(); 3]>>::foo(0u16, b);
32+
}

src/test/ui/issues/issue-69683.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0284]: type annotations needed: cannot satisfy `<u8 as Element<_>>::Array == [u8; 3]`
2+
--> $DIR/issue-69683.rs:30:10
3+
|
4+
LL | 0u16.foo(b);
5+
| ^^^ cannot satisfy `<u8 as Element<_>>::Array == [u8; 3]`
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0284`.

src/test/ui/issues/issue-71584.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
let n: u32 = 1;
3+
let mut d: u64 = 2;
4+
d = d % n.into(); //~ ERROR type annotations needed
5+
}

src/test/ui/issues/issue-71584.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0284]: type annotations needed: cannot satisfy `<u64 as std::ops::Rem<_>>::Output == u64`
2+
--> $DIR/issue-71584.rs:4:11
3+
|
4+
LL | d = d % n.into();
5+
| ^ cannot satisfy `<u64 as std::ops::Rem<_>>::Output == u64`
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0284`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Regression test for #72051, hang when resolving regions.
2+
3+
// check-pass
4+
// edition:2018
5+
6+
pub async fn query<'a>(_: &(), _: &(), _: (&(dyn std::any::Any + 'a),) ) {}
7+
fn main() {}

src/tools/compiletest/src/main.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,10 @@ pub fn run_tests(config: Config) {
347347
Ok(true) => {}
348348
Ok(false) => panic!("Some tests failed"),
349349
Err(e) => {
350-
println!("I/O failure during tests: {:?}", e);
350+
// We don't know if tests passed or not, but if there was an error
351+
// during testing we don't want to just suceeed (we may not have
352+
// tested something), so fail.
353+
panic!("I/O failure during tests: {:?}", e);
351354
}
352355
}
353356
}

0 commit comments

Comments
 (0)