Overriding dependencies in Cargo.toml

Hey,

Pretty new to Rust, but I'm trying to build GitHub - servo/rust-layers: A GPU-accelerated 2D animation library for Rust locally, but after running cargo build I get the following error:

   Compiling io-surface v0.2.0
/Users/tonydaly/.cargo/registry/src/github.com-88ac128001ac3a9a/io-surface-0.2.0/src/lib.rs:13:1: 13:30 error: #[feature] may not be used on the stable release channel
/Users/tonydaly/.cargo/registry/src/github.com-88ac128001ac3a9a/io-surface-0.2.0/src/lib.rs:13 #![feature(clone_from_slice)]

Looks like there is an issue with an old feature switch? So I fork io-surface and update it myself here: GitHub - tonydaly/io-surface-rs at feature-cleanup

I've then updated my local Cargo.toml file to add this as a dependency:

io-surface = { git = "https://github.com/tonydaly/io-surface-rs.git", branch = "feature-cleanup" }

However, now when I run cargo build it tries to build my branch and the old one? How can I override this? Or what's the process to locally test updates to a dependency?

Any help appreciated

Cargo has a special override mechanism for locally testing changes to dependencies.

2 Likes

Thanks @mbrubeck that works great! However, I'm now getting the same error from a different package:

error: #[feature] may not be used on the stable release channel

Is this standard? Is the workaround just to use a Beta or Nighty release?

Yes, you'd have to use nightly for that crate then. Some crates depend on unstable features like that (and some crates only do it if you opt into one of their features). Ideally the crate should be quite clear about this in its docs, albeit if it's a syntax extension or something obviously unstable, they might not mention it.

1 Like

Servo predates stable Rust, and continues to rely on things like compiler plugins, so a lot of the crates we produce have only been used so far on nightly. But if you'd like a particular crate to be usable in stable Rust, please let us know. We'd be happy to take patches, or to help out ourselves if we have time.

It looks like one of the problem packages is rust-azure, which uses compiler plugins for serde and heapsize. These could probably be made optional or converted to work with syntex.

Very few features are so good that they are worth using syntex for. Sorry for being such a party killer, but syntex can take 20 minutes or so to compile. racer is a project that's so awesome that it can afford it, but few can.