Skip to content

Remove speculative parameter from instantiate_poly_trait_ref_inner #114635

Closed
@compiler-errors

Description

@compiler-errors

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.

Metadata

Metadata

Assignees

Labels

C-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions