Skip to content

Commit 8bd1421

Browse files
authored
Merge pull request #94 from HenningHolmDE/fix_clippy
Fix Clippy for current stable Rust (1.45.2)
2 parents 34325ce + fb25787 commit 8bd1421

File tree

20 files changed

+56
-60
lines changed

20 files changed

+56
-60
lines changed

.github/workflows/build-test-all.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: Build & test all configs
33
on: [push, pull_request]
44

55
jobs:
6-
76
release-notice:
87
name: This is a release build
98
if: startsWith(github.ref, 'refs/tags/v')
@@ -29,7 +28,7 @@ jobs:
2928
include:
3029
- target: x86_64-unknown-linux-gnu
3130
os: ubuntu-latest
32-
ext: ''
31+
ext: ""
3332
- target: x86_64-pc-windows-msvc
3433
os: windows-latest
3534
ext: .exe
@@ -71,7 +70,7 @@ jobs:
7170
uses: actions-rs/cargo@v1
7271
with:
7372
command: clippy
74-
args: --package ${{ matrix.crate }} -- -D warnings
73+
args: --package ${{ matrix.crate }} --all-targets --all-features -- -D warnings
7574

7675
- name: Assemble
7776
if: matrix.rust == 'stable'
@@ -87,7 +86,7 @@ jobs:
8786
with:
8887
name: ${{ matrix.crate }}-${{ matrix.target }}
8988
path: ${{ matrix.crate }}-${{ matrix.target }}
90-
89+
9190
release:
9291
name: Release
9392
if: startsWith(github.ref, 'refs/tags/v')
@@ -160,4 +159,4 @@ jobs:
160159
draft: false
161160
artifacts: "vhdl_lang-x86_64-unknown-linux-gnu.zip,vhdl_ls-x86_64-unknown-linux-gnu.zip,vhdl_lang-x86_64-pc-windows-msvc.zip,vhdl_ls-x86_64-pc-windows-msvc.zip"
162161
bodyFile: "release_notes/v${{ steps.v.outputs.v }}.md"
163-
token: ${{ secrets.GITHUB_TOKEN }}
162+
token: ${{ secrets.GITHUB_TOKEN }}

vhdl_lang/src/analysis/lock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ mod tests {
167167
match lock.entry() {
168168
AnalysisEntry::Occupied(entry) => {
169169
assert_eq!(*entry, 2);
170-
assert_eq!(*entry.result(), 1.0);
170+
assert!((*entry.result() - 1.0_f64).abs() < std::f64::EPSILON);
171171
}
172172
_ => panic!("Expected Occupied entry"),
173173
};
174174

175175
assert_eq!(*lock.get().unwrap(), 2);
176-
assert_eq!(*lock.get().unwrap().result(), 1.0);
176+
assert!((*lock.get().unwrap().result() - 1.0_f64).abs() < std::f64::EPSILON);
177177

178178
// Check that lock is reset
179179
lock.reset();

vhdl_lang/src/analysis/root.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ mod tests {
637637
use super::*;
638638
use crate::syntax::test::{check_diagnostics, Code};
639639

640-
fn new_library_with_diagnostics<'a>(code: &Code, name: &str) -> (Library, Vec<Diagnostic>) {
640+
fn new_library_with_diagnostics(code: &Code, name: &str) -> (Library, Vec<Diagnostic>) {
641641
let mut diagnostics = Vec::new();
642642
let mut library = Library::new(code.symbol(name));
643643
library.add_design_file(code.design_file());

vhdl_lang/src/analysis/tests/incremental_analysis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ fn check_analysis_equal(got: &mut DesignRoot, expected: &mut DesignRoot) -> Vec<
307307
expected.analyze(&mut expected_diagnostics);
308308

309309
// Check that diagnostics are equal to doing analysis from scratch
310-
check_diagnostics(got_diagnostics.clone(), expected_diagnostics.clone());
310+
check_diagnostics(got_diagnostics.clone(), expected_diagnostics);
311311

312312
// Check that all references are equal, ensures the incremental
313313
// analysis has cleared refereces

vhdl_lang/src/analysis/tests/resolves_design_units.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ end architecture;
294294
// Find all references
295295
assert_eq_unordered(
296296
&root.find_all_references(&code.s1("ename1").pos()),
297-
&vec![
297+
&[
298298
code.s("ename1", 1).pos(),
299299
code.s("ename1", 2).pos(),
300300
code.s("ename1", 3).pos(),
@@ -403,7 +403,7 @@ end package body;
403403
// Find all references
404404
assert_eq_unordered(
405405
&root.find_all_references(&code.s1("pkg").pos()),
406-
&vec![code.s("pkg", 1).pos(), code.s("pkg", 2).pos()],
406+
&[code.s("pkg", 1).pos(), code.s("pkg", 2).pos()],
407407
);
408408
}
409409

vhdl_lang/src/analysis/tests/resolves_type_mark.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ end package;",
147147
// Cursor at end of symbol
148148
assert_eq!(
149149
root.search_reference(code2.source(), code2.s1("typ_t").end()),
150-
Some(decl_pos.clone())
150+
Some(decl_pos)
151151
);
152152

153153
// Cursor after end of symbol
@@ -206,10 +206,10 @@ end package;",
206206
check_no_diagnostics(&diagnostics);
207207

208208
let references = vec![
209-
code1.s("typ_t", 1).pos().clone(),
210-
code1.s("typ_t", 2).pos().clone(),
211-
code2.s("typ_t", 1).pos().clone(),
212-
code2.s("typ_t", 2).pos().clone(),
209+
code1.s("typ_t", 1).pos(),
210+
code1.s("typ_t", 2).pos(),
211+
code2.s("typ_t", 1).pos(),
212+
code2.s("typ_t", 2).pos(),
213213
];
214214

215215
assert_eq_unordered(
@@ -249,10 +249,7 @@ end package;",
249249

250250
assert_eq_unordered(
251251
&root.find_all_references(&code.s("typ_t", 1).pos()),
252-
&vec![
253-
code.s("typ_t", 1).pos().clone(),
254-
code.s("typ_t", 2).pos().clone(),
255-
],
252+
&[code.s("typ_t", 1).pos(), code.s("typ_t", 2).pos()],
256253
);
257254
}
258255

vhdl_lang/src/analysis/tests/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ impl LibraryBuilder {
2929
let library_name = self.code_builder.symbol(library_name);
3030
match self.libraries.entry(library_name) {
3131
Entry::Occupied(mut entry) => {
32-
entry.get_mut().push(code.clone());
32+
entry.get_mut().push(code);
3333
}
3434
Entry::Vacant(entry) => {
35-
entry.insert(vec![code.clone()]);
35+
entry.insert(vec![code]);
3636
}
3737
}
3838
}
@@ -102,7 +102,7 @@ pub fn add_standard_library(symbols: Arc<Symbols>, root: &mut DesignRoot) {
102102

103103
root.add_design_file(std_sym.clone(), std_standard.design_file());
104104
root.add_design_file(std_sym.clone(), std_textio.design_file());
105-
root.add_design_file(std_sym.clone(), std_env.design_file());
105+
root.add_design_file(std_sym, std_env.design_file());
106106
}
107107

108108
pub fn missing(code: &Code, name: &str, occ: usize) -> Diagnostic {

vhdl_lang/src/config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ fn is_literal(pattern: &str, is_windows: bool) -> bool {
311311
mod tests {
312312
use super::*;
313313
use pretty_assertions::assert_eq;
314-
use tempfile;
315314

316315
/// Utility function to create an empty file in parent folder
317316
fn touch(parent: &Path, file_name: &str) -> PathBuf {
@@ -444,7 +443,7 @@ lib3.files = [
444443
)
445444
.unwrap();
446445

447-
let mut merged_config = config0.clone();
446+
let mut merged_config = config0;
448447
merged_config.append(&config1, &mut Vec::new());
449448
assert_eq!(merged_config, expected_config);
450449
}

vhdl_lang/src/data/contents.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ mod tests {
457457
fn character_is_utf16_len() {
458458
// Bomb emojii requires 2 utf-16 codes
459459
let bomb = '\u{1F4A3}';
460-
let contents = new(&format!("aä{}", bomb).to_string());
460+
let contents = new(&format!("aä{}", bomb));
461461
assert_eq!(contents.end(), Position::new(0, 4));
462462
let mut reader = reader(&contents);
463463
assert_eq!(reader.pop_char(), Some('a'));

vhdl_lang/src/data/source.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ impl UniqueSource {
8181

8282
#[cfg(test)]
8383
pub fn from_contents(file_name: &Path, contents: Contents) -> UniqueSource {
84-
let file_name = file_name.into();
8584
Self {
8685
file_id: FileId::new(file_name),
8786
contents: RwLock::new(contents),
@@ -545,7 +544,6 @@ mod tests {
545544
use crate::data::Latin1String;
546545
use crate::syntax::test::{Code, CodeBuilder};
547546
use pretty_assertions::assert_eq;
548-
use tempfile;
549547

550548
#[test]
551549
fn srcpos_combine() {
@@ -568,7 +566,7 @@ mod tests {
568566
use std::io::Write;
569567
let mut file = tempfile::NamedTempFile::new().unwrap();
570568
let file_name = file.path().to_owned();
571-
file.write(&Latin1String::from_utf8_unchecked(contents).bytes)
569+
file.write_all(&Latin1String::from_utf8_unchecked(contents).bytes)
572570
.unwrap();
573571
fun(CodeBuilder::new().code_from_source(Source::from_latin1_file(&file_name).unwrap()))
574572
}

0 commit comments

Comments
 (0)