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

Consider precedence btw pat : type (ascription) & p0 | ... | pn (or_patterns) #67309

Closed
Centril opened this issue Dec 15, 2019 · 1 comment
Closed
Labels
A-parser Area: The parsing of Rust source code to an AST F-bindings_after_at `#![feature(bindings_after_at)]` F-or_patterns `#![feature(or_patterns)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@Centril
Copy link
Contributor

Centril commented Dec 15, 2019

We should ensure that we consider the precedence of type ascription in relation to or-patterns, e.g.

let A(x) | B(y): T;

should probably bind as (A(x)) | (B(y): T) and not (A(x) | B(x)): T. This might not make a semantic difference because both sides should be of the same type, but parsing in the right way is a more iron-clad guarantee of forward-compatibility.

For @-patterns, this should ideally also bind as binding @ (sub: T) as opposed to (binding @ sub): T when writing e.g. let binding @ sub: T;. This might be observable via type checking of things like let ref binding @ A(_): T = scrutinee; but fortunately binding: &T holds here and not binding: T so like with or-patterns above we might be good. Still, before stabilizing F-bindings_after_at (e.g. binding @ Some(sub_binding)) we should endeavor to be more sure.

@Centril Centril added A-parser Area: The parsing of Rust source code to an AST T-lang Relevant to the language team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. requires-nightly This issue requires a nightly compiler in some way. F-or_patterns `#![feature(or_patterns)]` F-bindings_after_at `#![feature(bindings_after_at)]` labels Dec 15, 2019
@chenyukang
Copy link
Member

Closing now for #101728

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST F-bindings_after_at `#![feature(bindings_after_at)]` F-or_patterns `#![feature(or_patterns)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants