Skip to content

Commit

Permalink
chore(rust): Bump Rust nightly to Version 1.66.0 (2022-12-15)
Browse files Browse the repository at this point in the history
closes #33
  • Loading branch information
Boshen committed Jan 6, 2023
1 parent e95fd36 commit 542fcaa
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2022-08-06"
channel = "nightly-2022-12-15"
profile = "default"
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl fmt::Display for Error {
Error::VlqLeftover => write!(f, "leftover cur/shift in vlq decode"),
Error::VlqNoValues => write!(f, "vlq decode did not produce any values"),
Error::VlqOverflow => write!(f, "vlq decode caused an overflow"),
Error::BadJson(err) => write!(f, "bad json: {}", err),
Error::BadJson(err) => write!(f, "bad json: {err}"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl<'a> Iterator for SegmentIter<'a> {
if self.nums.len() > 4 {
self.name_index =
(i64::from(self.name_index) + self.nums[4]) as u32;
name = Some(self.name_index as u32);
name = Some(self.name_index);
}
}

Expand Down Expand Up @@ -933,7 +933,7 @@ pub fn stream_chunks_of_combined_source_map(
let mut r = mappings_data.len() / 5;
while l < r {
let m = (l + r) >> 1;
if mappings_data[m * 5] <= column as i64 {
if mappings_data[m * 5] <= column {
l = m + 1;
} else {
r = m;
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Rusty [`webpack-sources`](https://github.com/webpack/webpack-sources) port.
#![feature(let_chains)]
#![forbid(unsafe_code)]
#![deny(missing_docs)]

Expand Down
2 changes: 1 addition & 1 deletion src/original_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ mod tests {
#[test]
fn should_return_the_correct_size_for_binary_files() {
let source = OriginalSource::new(
&String::from_utf8(vec![0; 256]).unwrap(),
String::from_utf8(vec![0; 256]).unwrap(),
"file.wasm",
);
assert_eq!(source.size(), 256);
Expand Down
24 changes: 13 additions & 11 deletions src/replace_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,16 @@ impl<T: Source + Hash + PartialEq + Eq + 'static> Source for ReplaceSource<T> {
for replacement in self.replacements.lock().iter() {
if inner_pos < replacement.start {
let end_pos = (replacement.start as usize).min(inner_source_code.len());
source_code.push_str(
inner_source_code.substring(inner_pos as usize, end_pos as usize),
);
source_code
.push_str(inner_source_code.substring(inner_pos as usize, end_pos));
}
source_code.push_str(&replacement.content);
inner_pos = inner_pos
.max(replacement.end)
.min(inner_source_code.len() as u32);
#[allow(clippy::manual_clamp)]
{
inner_pos = inner_pos
.max(replacement.end)
.min(inner_source_code.len() as u32);
}
}
source_code
.push_str(inner_source_code.substring(inner_pos as usize, usize::MAX));
Expand Down Expand Up @@ -248,7 +250,7 @@ impl<T: Source> StreamChunks for ReplaceSource<T> {
original.original_column,
chunk.substring(0, chunk_pos as usize),
) {
original.original_column += chunk_pos as u32;
original.original_column += chunk_pos;
}
pos += chunk_pos;
let line = mapping.generated_line as i64 + generated_line_offset;
Expand All @@ -258,7 +260,7 @@ impl<T: Source> StreamChunks for ReplaceSource<T> {
generated_column_offset = -(chunk_pos as i64);
generated_column_offset_line = line;
}
mapping.generated_column += chunk_pos as u32;
mapping.generated_column += chunk_pos;
}

// Is a replacement in the chunk?
Expand All @@ -278,7 +280,7 @@ impl<T: Source> StreamChunks for ReplaceSource<T> {
name_index: original.name_index.and_then(|name_index| name_index_mapping.borrow().get(&name_index).copied()),
}),
});
mapping.generated_column += offset as u32;
mapping.generated_column += offset;
chunk_pos += offset;
pos = next_replacement_pos;
if let Some(original) = &mut mapping.original
Expand Down Expand Up @@ -522,7 +524,7 @@ mod tests {
.and_then(
|original| sourcemap.get_source(original.source_index as usize)
)
.map_or("".to_owned(), |source| format!(" [{}]", source)),
.map_or("".to_owned(), |source| format!(" [{source}]")),
token
.original
.as_ref()
Expand All @@ -538,7 +540,7 @@ mod tests {
.as_ref()
.and_then(|original| original.name_index)
.and_then(|name_index| sourcemap.get_name(name_index as usize))
.map_or("".to_owned(), |source| format!(" ({})", source)),
.map_or("".to_owned(), |source| format!(" ({source})")),
)
})
.collect()
Expand Down
4 changes: 3 additions & 1 deletion src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl TryFrom<RawSourceMap> for SourceMap {
if is_valid {
x
} else {
format!("{}/{}", source_root, x)
format!("{source_root}/{x}")
}
})
.collect()
Expand Down Expand Up @@ -571,6 +571,7 @@ mod tests {
}

#[test]
#[allow(clippy::clone_double_ref)]
fn clone_available() {
let a = RawSource::from("a");
assert_eq!(a, a.clone());
Expand Down Expand Up @@ -607,6 +608,7 @@ mod tests {
}

#[test]
#[allow(clippy::clone_double_ref)]
fn ref_dyn_source_use_hashmap_available() {
let mut map = HashMap::new();
let a = &RawSource::from("a") as &dyn Source;
Expand Down

1 comment on commit 542fcaa

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 542fcaa Previous: c6bc9fa Ratio
benchmark_concat_generate_base64 26781 ns/iter (± 185) 26145 ns/iter (± 3637) 1.02
benchmark_concat_generate_base64_with_cache 17662 ns/iter (± 118) 17434 ns/iter (± 1507) 1.01
benchmark_concat_generate_string 12143 ns/iter (± 70) 9889 ns/iter (± 1425) 1.23
benchmark_concat_generate_string_with_cache 3009 ns/iter (± 46) 2839 ns/iter (± 441) 1.06

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.