Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
brson opened this Issue · 4 comments

3 participants

@brson
Owner

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

Still a bug as of a477c5a.

@catamorphism catamorphism referenced this issue from a commit in catamorphism/rust
@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 closed this issue from a commit
@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 referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@catamorphism catamorphism was unassigned by brson
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.