Skip to content

Commit e0d1a99

Browse files
committed
setup boilerplate and tests for 6-dup
1 parent 155a267 commit e0d1a99

File tree

11 files changed

+192
-0
lines changed

11 files changed

+192
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[target.aarch64-apple-darwin]
2+
linker = "dylint-link"
3+
4+
[target.x86_64-apple-darwin]
5+
linker = "dylint-link"
6+
7+
[target.x86_64-unknown-linux-gnu]
8+
linker = "dylint-link"
9+
10+
[target.x86_64-pc-windows-msvc]
11+
linker = "dylint-link"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
/Cargo.lock
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "duplicate_mutable_accounts"
3+
version = "0.1.0"
4+
authors = ["authors go here"]
5+
description = "decription goes here"
6+
edition = "2018"
7+
publish = false
8+
9+
[lib]
10+
crate-type = ["cdylib"]
11+
12+
[dependencies]
13+
clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "7b2896a8fc9f0b275692677ee6d2d66a7cbde16a" }
14+
dylint_linting = "2.0.1"
15+
if_chain = "1.0.2"
16+
17+
[dev-dependencies]
18+
dylint_testing = "2.0.1"
19+
20+
[package.metadata.rust-analyzer]
21+
rustc_private = true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "nightly-2022-02-24"
3+
components = ["llvm-tools-preview", "rustc-dev"]
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#![feature(rustc_private)]
2+
#![warn(unused_extern_crates)]
3+
4+
extern crate rustc_ast;
5+
extern crate rustc_ast_pretty;
6+
extern crate rustc_data_structures;
7+
extern crate rustc_errors;
8+
extern crate rustc_hir;
9+
extern crate rustc_hir_pretty;
10+
extern crate rustc_index;
11+
extern crate rustc_infer;
12+
extern crate rustc_lexer;
13+
extern crate rustc_middle;
14+
extern crate rustc_mir_dataflow;
15+
extern crate rustc_parse;
16+
extern crate rustc_parse_format;
17+
extern crate rustc_span;
18+
extern crate rustc_target;
19+
extern crate rustc_trait_selection;
20+
extern crate rustc_typeck;
21+
22+
use rustc_lint::LateLintPass;
23+
24+
dylint_linting::declare_late_lint! {
25+
/// **What it does:**
26+
///
27+
/// **Why is this bad?**
28+
///
29+
/// **Known problems:** None.
30+
///
31+
/// **Example:**
32+
///
33+
/// ```rust
34+
/// // example code where a warning is issued
35+
/// ```
36+
/// Use instead:
37+
/// ```rust
38+
/// // example code that does not raise a warning
39+
/// ```
40+
pub DUPLICATE_MUTABLE_ACCOUNTS,
41+
Warn,
42+
"description goes here"
43+
}
44+
45+
impl<'tcx> LateLintPass<'tcx> for DuplicateMutableAccounts {
46+
// A list of things you might check can be found here:
47+
// https://doc.rust-lang.org/stable/nightly-rustc/rustc_lint/trait.LateLintPass.html
48+
}
49+
50+
#[test]
51+
fn ui() {
52+
dylint_testing::ui_test(
53+
env!("CARGO_PKG_NAME"),
54+
&std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("ui"),
55+
);
56+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "duplicate-mutable-accounts-insecure"
3+
version = "0.1.0"
4+
description = "Created with Anchor"
5+
edition = "2018"
6+
7+
[lib]
8+
crate-type = ["cdylib", "lib"]
9+
name = "duplicate_mutable_accounts_insecure"
10+
11+
[features]
12+
no-entrypoint = []
13+
no-idl = []
14+
no-log-ix-name = []
15+
cpi = ["no-entrypoint"]
16+
default = []
17+
18+
[dependencies]
19+
anchor-lang = "0.20.1"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.bpfel-unknown-unknown.dependencies.std]
2+
features = []
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use anchor_lang::prelude::*;
2+
3+
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
4+
5+
#[program]
6+
pub mod duplicate_mutable_accounts_insecure {
7+
use super::*;
8+
9+
pub fn update(ctx: Context<Update>, a: u64, b: u64) -> ProgramResult {
10+
let user_a = &mut ctx.accounts.user_a;
11+
let user_b = &mut ctx.accounts.user_b;
12+
13+
user_a.data = a;
14+
user_b.data = b;
15+
Ok(())
16+
}
17+
}
18+
19+
#[derive(Accounts)]
20+
pub struct Update<'info> {
21+
user_a: Account<'info, User>,
22+
user_b: Account<'info, User>,
23+
}
24+
25+
#[account]
26+
pub struct User {
27+
data: u64,
28+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "duplicate-mutable-accounts-secure"
3+
version = "0.1.0"
4+
description = "Created with Anchor"
5+
edition = "2018"
6+
7+
[lib]
8+
crate-type = ["cdylib", "lib"]
9+
name = "duplicate_mutable_accounts_secure"
10+
11+
[features]
12+
no-entrypoint = []
13+
no-idl = []
14+
no-log-ix-name = []
15+
cpi = ["no-entrypoint"]
16+
default = []
17+
18+
[dependencies]
19+
anchor-lang = "0.20.1"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.bpfel-unknown-unknown.dependencies.std]
2+
features = []

0 commit comments

Comments
 (0)