Skip to content

Compiler error after running cargo clippy --fix #9926

@typesanitizer

Description

@typesanitizer

Configurations checked:

  • clippy 0.1.66 (42325c52 2022-11-11), cargo 1.67.0-nightly (9286a1beb 2022-11-04) (via cargo +nightly clippy --fix)
  • clippy 0.1.65 (897e3755 2022-11-02), cargo 1.65.0 (4bc8f24d3 2022-10-20)

If you clone the repo with the initial commit:

https://github.com/typesanitizer/pichpich/tree/b971066734479f1bae779a0fa481fdc0d2b4e458

Then running cargo clippy --fix gives an error: (there are other warnings from clippy too but not showing those here)

after fixes were automatically applied the compiler reported errors within these files:

  * src/lib.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

The following errors were reported:
error[E0277]: a value of type `std::vec::Vec<AppErrorNewtype>` cannot be built from an iterator over elements of type `std::boxed::Box<AppErrorNewtype>`
    --> src/lib.rs:30:24
     |
30   |               unrelated: errors
     |  ________________________^
31   | |                 .into_iter()
32   | |                 .map(|e| Box::new(AppErrorNewtype(e)))
     | |______________________________________________________^ value of type `std::vec::Vec<AppErrorNewtype>` cannot be built from `std::iter::Iterator<Item=std::boxed::Box<AppErrorNewtype>>`
33   |                   .collect(),
     |                    ------- required by a bound introduced by this call
     |
     = help: the trait `std::iter::FromIterator<std::boxed::Box<AppErrorNewtype>>` is not implemented for `std::vec::Vec<AppErrorNewtype>`
     = help: the trait `std::iter::FromIterator<T>` is implemented for `std::vec::Vec<T>`
note: required by a bound in `std::iter::Iterator::collect`
    --> /Users/varun/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1832:19
     |
1832 |     fn collect<B: FromIterator<Self::Item>>(self) -> B
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::collect`

error[E0599]: the method `as_ref` exists for reference `&AppErrorNewtype`, but its trait bounds were not satisfied
   --> src/lib.rs:57:45
    |
57  |             self.unrelated.iter().map(|b| b.as_ref() as &dyn Diagnostic),
    |                                             ^^^^^^ method cannot be called on `&AppErrorNewtype` due to unsatisfied trait bounds
...
79  | pub struct AppErrorNewtype(pub AppError);
    | -------------------------- doesn't satisfy `AppErrorNewtype: std::convert::AsRef<_>`
    |
    = note: the following trait bounds were not satisfied:
            `AppErrorNewtype: std::convert::AsRef<_>`
            which is required by `&AppErrorNewtype: std::convert::AsRef<_>`
note: the following trait must be implemented
   --> /Users/varun/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/convert/mod.rs:218:1
    |
218 | pub trait AsRef<T: ?Sized> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `as_ref`, perhaps you need to implement it:
            candidate rust-lang/rust#1: `std::convert::AsRef`

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
Original diagnostics will follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingS-triageStatus: PR was triaged and is waiting for an action from a maintainer (closing/moving/... the PR)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions