Skip to content

Allow trivial constraints to appear in where clauses#2056

Merged
aturon merged 4 commits into
rust-lang:masterfrom
sgrif:sg-allow-trivial-where-clause-constraints
Feb 14, 2018
Merged

Allow trivial constraints to appear in where clauses#2056
aturon merged 4 commits into
rust-lang:masterfrom
sgrif:sg-allow-trivial-where-clause-constraints

Conversation

@sgrif

@sgrif sgrif commented Jul 5, 2017

Copy link
Copy Markdown
Contributor

@aturon aturon added the T-lang Relevant to the language team, which will review and decide on the RFC. label Jul 5, 2017
@Ixrec

Ixrec commented Jul 5, 2017

Copy link
Copy Markdown
Contributor

Making this not an error seems like a good idea to me, but I'd keep it around as a lint/warning, since we are talking about "nonsensical" code, and I assume there are also macros where it'd be considered a bug if a trivial where clause got generated.

@sgrif

sgrif commented Jul 5, 2017

Copy link
Copy Markdown
Contributor Author

That's an excellent point. I'm not able to update right now, but I like the idea of having it be around as a lint. I'll update the text to go that direction when I have a chance, and leave whether the lint is enabled by default or not as an unresolved question

@ExpHP

ExpHP commented Jul 5, 2017

Copy link
Copy Markdown

This limitation has been a thorn in my side at least once. To my memory, it is the lack of this feature which makes it impossible for macros like newtype_derive to automatically and correctly generate impls for pairings of owned/borrowed arguments like

impl Add<Foo>  for Foo  where  i8: Add< i8, Output=i8> { ... }
impl Add<&Foo> for Foo  where  i8: Add<&i8, Output=i8> { ... }
impl Add<Foo>  for &Foo where &i8: Add< i8, Output=i8> { ... }
impl Add<&Foo> for &Foo where &i8: Add<&i8, Output=i8> { ... }

To play devil's advocate, I do have to wonder if some crates may have popped up since 1.7 that rely on these errors as a form of static assertion about what traits are implemented (as the author was likely unaware that trivially true bounds were intended to produce compiler errors). Out of concern for this, I might lean towards "warn by default", since macros can easily disable the warnings in their output.

@aturon

aturon commented Sep 6, 2017

Copy link
Copy Markdown
Contributor

@sgrif Sorry for the lack of attention from the lang team. I've nominated to get it in front of people ahead of the impl period.

@nikomatsakis

Copy link
Copy Markdown
Contributor

@rfcbot fcp merge

Discussed this in the @rust-lang/lang meeting. There are already many points in the language where we allow similar things, and we've been generally moving in the direciton of allowing unsatisfiable constraints (with a warning). I propose to merge.

@rfcbot rfcbot added the proposed-final-comment-period Currently awaiting signoff of all team members in order to enter the final comment period. label Jan 18, 2018
@rfcbot

rfcbot commented Jan 18, 2018

Copy link
Copy Markdown

Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged teams:

No concerns currently listed.

Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot

rfcbot commented Jan 31, 2018

Copy link
Copy Markdown

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. and removed proposed-final-comment-period Currently awaiting signoff of all team members in order to enter the final comment period. labels Jan 31, 2018
@rfcbot

rfcbot commented Feb 10, 2018

Copy link
Copy Markdown

The final comment period is now complete.

@aturon

aturon commented Feb 14, 2018

Copy link
Copy Markdown
Contributor

This RFC has been merged!

Tracking issue

@aturon aturon merged commit 6f82eb1 into rust-lang:master Feb 14, 2018
@nox

nox commented Feb 25, 2018

Copy link
Copy Markdown
Contributor

The RFC doesn't mention what should happen for where clauses on structs and other type definitions.

struct Foo where i32: IntoIterator;

fn main() {
    Foo;
}

@Centril Centril added A-traits Trait system related proposals & ideas A-typesystem Type system related proposals & ideas labels Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-traits Trait system related proposals & ideas A-typesystem Type system related proposals & ideas final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. T-lang Relevant to the language team, which will review and decide on the RFC.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants