Skip to content

MIR dead code analysis affects TAIT inference #99490

Closed
@compiler-errors

Description

@compiler-errors

Given the code:

#![feature(type_alias_impl_trait)]

type Tait = impl Sized;

struct One;
fn one() -> Tait { One }

struct Two<T>(T);
fn two() -> Tait { Two::<()>(todo!()) }

If you run the code, you can see that the compiler ends up "successfully" inferencing Tait = One and succeeding compilation, even though upon visual inspection, the compiler should be raising an error since fn two should cause the conflicting inference Tait = Two<()>.

The key here is the todo!() macro, which causes the SimplifyCfg MIR pass to remove MIR that actually causes us to make this second inference.

Is this expected? How would we even change this behavior, since it would require us to disentangle TAIT inference from borrowck..?

Metadata

Metadata

Assignees

Labels

A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions