Skip to content

Document which trait bounds are implicit available for functions #34106

Closed
@malbarbo

Description

@malbarbo
Contributor

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"?

Activity

changed the title [-]Document which trait bounds are implicit avaible for functions[/-] [+]Document which trait bounds are implicit available for functions[/+] on Jun 6, 2016
added
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
on Mar 10, 2017
steveklabnik

steveklabnik commented on Apr 24, 2017

@steveklabnik
Member
malbarbo

malbarbo commented on Apr 24, 2017

@malbarbo
ContributorAuthor

@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 commented on Apr 25, 2017

@steveklabnik
Member

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

steveklabnik

steveklabnik commented on May 28, 2018

@steveklabnik
Member

Triage: no changes.

steveklabnik

steveklabnik commented on Jan 10, 2019

@steveklabnik
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.P-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@malbarbo@Mark-Simulacrum

        Issue actions

          Document which trait bounds are implicit available for functions · Issue #34106 · rust-lang/rust