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

Compiler errors (Copy constraint on Buffer) #181

Closed
bvssvni opened this issue Jan 30, 2015 · 20 comments
Closed

Compiler errors (Copy constraint on Buffer) #181

bvssvni opened this issue Jan 30, 2015 · 20 comments
Assignees

Comments

@bvssvni
Copy link
Member

bvssvni commented Jan 30, 2015

The methods on Cell requires a Copy constraint, which is no longer implemented by Buffer.

src/chunk.rs:113:40: 113:45 error: type `&core::cell::Cell<core::option::Option<shader::Buffer>>` does not implement any method in scope named `get`
src/chunk.rs:113                 f(x, y as i32, z, c, b.get())
                                                        ^~~~~
src/chunk.rs:113:45: 113:45 help: methods from traits can only be called if the trait is implemented and in scope; the following traits define a method `get`, perhaps you need to implement one of them:
src/chunk.rs:113:45: 113:45 help: candidate #1: `core::slice::SliceExt`
src/chunk.rs:113:45: 113:45 help: candidate #2: `collections::slice::SliceExt`
src/chunk.rs:113:45: 113:45 help: candidate #3: `quack::get::Get`
src/minecraft/region.rs:143:41: 143:50 error: the trait `core::marker::Copy` is not implemented for the type `shader::Buffer` [E0277]
src/minecraft/region.rs:143             buffers: Array::from_fn(|_| Cell::new(None)),
                                                                    ^~~~~~~~~
src/main.rs:294:38: 294:43 error: type `&core::cell::Cell<core::option::Option<shader::Buffer>>` does not implement any method in scope named `get`
src/main.rs:294                         match buffer.get() {
                                                     ^~~~~
src/main.rs:294:43: 294:43 help: methods from traits can only be called if the trait is implemented and in scope; the following traits define a method `get`, perhaps you need to implement one of them:
src/main.rs:294:43: 294:43 help: candidate #1: `core::slice::SliceExt`
src/main.rs:294:43: 294:43 help: candidate #2: `collections::slice::SliceExt`
src/main.rs:294:43: 294:43 help: candidate #3: `quack::get::Get`
src/main.rs:302:32: 304:27 error: type `&core::cell::Cell<core::option::Option<shader::Buffer>>` does not implement any method in scope named `set`
src/main.rs:302                         buffer.set(Some(
src/main.rs:303                             renderer.create_buffer(staging_buffer.as_slice())
src/main.rs:304                         ));
src/main.rs:304:27: 304:27 help: methods from traits can only be called if the trait is implemented and in scope; the following trait defines a method `set`, perhaps you need to implement it:
src/main.rs:304:27: 304:27 help: candidate #1: `quack::set::Set`
error: aborting due to 4 previous errors
Could not compile `hematite`.
@bvssvni
Copy link
Member Author

bvssvni commented Jan 30, 2015

The PR that broke it in Gfx was gfx-rs/gfx#507

@bvssvni
Copy link
Member Author

bvssvni commented Jan 30, 2015

@bvssvni
Copy link
Member Author

bvssvni commented Jan 30, 2015

No, I was wrong. The Copy constraint was moved here sectopod/gfx-rs@7de1690#diff-9727ac41ee298b338aa97b20cd10c264R214

@bvssvni
Copy link
Member Author

bvssvni commented Jan 30, 2015

The problem is that Copy is implemented with a where constraint.

I guess, somehow the <ShaderParam as gfx::shade::ShaderParam>::Link is not Copy.

@eddyb
Copy link
Contributor

eddyb commented Jan 30, 2015

There should be a rust issue about deriving not working correctly with associated types.

@toqueteos
Copy link
Contributor

Dup of #170 ?

@bvssvni
Copy link
Member Author

bvssvni commented Feb 1, 2015

@eddyb Are you suspicious about this being a bug in Rust?

@eddyb
Copy link
Contributor

eddyb commented Feb 1, 2015

It's a known issue, and I expect there to an issue open on it in the Rust repo.

@bvssvni
Copy link
Member Author

bvssvni commented Feb 4, 2015

See rust-lang/rust#21237

@kvark
Copy link
Member

kvark commented Feb 4, 2015

I'll deal with it tonight, unless it's fixed by then.

@kvark
Copy link
Member

kvark commented Feb 5, 2015

This should be fixed in latest, but the new gfx-rs version has not yet been published.

@kvark
Copy link
Member

kvark commented Feb 5, 2015

Gfx v0.1.2 has been published. Please try again with cargo update.

@toqueteos
Copy link
Contributor

I just tried on windows. Still got the same errors as before.

NOPE. I'M AN IDIOT AND WRONG.

@kvark
Copy link
Member

kvark commented Feb 5, 2015

Thanks @toqueteos ! I'll have a closer look at this when I'm back at home. We do have the Copy implemented now, and there is even a test for it, so I find it strange that the error is still there.

@toqueteos
Copy link
Contributor

You're welcome @kvark! Just in case I also tried with a fresh clone in a different folder but still no luck. Same 4 nasty errors.

NOPE. I'M AN IDIOT AND WRONG.

@kvark
Copy link
Member

kvark commented Feb 5, 2015

I think I found something. Here is your struct:

pub struct Buffer {
    buf: gfx::BufferHandle<Vertex>,
    batch: gfx::batch::RefBatch<ShaderParam>,
}

So even if both gfx parts are Copy, it doesn't make Copy implemented for your Buffer by default. I think you are just missing #[derive(Copy)] for it.

@toqueteos
Copy link
Contributor

Totally right, I forgot to add the missing derive Copy. It does indeed compile again!

Let me copy the MC assets and make a screenshot! YAY for @kvark 👍 ❤️

@kvark
Copy link
Member

kvark commented Feb 5, 2015

Thanks! Closing as fixed.

@kvark kvark closed this as completed Feb 5, 2015
@bvssvni
Copy link
Member Author

bvssvni commented Feb 5, 2015

This needs a PR, but mac nightlies are delayed so I can't fix it now.

@bvssvni bvssvni reopened this Feb 5, 2015
@toqueteos
Copy link
Contributor

@bvssvni Working my ass off on it, also fixing loads of stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants