Skip to content

Commit c6833fa

Browse files
authored
Unrolled build for rust-lang#130440
Rollup merge of rust-lang#130440 - compiler-errors:rpitit-opaque-hidden, r=jieyouxu Don't ICE in `opaque_hidden_inferred_bound` lint for RPITIT in trait with no default method body Inline comment should explain the fix. Fixes rust-lang#130422
2 parents e9e13a6 + 6e982f5 commit c6833fa

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs

+12
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
7272
let hir::ItemKind::OpaqueTy(opaque) = &item.kind else {
7373
return;
7474
};
75+
76+
// If this is an RPITIT from a trait method with no body, then skip.
77+
// That's because although we may have an opaque type on the function,
78+
// it won't have a hidden type, so proving predicates about it is
79+
// not really meaningful.
80+
if let hir::OpaqueTyOrigin::FnReturn(method_def_id) = opaque.origin
81+
&& let hir::Node::TraitItem(trait_item) = cx.tcx.hir_node_by_def_id(method_def_id)
82+
&& !trait_item.defaultness.has_value()
83+
{
84+
return;
85+
}
86+
7587
let def_id = item.owner_id.def_id.to_def_id();
7688
let infcx = &cx.tcx.infer_ctxt().build();
7789
// For every projection predicate in the opaque type's explicit bounds,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ check-pass
2+
3+
// Make sure that the `opaque_hidden_inferred_bound` lint doesn't fire on
4+
// RPITITs with no hidden type.
5+
6+
trait T0 {}
7+
8+
trait T1 {
9+
type A: Send;
10+
}
11+
12+
trait T2 {
13+
fn foo() -> impl T1<A = ((), impl T0)>;
14+
}
15+
16+
fn main() {}

0 commit comments

Comments
 (0)