Skip to content

Commit

Permalink
chore: upgrade Rust to 1.54.0 (denoland#11554)
Browse files Browse the repository at this point in the history
  • Loading branch information
magurotuna committed Jul 30, 2021
1 parent c909faf commit 8f00b55
Show file tree
Hide file tree
Showing 36 changed files with 156 additions and 161 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- name: Install Rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: 1.53.0
rust-version: 1.54.0

- name: Install clippy and rustfmt
if: matrix.kind == 'lint'
Expand Down Expand Up @@ -253,7 +253,7 @@ jobs:
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: e-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }}
key: f-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }}

# In main branch, always creates fresh cache
- name: Cache build output (main)
Expand All @@ -268,7 +268,7 @@ jobs:
!./target/*/*.zip
!./target/*/*.tar.gz
key: |
d-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }}
f-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }}
# Restore cache from the latest 'main' branch build.
- name: Cache build output (PR)
Expand All @@ -284,7 +284,7 @@ jobs:
!./target/*/*.tar.gz
key: never_saved
restore-keys: |
d-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-
f-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-
# Don't save cache after building PRs or branches other than 'main'.
- name: Skip save cache (PR)
Expand Down
4 changes: 2 additions & 2 deletions cli/bench/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ fn get_binary_sizes(target_dir: &Path) -> Result<HashMap<String, u64>> {
);

// add up size for everything in target/release/deps/libswc*
let swc_size = rlib_size(&target_dir, "libswc");
let swc_size = rlib_size(target_dir, "libswc");
println!("swc {} bytes", swc_size);
sizes.insert("swc_rlib".to_string(), swc_size);

let rusty_v8_size = rlib_size(&target_dir, "librusty_v8");
let rusty_v8_size = rlib_size(target_dir, "librusty_v8");
println!("rusty_v8 {} bytes", rusty_v8_size);
sizes.insert("rusty_v8_rlib".to_string(), rusty_v8_size);

Expand Down
2 changes: 1 addition & 1 deletion cli/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl DiagnosticMessageChain {
pub fn format_message(&self, level: usize) -> String {
let mut s = String::new();

s.push_str(&std::iter::repeat(" ").take(level * 2).collect::<String>());
s.push_str(&" ".repeat(level * 2));
s.push_str(&self.message_text);
if let Some(next) = &self.next {
s.push('\n');
Expand Down
2 changes: 1 addition & 1 deletion cli/disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl DiskCache {
pub fn set(&self, filename: &Path, data: &[u8]) -> std::io::Result<()> {
let path = self.location.join(filename);
match path.parent() {
Some(ref parent) => self.ensure_dir_exists(parent),
Some(parent) => self.ensure_dir_exists(parent),
None => Ok(()),
}?;
fs_util::atomic_write_file(&path, data, crate::http_cache::CACHE_PERM)
Expand Down
2 changes: 1 addition & 1 deletion cli/file_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl FileFetcher {
Ok((_, headers)) => headers.get("etag").cloned(),
_ => None,
};
let maybe_auth_token = self.auth_tokens.get(&specifier);
let maybe_auth_token = self.auth_tokens.get(specifier);
let specifier = specifier.clone();
let mut permissions = permissions.clone();
let client = self.http_client.clone();
Expand Down
4 changes: 2 additions & 2 deletions cli/fmt_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn format_frame(frame: &JsStackFrame) -> String {
formatted_method += &format!("{}.", type_name);
}
}
formatted_method += &function_name;
formatted_method += function_name;
if let Some(method_name) = &frame.method_name {
if !function_name.ends_with(method_name) {
formatted_method += &format!(" [as {}]", method_name);
Expand All @@ -78,7 +78,7 @@ fn format_frame(frame: &JsStackFrame) -> String {
formatted_method += &format!("{}.", type_name);
}
if let Some(method_name) = &frame.method_name {
formatted_method += &method_name
formatted_method += method_name
} else {
formatted_method += "<anonymous>";
}
Expand Down
2 changes: 1 addition & 1 deletion cli/http_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Metadata {

#[cfg(test)]
pub fn read(cache_filename: &Path) -> Result<Metadata, AnyError> {
let metadata_filename = Metadata::filename(&cache_filename);
let metadata_filename = Metadata::filename(cache_filename);
let metadata = fs::read_to_string(metadata_filename)?;
let metadata: Metadata = serde_json::from_str(&metadata)?;
Ok(metadata)
Expand Down
6 changes: 3 additions & 3 deletions cli/import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl ImportMap {
}

// Sort in longest and alphabetical order.
normalized_map.sort_by(|k1, _v1, k2, _v2| match k1.cmp(&k2) {
normalized_map.sort_by(|k1, _v1, k2, _v2| match k1.cmp(k2) {
Ordering::Greater => Ordering::Less,
Ordering::Less => Ordering::Greater,
// JSON guarantees that there can't be duplicate keys
Expand Down Expand Up @@ -324,7 +324,7 @@ impl ImportMap {
}

// Sort in longest and alphabetical order.
normalized_map.sort_by(|k1, _v1, k2, _v2| match k1.cmp(&k2) {
normalized_map.sort_by(|k1, _v1, k2, _v2| match k1.cmp(k2) {
Ordering::Greater => Ordering::Less,
Ordering::Less => Ordering::Greater,
// JSON guarantees that there can't be duplicate keys
Expand Down Expand Up @@ -691,7 +691,7 @@ mod tests {
ImportMap::from_json(&test.import_map_base_url, &test.import_map)
.unwrap();
let maybe_resolved = import_map
.resolve(&given_specifier, &base_url)
.resolve(given_specifier, base_url)
.ok()
.map(|url| url.to_string());
assert_eq!(expected_specifier, &maybe_resolved, "{}", test.name);
Expand Down
6 changes: 3 additions & 3 deletions cli/lsp/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ pub fn parse_module(
ast::parse_with_source_map(
&specifier.to_string(),
source,
&media_type,
media_type,
source_map,
)
}
Expand All @@ -309,7 +309,7 @@ pub fn analyze_dependencies(

// Parse leading comments for supported triple slash references.
for comment in parsed_module.get_leading_comments().iter() {
if let Some((ts_reference, span)) = parse_ts_reference(&comment) {
if let Some((ts_reference, span)) = parse_ts_reference(comment) {
let loc = parsed_module.source_map.lookup_char_pos(span.lo);
match ts_reference {
TypeScriptReference::Path(import) => {
Expand Down Expand Up @@ -364,7 +364,7 @@ pub fn analyze_dependencies(
let maybe_resolved_type_dependency =
// Check for `@deno-types` pragmas that affect the import
if let Some(comment) = desc.leading_comments.last() {
parse_deno_types(&comment).as_ref().map(|(deno_types, span)| {
parse_deno_types(comment).as_ref().map(|(deno_types, span)| {
(
resolve_import(deno_types, specifier, maybe_import_map),
deno_types.clone(),
Expand Down
20 changes: 10 additions & 10 deletions cli/lsp/code_lens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl DenoTestCollector {
key_value_prop.value.as_ref()
{
let name = lit_str.value.to_string();
self.add_code_lens(name, &span);
self.add_code_lens(name, span);
}
}
}
Expand All @@ -112,7 +112,7 @@ impl DenoTestCollector {
}
ast::Expr::Lit(ast::Lit::Str(lit_str)) => {
let name = lit_str.value.to_string();
self.add_code_lens(name, &span);
self.add_code_lens(name, span);
}
_ => (),
}
Expand Down Expand Up @@ -415,7 +415,7 @@ async fn collect_tsc(
) -> Result<Vec<lsp::CodeLens>, AnyError> {
let workspace_settings = language_server.config.get_workspace_settings();
let line_index = language_server
.get_line_index_sync(&specifier)
.get_line_index_sync(specifier)
.ok_or_else(|| anyhow!("Missing line index."))?;
let navigation_tree = language_server.get_navigation_tree(specifier).await?;
let code_lenses = Rc::new(RefCell::new(Vec::new()));
Expand All @@ -435,7 +435,7 @@ async fn collect_tsc(
| tsc::ScriptElementKind::MemberGetAccessorElement
| tsc::ScriptElementKind::MemberSetAccessorElement => {
if ABSTRACT_MODIFIER.is_match(&i.kind_modifiers) {
code_lenses.push(i.to_code_lens(&line_index, &specifier, &source));
code_lenses.push(i.to_code_lens(&line_index, specifier, &source));
}
}
_ => (),
Expand All @@ -447,31 +447,31 @@ async fn collect_tsc(
let source = CodeLensSource::References;
if let Some(parent) = &mp {
if parent.kind == tsc::ScriptElementKind::EnumElement {
code_lenses.push(i.to_code_lens(&line_index, &specifier, &source));
code_lenses.push(i.to_code_lens(&line_index, specifier, &source));
}
}
match i.kind {
tsc::ScriptElementKind::FunctionElement => {
if workspace_settings.code_lens.references_all_functions {
code_lenses.push(i.to_code_lens(&line_index, &specifier, &source));
code_lenses.push(i.to_code_lens(&line_index, specifier, &source));
}
}
tsc::ScriptElementKind::ConstElement
| tsc::ScriptElementKind::LetElement
| tsc::ScriptElementKind::VariableElement => {
if EXPORT_MODIFIER.is_match(&i.kind_modifiers) {
code_lenses.push(i.to_code_lens(&line_index, &specifier, &source));
code_lenses.push(i.to_code_lens(&line_index, specifier, &source));
}
}
tsc::ScriptElementKind::ClassElement => {
if i.text != "<class>" {
code_lenses.push(i.to_code_lens(&line_index, &specifier, &source));
code_lenses.push(i.to_code_lens(&line_index, specifier, &source));
}
}
tsc::ScriptElementKind::InterfaceElement
| tsc::ScriptElementKind::TypeElement
| tsc::ScriptElementKind::EnumElement => {
code_lenses.push(i.to_code_lens(&line_index, &specifier, &source));
code_lenses.push(i.to_code_lens(&line_index, specifier, &source));
}
tsc::ScriptElementKind::LocalFunctionElement
| tsc::ScriptElementKind::MemberGetAccessorElement
Expand All @@ -486,7 +486,7 @@ async fn collect_tsc(
| tsc::ScriptElementKind::TypeElement => {
code_lenses.push(i.to_code_lens(
&line_index,
&specifier,
specifier,
&source,
));
}
Expand Down
12 changes: 6 additions & 6 deletions cli/lsp/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,13 @@ fn to_lsp_related_information(
if let (Some(source), Some(start), Some(end)) =
(&ri.source, &ri.start, &ri.end)
{
let uri = lsp::Url::parse(&source).unwrap();
let uri = lsp::Url::parse(source).unwrap();
Some(lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri,
range: to_lsp_range(start, end),
},
message: get_diagnostic_message(&ri),
message: get_diagnostic_message(ri),
})
} else {
None
Expand Down Expand Up @@ -421,8 +421,8 @@ fn diagnose_dependency(
})
}
analysis::ResolvedDependency::Resolved(specifier) => {
if !(documents.contains_key(&specifier)
|| sources.contains_key(&specifier))
if !(documents.contains_key(specifier)
|| sources.contains_key(specifier))
{
let (code, message) = match specifier.scheme() {
"file" => (Some(lsp::NumberOrString::String("no-local".to_string())), format!("Unable to load a local module: \"{}\".\n Please check the file path.", specifier)),
Expand All @@ -439,8 +439,8 @@ fn diagnose_dependency(
data: Some(json!({ "specifier": specifier })),
..Default::default()
});
} else if sources.contains_key(&specifier) {
if let Some(message) = sources.get_maybe_warning(&specifier) {
} else if sources.contains_key(specifier) {
if let Some(message) = sources.get_maybe_warning(specifier) {
diagnostics.push(lsp::Diagnostic {
range,
severity: Some(lsp::DiagnosticSeverity::Warning),
Expand Down
6 changes: 3 additions & 3 deletions cli/lsp/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ impl DocumentData {
let mut line_index = if let Some(line_index) = &self.line_index {
line_index.clone()
} else {
LineIndex::new(&content)
LineIndex::new(content)
};
let mut index_valid = IndexValid::All;
for change in content_changes {
if let Some(range) = change.range {
if !index_valid.covers(range.start.line) {
line_index = LineIndex::new(&content);
line_index = LineIndex::new(content);
}
index_valid = IndexValid::UpTo(range.start.line);
let range = line_index.get_text_range(range)?;
Expand All @@ -139,7 +139,7 @@ impl DocumentData {
self.line_index = if index_valid == IndexValid::All {
Some(line_index)
} else {
Some(LineIndex::new(&content))
Some(LineIndex::new(content))
};
self.maybe_navigation_tree = None;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ impl Inner {
Ok(maybe_asset.clone())
} else {
let maybe_asset =
tsc::get_asset(&specifier, &self.ts_server, self.snapshot()?).await?;
tsc::get_asset(specifier, &self.ts_server, self.snapshot()?).await?;
self.assets.insert(specifier.clone(), maybe_asset.clone());
Ok(maybe_asset)
}
Expand Down
15 changes: 7 additions & 8 deletions cli/lsp/registries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn get_completor_type(
if let StringOrNumber::String(name) = &k.name {
let value = match_result
.get(name)
.map(|s| s.to_string(Some(&k)))
.map(|s| s.to_string(Some(k)))
.unwrap_or_default();
len += value.chars().count();
if offset <= len {
Expand Down Expand Up @@ -183,14 +183,13 @@ fn validate_config(config: &RegistryConfigurationJson) -> Result<(), AnyError> {
.collect()
});

let variable_names: Vec<String> = registry
.variables
.iter()
.map(|var| var.key.to_owned())
.collect();

for key_name in &key_names {
if !variable_names.contains(key_name) {
if !registry
.variables
.iter()
.map(|var| var.key.to_owned())
.any(|x| x == *key_name)
{
return Err(anyhow!("Invalid registry configuration. Registry with schema \"{}\" is missing variable declaration for key \"{}\".", registry.schema, key_name));
}
}
Expand Down
8 changes: 4 additions & 4 deletions cli/lsp/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl Inner {
&mut self,
specifier: &ModuleSpecifier,
) -> Option<String> {
let metadata = self.get_metadata(&specifier)?;
let metadata = self.get_metadata(specifier)?;
metadata.maybe_warning
}

Expand Down Expand Up @@ -399,7 +399,7 @@ impl Inner {
map_content_type(specifier, maybe_content_type);
let source = get_source_from_bytes(bytes, maybe_charset).ok()?;
let maybe_types = headers.get("x-typescript-types").map(|s| {
analysis::resolve_import(s, &specifier, &self.maybe_import_map)
analysis::resolve_import(s, specifier, &self.maybe_import_map)
});
let maybe_warning = headers.get("x-deno-warning").cloned();
(source, media_type, maybe_types, maybe_warning)
Expand Down Expand Up @@ -432,10 +432,10 @@ impl Inner {
fn get_path(&mut self, specifier: &ModuleSpecifier) -> Option<PathBuf> {
if specifier.scheme() == "file" {
specifier.to_file_path().ok()
} else if let Some(path) = self.remotes.get(&specifier) {
} else if let Some(path) = self.remotes.get(specifier) {
Some(path.clone())
} else {
let path = self.http_cache.get_cache_filename(&specifier)?;
let path = self.http_cache.get_cache_filename(specifier)?;
if path.is_file() {
self.remotes.insert(specifier.clone(), path.clone());
Some(path)
Expand Down
2 changes: 1 addition & 1 deletion cli/lsp/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ impl CallHierarchyOutgoingCall {
from_ranges: self
.from_spans
.iter()
.map(|span| span.to_range(&line_index))
.map(|span| span.to_range(line_index))
.collect(),
})
}
Expand Down
4 changes: 2 additions & 2 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ async fn test_command(
output.insert(specifier);

get_dependencies(
&graph,
graph,
graph.get_specifier(specifier)?,
output,
)?;
Expand All @@ -1099,7 +1099,7 @@ async fn test_command(
output.insert(specifier);

get_dependencies(
&graph,
graph,
graph.get_specifier(specifier)?,
output,
)?;
Expand Down
Loading

0 comments on commit 8f00b55

Please sign in to comment.