chore(core/rust): use clippy for all features

pull/2259/head
grdddj 2 years ago committed by matejcik
parent 11cb171e1a
commit feb96c84b0

@ -121,7 +121,7 @@ pyright:
python ../tools/pyright_tool.py
clippy:
cd embed/rust ; cargo clippy
cd embed/rust ; cargo clippy --all-features
## code generation:

@ -8,11 +8,14 @@ build = "build.rs"
[features]
default = ["model_tt"]
bitcoin_only = []
model_tt = []
model_t1 = []
model_tr = []
model_tt = ["touch"]
model_t1 = ["buttons"]
model_tr = ["buttons"]
ui = []
ui_debug = []
buttons = []
touch = []
clippy = []
test = ["cc", "glob"]
[lib]

@ -19,7 +19,7 @@ pub mod ui;
mod util;
#[cfg(not(test))]
#[cfg(not(feature = "test"))]
#[cfg(any(not(feature = "test"), feature = "clippy"))]
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
use cstr_core::CStr;

@ -7,9 +7,9 @@ use crate::{
ui::{component::Map, geometry::Rect},
};
#[cfg(any(feature = "model_t1", feature = "model_tr"))]
#[cfg(feature = "buttons")]
use crate::ui::event::ButtonEvent;
#[cfg(feature = "model_tt")]
#[cfg(feature = "touch")]
use crate::ui::event::TouchEvent;
/// Type used by components that do not return any messages.
@ -219,9 +219,9 @@ where
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum Event {
#[cfg(any(feature = "model_t1", feature = "model_tr"))]
#[cfg(feature = "buttons")]
Button(ButtonEvent),
#[cfg(feature = "model_tt")]
#[cfg(feature = "touch")]
Touch(TouchEvent),
/// Previously requested timer was triggered. This invalidates the timer
/// token (another timer has to be requested).

@ -0,0 +1,13 @@
//! Reexporting the `constant` module according to the
//! current feature (Trezor model)
#[cfg(feature = "model_t1")]
pub use super::model_t1::constant::*;
#[cfg(all(feature = "model_tr", not(feature = "model_t1")))]
pub use super::model_tr::constant::*;
#[cfg(all(
feature = "model_tt",
not(feature = "model_tr"),
not(feature = "model_t1")
))]
pub use super::model_tt::constant::*;

