`copy` and `send` ifaces cannot be used as type parameter bounds #2284

Closed
brson opened this Issue Apr 25, 2012 · 4 comments

Projects

None yet

3 participants

@brson

While ifaces with the name copy and send can be declared and implemented, they are always shadowed by the copy and send kind bounds when used like fn f<T: send>. A small inconsistency.

iface send {
    fn f();
}

fn f<T: send>(t: T) {
    t.f();
}

fn main() {
}
../src/test/run-pass/test.rs:6:4: 6:7 error: attempted access of field f on type 'a, but no public field or method with that name was found
../src/test/run-pass/test.rs:6     t.f();
                                   ^~~
../src/test/run-pass/test.rs:6:4: 6:9 error: the type of this value must be known in this context
../src/test/run-pass/test.rs:6     t.f();
                                   ^~~~~
@marijnh

Does disallowing these words as iface names sound like an acceptable solution?

@marijnh marijnh was assigned Apr 26, 2012
@catamorphism

We won't disallow these words as trait names, now that copy and send are just traits. But, I'll fix the code so it doesn't prioritize copy and send over a user-defined trait shadowing one of these names.

@catamorphism catamorphism was assigned Aug 24, 2012
@catamorphism

Still a bug as of a477c5a.

@catamorphism catamorphism added a commit to catamorphism/rust that referenced this issue Oct 17, 2012
@catamorphism catamorphism Simplify the AST representation of ty param bounds
Change ast::ty_param_bound so that all ty param bounds are represented
as traits, with no special cases for Copy/Send/Owned/Const.
typeck::collect generates the special cases.

A consequence of this is that code using the #[no_core] attribute
can't use the Copy kind/trait. Probably not a big deal?

As a side effect, any user-defined traits that happen to be called
Copy, etc. in the same module override the built-in Copy trait.
Closes #2284
bbc94e8
@catamorphism

Fixed, pending code review by @nikomatsakis .

@catamorphism catamorphism added a commit that closed this issue Oct 22, 2012
@catamorphism catamorphism Simplify the AST representation of ty param bounds
Change ast::ty_param_bound so that all ty param bounds are represented
as traits, with no special cases for Copy/Send/Owned/Const.
typeck::collect generates the special cases.

A consequence of this is that code using the #[no_core] attribute
can't use the Copy kind/trait. Probably not a big deal?

As a side effect, any user-defined traits that happen to be called
Copy, etc. in the same module override the built-in Copy trait.

r=nmatsakis

Closes #2284
46d4bbb
@jayanderson jayanderson pushed a commit that referenced this issue Nov 11, 2013
@catamorphism catamorphism Simplify the AST representation of ty param bounds
Change ast::ty_param_bound so that all ty param bounds are represented
as traits, with no special cases for Copy/Send/Owned/Const.
typeck::collect generates the special cases.

A consequence of this is that code using the #[no_core] attribute
can't use the Copy kind/trait. Probably not a big deal?

As a side effect, any user-defined traits that happen to be called
Copy, etc. in the same module override the built-in Copy trait.

r=nmatsakis

Closes #2284
9cd48f2
@catamorphism catamorphism was unassigned by brson Jun 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment