Skip to content

Add targets to MSRV cargo check#27

Open
rustworthy wants to merge 1 commit into
jonhoo:mainfrom
rustworthy:chore/msrv-job-update
Open

Add targets to MSRV cargo check#27
rustworthy wants to merge 1 commit into
jonhoo:mainfrom
rustworthy:chore/msrv-job-update

Conversation

@rustworthy
Copy link
Copy Markdown

as per this thread

@jonhoo
Copy link
Copy Markdown
Owner

jonhoo commented Jul 26, 2025

My only worry is that --lib will fail if there is no library (i.e., a binary-only crate) and --bins will fail if there are no binaries (and also --examples if there are no examples)? Could you please check that that's not the case?

@rustworthy
Copy link
Copy Markdown
Author

My only worry is that --lib will fail if there is no library (i.e., a binary-only crate) and --bins will fail if there are no binaries (and also --examples if there are no examples)? Could you please check that that's not the case?

I just realized I forgot to add the --all-features flag - since this is what was actually discovered in the faktory-rs crate and led to this PR here upstream.

As for your worries - you are right, but, interestingly, --bins and --examples will not fail if targets are not there, rather emit a warning, e.g. for a crate which is only a library, running cargo check --all-features --bins --examples (w/o --lib) will exit successfully but emit:

warning: target filters `bins`, `examples` specified, but no targets matched; this is a no-op

While in case of running cargo check --all-features --bins --examples --lib (note the --lib flag), even that warning will be suppressed (at least with the regular verbosity).

BUT! If this is a binary crate, and we run it with the command above, we get an error error: no library targets found in package

Possible ways out:

  • we can read manifest as suggested here and run cargo check --all-features --bins --examples --lib if a lib target is there. Me running cargo read-manifest | jq .targets outputs:
 [
  {
    "kind": [
      "lib"
    ],
    "crate_types": [
      "lib"
    ],
    "name": "checking",
    "src_path": "/tmp/checking/src/lib.rs",
    "edition": "2024",
    "doc": true,
    "doctest": true,
    "test": true
  },
  {
    "kind": [
      "bin"
    ],
    "crate_types": [
      "bin"
    ],
    "name": "checking",
    "src_path": "/tmp/checking/src/main.rs",
    "edition": "2024",
    "doc": true,
    "doctest": false,
    "test": true
  }
]
  • we can simply leave cargo check --all-features in this CI job with a comment that folks should enable other targets, such as --lib, --bins and --examples, as needed.

@jonhoo
Copy link
Copy Markdown
Owner

jonhoo commented Jul 26, 2025

I like the idea of auto-detecting here I think — it's always unfortunate if users need to carry permanent diffs!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants