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

Use cargo fix command not check [dependencies] crate code #11096

Open
baoyachi opened this issue Sep 16, 2022 · 1 comment
Open

Use cargo fix command not check [dependencies] crate code #11096

baoyachi opened this issue Sep 16, 2022 · 1 comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-fix S-triage Status: This issue is waiting on initial triage.

Comments

@baoyachi
Copy link

baoyachi commented Sep 16, 2022

Problem

when use cargo fix command, does cargo ignore check dependencies crate code ,just fix check current repository code

error detail

➜  odbc-api-helper git:(main) rustc -V
rustc 1.63.0 (4b91a6ea7 2022-08-08)
➜  odbc-api-helper git:(main) rustup default 1.61.0
info: using existing install for '1.61.0-x86_64-apple-darwin'
info: default toolchain set to '1.61.0-x86_64-apple-darwin'

  1.61.0-x86_64-apple-darwin unchanged - rustc 1.61.0 (fe5b13d68 2022-05-18)

➜  odbc-api-helper git:(main) cargo fix
   Compiling libc v0.2.132
   Compiling proc-macro2 v1.0.43
   Compiling unicode-ident v1.0.3
   Compiling quote v1.0.21
   Compiling memchr v2.5.0
   Compiling syn v1.0.99
    Checking cfg-if v1.0.0
   Compiling autocfg v1.1.0
   Compiling version_check v0.9.4
   Compiling serde_derive v1.0.144
   Compiling typenum v1.15.0
   ...
    Checking miette v5.3.0
error[E0658]: use of unstable library feature 'bool_to_option'
   --> /Users/baoyachi/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/odbc-api-0.49.0/src/cursor.rs:572:24
    |
572 |             Ok(has_row.then_some(&self.buffer))
    |                        ^^^^^^^^^
    |
    = note: see issue #80967 <https://github.com/rust-lang/rust/issues/80967> for more information

error[E0658]: use of unstable library feature 'bool_to_option'
   --> /Users/baoyachi/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/odbc-api-0.49.0/src/cursor.rs:429:24
    |
429 |             Ok(has_row.then_some(&self.buffer))
    |                        ^^^^^^^^^
    |
    = note: see issue #80967 <https://github.com/rust-lang/rust/issues/80967> for more information

error[E0658]: use of unstable library feature 'bool_to_option'
   --> /Users/baoyachi/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/odbc-api-0.49.0/src/handles/environment.rs:228:24
    |
228 |         .map(|res| res.then_some((length_description, length_attributes)))
    |                        ^^^^^^^^^
    |
    = note: see issue #80967 <https://github.com/rust-lang/rust/issues/80967> for more information

error[E0658]: use of unstable library feature 'bool_to_option'
   --> /Users/baoyachi/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/odbc-api-0.49.0/src/handles/environment.rs:270:24
    |
270 |         .map(|res| res.then_some((length_name, length_description)))
    |                        ^^^^^^^^^
    |
    = note: see issue #80967 <https://github.com/rust-lang/rust/issues/80967> for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `odbc-api` due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
➜  odbc-api-helper git:(main) 

Proposed Solution

just cargo fix check current repository code,and fix

Notes

No response

@baoyachi baoyachi added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Sep 16, 2022
@weihanglo
Copy link
Member

Thanks for the report. I believe this is the default behaviour for all compilation commands in Cargo.

Those errors you saw were actually non-fixable with cargo fix. Cargo fix does its job by taking rustc's diagnostic suggestions and apply them to your source code. Without succeeding to compile dependencies, cargo cannot proceed to "fix" your crate. You will get the same errors when performing a cargo build as well.

One way to improve the error message is the author of odbc-api adding rust-version field in Cargo.toml. The rust-version field would be checked upfront, so you won't get those detailed error messages from dependencies.

error: package `foo v0.0.1 (/projects/foo)` cannot be built 
because it requires rustc 1.9876.0 or newer, 
while the currently active rustc version is 1.63.0

I am not sure how Cargo can improve at this moment. Do you have any further suggestion?

@epage epage added the S-triage Status: This issue is waiting on initial triage. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-fix S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

3 participants