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

Conflict about Some(1|2) in 1.53 #86408

Closed
kkonghao opened this issue Jun 17, 2021 · 2 comments
Closed

Conflict about Some(1|2) in 1.53 #86408

kkonghao opened this issue Jun 17, 2021 · 2 comments

Comments

@kkonghao
Copy link

kkonghao commented Jun 17, 2021

hi when i use rust 1.53 version some code about pattern match below make me confused,and i think this is a bug or a problem that cannot be ignored.

	let x = Some(2);
	assert!(matches!(x,Some(1 | 2)));//ok x is Some(2)
	assert!(matches!(Some(1),Some(1|2)));//ok
	assert!(matches!(Some(2),Some(1|2)));//ok

	let y = Some(1 | 2);//y is Some(3)
	// assert!(matches!(Some(3),Some(1|2)));// error, Some(1|2) =>is Some(1) | Some(2) or Some(3)?
@bugadani
Copy link
Contributor

This isn't new at all: rust-lang/rfcs#2535 (comment)

Since 1|2 already had the same ambiguoity, this has been kind of "ignored" as far as I understand, but don't quote me on the reasoning.

@jonas-schievink
Copy link
Contributor

or-patterns do not function as binary operators. This is working as intended, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants