Revert some span_bug
s to span_delayed_bug
.
Fixes #121445. Fixes #121457.
This commit is contained in:
parent
c5f69bdd51
commit
109321ac47
@ -154,10 +154,8 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||
trait_m_sig.inputs_and_output,
|
||||
));
|
||||
if !ocx.select_all_or_error().is_empty() {
|
||||
// This code path is not reached in any tests, but may be reachable. If
|
||||
// this is triggered, it should be converted to `delayed_bug` and the
|
||||
// triggering case turned into a test.
|
||||
tcx.dcx().bug("encountered errors when checking RPITIT refinement (selection)");
|
||||
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)");
|
||||
return;
|
||||
}
|
||||
let outlives_env = OutlivesEnvironment::with_bounds(
|
||||
param_env,
|
||||
@ -165,10 +163,8 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||
);
|
||||
let errors = infcx.resolve_regions(&outlives_env);
|
||||
if !errors.is_empty() {
|
||||
// This code path is not reached in any tests, but may be reachable. If
|
||||
// this is triggered, it should be converted to `delayed_bug` and the
|
||||
// triggering case turned into a test.
|
||||
tcx.dcx().bug("encountered errors when checking RPITIT refinement (regions)");
|
||||
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (regions)");
|
||||
return;
|
||||
}
|
||||
// Resolve any lifetime variables that may have been introduced during normalization.
|
||||
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
|
||||
|
@ -76,9 +76,16 @@ pub fn check_expr_has_type_or_error(
|
||||
// While we don't allow *arbitrary* coercions here, we *do* allow
|
||||
// coercions from ! to `expected`.
|
||||
if ty.is_never() {
|
||||
if let Some(_) = self.typeck_results.borrow().adjustments().get(expr.hir_id) {
|
||||
self.dcx()
|
||||
.span_bug(expr.span, "expression with never type wound up being adjusted");
|
||||
if let Some(adjustments) = self.typeck_results.borrow().adjustments().get(expr.hir_id) {
|
||||
let reported = self.dcx().span_delayed_bug(
|
||||
expr.span,
|
||||
"expression with never type wound up being adjusted",
|
||||
);
|
||||
return if let [Adjustment { kind: Adjust::NeverToAny, target }] = &adjustments[..] {
|
||||
target.to_owned()
|
||||
} else {
|
||||
Ty::new_error(self.tcx(), reported)
|
||||
};
|
||||
}
|
||||
|
||||
let adj_ty = self.next_ty_var(TypeVariableOrigin {
|
||||
|
18
tests/ui/impl-trait/in-trait/span-bug-issue-121457.rs
Normal file
18
tests/ui/impl-trait/in-trait/span-bug-issue-121457.rs
Normal file
@ -0,0 +1,18 @@
|
||||
pub trait Iterable {
|
||||
type Item<'a>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
fn iter(&self) -> impl Iterator;
|
||||
}
|
||||
|
||||
impl<'a, I: 'a + Iterable> Iterable for &'a I {
|
||||
type Item = u32;
|
||||
//~^ ERROR lifetime parameters or bounds on type `Item` do not match the trait declaration
|
||||
|
||||
fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {}
|
||||
//~^ ERROR binding for associated type `Item` references lifetime `'missing`
|
||||
//~| ERROR `()` is not an iterator
|
||||
}
|
||||
|
||||
fn main() {}
|
30
tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr
Normal file
30
tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr
Normal file
@ -0,0 +1,30 @@
|
||||
error[E0582]: binding for associated type `Item` references lifetime `'missing`, which does not appear in the trait input types
|
||||
--> $DIR/span-bug-issue-121457.rs:13:51
|
||||
|
|
||||
LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0195]: lifetime parameters or bounds on type `Item` do not match the trait declaration
|
||||
--> $DIR/span-bug-issue-121457.rs:10:14
|
||||
|
|
||||
LL | type Item<'a>
|
||||
| ---- lifetimes in impl do not match this type in trait
|
||||
LL | where
|
||||
LL | Self: 'a;
|
||||
| -- this bound might be missing in the impl
|
||||
...
|
||||
LL | type Item = u32;
|
||||
| ^ lifetimes do not match type in trait
|
||||
|
||||
error[E0277]: `()` is not an iterator
|
||||
--> $DIR/span-bug-issue-121457.rs:13:23
|
||||
|
|
||||
LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
|
||||
|
|
||||
= help: the trait `Iterator` is not implemented for `()`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0195, E0277, E0582.
|
||||
For more information about an error, try `rustc --explain E0195`.
|
15
tests/ui/never_type/span-bug-issue-121445.rs
Normal file
15
tests/ui/never_type/span-bug-issue-121445.rs
Normal file
@ -0,0 +1,15 @@
|
||||
#![feature(never_type)]
|
||||
|
||||
fn test2() {
|
||||
let x: !;
|
||||
let c2 = SingleVariant::Points(0)
|
||||
| match x { //~ ERROR no implementation for `SingleVariant | ()`
|
||||
_ => (),
|
||||
};
|
||||
}
|
||||
|
||||
enum SingleVariant {
|
||||
Points(u32),
|
||||
}
|
||||
|
||||
fn main() {}
|
22
tests/ui/never_type/span-bug-issue-121445.stderr
Normal file
22
tests/ui/never_type/span-bug-issue-121445.stderr
Normal file
@ -0,0 +1,22 @@
|
||||
error[E0369]: no implementation for `SingleVariant | ()`
|
||||
--> $DIR/span-bug-issue-121445.rs:6:9
|
||||
|
|
||||
LL | let c2 = SingleVariant::Points(0)
|
||||
| ------------------------ SingleVariant
|
||||
LL | | match x {
|
||||
| _________^_-
|
||||
LL | | _ => (),
|
||||
LL | | };
|
||||
| |_________- ()
|
||||
|
|
||||
note: an implementation of `BitOr<()>` might be missing for `SingleVariant`
|
||||
--> $DIR/span-bug-issue-121445.rs:11:1
|
||||
|
|
||||
LL | enum SingleVariant {
|
||||
| ^^^^^^^^^^^^^^^^^^ must implement `BitOr<()>`
|
||||
note: the trait `BitOr` must be implemented
|
||||
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0369`.
|
Loading…
Reference in New Issue
Block a user