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

CI: treat compiler warnings as errors #895

Merged
merged 6 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
branches:
- master
pull_request:
env:
RUSTFLAGS: -D warnings
jobs:
test:
runs-on: ${{ matrix.platform }}
Expand All @@ -30,7 +32,7 @@ jobs:
- uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
branches:
- master
pull_request:
env:
RUSTFLAGS: -D warnings
jobs:
test:
runs-on: ${{ matrix.platform }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_examples_small.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
branches:
- master
pull_request:
env:
RUSTFLAGS: -D warnings
jobs:
test:
runs-on: ${{ matrix.platform }}
Expand Down
4 changes: 3 additions & 1 deletion near-sdk/compilation_tests/metadata_invalid_rust.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use near_sdk::{near_bindgen, metadata};
#![allow(unused_imports)]

use borsh::{BorshDeserialize, BorshSerialize};
use near_sdk::{metadata, near_bindgen};
metadata! {
FOOBAR

Expand Down
28 changes: 7 additions & 21 deletions near-sdk/compilation_tests/metadata_invalid_rust.stderr
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
error: Failed to parse code decorated with `metadata!{}` macro. Only valid Rust is supported.
--> $DIR/metadata_invalid_rust.rs:3:1
--> compilation_tests/metadata_invalid_rust.rs:5:1
|
3 | / metadata! {
4 | | FOOBAR
5 | |
6 | | #[near_bindgen]
5 | / metadata! {
6 | | FOOBAR
7 | |
8 | | #[near_bindgen]
... |
17 | | }
18 | | }
19 | | }
20 | | }
| |_^
|
= note: this error originates in the macro `metadata` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused import: `near_bindgen`
--> $DIR/metadata_invalid_rust.rs:1:16
|
1 | use near_sdk::{near_bindgen, metadata};
| ^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default

warning: unused imports: `BorshDeserialize`, `BorshSerialize`
--> $DIR/metadata_invalid_rust.rs:2:13
|
2 | use borsh::{BorshDeserialize, BorshSerialize};
| ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
3 changes: 1 addition & 2 deletions near-sdk/src/collections/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::marker::PhantomData;
use borsh::{BorshDeserialize, BorshSerialize};

use crate::collections::append_slice;
use crate::store::IndexMap;
use crate::{env, IntoStorageKey};

const ERR_INCONSISTENT_STATE: &str = "The collection is an inconsistent state. Did previous smart contract execution terminate unexpectedly?";
Expand Down Expand Up @@ -69,7 +68,7 @@ impl<T> Vector<T> {
crate::store::Vector {
// Length cannot feasibly exceed u32::MAX, but checked conversion anyway.
len: self.len.try_into().unwrap(),
values: IndexMap::new(self.prefix.as_slice()),
values: crate::store::IndexMap::new(self.prefix.as_slice()),
}
}

Expand Down