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

Add support for half-open range patterns #13739

Closed
jplatte opened this issue Dec 8, 2022 · 3 comments · Fixed by #13769
Closed

Add support for half-open range patterns #13739

jplatte opened this issue Dec 8, 2022 · 3 comments · Fixed by #13769
Labels
A-parser parser issues A-ty type system / type inference / traits / method resolution C-feature Category: feature request E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now

Comments

@jplatte
Copy link
Contributor

jplatte commented Dec 8, 2022

fn main() {
    match 5 {
        ..=1 => {}
        _ => {}
    }
}
Currently produces three syntax errors
[{
	"resource": "/home/jplatte/code/playground/src/lib.rs",
	"owner": "rustc",
	"code": {
		"value": "syntax-error",
		"target": {
			"$mid": 1,
			"external": "https://rust-analyzer.github.io/manual.html#syntax-error",
			"path": "/manual.html",
			"scheme": "https",
			"authority": "rust-analyzer.github.io",
			"fragment": "syntax-error"
		}
	},
	"severity": 8,
	"message": "Syntax Error: expected FAT_ARROW",
	"source": "rust-analyzer",
	"startLineNumber": 3,
	"startColumn": 11,
	"endLineNumber": 3,
	"endColumn": 11
}]

[{
	"resource": "/home/jplatte/code/playground/src/lib.rs",
	"owner": "rustc",
	"code": {
		"value": "syntax-error",
		"target": {
			"$mid": 1,
			"external": "https://rust-analyzer.github.io/manual.html#syntax-error",
			"path": "/manual.html",
			"scheme": "https",
			"authority": "rust-analyzer.github.io",
			"fragment": "syntax-error"
		}
	},
	"severity": 8,
	"message": "Syntax Error: expected expression",
	"source": "rust-analyzer",
	"startLineNumber": 3,
	"startColumn": 11,
	"endLineNumber": 3,
	"endColumn": 11
}]

[{
	"resource": "/home/jplatte/code/playground/src/lib.rs",
	"owner": "rustc",
	"code": {
		"value": "syntax-error",
		"target": {
			"$mid": 1,
			"external": "https://rust-analyzer.github.io/manual.html#syntax-error",
			"path": "/manual.html",
			"scheme": "https",
			"authority": "rust-analyzer.github.io",
			"fragment": "syntax-error"
		}
	},
	"severity": 8,
	"message": "Syntax Error: expected `,`",
	"source": "rust-analyzer",
	"startLineNumber": 3,
	"startColumn": 12,
	"endLineNumber": 3,
	"endColumn": 12
}]

Half-open range patterns were stabilized for 1.66 in rust-lang/rust#102275.

@flodiebold flodiebold added A-ty type system / type inference / traits / method resolution A-parser parser issues C-feature Category: feature request labels Dec 8, 2022
@jonas-schievink
Copy link
Contributor

To fix this, this function needs to be rewritten slightly to handle range patterns without a lower bound (left-hand side):

fn pattern_single_r(p: &mut Parser<'_>, recovery_set: TokenSet) {

Then parsing for ..1 and ..=1 can be implemented and added to the test in the function.

@jonas-schievink jonas-schievink added E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now labels Dec 9, 2022
@msfjarvis
Copy link

I'd like to try working on this

@rustbot claim

@msfjarvis
Copy link

I've been unable to make much progress and with the 1.66 release being fairly close it'd be better to let someone more experienced get to this soon.

@rustbot release-assignment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser parser issues A-ty type system / type inference / traits / method resolution C-feature Category: feature request E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants