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

Compiling Errors When Using on Solana Contracts #114

Open
mdulin2 opened this issue Dec 30, 2024 · 9 comments
Open

Compiling Errors When Using on Solana Contracts #114

mdulin2 opened this issue Dec 30, 2024 · 9 comments

Comments

@mdulin2
Copy link

mdulin2 commented Dec 30, 2024

I've tried running the lints on the built-in Solana test contracts and on personal projects with the current toolchains that are set up. However, I keep getting errors in solana-program:

    Checking solana-program v1.18.26
error[E0658]: use of unstable library feature 'offset_of'
   --> /Users/strikeout/.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-program-1.18.26/src/program.rs:441:20
    |
441 |         assert_eq!(offset_of!(StableInstruction, program_id), 48);

When I tried to change the toolchain to the nightly setup, I also got build errors within clippy.

Am I missing something here? I am happy to admit fault on compiling the code but would appreciate some guidance on running the built-in Solana test contracts for the specific lints.

@mdulin2
Copy link
Author

mdulin2 commented Dec 30, 2024

This project is awesome though :) I'm looking to build some stuff on top of this.

@mdulin2
Copy link
Author

mdulin2 commented Feb 3, 2025

This seems to be from out-dated dependencies for the specified Rust toolchain. I tried increasing to nightly but kept running into issues. I'd love some help trying to fix this.

@smoelius
Copy link
Member

smoelius commented Feb 4, 2025

@mdulin2 I'm very sorry for not replying when you opened the issue.

I haven't reproduced your exact issue, but the lints definitely need to be updated.

I have updated the lints' toolchains and dependencies, but one of the missing_signer_check tests is failing.

I will do my best to respond within the next few days.

@smoelius
Copy link
Member

smoelius commented Feb 5, 2025

@mdulin2 The lints have been updated. Could you please try again with the current master (1fdb13b) and see whether the problem persists?

@mdulin2
Copy link
Author

mdulin2 commented Feb 7, 2025

Yes! Most of the lints build on my machine locally now. Thanks for taking the time to fix it!

@mdulin2
Copy link
Author

mdulin2 commented Feb 7, 2025

The arbitrary CPI lint is still giving me errors when I try to build it though:

strikeout@maxwells-mbp arbitrary_cpi % cargo build
   Compiling proc-macro2 v1.0.93
   Compiling unicode-ident v1.0.16
   Compiling serde v1.0.217
   Compiling libc v0.2.169
   Compiling shlex v1.3.0
   Compiling pkg-config v0.3.31
   Compiling stable_deref_trait v1.2.0
   Compiling version_check v0.9.5
   Compiling typenum v1.17.0
   Compiling memchr v2.7.4
   Compiling vcpkg v0.2.15
   Compiling litemap v0.7.4
   Compiling writeable v0.5.5
   Compiling smallvec v1.13.2
   Compiling subtle v2.4.1
   Compiling icu_locid_transform_data v1.5.0
   Compiling icu_properties_data v1.5.0
   Compiling cfg-if v1.0.0
   Compiling regex-syntax v0.8.5
   Compiling write16 v1.0.0
   Compiling utf8_iter v1.0.4
   Compiling equivalent v1.0.1
   Compiling utf16_iter v1.0.5
   Compiling hashbrown v0.15.2
   Compiling icu_normalizer_data v1.5.0
   Compiling log v0.4.25
   Compiling serde_json v1.0.138
   Compiling winnow v0.7.1
   Compiling same-file v1.0.6
   Compiling itoa v1.0.14
   Compiling ryu v1.0.19
   Compiling generic-array v0.14.7
   Compiling aho-corasick v1.1.3
   Compiling bstr v1.11.3
   Compiling anyhow v1.0.95
   Compiling walkdir v2.5.0
   Compiling semver v1.0.25
   Compiling percent-encoding v2.3.1
   Compiling thiserror v2.0.11
   Compiling camino v1.1.9
   Compiling indexmap v2.7.1
   Compiling form_urlencoded v1.2.1
   Compiling rustc_apfloat v0.2.2+llvm-462a31f5a5ab
   Compiling syn v1.0.109
   Compiling thiserror v1.0.69
   Compiling rustversion v1.0.19
   Compiling quote v1.0.38
   Compiling syn v2.0.98
   Compiling either v1.13.0
   Compiling regex-automata v0.4.9
   Compiling if_chain v1.0.2
   Compiling unicode-segmentation v1.12.0
   Compiling jobserver v0.1.32
   Compiling cpufeatures v0.2.17
   Compiling paste v1.0.15
   Compiling cc v1.2.11
   Compiling heck v0.3.3
   Compiling itertools v0.12.1
   Compiling once_cell v1.20.2
   Compiling home v0.5.9
   Compiling arrayvec v0.7.6
   Compiling bs58 v0.5.1
   Compiling ansi_term v0.12.1
   Compiling libz-sys v1.1.21
   Compiling openssl-sys v0.9.105
   Compiling libssh2-sys v0.3.1
   Compiling libgit2-sys v0.16.2+1.7.2
   Compiling globset v0.4.15
   Compiling regex v1.11.1
   Compiling synstructure v0.13.1
   Compiling serde_derive v1.0.217
   Compiling zerofrom-derive v0.1.5
   Compiling yoke-derive v0.7.5
   Compiling zerovec-derive v0.10.3
   Compiling displaydoc v0.2.5
   Compiling icu_provider_macros v1.5.0
   Compiling thiserror-impl v2.0.11
   Compiling thiserror-impl v1.0.69
   Compiling zerofrom v0.1.5
   Compiling yoke v0.7.5
   Compiling zerovec v0.10.4
   Compiling tinystr v0.7.6
   Compiling icu_collections v1.5.0
   Compiling icu_locid v1.5.0
   Compiling icu_provider v1.5.0
   Compiling bitflags v2.8.0
   Compiling serde_spanned v0.6.8
   Compiling toml_datetime v0.6.8
   Compiling cargo-platform v0.1.9
   Compiling toml_edit v0.22.23
   Compiling crypto-common v0.1.6
   Compiling block-buffer v0.10.4
   Compiling clippy_utils v0.1.86 (https://github.com/rust-lang/rust-clippy?rev=19e305bb57a7595f2a8d81f521c0dd8bf854e739#19e305bb)
   Compiling icu_locid_transform v1.5.0
   Compiling digest v0.10.7
error[E0463]: can't find crate for `rustc_attr_parsing`
  --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:34:1
   |
34 | extern crate rustc_attr_parsing;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
   |
   = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

   Compiling sha2 v0.10.8
   Compiling cargo_metadata v0.19.1
   Compiling rust-embed-utils v8.5.0
   Compiling icu_properties v1.5.1
   Compiling anchor-syn v0.30.1
   Compiling rust-embed-impl v8.5.0
error[E0432]: unresolved import `rustc_ast::attr::AttributeExt`
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/attrs.rs:2:5
  |
2 | use rustc_ast::attr::AttributeExt;
  |     ^^^^^^^^^^^^^^^^^------------
  |     |                |
  |     |                help: a similar name exists in the module: `Attribute`
  |     no `AttributeExt` in `attr`

error[E0432]: unresolved import `rustc_hir::StructTailExpr`
  --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/higher.rs:11:95
   |
11 | use rustc_hir::{Arm, Block, Expr, ExprKind, HirId, LoopSource, MatchSource, Node, Pat, QPath, StructTailExpr};
   |                                                                                               ^^^^^^^^^^^^^^ no `StructTailExpr` in the root

error[E0432]: unresolved import `rustc_hir::StructTailExpr`
  --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/hir_utils.rs:12:79
   |
12 |     Pat, PatField, PatKind, Path, PathSegment, PrimTy, QPath, Stmt, StmtKind, StructTailExpr, TraitBoundModifiers, Ty,
   |                                                                               ^^^^^^^^^^^^^^ no `StructTailExpr` in the root

error[E0432]: unresolved import `rustc_ast::attr::AttributeExt`
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/msrvs.rs:1:5
  |
1 | use rustc_ast::attr::AttributeExt;
  |     ^^^^^^^^^^^^^^^^^------------
  |     |                |
  |     |                help: a similar name exists in the module: `Attribute`
  |     no `AttributeExt` in `attr`

error[E0432]: unresolved import `rustc_hir::StructTailExpr`
  --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/visitors.rs:10:11
   |
10 |     Stmt, StructTailExpr, UnOp, UnsafeSource,
   |           ^^^^^^^^^^^^^^ no `StructTailExpr` in the root

error[E0432]: unresolved import `WherePredicateKind`
   --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/ast_utils/mod.rs:664:9
    |
664 |     use WherePredicateKind::*;
    |         ^^^^^^^^^^^^^^^^^^ use of undeclared type `WherePredicateKind`

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:1:1
  |
1 | #![feature(array_chunks)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:2:1
  |
2 | #![feature(box_patterns)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:3:1
  |
3 | #![feature(f128)]
  | ^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:4:1
  |
4 | #![feature(f16)]
  | ^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:5:1
  |
5 | #![feature(if_let_guard)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:6:1
  |
6 | #![feature(macro_metavar_expr_concat)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:7:1
  |
7 | #![feature(let_chains)]
  | ^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:8:1
  |
8 | #![feature(never_type)]
  | ^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:9:1
  |
9 | #![feature(rustc_private)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:10:1
   |
10 | #![feature(assert_matches)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:11:1
   |
11 | #![feature(unwrap_infallible)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:12:1
   |
12 | #![feature(array_windows)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

   Compiling rust-embed v8.5.0
   Compiling toml v0.8.19
Some errors have detailed explanations: E0432, E0463, E0554.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `clippy_utils` (lib) due to 19 previous errors
warning: build failed, waiting for other jobs to finish...

@smoelius
Copy link
Member

smoelius commented Feb 7, 2025

This warning surprises me:

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /Users/strikeout/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/19e305b/clippy_utils/src/lib.rs:1:1
  |
1 | #![feature(array_chunks)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^

What should happen is rustup finds this rust-toolchain file and builds using nightly-2025-01-09: https://github.com/crytic/solana-lints/blob/master/lints/arbitrary_cpi/rust-toolchain

Can you think of why that might not be happening?

Do you have another rust-toolchain file that could be overriding the one I pointed to?

@mdulin2
Copy link
Author

mdulin2 commented Feb 7, 2025

I struggle with a lot of the Rust build things - I'm still pretty new to it. Thanks for your patience!

I used a directory override to be the same one on the rust-toolchain file and it builds now. I think I had a previous directory override on it while trying to debug all of this before that stayed around.

We're all good now :)

@smoelius
Copy link
Member

smoelius commented Feb 7, 2025

I'm glad to hear it! Please let me know if you run into any more problems.

In the meantime, is it okay if we close this issue?

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

No branches or pull requests

2 participants