Crate Attributes through rustc or cargo flags

I am trying to compile an older version of tide using an older version of the rust compiler. Some of the dependencies deep down use features not supported by my old version of the compiler, for example I see

error[E0658]: `match` is not allowed in a `const`
  --> /home/utsav/.cargo/registry/src/github.com-1ecc6299db9ec823/value-bag-1.0.0-alpha.7/src/internal/cast/primitive.rs:29:25
...
   = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
   = help: add `#![feature(const_if_match)]` to the crate attributes to enable
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

If I add the language feature attribute in the source code checked out at github.com-1ecc6299db9ec823 repo, it does compile. I do not want to maintain this entire crate as a patch in my online repo for that one line of change. Is there a way to pass a rustc flag (using rustflags in .cargo/config.toml) or is there some addition to Cargo.toml file which would enable this feature attribute for that one crate, or the entire dependency tree?

rustc flags like --cfg feature(const_if_match) and --feature const_if_match did not work.

You can try -Zcrate-attr=feature(const_if_match).

Don't you need a nightly compiler to use the -Z flags?

If it were me, I'd fork tide and add the attribute to lib.rs, then use the [patch] section in your Cargo.toml to say "use my version of tide instead of the crates.io one".

A really dirty hack which may or may not be acceptable is to go into the ~/.cargo/registry/src/github.com-1ecc6299db9ec823/ directory and modify the lib.rs file to have that attribute. You would then need to re-apply this hack any time the tide crate is retrieved from crates.io.

Nightly is necessary to use #![feature(...)], too, so it is likely already being used.

Could you add some reference to this? Cargo book seems to not mention such feature.

This is a rustc flag, so you have to pass it using RUSTFLAGS="-Zcrate-attr=feature(const_if_match). I am not sure if it is documented somewhere. It shows up in rustc -Zhelp and is used by the rust build system I believe.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.