Skip to content
This repository

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

Closed
brson opened this Issue April 24, 2012 · 4 comments

3 participants

Brian Anderson Marijn Haverbeke Tim Chevalier
Brian Anderson
Owner
brson commented April 24, 2012

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();
                                   ^~~~~
Marijn Haverbeke
Collaborator

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

Tim Chevalier
Collaborator

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.

Tim Chevalier
Collaborator

Still a bug as of a477c5a.

Tim Chevalier catamorphism referenced this issue from a commit in catamorphism/rust October 16, 2012
Tim Chevalier 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
Tim Chevalier
Collaborator

Fixed, pending code review by @nikomatsakis .

Tim Chevalier catamorphism closed this issue from a commit October 16, 2012
Tim Chevalier 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
Tim Chevalier catamorphism closed this in 46d4bbb October 22, 2012
Jay Anderson jayanderson referenced this issue from a commit November 10, 2013
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.