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

Linter: Update toolchain #2067

Merged
merged 2 commits into from
Jan 19, 2024
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: 2 additions & 2 deletions linting/extra/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ include = ["Cargo.toml", "*.rs", "LICENSE"]
crate-type = ["cdylib"]

[dependencies]
dylint_linting = "2.1.12"
dylint_linting = "2.6.0"
if_chain = "1.0.2"
log = "0.4.14"
regex = "1.5.4"
ink_linting_utils = { workspace = true }
ink_env = { version = "=5.0.0-rc", path = "../../crates/env", default-features = false }

[dev-dependencies]
dylint_testing = "2.1.12"
dylint_testing = "2.6.0"

# The ink! dependencies used to build the `ui` tests and to compile the linting
# library with `--default-features=std` (see the `features` section bellow).
Expand Down
2 changes: 1 addition & 1 deletion linting/extra/src/non_fallible_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use rustc_session::{
declare_lint,
declare_lint_pass,
};
use rustc_type_ir::sty::TyKind;
use rustc_type_ir::ty_kind::TyKind;

declare_lint! {
/// ## What it does
Expand Down
6 changes: 3 additions & 3 deletions linting/extra/src/storage_never_freed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn find_collection_def_id(
if_chain! {
if let Res::Def(DefKind::TyAlias, def_id) = path.res;
if let Some(local_id) = def_id.as_local();
if let Some(alias_ty) = cx.tcx.hir().get_by_def_id(local_id).alias_ty();
if let Some(alias_ty) = cx.tcx.hir_node_by_def_id(local_id).alias_ty();
if let TyKind::Path(QPath::Resolved(_, path)) = alias_ty.kind;
then { return find_collection_def_id(cx, path); }
};
Expand Down Expand Up @@ -214,7 +214,7 @@ fn find_collection_fields(cx: &LateContext, storage_struct_id: ItemId) -> Fields
/// Reports the given field definition
fn report_field(cx: &LateContext, field_info: &FieldInfo) {
if_chain! {
if let Node::Field(field) = cx.tcx.hir().get_by_def_id(field_info.did);
if let Node::Field(field) = cx.tcx.hir_node_by_def_id(field_info.did);
if !is_lint_allowed(cx, STORAGE_NEVER_FREED, field.hir_id);
then {
span_lint_and_help(
Expand Down Expand Up @@ -257,7 +257,7 @@ impl<'hir> Visitor<'hir> for InsertRemoveCollector<'_> {
match &e.kind {
ExprKind::Assign(lhs, ..) => {
if_chain! {
if let ExprKind::Index(field, _) = lhs.kind;
if let ExprKind::Index(field, _, _) = lhs.kind;
if let Some(field_name) = self.find_field_name(field);
then {
self.fields
Expand Down
19 changes: 9 additions & 10 deletions linting/extra/src/strict_balance_equality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ use rustc_middle::{
BinOp,
Body,
BorrowKind,
Constant,
CallReturnPlaces,
ConstOperand,
HasLocalDecls,
Local,
Location,
Expand All @@ -51,15 +52,14 @@ use rustc_middle::{
Rvalue,
Statement,
Terminator,
TerminatorEdges,
TerminatorKind,
},
ty as mir_ty,
};
use rustc_mir_dataflow::{
Analysis,
AnalysisDomain,
CallReturnPlaces,
Forward,
};
use rustc_session::{
declare_lint,
Expand Down Expand Up @@ -224,8 +224,6 @@ impl<'a, 'tcx> AnalysisDomain<'tcx> for StrictBalanceEqualityAnalysis<'a, 'tcx>

const NAME: &'static str = "strict_balance_equality";

type Direction = Forward;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default Direction is Forward, see: rust-lang/rust#120130


fn bottom_value(&self, body: &Body) -> Self::Domain {
// bottom = no balance taints
BitSet::new_empty(body.local_decls().len())
Expand Down Expand Up @@ -262,19 +260,20 @@ impl<'a, 'tcx> Analysis<'tcx> for StrictBalanceEqualityAnalysis<'a, 'tcx> {
.visit_statement(statement, location);
}

fn apply_terminator_effect(
fn apply_terminator_effect<'mir>(
&mut self,
state: &mut Self::Domain,
terminator: &Terminator,
terminator: &'mir Terminator<'tcx>,
location: Location,
) {
) -> TerminatorEdges<'mir, 'tcx> {
TransferFunction::new(
self.cx,
self.fun_cache,
state,
&mut self.mutable_references,
)
.visit_terminator(terminator, location);
terminator.edges()
}

fn apply_call_return_effect(
Expand Down Expand Up @@ -422,7 +421,7 @@ impl<'tcx> TransferFunction<'_, 'tcx> {
fn_def_id.is_local()
}

fn visit_call(&mut self, func: &Constant, args: &[Operand], destination: &Place) {
fn visit_call(&mut self, func: &ConstOperand, args: &[Operand], destination: &Place) {
let init_taints = args.iter().fold(Vec::new(), |mut acc, arg| {
if let Operand::Move(place) | Operand::Copy(place) = arg {
acc.push(self.state.contains(place.local))
Expand All @@ -431,7 +430,7 @@ impl<'tcx> TransferFunction<'_, 'tcx> {
});

let fn_def_id =
if let mir_ty::TyKind::FnDef(fn_def_id, _) = func.literal.ty().kind() {
if let mir_ty::TyKind::FnDef(fn_def_id, _) = func.const_.ty().kind() {
fn_def_id
} else {
return
Expand Down
1 change: 1 addition & 0 deletions linting/extra/ui/fail/non_fallible_api.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | let _ = self.map_1.insert(a.clone(), &b);
| ^^^^^^ help: consider using `try_insert`
|
= note: `-D non-fallible-api` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(non_fallible_api)]`

error: using a non-fallible `Mapping::get` with an argument that may not fit into the static buffer
--> $DIR/non_fallible_api.rs:48:32
Expand Down
1 change: 1 addition & 0 deletions linting/extra/ui/fail/primitive_topic.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | value_1: u8,
| ^^^^^^^^^^^ help: consider removing `#[ink(topic)]`: `value_1: u8`
|
= note: `-D primitive-topic` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(primitive_topic)]`

error: using `#[ink(topic)]` for a field with a primitive number type
--> $DIR/primitive_topic.rs:16:9
Expand Down
1 change: 1 addition & 0 deletions linting/extra/ui/fail/strict_balance_equality.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | if self.env().balance() == 10 { /* ... */ }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using non-strict equality operators instead: `<`, `>`
|
= note: `-D strict-balance-equality` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(strict_balance_equality)]`

error: dangerous strict balance equality
--> $DIR/strict_balance_equality.rs:60:16
Expand Down
4 changes: 2 additions & 2 deletions linting/extra/ui/pass/non_fallible_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ pub mod non_fallible_api {
// StorageVec
let _ = self.vec_1.try_peek();
let _ = self.vec_1.try_get(0);
self.vec_1.try_set(0, &a);
let _ = self.vec_1.try_set(0, &a);
let _ = self.vec_1.try_pop();
self.vec_1.try_push(&a);
let _ = self.vec_1.try_push(&a);
}

// Don't raise warnings when using non-fallible API with argument which encoded
Expand Down
4 changes: 2 additions & 2 deletions linting/mandatory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ include = ["Cargo.toml", "*.rs", "LICENSE"]
crate-type = ["cdylib"]

[dependencies]
dylint_linting = "2.1.12"
dylint_linting = "2.6.0"
if_chain = "1.0.2"
log = "0.4.14"
regex = "1.5.4"
ink_linting_utils = { workspace = true }

[dev-dependencies]
dylint_testing = "2.1.12"
dylint_testing = "2.6.0"

# The ink! dependencies used to build the `ui` tests and to compile the linting
# library with `--default-features=std` (see the `features` section bellow).
Expand Down
2 changes: 1 addition & 1 deletion linting/rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# https://github.com/trailofbits/dylint/blob/ef7210cb08aac920c18d2141604efe210029f2a2/internal/template/rust-toolchain

[toolchain]
channel = "nightly-2023-07-14"
channel = "nightly-2023-12-28"
components = ["llvm-tools-preview", "rustc-dev"]
2 changes: 1 addition & 1 deletion linting/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include = ["Cargo.toml", "*.rs", "LICENSE"]

[dependencies]
if_chain = "1.0.2"
parity_clippy_utils = "0.1.73"
parity_clippy_utils = { package = "clippy_utils", git = "https://github.com/rust-lang/rust-clippy", rev = "3fceca23bb64e304df56b3bd86d26790b5301bdf" }

[package.metadata.rust-analyzer]
rustc_private = true
2 changes: 1 addition & 1 deletion linting/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn find_storage_struct(cx: &LateContext, item_ids: &[ItemId]) -> Option<Item
/// implementations of a contract.
fn items_in_unnamed_const(cx: &LateContext<'_>, id: &ItemId) -> Vec<ItemId> {
if_chain! {
if let ItemKind::Const(ty, body_id) = cx.tcx.hir().item(*id).kind;
if let ItemKind::Const(ty, _, body_id) = cx.tcx.hir().item(*id).kind;
if let TyKind::Tup([]) = ty.kind;
let body = cx.tcx.hir().body(body_id);
if let ExprKind::Block(block, _) = body.value.kind;
Expand Down