Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove speculative parameter from instantiate_poly_trait_ref_inner #114635

Closed
compiler-errors opened this issue Aug 8, 2023 · 1 comment · Fixed by #122577
Closed

Remove speculative parameter from instantiate_poly_trait_ref_inner #114635

compiler-errors opened this issue Aug 8, 2023 · 1 comment · Fixed by #122577
Assignees
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@compiler-errors
Copy link
Member

instantiate_poly_trait_ref_inner has a speculative parameter:

This parameter is used to suppress several errors downstream, and has only one usage:

... which is inside of hir_trait_to_predicates, which itself has only one usage:

// The traits' privacy in bodies is already checked as a part of trait object types.
let bounds = rustc_hir_analysis::hir_trait_to_predicates(
self.tcx,
trait_ref,
// NOTE: This isn't really right, but the actual type doesn't matter here. It's
// just required by `ty::TraitRef`.
self.tcx.types.never,
);

The reason why speculative = true at this call-site is because we're passing the wrong self type when instantiating the trait ref:

// NOTE: This isn't really right, but the actual type doesn't matter here. It's
// just required by `ty::TraitRef`.
self.tcx.types.never,

If we were able to pass the correct self type here, then we can totally remove the speculative parameter. I think that would be a nice clean-up if possible.

@compiler-errors compiler-errors added C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 8, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 8, 2023
@compiler-errors compiler-errors removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 8, 2023
@compiler-errors
Copy link
Member Author

The reason I marked this as "hard" is that it's not immediately clear how we're gonna funnel an appropriate self type to visit_trait_ref in the TypePrivacyVisitor. The HIR tree doesn't make it easy. This work will need lots of investigation and experimentation, and may not work out in the end.

@fmease fmease self-assigned this Mar 16, 2024
@bors bors closed this as completed in 4cbfa15 Mar 17, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 17, 2024
Rollup merge of rust-lang#122577 - fmease:speculative-say-what, r=compiler-errors

Remove obsolete parameter `speculative` from `instantiate_poly_trait_ref`

In rust-lang#122527 I totally missed that `speculative` has become obsolete with the removal of `hir_trait_to_predicates` / due to rust-lang#113671.

Fixes rust-lang#114635.

r? `@compiler-errors`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants