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

Document which trait bounds are implicit available for functions #34106

Closed
malbarbo opened this issue Jun 6, 2016 · 5 comments
Closed

Document which trait bounds are implicit available for functions #34106

malbarbo opened this issue Jun 6, 2016 · 5 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR. P-medium Medium priority

Comments

@malbarbo
Copy link
Contributor

malbarbo commented Jun 6, 2016

I opened the issue #28055 last year thinking that I had found a inconsistency in the type checker. Recently, some one asked a question in stackoverflow that involves the same issue. The question is about the need to repeat the bound of a trait in a function that uses the trait. For example:

trait A { }

trait B {
    type C;
}

trait D: B where Self::C: A { }

// does not compile, need to repeat the bound where T::C: A
fn f<T: D>(x: T) { }

@arielb1 closed the issue #28055 and wrote that it is the expected behavior. He also pointed which bounds are implicit available for function and wrote "I guess this should be a FAQ entry."

So, I'm opening this issue to register that this information need to be add to the docs (or FAQ).

One question for all: Do you agree with the justification "The thing is that we don't want too many bounds to be implicitly available for functions, as this can lead to fragility with distant changes causing functions to stop compiling"?

@malbarbo malbarbo changed the title Document which trait bounds are implicit avaible for functions Document which trait bounds are implicit available for functions Jun 6, 2016
jonysy added a commit to jonysy/hypospray that referenced this issue Dec 27, 2016
Trait bounds on Self are considered "supertraits". These are required
to be acyclic. Supertraits are somewhat different from other
constraints in that they affect what methods are available in the
vtable when the trait is used as a trait object.

Referencing rust-lang/rust#28055 and rust-lang/rust#34106
@steveklabnik steveklabnik added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Mar 10, 2017
@steveklabnik steveklabnik added P-medium Medium priority and removed A-docs labels Mar 22, 2017
@steveklabnik
Copy link
Member

Closed by rust-lang/reference#40

@malbarbo
Copy link
Contributor Author

@steveklabnik I think that rust-lang/reference#40 is only related with lifetimes. This is related with all implicit (trait) bounds, not only lifetime. Also the information on arial1b comment is not included.

@steveklabnik steveklabnik reopened this Apr 25, 2017
@steveklabnik
Copy link
Member

Sorry, I somehow got my links mixed up! it was #31137 i was intending to close, not this one ☹️

@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 25, 2017
@steveklabnik
Copy link
Member

Triage: no changes.

@steveklabnik
Copy link
Member

The place to document this is in the reference, so I've filed a bug against it there: rust-lang/reference#504

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR. P-medium Medium priority
Projects
None yet
Development

No branches or pull requests

3 participants