Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

brson opened this issue Apr 25, 2012 · 4 comments
Labels
A-grammar Area: The grammar of Rust
Milestone

Comments

@brson
Copy link
Contributor

brson commented Apr 25, 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();
                                   ^~~~~
@marijnh
Copy link
Contributor

marijnh commented Apr 25, 2012

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

@ghost ghost assigned marijnh Apr 26, 2012
@catamorphism
Copy link
Contributor

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.

@ghost ghost assigned catamorphism Aug 24, 2012
@catamorphism
Copy link
Contributor

Still a bug as of a477c5a.

catamorphism added a commit to catamorphism/rust that referenced this issue Oct 17, 2012
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 rust-lang#2284
@catamorphism
Copy link
Contributor

Fixed, pending code review by @nikomatsakis .

flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 3, 2021
Move mini-macro to tests/ui/auxilary

changelog: none

Merges `/mini-macro` into `/tests/ui/auxilary/proc_macro_derive.rs`.

The mini-macro crate is an artifact of the distant past. A lot has changed (rust-lang#2284) and it doesn't make sense as a top-level crate anymore. Especially since we can use the auxilary folder to accompolish the same thing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-grammar Area: The grammar of Rust
Projects
None yet
Development

No branches or pull requests

3 participants