-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.F-type_ascription`#![feature(type_ascription)]``#![feature(type_ascription)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
After #109128, there's some leftover code in feature gating.
rust/compiler/rustc_ast_passes/src/feature_gate.rs
Lines 378 to 401 in 613a5c9
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.Category: PRs that clean code up or issues documenting cleanup.F-type_ascription`#![feature(type_ascription)]``#![feature(type_ascription)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.