Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrades rust to 1.40.0 #3542

Merged
merged 2 commits into from
Dec 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Install rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: "1.39.0"
rust-version: "1.40.0"

- name: Install clippy and rustfmt
if: matrix.kind == 'lint'
Expand Down
58 changes: 21 additions & 37 deletions cli/compilers/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,15 @@ impl CompilerConfig {
// Convert the PathBuf to a canonicalized string. This is needed by the
// compiler to properly deal with the configuration.
let config_path = match &config_file {
Some(config_file) => Some(
config_file
.canonicalize()
.map_err(|_| {
io::Error::new(
io::ErrorKind::InvalidInput,
format!(
"Could not find the config file: {}",
config_file.to_string_lossy()
),
)
})?
.to_owned(),
),
Some(config_file) => Some(config_file.canonicalize().map_err(|_| {
io::Error::new(
io::ErrorKind::InvalidInput,
format!(
"Could not find the config file: {}",
config_file.to_string_lossy()
),
)
})),
_ => None,
};

Expand Down Expand Up @@ -102,7 +97,7 @@ impl CompilerConfig {
};

let ts_config = Self {
path: config_path,
path: config_path.unwrap_or_else(|| Ok(PathBuf::new())).ok(),
content: config,
hash: config_hash,
compile_js,
Expand Down Expand Up @@ -261,15 +256,15 @@ impl TsCompiler {
module_name
);

let root_names = vec![module_name.clone()];
let root_names = vec![module_name];
let req_msg = req(
msg::CompilerRequestType::Bundle,
root_names,
self.config.clone(),
out_file,
);

let worker = TsCompiler::setup_worker(global_state.clone());
let worker = TsCompiler::setup_worker(global_state);
let worker_ = worker.clone();

async move {
Expand Down Expand Up @@ -368,7 +363,7 @@ impl TsCompiler {
let compiling_job = global_state
.progress
.add("Compile", &module_url.to_string());
let global_state_ = global_state.clone();
let global_state_ = global_state;

async move {
worker.post_message(req_msg).await?;
Expand All @@ -390,7 +385,7 @@ impl TsCompiler {
debug!(">>>>> compile_sync END");
Ok(compiled_module)
}
.boxed()
.boxed()
}

/// Get associated `CompiledFileMetadata` for given module if it exists.
Expand Down Expand Up @@ -483,7 +478,7 @@ impl TsCompiler {
);

let compiled_file_metadata = CompiledFileMetadata {
source_path: source_file.filename.to_owned(),
source_path: source_file.filename,
version_hash,
};
let meta_key = self
Expand Down Expand Up @@ -618,8 +613,7 @@ mod tests {
let p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.join("tests/002_hello.ts")
.to_owned();
.join("tests/002_hello.ts");
let specifier =
ModuleSpecifier::resolve_url_or_path(p.to_str().unwrap()).unwrap();

Expand Down Expand Up @@ -658,8 +652,7 @@ mod tests {
let p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.join("tests/002_hello.ts")
.to_owned();
.join("tests/002_hello.ts");
use deno::ModuleSpecifier;
let module_name = ModuleSpecifier::resolve_url_or_path(p.to_str().unwrap())
.unwrap()
Expand Down Expand Up @@ -717,25 +710,16 @@ mod tests {

let test_cases = vec![
// valid JSON
(
r#"{ "compilerOptions": { "checkJs": true } } "#,
true,
),
(r#"{ "compilerOptions": { "checkJs": true } } "#, true),
// JSON with comment
(
r#"{ "compilerOptions": { // force .js file compilation by Deno "checkJs": true } } "#,
true,
),
// invalid JSON
(
r#"{ "compilerOptions": { "checkJs": true },{ } "#,
true,
),
(r#"{ "compilerOptions": { "checkJs": true },{ } "#, true),
// without content
(
"",
false,
),
("", false),
];

let path = temp_dir_path.join("tsconfig.json");
Expand All @@ -754,7 +738,7 @@ mod tests {
let temp_dir_path = temp_dir.path();
let path = temp_dir_path.join("doesnotexist.json");
let path_str = path.to_str().unwrap().to_string();
let res = CompilerConfig::load(Some(path_str.clone()));
let res = CompilerConfig::load(Some(path_str));
assert!(res.is_err());
}
}
4 changes: 2 additions & 2 deletions cli/compilers/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ impl WasmCompiler {
let cache = self.cache.clone();
let maybe_cached = { cache.lock().unwrap().get(&source_file.url).cloned() };
if let Some(m) = maybe_cached {
return futures::future::ok(m.clone()).boxed();
return futures::future::ok(m).boxed();
}
let cache_ = self.cache.clone();

debug!(">>>>> wasm_compile_async START");
let base64_data = base64::encode(&source_file.source_code);
let worker = WasmCompiler::setup_worker(global_state.clone());
let worker = WasmCompiler::setup_worker(global_state);
let worker_ = worker.clone();
let url = source_file.url.clone();

Expand Down
26 changes: 9 additions & 17 deletions cli/file_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,10 +819,7 @@ mod tests {
let headers = fetcher.get_source_code_headers(&url);

assert_eq!(headers.mime_type.clone().unwrap(), "text/javascript");
assert_eq!(
headers.redirect_to.clone().unwrap(),
"http:https://example.com/a.js"
);
assert_eq!(headers.redirect_to.unwrap(), "http:https://example.com/a.js");

let _ = fetcher.save_source_code_headers(
&url,
Expand All @@ -831,10 +828,7 @@ mod tests {
);
let headers2 = fetcher.get_source_code_headers(&url);
assert_eq!(headers2.mime_type.clone().unwrap(), "text/typescript");
assert_eq!(
headers2.redirect_to.clone().unwrap(),
"http:https://deno.land/a.js"
);
assert_eq!(headers2.redirect_to.unwrap(), "http:https://deno.land/a.js");
}

#[test]
Expand Down Expand Up @@ -868,7 +862,7 @@ mod tests {
);
let headers_file_name_1 = headers_file_name.clone();
let headers_file_name_2 = headers_file_name.clone();
let headers_file_name_3 = headers_file_name.clone();
let headers_file_name_3 = headers_file_name;

let fut = fetcher
.get_source_file_async(&module_url, true, false, false)
Expand Down Expand Up @@ -1128,7 +1122,7 @@ mod tests {
assert!(redirect_target_headers.redirect_to.is_none());

// Examine the meta result.
assert_eq!(mod_meta.url.clone(), target_module_url);
assert_eq!(mod_meta.url, target_module_url);
futures::future::ok(())
});

Expand Down Expand Up @@ -1195,7 +1189,7 @@ mod tests {
assert!(redirect_target_headers.redirect_to.is_none());

// Examine the meta result.
assert_eq!(mod_meta.url.clone(), target_url);
assert_eq!(mod_meta.url, target_url);
futures::future::ok(())
});

Expand Down Expand Up @@ -1507,9 +1501,8 @@ mod tests {
},
));

let p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("js/main.ts")
.to_owned();
let p =
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("js/main.ts");
let specifier =
ModuleSpecifier::resolve_url_or_path(p.to_str().unwrap()).unwrap();
tokio_util::run(fetcher.fetch_source_file_async(&specifier, None).then(
Expand All @@ -1535,9 +1528,8 @@ mod tests {
},
));

let p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("js/main.ts")
.to_owned();
let p =
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("js/main.ts");
let specifier =
ModuleSpecifier::resolve_url_or_path(p.to_str().unwrap()).unwrap();
tokio_util::run(fetcher.fetch_source_file_async(&specifier, None).then(
Expand Down
2 changes: 1 addition & 1 deletion cli/fmt_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub fn format_maybe_source_line(
assert!(end_column.is_some());
let line = (1 + line_number.unwrap()).to_string();
let line_color = colors::black_on_white(line.to_string());
let line_len = line.clone().len();
let line_len = line.len();
let line_padding =
colors::black_on_white(format!("{:indent$}", "", indent = line_len))
.to_string();
Expand Down
24 changes: 8 additions & 16 deletions cli/import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,10 @@ impl ImportMap {
}

// Sort in longest and alphabetical order.
normalized_map.sort_by(|k1, _v1, k2, _v2| {
if k1.len() > k2.len() {
return Ordering::Less;
} else if k2.len() > k1.len() {
return Ordering::Greater;
}

k2.cmp(k1)
normalized_map.sort_by(|k1, _v1, k2, _v2| match k1.cmp(&k2) {
Ordering::Greater => Ordering::Less,
Ordering::Less => Ordering::Greater,
Ordering::Equal => k2.cmp(k1),
});

normalized_map
Expand Down Expand Up @@ -313,14 +309,10 @@ impl ImportMap {
}

// Sort in longest and alphabetical order.
normalized_map.sort_by(|k1, _v1, k2, _v2| {
if k1.len() > k2.len() {
return Ordering::Less;
} else if k2.len() > k1.len() {
return Ordering::Greater;
}

k2.cmp(k1)
normalized_map.sort_by(|k1, _v1, k2, _v2| match k1.cmp(&k2) {
Ordering::Greater => Ordering::Less,
Ordering::Less => Ordering::Greater,
Ordering::Equal => k2.cmp(k1),
});

Ok(normalized_map)
Expand Down
2 changes: 1 addition & 1 deletion cli/ops/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn op_apply_source_map(
);

Ok(JsonOp::Sync(json!({
"filename": orig_filename.to_string(),
"filename": orig_filename,
"line": orig_line as u32,
"column": orig_column as u32,
})))
Expand Down
2 changes: 1 addition & 1 deletion cli/ops/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::ffi::OsStr;
use std::sync::Arc;

pub fn init(i: &mut Isolate, s: &ThreadSafeState, r: Arc<deno::OpRegistry>) {
let r_ = r.clone();
let r_ = r;
i.register_op(
"open_plugin",
s.core_op(json_op(s.stateful_op(move |state, args, zero_copy| {
Expand Down
4 changes: 2 additions & 2 deletions cli/ops/workers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn op_worker_get_message(
debug!("op_worker_get_message");

futures::future::ok(json!({
"data": maybe_buf.map(|buf| buf.to_owned())
"data": maybe_buf.map(|buf| buf)
}))
});

Expand Down Expand Up @@ -261,7 +261,7 @@ fn op_host_get_message(
.map_err(move |_| -> ErrBox { unimplemented!() })
.and_then(move |maybe_buf| {
futures::future::ok(json!({
"data": maybe_buf.map(|buf| buf.to_owned())
"data": maybe_buf.map(|buf| buf)
}))
});

Expand Down
8 changes: 4 additions & 4 deletions cli/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ mod tests {

let perms = DenoPermissions::from_flags(&DenoFlags {
read_whitelist: whitelist.clone(),
write_whitelist: whitelist.clone(),
write_whitelist: whitelist,
..Default::default()
});

Expand Down Expand Up @@ -555,7 +555,7 @@ mod tests {
);

let mut perms2 = DenoPermissions::from_flags(&DenoFlags {
read_whitelist: whitelist.clone(),
read_whitelist: whitelist,
..Default::default()
});
set_prompt_result(false);
Expand Down Expand Up @@ -591,7 +591,7 @@ mod tests {
);

let mut perms2 = DenoPermissions::from_flags(&DenoFlags {
write_whitelist: whitelist.clone(),
write_whitelist: whitelist,
..Default::default()
});
set_prompt_result(false);
Expand Down Expand Up @@ -644,7 +644,7 @@ mod tests {
);

let mut perms3 = DenoPermissions::from_flags(&DenoFlags {
net_whitelist: whitelist.clone(),
net_whitelist: whitelist,
..Default::default()
});
set_prompt_result(true);
Expand Down
8 changes: 6 additions & 2 deletions cli/source_maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,12 @@ mod tests {
impl SourceMapGetter for MockSourceMapGetter {
fn get_source_map(&self, script_name: &str) -> Option<Vec<u8>> {
let s = match script_name {
"foo_bar.ts" => r#"{"sources": ["foo_bar.ts"], "mappings":";;;IAIA,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE3C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}"#,
"bar_baz.ts" => r#"{"sources": ["bar_baz.ts"], "mappings":";;;IAEA,CAAC,KAAK,IAAI,EAAE;QACV,MAAM,GAAG,GAAG,sDAAa,OAAO,2BAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC,CAAC,EAAE,CAAC;IAEQ,QAAA,GAAG,GAAG,KAAK,CAAC;IAEzB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}"#,
"foo_bar.ts" => {
r#"{"sources": ["foo_bar.ts"], "mappings":";;;IAIA,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE3C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}"#
}
"bar_baz.ts" => {
r#"{"sources": ["bar_baz.ts"], "mappings":";;;IAEA,CAAC,KAAK,IAAI,EAAE;QACV,MAAM,GAAG,GAAG,sDAAa,OAAO,2BAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC,CAAC,EAAE,CAAC;IAEQ,QAAA,GAAG,GAAG,KAAK,CAAC;IAEzB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}"#
}
_ => return None,
};
Some(s.as_bytes().to_owned())
Expand Down
2 changes: 1 addition & 1 deletion cli/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl ThreadSafeState {
Op::Async(fut) => {
let state = state.clone();
let result_fut = fut.map_ok(move |buf: Buf| {
state.clone().metrics_op_completed(buf.len());
state.metrics_op_completed(buf.len());
buf
});
Op::Async(result_fut.boxed())
Expand Down
Loading