Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 90580da

Browse files
authoredAug 23, 2024
Unrolled build for rust-lang#129417
Rollup merge of rust-lang#129417 - compiler-errors:refine-err, r=lqd Don't trigger refinement lint if predicates reference errors Fixes rust-lang#129404
2 parents b5723af + 8eb1558 commit 90580da

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed
 

‎compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use rustc_lint_defs::builtin::{REFINING_IMPL_TRAIT_INTERNAL, REFINING_IMPL_TRAIT
77
use rustc_middle::span_bug;
88
use rustc_middle::traits::{ObligationCause, Reveal};
99
use rustc_middle::ty::{
10-
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperVisitable, TypeVisitable, TypeVisitor,
10+
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperVisitable, TypeVisitable,
11+
TypeVisitableExt, TypeVisitor,
1112
};
1213
use rustc_span::Span;
1314
use rustc_trait_selection::regions::InferCtxtRegionExt;
@@ -177,6 +178,10 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
177178
return;
178179
};
179180

181+
if trait_bounds.references_error() || impl_bounds.references_error() {
182+
return;
183+
}
184+
180185
// For quicker lookup, use an `IndexSet` (we don't use one earlier because
181186
// it's not foldable..).
182187
// Also, We have to anonymize binders in these types because they may contain
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![deny(refining_impl_trait)]
2+
3+
trait FromRow {
4+
fn prepare(self) -> impl Fn() -> T;
5+
//~^ ERROR cannot find type `T` in this scope
6+
}
7+
8+
impl<T> FromRow for T {
9+
fn prepare(self) -> impl Fn() -> T {
10+
|| todo!()
11+
}
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `T` in this scope
2+
--> $DIR/refine-err.rs:4:38
3+
|
4+
LL | fn prepare(self) -> impl Fn() -> T;
5+
| ^ not found in this scope
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.

‎tests/ui/impl-trait/in-trait/span-bug-issue-121457.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ impl<'a, I: 'a + Iterable> Iterable for &'a I {
1414
//~^ ERROR binding for associated type `Item` references lifetime `'missing`
1515
//~| ERROR binding for associated type `Item` references lifetime `'missing`
1616
//~| ERROR `()` is not an iterator
17-
//~| WARNING impl trait in impl method signature does not match trait method signature
1817
}
1918

2019
fn main() {}

‎tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr

+1-18
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,7 @@ LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missin
3232
|
3333
= help: the trait `Iterator` is not implemented for `()`
3434

35-
warning: impl trait in impl method signature does not match trait method signature
36-
--> $DIR/span-bug-issue-121457.rs:13:51
37-
|
38-
LL | fn iter(&self) -> impl Iterator;
39-
| ------------- return type from trait method defined here
40-
...
41-
LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {}
42-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ this bound is stronger than that defined on the trait
43-
|
44-
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
45-
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
46-
= note: `#[warn(refining_impl_trait_reachable)]` on by default
47-
help: replace the return type so that it matches the trait
48-
|
49-
LL | fn iter(&self) -> impl Iterator {}
50-
| ~~~~~~~~~~~~~
51-
52-
error: aborting due to 4 previous errors; 1 warning emitted
35+
error: aborting due to 4 previous errors
5336

5437
Some errors have detailed explanations: E0195, E0277, E0582.
5538
For more information about an error, try `rustc --explain E0195`.

0 commit comments

Comments
 (0)
Failed to load comments.