Skip to content

Commit 9fc04a0

Browse files
committed
Workaround silent ignores of cargo features
This tripped me up and caused me a couple of hours of confusion. Cargo does not seem to pass on features to subcrates in a virtual workspace, nor does it respond to something you’d expect, like `cargo test -features=“moniker/codespan”`. This meant that I actually comitted buggy code to the repository! I’m working around this for now using `--manifest-path` method - it’s pretty gross though. There is an issue at rust-lang/cargo#4942 recording other people’s experiences with this behaviour.
1 parent 484b343 commit 9fc04a0

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

.travis.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@ rust:
66
- beta
77
- nightly
88
env:
9-
- CARGO_FEATURES=""
10-
- CARGO_FEATURES="codespan"
11-
- CARGO_FEATURES="default"
12-
- CARGO_FEATURES="default codespan"
9+
- MONIKER_CARGO_FEATURES=""
10+
- MONIKER_CARGO_FEATURES="codespan"
1311
matrix:
1412
allow_failures:
1513
- rust: nightly
1614
script:
17-
- cargo build --no-default-features --features "$CARGO_FEATURES" --verbose
18-
- cargo test --no-default-features --features "$CARGO_FEATURES" --verbose
19-
- bash -c 'if [[ $CARGO_FEATURES = *"default"* ]]; then
20-
cargo test --no-default-features --features "$CARGO_FEATURES" --examples --verbose;
21-
fi'
15+
# moniker-derive
16+
- cargo build --manifest-path=moniker-derive/Cargo.toml --verbose
17+
- cargo test --manifest-path=moniker-derive/Cargo.toml --verbose
18+
# moniker
19+
- cargo build --manifest-path=moniker/Cargo.toml --features="$MONIKER_CARGO_FEATURES" --verbose
20+
- cargo test --manifest-path=moniker/Cargo.toml --features="$MONIKER_CARGO_FEATURES" --verbose
21+
# moniker examples
22+
- cargo build --manifest-path=moniker/Cargo.toml --features="$MONIKER_CARGO_FEATURES" --verbose --examples
23+
- cargo test --manifest-path=moniker/Cargo.toml --features="$MONIKER_CARGO_FEATURES" --verbose --examples
2224
notifications:
2325
webhooks:
2426
urls:

moniker/src/bound.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl_bound_term_partial_eq!(f64);
193193
macro_rules! impl_bound_term_ignore {
194194
($T:ty) => {
195195
impl<Ident> BoundTerm<Ident> for $T {
196-
fn term_eq(&self, other: &$T) -> bool {
196+
fn term_eq(&self, _: &$T) -> bool {
197197
true
198198
}
199199

@@ -227,7 +227,7 @@ impl_bound_term_ignore!(LineOffset);
227227

228228
#[cfg(feature = "codespan")]
229229
impl<Ident, T> BoundTerm<Ident> for Span<T> {
230-
fn term_eq(&self, other: &Span<T>) -> bool {
230+
fn term_eq(&self, _: &Span<T>) -> bool {
231231
true
232232
}
233233

@@ -645,7 +645,7 @@ impl_bound_pattern_partial_eq!(f64);
645645
macro_rules! impl_bound_pattern_ignore {
646646
($T:ty) => {
647647
impl<Ident> BoundPattern<Ident> for $T {
648-
fn pattern_eq(&self, other: &$T) -> bool {
648+
fn pattern_eq(&self, _: &$T) -> bool {
649649
true
650650
}
651651

@@ -688,8 +688,8 @@ impl_bound_pattern_ignore!(LineNumber);
688688
impl_bound_pattern_ignore!(LineOffset);
689689

690690
#[cfg(feature = "codespan")]
691-
impl<Ident, T> BoundTerm<Ident> for Span<T> {
692-
fn pattern_eq(&self, other: &Span<T>) -> bool {
691+
impl<Ident, T> BoundPattern<Ident> for Span<T> {
692+
fn pattern_eq(&self, _: &Span<T>) -> bool {
693693
true
694694
}
695695

0 commit comments

Comments
 (0)