Skip to content

Terminology: prefer "outside inference" to "after typeck" (or worse "during codegen"). #70258

Closed
@eddyb

Description

@eddyb

Example offenders:

/// This is appropriate to use only after type-check: it assumes
/// that normalization will succeed, for example.
pub fn normalize_erasing_regions<T>(self, param_env: ty::ParamEnv<'tcx>, value: T) -> T

/// Assumes that this is run after the entire crate has been successfully type-checked.
pub fn codegen_fulfill_obligation<'tcx>(

None of this is particularly true anymore (not that it was great when it used to be true), especially since we started using miri for constant evaluation, which uses all the same tools codegen does, and is interleaved/mutually recursive with type-checking.

The only real thing to keep in mind is that if you have inference variables, you're responsible for using InferCtxt correctly.

cc @rust-lang/compiler

Metadata

Metadata

Assignees

Labels

C-cleanupCategory: PRs that clean code up or issues documenting cleanup.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