Skip to content

Commit f7996fa

Browse files
authored
Fix warnings from new rustc (skipping 1.88) (#559)
* Fix warnings from new rustc * Replace rust-toolchain.toml with rust-version key * Use stable toolchain in CI
1 parent 5f3492d commit f7996fa

11 files changed

Lines changed: 42 additions & 59 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ jobs:
2525
- uses: actions/checkout@v2
2626
with:
2727
submodules: true
28+
- uses: actions-rs/toolchain@v1
29+
with:
30+
profile: minimal
31+
toolchain: "1.82" # must match Cargo.toml
32+
override: true
2833
- uses: Swatinem/rust-cache@v1
2934
- uses: actions-rs/cargo@v1
3035
with:
@@ -74,6 +79,11 @@ jobs:
7479
- uses: actions/checkout@v2
7580
with:
7681
submodules: true
82+
- uses: actions-rs/toolchain@v1
83+
with:
84+
profile: minimal
85+
toolchain: stable
86+
override: true
7787
- uses: Swatinem/rust-cache@v1
7888
- uses: actions-rs/cargo@v1
7989
with:
@@ -88,6 +98,12 @@ jobs:
8898
- uses: actions/checkout@v2
8999
with:
90100
submodules: true
101+
- uses: actions-rs/toolchain@v1
102+
with:
103+
profile: minimal
104+
toolchain: stable
105+
components: clippy
106+
override: true
91107
- uses: Swatinem/rust-cache@v1
92108
- uses: actions-rs/cargo@v1
93109
with:

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ members = [
8080
]
8181
resolver = "2"
8282

83+
[workspace.package]
84+
rust-version = "1.82" # if this changes, edit ci.yaml as well!
85+
8386
[workspace.dependencies]
8487
# `git`-based deps
8588
gimlet-inspector-protocol = { git = "https://github.com/oxidecomputer/gimlet-inspector-protocol" }

cmd/test/src/lib.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -162,34 +162,6 @@ impl fmt::Display for TestResult {
162162
}
163163
}
164164

165-
#[derive(Clone, Debug, PartialEq)]
166-
enum TestRunResult {
167-
Pass,
168-
Fail,
169-
Unknown(String),
170-
}
171-
172-
impl From<&str> for TestRunResult {
173-
fn from(input: &str) -> Self {
174-
match input {
175-
"pass" => TestRunResult::Pass,
176-
"FAIL" => TestRunResult::Fail,
177-
_ => TestRunResult::Unknown(input.to_owned()),
178-
}
179-
}
180-
}
181-
182-
#[rustfmt::skip::macros(write)]
183-
impl fmt::Display for TestRunResult {
184-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
185-
write!(f, "{}", match self {
186-
TestRunResult::Pass => "pass".green(),
187-
TestRunResult::Fail => "fail".red(),
188-
TestRunResult::Unknown(ref _str) => "unknown".bold(),
189-
})
190-
}
191-
}
192-
193165
fn test(context: &mut ExecutionContext) -> Result<()> {
194166
let core = &mut **context.core.as_mut().unwrap();
195167
let Subcommand::Other(subargs) = context.cli.cmd.as_ref().unwrap();

humility-bin/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ name = "humility-bin"
2020
version = "0.12.7"
2121
edition = "2021"
2222
license = "MPL-2.0"
23-
rust-version = "1.68"
2423

2524
[build-dependencies]
2625
cargo_metadata = { workspace = true }

humility-bin/src/cmd.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ pub fn subcommand(
6262
CommandKind::Detached { archive, .. } => {
6363
(*archive, HubrisArchiveDoneness::Cook)
6464
}
65-
CommandKind::Raw { .. } => {
66-
(Archive::Required, HubrisArchiveDoneness::Raw)
67-
}
65+
CommandKind::Raw => (Archive::Required, HubrisArchiveDoneness::Raw),
6866
};
6967

7068
if archive != Archive::Ignored {
@@ -112,6 +110,6 @@ pub fn subcommand(
112110

113111
(run)(context)
114112
}
115-
CommandKind::Raw { .. } => (run)(context),
113+
CommandKind::Raw => (run)(context),
116114
}
117115
}

humility-bin/src/cmd_repl.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,29 @@ impl Prompt {
4141
}
4242

4343
impl reedline::Prompt for Prompt {
44-
fn render_prompt_left(&self) -> Cow<str> {
44+
fn render_prompt_left(&self) -> Cow<'_, str> {
4545
Cow::from(&self.prefix)
4646
}
4747

48-
fn render_prompt_right(&self) -> Cow<str> {
48+
fn render_prompt_right(&self) -> Cow<'_, str> {
4949
self.default_prompt.render_prompt_right()
5050
}
5151

5252
fn render_prompt_indicator(
5353
&self,
5454
prompt_mode: reedline::PromptEditMode,
55-
) -> Cow<str> {
55+
) -> Cow<'_, str> {
5656
self.default_prompt.render_prompt_indicator(prompt_mode)
5757
}
5858

