Skip to content

Commit 5de3a4c

Browse files
authored
Rollup merge of #121480 - nnethercote:fix-more-121208-fallout, r=lcnr
Fix more #121208 fallout #121208 converted lots of delayed bugs to bugs. Unsurprisingly, there were a few invalid conversion found via fuzzing. r? `@lcnr`
2 parents 7ae95b2 + 938e594 commit 5de3a4c

File tree

6 files changed

+94
-10
lines changed

6 files changed

+94
-10
lines changed

Diff for: compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,17 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
154154
trait_m_sig.inputs_and_output,
155155
));
156156
if !ocx.select_all_or_error().is_empty() {
157-
// This code path is not reached in any tests, but may be reachable. If
158-
// this is triggered, it should be converted to `delayed_bug` and the
159-
// triggering case turned into a test.
160-
tcx.dcx().bug("encountered errors when checking RPITIT refinement (selection)");
157+
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)");
158+
return;
161159
}
162160
let outlives_env = OutlivesEnvironment::with_bounds(
163161
param_env,
164162
infcx.implied_bounds_tys(param_env, impl_m.def_id.expect_local(), &implied_wf_types),
165163
);
166164
let errors = infcx.resolve_regions(&outlives_env);
167165
if !errors.is_empty() {
168-
// This code path is not reached in any tests, but may be reachable. If
169-
// this is triggered, it should be converted to `delayed_bug` and the
170-
// triggering case turned into a test.
171-
tcx.dcx().bug("encountered errors when checking RPITIT refinement (regions)");
166+
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (regions)");
167+
return;
172168
}
173169
// Resolve any lifetime variables that may have been introduced during normalization.
174170
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {

Diff for: compiler/rustc_hir_typeck/src/expr.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7777
// coercions from ! to `expected`.
7878
if ty.is_never() {
7979
if let Some(_) = self.typeck_results.borrow().adjustments().get(expr.hir_id) {
80-
self.dcx()
81-
.span_bug(expr.span, "expression with never type wound up being adjusted");
80+
let reported = self.dcx().span_delayed_bug(
81+
expr.span,
82+
"expression with never type wound up being adjusted",
83+
);
84+
return Ty::new_error(self.tcx(), reported);
8285
}
8386

8487
let adj_ty = self.next_ty_var(TypeVariableOrigin {
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pub trait Iterable {
2+
type Item<'a>
3+
where
4+
Self: 'a;
5+
6+
fn iter(&self) -> impl Iterator;
7+
}
8+
9+
impl<'a, I: 'a + Iterable> Iterable for &'a I {
10+
type Item = u32;
11+
//~^ ERROR lifetime parameters or bounds on type `Item` do not match the trait declaration
12+
13+
fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {}
14+
//~^ ERROR binding for associated type `Item` references lifetime `'missing`
15+
//~| ERROR `()` is not an iterator
16+
}
17+
18+
fn main() {}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
error[E0582]: binding for associated type `Item` references lifetime `'missing`, which does not appear in the trait input types
2+
--> $DIR/span-bug-issue-121457.rs:13:51
3+
|
4+
LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error[E0195]: lifetime parameters or bounds on type `Item` do not match the trait declaration
8+
--> $DIR/span-bug-issue-121457.rs:10:14
9+
|
10+
LL | type Item<'a>
11+
| ---- lifetimes in impl do not match this type in trait
12+
LL | where
13+
LL | Self: 'a;
14+
| -- this bound might be missing in the impl
15+
...
16+
LL | type Item = u32;
17+
| ^ lifetimes do not match type in trait
18+
19+
error[E0277]: `()` is not an iterator
20+
--> $DIR/span-bug-issue-121457.rs:13:23
21+
|
22+
LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {}
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
24+
|
25+
= help: the trait `Iterator` is not implemented for `()`
26+
27+
error: aborting due to 3 previous errors
28+
29+
Some errors have detailed explanations: E0195, E0277, E0582.
30+
For more information about an error, try `rustc --explain E0195`.

Diff for: tests/ui/never_type/span-bug-issue-121445.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![feature(never_type)]
2+
3+
fn test2() {
4+
let x: !;
5+
let c2 = SingleVariant::Points(0)
6+
| match x { //~ ERROR no implementation for `SingleVariant | ()`
7+
_ => (),
8+
};
9+
}
10+
11+
enum SingleVariant {
12+
Points(u32),
13+
}
14+
15+
fn main() {}

Diff for: tests/ui/never_type/span-bug-issue-121445.stderr

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0369]: no implementation for `SingleVariant | ()`
2+
--> $DIR/span-bug-issue-121445.rs:6:9
3+
|
4+
LL | let c2 = SingleVariant::Points(0)
5+
| ------------------------ SingleVariant
6+
LL | | match x {
7+
| _________^_-
8+
LL | | _ => (),
9+
LL | | };
10+
| |_________- ()
11+
|
12+
note: an implementation of `BitOr<()>` might be missing for `SingleVariant`
13+
--> $DIR/span-bug-issue-121445.rs:11:1
14+
|
15+
LL | enum SingleVariant {
16+
| ^^^^^^^^^^^^^^^^^^ must implement `BitOr<()>`
17+
note: the trait `BitOr` must be implemented
18+
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
19+
20+
error: aborting due to 1 previous error
21+
22+
For more information about this error, try `rustc --explain E0369`.

0 commit comments

Comments
 (0)