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

RFC: Exempt .field from forms-not-allowed-after-block-calls #1716

Closed
marijnh opened this issue Jan 31, 2012 · 3 comments
Closed

RFC: Exempt .field from forms-not-allowed-after-block-calls #1716

marijnh opened this issue Jan 31, 2012 · 3 comments

Comments

@marijnh
Copy link
Contributor

marijnh commented Jan 31, 2012

So, playing with monads, I really wanted to do this:

optval.bind {|v| if something() { some(v + 1) } else { none }}
      .bind {|v| some(other_operation(v))}

i.e. chaining bind calls together. Such a thing is probably also useful in other minilanguage-like abstractions. It seems this syntax introduces no ambiguities -- expressions can not start with a dot token (.5 is a number token).

I guess allowing this doesn't make the rules any harder to explain -- in fact, there are fewer exceptions (now just calls and []-indexing) to enumerate.

@ghost ghost assigned marijnh Jan 31, 2012
@nikomatsakis
Copy link
Contributor

Makes sense to me. I presume that a semicolon is required in the case of foo.bar {||...}.fld or foo.bar {||...}[0]?

@marijnh
Copy link
Contributor Author

marijnh commented Jan 31, 2012

I presume that a semicolon is required in the case of foo.bar {||...}.fld or foo.bar {||...}[0]?

Yes, of course.

@brson
Copy link
Contributor

brson commented Feb 1, 2012

I've wanted this too.

marijnh added a commit that referenced this issue Feb 6, 2012
There is no valid expression that starts with a dot token (.5 is a number token),
so this introduces no ambiguities.

Issue #1716
@marijnh marijnh closed this as completed Feb 6, 2012
@marijnh marijnh removed their assignment Jun 16, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 7, 2021
Add lint `equatable_if_let`

This is my attempt for rust-lang#1716. There is a major false positive, which is people may implement `PartialEq` in a different way. It is unactionable at the moment so I put it into `nursery`.

There is a trait `StructuralPartialEq` for solving this problem which is promising but it has several problems currently:
* Integers and tuples doesn't implement it.
* Some types wrongly implement it, like `Option<T>` when `T` doesn't implement it.

I consider them bugs and against the propose of `StructuralPartialEq`. When they become fixed, this lint can become a useful lint with a single line change.

changelog: New lint: [`equatable_if_let`]
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