59-
fn render_prompt_multiline_indicator(&self) -> Cow<str> {
59+
fn render_prompt_multiline_indicator(&self) -> Cow<'_, str> {
6060
self.default_prompt.render_prompt_multiline_indicator()
6161
}
6262

6363
fn render_prompt_history_search_indicator(
6464
&self,
6565
history_search: reedline::PromptHistorySearch,
66-
) -> Cow<str> {
66+
) -> Cow<'_, str> {
6767
self.default_prompt
6868
.render_prompt_history_search_indicator(history_search)
6969
}

humility-cli/src/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn validate_single_archive() {
8989
}
9090
"#;
9191

92-
let v: IndexMap<String, Environment> = serde_json::from_str(&data).unwrap();
92+
let v: IndexMap<String, Environment> = serde_json::from_str(data).unwrap();
9393

9494
let _b = v.get("board1").unwrap().archive(&None);
9595
}
@@ -109,7 +109,7 @@ fn validate_multi_archive() {
109109
}
110110
"#;
111111

112-
let v: IndexMap<String, Environment> = serde_json::from_str(&data).unwrap();
112+
let v: IndexMap<String, Environment> = serde_json::from_str(data).unwrap();
113113

114114
let _b = v.get("board1").unwrap().archive(&Some("name1".to_string()));
115115
let _b = v.get("board1").unwrap().archive(&Some("name2".to_string()));

humility-core/src/hubris.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ impl Namespaces {
583583
fn to_full_name(
584584
&self,
585585
id: Option<NamespaceId>,
586-
name: &String,
586+
name: &str,
587587
) -> Result<Option<String>> {
588588
let mut n = self.to_full(id)?;
589589

@@ -790,7 +790,7 @@ impl HubrisArchive {
790790
})
791791
}
792792

793-
pub fn instr_inlined(&self, pc: u32, base: u32) -> Vec<HubrisInlined> {
793+
pub fn instr_inlined(&self, pc: u32, base: u32) -> Vec<HubrisInlined<'_>> {
794794
let mut inlined: Vec<HubrisInlined> = vec![];
795795

796796
//
@@ -895,7 +895,7 @@ impl HubrisArchive {
895895
.unwrap()
896896
.sensors
897897
.as_ref()
898-
.map_or(true, |s| s.contains(&kind))
898+
.is_none_or(|s| s.contains(&kind))
899899
{
900900
if let Some(rails) = &d.power.as_ref().unwrap().rails {
901901
if idx < rails.len() {
@@ -1821,7 +1821,7 @@ impl HubrisArchive {
18211821
}
18221822
}
18231823

1824-
pub fn lookup_type(&self, goff: HubrisGoff) -> Result<HubrisType> {
1824+
pub fn lookup_type(&self, goff: HubrisGoff) -> Result<HubrisType<'_>> {
18251825
let r = self
18261826
.lookup_struct(goff)
18271827
.map(HubrisType::Struct)
@@ -2840,7 +2840,7 @@ impl HubrisArchive {
28402840
task: HubrisTask,
28412841
limit: u32,
28422842
regs: &BTreeMap<ARMRegister, u32>,
2843-
) -> Result<Vec<HubrisStackFrame>> {
2843+
) -> Result<Vec<HubrisStackFrame<'_>>> {
28442844
let regions = self.regions(core)?;
28452845
let sp = regs
28462846
.get(&ARMRegister::SP)
@@ -6427,9 +6427,8 @@ impl HubrisModule {
64276427
.map(|g| {
64286428
let ns = hubris.structs.get(g).unwrap().namespace;
64296429

6430-
if let Ok(Some(name)) = hubris
6431-
.namespaces
6432-
.to_full_name(ns, &name.to_string())
6430+
if let Ok(Some(name)) =
6431+
hubris.namespaces.to_full_name(ns, name)
64336432
{
64346433
format!("{name} as {g}")
64356434
} else {
@@ -6474,9 +6473,8 @@ impl HubrisModule {
64746473
.map(|g| {
64756474
let n = hubris.enums.get(g).unwrap().namespace;
64766475

6477-
if let Ok(Some(name)) = hubris
6478-
.namespaces
6479-
.to_full_name(n, &name.to_string())
6476+
if let Ok(Some(name)) =
6477+
hubris.namespaces.to_full_name(n, name)
64806478
{
64816479
format!("{name} as {g}")
64826480
} else {

humility-idol/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,11 +865,11 @@ pub fn lookup_reply<'a>(
865865

866866
/// Extention trait to add `get_idol_command` to a `HubrisArchive`
867867
pub trait HubrisIdol {
868-
fn get_idol_command(&self, name: &str) -> Result<IdolOperation>;
868+
fn get_idol_command(&self, name: &str) -> Result<IdolOperation<'_>>;
869869
}
870870

871871
impl HubrisIdol for HubrisArchive {
872-
fn get_idol_command(&self, name: &str) -> Result<IdolOperation> {
872+
fn get_idol_command(&self, name: &str) -> Result<IdolOperation<'_>> {
873873
let mut iter = name.split('.');
874874
let interface = iter
875875
.next()

0 commit comments

Comments
 (0)