Skip to content

Add #[diagnostic::do_not_recommend] to impl AsExpression for T: Expression #4760

@weiznich

Description

@weiznich

We would like to add #[diagnostic::do_not_recommend] to this particular impl:

impl<T, ST> AsExpression<ST> for T
where
T: Expression<SqlType = ST>,
ST: SqlType + TypedExpressionType,
{
type Expression = T;
fn as_expression(self) -> T {
self
}
}

This would significantly improve the error messages emitted by #[derive(Insertable)] for type mismatches. It's currently not possible to add this attribute as it regresses the error message by rustc loosing the relevant span. This was reported upstream as regression in rust-lang/rust#123503 but is still not resolved.

We would need investigate if:

  • There is something we can to in the derive code to fix these spans
  • It's an actual rustc issue and needs to be resolved there.

Metadata

Metadata

Assignees

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions