Skip to content

remove leftover type_ascription remains in feature gating #111325

Closed
@Noratrieb

Description

@Noratrieb

After #109128, there's some leftover code in feature gating.

fn visit_stmt(&mut self, stmt: &'a ast::Stmt) {
if let ast::StmtKind::Semi(expr) = &stmt.kind
&& let ast::ExprKind::Assign(lhs, _, _) = &expr.kind
&& let ast::ExprKind::Type(..) = lhs.kind
&& self.sess.parse_sess.span_diagnostic.err_count() == 0
&& !self.features.type_ascription
&& !lhs.span.allows_unstable(sym::type_ascription)
{
// When we encounter a statement of the form `foo: Ty = val;`, this will emit a type
// ascription error, but the likely intention was to write a `let` statement. (#78907).
feature_err(
&self.sess.parse_sess,
sym::type_ascription,
lhs.span,
"type ascription is experimental",
).span_suggestion_verbose(
lhs.span.shrink_to_lo(),
"you might have meant to introduce a new binding",
"let ",
Applicability::MachineApplicable,
).emit();
}
visit::walk_stmt(self, stmt);
}

It should be removed, although it needs to be ensured that code like it does not compile afterwards (I haven't tested it).

cc @chenyukang

Metadata

Metadata

Assignees

Labels

C-cleanupCategory: PRs that clean code up or issues documenting cleanup.F-type_ascription`#![feature(type_ascription)]`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