@ -1,12 +1,6 @@
use super::constant;
use crate::{micropython::time, time::Duration, trezorhal::display};
#[cfg(feature = "model_t1")]
use crate::ui::model_t1::constant;
#[cfg(feature = "model_tr")]
use crate::ui::model_tr::constant;
#[cfg(feature = "model_tt")]
use crate::ui::model_tt::constant;
use super::geometry::{Offset, Point, Rect};
pub fn backlight() -> i32 {
@ -233,7 +227,7 @@ impl Color {
self.0
}
pub fn neg(self) -> Self {
pub fn negate(self) -> Self {
Self(!self.0)
}
}

@ -15,23 +15,17 @@ use crate::{
time::Duration,
ui::{
component::{Child, Component, Event, EventCtx, Never, TimerToken},
constant,
geometry::Rect,
},
util,
};
#[cfg(any(feature = "model_t1", feature = "model_tr"))]
#[cfg(feature = "buttons")]
use crate::ui::event::ButtonEvent;
#[cfg(feature = "model_tt")]
#[cfg(feature = "touch")]
use crate::ui::event::TouchEvent;
#[cfg(feature = "model_t1")]
use crate::ui::model_t1::constant;
#[cfg(feature = "model_tr")]
use crate::ui::model_tr::constant;
#[cfg(feature = "model_tt")]
use crate::ui::model_tt::constant;
/// Conversion trait implemented by components that know how to convert their
/// message values into MicroPython `Obj`s. We can automatically implement
/// `ComponentMsgObj` for components whose message types implement `TryInto`.
@ -354,7 +348,7 @@ extern "C" fn ui_layout_set_timer_fn(this: Obj, timer_fn: Obj) -> Obj {
unsafe { util::try_or_raise(block) }
}
#[cfg(feature = "model_tt")]
#[cfg(feature = "touch")]
extern "C" fn ui_layout_touch_event(n_args: usize, args: *const Obj) -> Obj {
let block = |args: &[Obj], _kwargs: &Map| {
if args.len() != 4 {
@ -372,12 +366,12 @@ extern "C" fn ui_layout_touch_event(n_args: usize, args: *const Obj) -> Obj {
unsafe { util::try_with_args_and_kwargs(n_args, args, &Map::EMPTY, block) }
}
#[cfg(any(feature = "model_t1", feature = "model_tr"))]
#[cfg(not(feature = "touch"))]
extern "C" fn ui_layout_touch_event(_n_args: usize, _args: *const Obj) -> Obj {
Obj::const_none()
}
#[cfg(any(feature = "model_t1", feature = "model_tr"))]
#[cfg(feature = "buttons")]
extern "C" fn ui_layout_button_event(n_args: usize, args: *const Obj) -> Obj {
let block = |args: &[Obj], _kwargs: &Map| {
if args.len() != 3 {
@ -391,7 +385,7 @@ extern "C" fn ui_layout_button_event(n_args: usize, args: *const Obj) -> Obj {
unsafe { util::try_with_args_and_kwargs(n_args, args, &Map::EMPTY, block) }
}
#[cfg(feature = "model_tt")]
#[cfg(not(feature = "buttons"))]
extern "C" fn ui_layout_button_event(_n_args: usize, _args: *const Obj) -> Obj {
Obj::const_none()
}

@ -3,6 +3,7 @@ pub mod macros;
pub mod animation;
pub mod component;
pub mod constant;
pub mod display;
pub mod event;
pub mod geometry;

@ -92,7 +92,7 @@ impl<T: AsRef<str>> Button<T> {
let start_of_baseline = area.bottom_left() + Offset::new(border_width, -2);
return (area, start_of_baseline);
(area, start_of_baseline)
}
}
@ -130,7 +130,7 @@ where
match &self.content {
ButtonContent::Text(text) => {
let background_color = style.text_color.neg();
let background_color = style.text_color.negate();
if style.border_horiz {
display::rect_fill_rounded1(self.area, background_color, theme::BG);
} else {

@ -92,7 +92,7 @@ impl<T: AsRef<str>> Button<T> {
let start_of_baseline = area.bottom_left() + Offset::new(border_width, -2);
return (area, start_of_baseline);
(area, start_of_baseline)
}
}
@ -130,7 +130,7 @@ where
match &self.content {
ButtonContent::Text(text) => {
let background_color = style.text_color.neg();
let background_color = style.text_color.negate();
if style.border_horiz {
display::rect_fill_rounded1(self.area, background_color, theme::BG);
} else {

@ -255,8 +255,8 @@ where
fn paint(&mut self) {
let style = self.style();
self.paint_background(&style);
self.paint_content(&style);
self.paint_background(style);
self.paint_content(style);
}
fn bounds(&self, sink: &mut dyn FnMut(Rect)) {

@ -25,7 +25,7 @@ where
}
pub fn inner(&self) -> &T {
&self.content.inner()
self.content.inner()
}
}

@ -92,7 +92,7 @@ impl Component for Bip39Input {
let style = self.button.style();
// First, paint the button background.
self.button.paint_background(&style);
self.button.paint_background(style);
// Paint the entered content (the prefix of the suggested word).
let text = self.textbox.content();

@ -115,7 +115,7 @@ impl Component for Slip39Input {
let style = self.button.style();
// First, paint the button background.
self.button.paint_background(&style);
self.button.paint_background(style);
// Content starts in the left-center point, offset by 16px to the right and 8px
// to the bottom.

Loading…
Cancel
Save