Skip to content

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Aug 29, 2025

Stacked on top of #140375 and #145990. Revival of #140496.

Fixes rust-lang/trait-system-refactor-initiative#181

r? @BoxyUwU

@rustbot
Copy link
Collaborator

rustbot commented Aug 29, 2025

BoxyUwU is currently at their maximum review capacity.
They may take a while to respond.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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 Aug 29, 2025
@lcnr lcnr changed the title -Znext-solver allow ExprKind::Call on not-yet defined opaques -Znext-solver allow ExprKind::Call for not-yet defined opaques Aug 29, 2025
@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
tidy check
Checking tidy rustdoc_json...
No error code explanation was removed!
tidy: Skipping binary file check, read-only filesystem
##[error]tidy error: /checkout/tests/ui/impl-trait/non-defining-uses/method-call-on-infer.rs:20: trailing whitespace
##[error]tidy error: /checkout/tests/ui/impl-trait/non-defining-uses/method-call-on-infer.rs:33: trailing whitespace
removing old virtual environment
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'venv'
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'virtualenv'
Requirement already satisfied: pip in ./build/venv/lib/python3.10/site-packages (25.2)
linting python files
---

added 291 packages in 37s
Running eslint on rustdoc JS files
info: ES-Check: there were no ES version matching errors!  🎉
some tidy checks failed
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy /checkout /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo /checkout/obj/build 4 /node/bin/npm --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1583:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1225:29

Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `test --stage 0 src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Build completed unsuccessfully in 0:03:10
  local time: Fri Aug 29 09:40:50 UTC 2025
  network time: Fri, 29 Aug 2025 09:40:50 GMT
##[error]Process completed with exit code 1.

Comment on lines +490 to +494
// bounds list, which can lead to inference weirdness but doesn't
// matter today.
for clause in
self.tcx.item_self_bounds(alias_ty.def_id).iter_instantiated(self.tcx, alias_ty.args)
{
Copy link
Contributor Author

@lcnr lcnr Aug 29, 2025

Choose a reason for hiding this comment

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

The desired behavior is quite 🤷 here...

if we've got impl FnMut(u32) + FnMut(u32) we should prefer the Fn bound. We should do for call_trait { for item bound { check }}.

If we've got impl Fn(&'a str) + Fn(&'b str) or sth that should be handled fine, even for non-defining uses. Needs tests

Even if we've got impl Fn(T) as the opaque type, rn we don't use this at all, but instead lookup_method_for_operator just emits all the bounds necessary to use that method, so we then rely on incomplete item bounds jank to actually constrain the args of the call.

This is necessary to support stuff like

fn recur() -> impl Fn(fn(&str) -> usize) {
   if false {
       let x = recur();
       x(|s| s.len());
   }

   |_func| ()
}

the other issue is handling

fn recur() -> impl Sized {
   if false {
       let x = recur();
       x();
   }

   || ()
}

this should result in a "type must be known at this point error, not a "type doesn't implement fn"

I guess I am gonna block this PR on getting item bounds working as otherwise we're missing some important tests here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

calling impl Fn in defining scope
4 participants