Skip to content

Check for region dependent goals on type_op itself as well#152816

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
ShoyuVanilla:issue-151318
Mar 4, 2026
Merged

Check for region dependent goals on type_op itself as well#152816
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
ShoyuVanilla:issue-151318

Conversation

@ShoyuVanilla
Copy link
Member

Fixes #151318

r? lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Feb 18, 2026
Comment on lines +95 to +101
infcx.tcx.check_potentially_region_dependent_goals(root_def_id).err().unwrap_or_else(
|| {
infcx
.dcx()
.span_delayed_bug(span, format!("error performing operation: {name}"))
},
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does just unwrapping here cause any ICE?

Copy link
Member Author

@ShoyuVanilla ShoyuVanilla Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing so far
Edit) Oh we have one 😅 I've run only next-solver test suite locally

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you look into why that obligation is failing even though HIR typeck is erroring, can't see the obligation which causes this ICE in CI

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll look into it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the obligation fails here is &T: Iterator here(L15):

type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; //~ ERROR `&'a T` is not an iterator
//~^ ERROR `&'a T` is not an iterator
type Item = &'a T;
fn into_iter(self) -> Self::IntoIter {
//~^ ERROR `&'a T` is not an iterator
//[nll]~| ERROR `&T` is not an iterator
unimplemented!()
}

which is caused in here
for ty in constraints.dtorck_types.drain(..) {
let ty = if let Ok(Normalized { value: ty, obligations }) =
ocx.infcx.at(&cause, param_env).query_normalize(ty)
{
ocx.register_obligations(obligations);
debug!("dropck_outlives: ty from dtorck_types = {:?}", ty);
ty
} else {
// Flush errors b/c `deeply_normalize` doesn't expect pending
// obligations, and we may have pending obligations from the
// branch above (from other types).
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
return Err(errors);
}
// When query normalization fails, we don't get back an interesting
// reason that we could use to report an error in borrowck. In order to turn
// this into a reportable error, we deeply normalize again. We don't expect
// this to succeed, so delay a bug if it does.
match ocx.deeply_normalize(&cause, param_env, ty) {
Ok(_) => {
tcx.dcx().span_delayed_bug(
span,
format!(
"query normalize succeeded of {ty}, \
but deep normalize failed",
),
);
ty
}
Err(errors) => return Err(errors),

while trying to normalize <<Iter<'a, T> as Iterator>::Item as IntoIterator>::Iterator.

It's surprising that fn into_iter in L15 survives the typeck (or other earlier steps before MIR) without being tainted.
Maybe that's because of never type on unimplemented!() which bypasses actually touching the function's return type with NeverToAny coercion, otherwise the other concrete typed return would resulted in type mismatch error or fulfillment error while trying to normalize the function's return type?

I guess we ought to check the well-formedness of the type that never type is coerced into or the function's signature itself before MIR?

Copy link
Contributor

@lcnr lcnr Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue is that we check the return type is well-formed in wfcheck::check_well_formed and to avoid duplicate errors we don't check it in HIR typeck.

This means that non-wf return types go through HIR typeck without tainting it, only erroring in wfcheck.rs.

Hmm, I feel like ideally we do taint the MIR body here, but I think for now, just keep a span_delay_bug here and add a FIXME that we should try to make this an ICE (and why it doesn't work)

@rust-log-analyzer

This comment has been minimized.

@lcnr
Copy link
Contributor

lcnr commented Mar 4, 2026

@bors r+ rollup

thanks

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 4, 2026

📌 Commit 5f3bdde has been approved by lcnr

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 4, 2026
rust-bors bot pushed a commit that referenced this pull request Mar 4, 2026
Rollup of 5 pull requests

Successful merges:

 - #153341 (std: refactor Xous startup code)
 - #152816 (Check for region dependent goals on type_op itself as well)
 - #153224 (Fix LegacyKeyValueFormat report from docker build: disabled)
 - #153274 (Fix async drop multi crate crash)
 - #153324 (fix autodiff parsing for non-trait impl)
@rust-bors rust-bors bot merged commit f222b55 into rust-lang:main Mar 4, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 4, 2026
rust-timer added a commit that referenced this pull request Mar 4, 2026
Rollup merge of #152816 - ShoyuVanilla:issue-151318, r=lcnr

Check for region dependent goals on type_op itself as well

Fixes #151318

r? lcnr
@ShoyuVanilla ShoyuVanilla deleted the issue-151318 branch March 4, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: error performing operation: query type op

4 participants