I believe it works today by looking at the traits that are in scope. This
RFC is all about modifying that to look at the impls in the other crate for
that type.

I honestly do not know enough about the algorithm to state in much more
detail precisely what this would mean, but it wouldn't be considering only
in-scope traits.


On Mon, Apr 7, 2014 at 10:48 AM, Niko Matsakis <notifications@github.com>wrote:

> In active/0000-less-trait-imports.md:
>
> > +A more concrete example arises in `libterm`. Ideally `AnsiTerminal` would be a
> > +trait with `Win32Terminal` and `TerminfoTerminal` implementing it. Doing so,
> > +however, affects every use of the crate. Were `libterm` marked stable,
> > +introducing such an abstraction would be impossible. I worry that this will be
> > +a significant backwards compat hazard, since most crates do not have the
> > +luxury of a language-supported prelude.
> > +
> > +A nice benefit of this is that we will never need a trait in the prelude
> > +again. Since the traits are all in std, there can never be an extension
> > +implementation.
> > +
> > +# Detailed design
> > +
> > +When looking up a type's methods, instead of just looking at what traits are
> > +in scope and the inherent methods, consider every implementation from the
> > +crate the type is defined in. When both an non-extension and extension method
>
> This doesn't fit with my mental model for how method lookup works. (In
> fact, I'm in the process of writing up a detailed RFC on this...). In my
> head, method lookup considers inherent methods + methods from some set of
> *traits*, not impls. So we have to define this in terms of the traits
> that are in scope.
>
> Also, it is not exactly well-defined what type you are referring to --
> e.g., in something like &Rc<[Foo]>, do you mean the builtin type &, the
> type Rc, the type [...], the type [Foo]? I think we will need to find a
> more precise definition.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/rust-lang/rfcs/pull/37/files#r11346542>
> .
>



-- 
http://octayn.net/