Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove leftover type_ascription remains in feature gating #111325

Closed
Noratrieb opened this issue May 7, 2023 · 0 comments · Fixed by #111350
Closed

remove leftover type_ascription remains in feature gating #111325

Noratrieb opened this issue May 7, 2023 · 0 comments · Fixed by #111350
Assignees
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. F-type_ascription `#![feature(type_ascription)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Noratrieb
Copy link
Member

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

@Noratrieb Noratrieb added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. F-type_ascription `#![feature(type_ascription)]` labels May 7, 2023
@chenyukang chenyukang self-assigned this May 7, 2023
@bors bors closed this as completed in 7d5b746 Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. F-type_ascription `#![feature(type_ascription)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants