From 730fda0f9ef8dda211ad5c077f6b4fc09fa7a65d Mon Sep 17 00:00:00 2001 From: Noa Date: Thu, 13 Jan 2022 23:26:01 -0600 Subject: [PATCH 1/3] Fix doc comment for Interpreter --- vm/src/vm.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vm/src/vm.rs b/vm/src/vm.rs index 25a525bd4..b969b91cb 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -1956,10 +1956,6 @@ impl<'vm> Drop for ReprGuard<'vm> { } } -pub struct Interpreter { - vm: VirtualMachine, -} - /// The general interface for the VM /// /// # Examples @@ -1976,6 +1972,10 @@ pub struct Interpreter { /// vm.run_code_obj(code_obj, scope).unwrap(); /// }); /// ``` +pub struct Interpreter { + vm: VirtualMachine, +} + impl Interpreter { pub fn new(settings: PySettings, init: InitParameter) -> Self { Self::new_with_init(settings, |_| init) From 78b17ba940001061c371239236272cca5c5a3ae5 Mon Sep 17 00:00:00 2001 From: Noa Date: Thu, 13 Jan 2022 23:25:45 -0600 Subject: [PATCH 2/3] Fix doctests in ci --- Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index dee8c71b2..e4884dd44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,7 +71,8 @@ opt-level = 3 [profile.test] opt-level = 3 -lto = "thin" +# https://github.com/rust-lang/rust/issues/92869 +# lto = "thin" [profile.bench] lto = true From 11883699561f4d5b872ac353659596f321f4fd8b Mon Sep 17 00:00:00 2001 From: Noa Date: Thu, 13 Jan 2022 23:08:56 -0600 Subject: [PATCH 3/3] Fix clippy warnings with 1.58 & convert some format strings to capture-args --- common/src/boxvec.rs | 2 +- common/src/linked_list.rs | 3 +++ compiler/src/compile.rs | 1 + derive/src/util.rs | 8 +++----- jit/src/lib.rs | 3 +++ vm/src/codecs.rs | 8 ++++---- vm/src/exceptions.rs | 2 +- vm/src/format.rs | 11 ++--------- vm/src/pyobjectrc.rs | 3 ++- 9 files changed, 20 insertions(+), 21 deletions(-) diff --git a/common/src/boxvec.rs b/common/src/boxvec.rs index 66ef9e895..7d2e8a4c7 100644 --- a/common/src/boxvec.rs +++ b/common/src/boxvec.rs @@ -465,7 +465,7 @@ pub struct Drain<'a, T> { } unsafe impl<'a, T: Sync> Sync for Drain<'a, T> {} -unsafe impl<'a, T: Send> Send for Drain<'a, T> {} +unsafe impl<'a, T: Sync> Send for Drain<'a, T> {} impl Iterator for Drain<'_, T> { type Item = T; diff --git a/common/src/linked_list.rs b/common/src/linked_list.rs index 5834a1443..ac4f01343 100644 --- a/common/src/linked_list.rs +++ b/common/src/linked_list.rs @@ -128,6 +128,9 @@ struct PointersInner { _pin: PhantomPinned, } +unsafe impl Send for PointersInner {} +unsafe impl Sync for PointersInner {} + unsafe impl Send for Pointers {} unsafe impl Sync for Pointers {} diff --git a/compiler/src/compile.rs b/compiler/src/compile.rs index 2d877bfba..7d7d99ef8 100644 --- a/compiler/src/compile.rs +++ b/compiler/src/compile.rs @@ -88,6 +88,7 @@ struct CompileContext { } #[derive(Debug, Clone, Copy, PartialEq)] +#[allow(clippy::enum_variant_names)] enum FunctionContext { NoFunction, Function, diff --git a/derive/src/util.rs b/derive/src/util.rs index f104c03c9..552dbc01c 100644 --- a/derive/src/util.rs +++ b/derive/src/util.rs @@ -102,9 +102,7 @@ impl ItemMetaInner { Err(syn::Error::new_spanned( ident, format!( - "#[{}({})] is not one of allowed attributes [{}]", - meta_ident.to_string(), - name, + "#[{meta_ident}({name})] is not one of allowed attributes [{}]", allowed_names.join(", ") ), )) @@ -116,7 +114,7 @@ impl ItemMetaInner { if !lits.is_empty() { return Err(syn::Error::new_spanned( &meta_ident, - format!("#[{}(..)] cannot contain literal", meta_ident.to_string()), + format!("#[{meta_ident}(..)] cannot contain literal"), )); } @@ -381,7 +379,7 @@ impl AttributeExt for Attribute { other.span(), format!( "#[{name}(...)] doesn't contain '{item}' to remove", - name = other.get_ident().unwrap().to_string(), + name = other.get_ident().unwrap(), item = item_name ), )), diff --git a/jit/src/lib.rs b/jit/src/lib.rs index 3b4920f6d..5c8f43632 100644 --- a/jit/src/lib.rs +++ b/jit/src/lib.rs @@ -286,6 +286,9 @@ impl UnTypedAbiValue { } } +// we don't actually ever touch CompiledCode til we drop it, it should be safe. +// TODO: confirm with wasmtime ppl that it's not unsound? +#[allow(clippy::non_send_fields_in_send_ty)] unsafe impl Send for CompiledCode {} unsafe impl Sync for CompiledCode {} diff --git a/vm/src/codecs.rs b/vm/src/codecs.rs index b06f61848..11fb587a2 100644 --- a/vm/src/codecs.rs +++ b/vm/src/codecs.rs @@ -455,13 +455,13 @@ fn namereplace_errors(err: PyObjectRef, vm: &VirtualMachine) -> PyResult<(String use std::fmt::Write; let c_u32 = c as u32; if let Some(c_name) = unicode_names2::name(c) { - write!(out, "\\N{{{}}}", c_name.to_string()).unwrap(); + write!(out, "\\N{{{c_name}}}").unwrap(); } else if c_u32 >= 0x10000 { - write!(out, "\\U{:08x}", c_u32).unwrap(); + write!(out, "\\U{c_u32:08x}").unwrap(); } else if c_u32 >= 0x100 { - write!(out, "\\u{:04x}", c_u32).unwrap(); + write!(out, "\\u{c_u32:04x}").unwrap(); } else { - write!(out, "\\x{:02x}", c_u32).unwrap(); + write!(out, "\\x{c_u32:02x}").unwrap(); } } Ok((out, range.end)) diff --git a/vm/src/exceptions.rs b/vm/src/exceptions.rs index d52cecb18..b5db562b0 100644 --- a/vm/src/exceptions.rs +++ b/vm/src/exceptions.rs @@ -144,7 +144,7 @@ impl VirtualMachine { }?; match offer_suggestions(exc, vm) { - Some(suggestions) => writeln!(output, ". Did you mean: '{}'?", suggestions.to_string()), + Some(suggestions) => writeln!(output, ". Did you mean: '{suggestions}'?"), None => writeln!(output), } } diff --git a/vm/src/format.rs b/vm/src/format.rs index 4351cd8ff..8affa8d2f 100644 --- a/vm/src/format.rs +++ b/vm/src/format.rs @@ -413,11 +413,7 @@ impl FormatSpec { }, }; - if raw_magnitude_string_result.is_err() { - return raw_magnitude_string_result; - } - - let magnitude_string = self.add_magnitude_separators(raw_magnitude_string_result.unwrap()); + let magnitude_string = self.add_magnitude_separators(raw_magnitude_string_result?); let format_sign = self.sign.unwrap_or(FormatSign::Minus); let sign_str = if num.is_sign_negative() && !num.is_nan() { "-" @@ -474,13 +470,10 @@ impl FormatSpec { }, None => Ok(magnitude.to_str_radix(10)), }; - if raw_magnitude_string_result.is_err() { - return raw_magnitude_string_result; - } let magnitude_string = format!( "{}{}", prefix, - self.add_magnitude_separators(raw_magnitude_string_result.unwrap()) + self.add_magnitude_separators(raw_magnitude_string_result?) ); let format_sign = self.sign.unwrap_or(FormatSign::Minus); diff --git a/vm/src/pyobjectrc.rs b/vm/src/pyobjectrc.rs index 4dd10ec04..ebd7bd5ba 100644 --- a/vm/src/pyobjectrc.rs +++ b/vm/src/pyobjectrc.rs @@ -307,6 +307,7 @@ pub struct PyWeak { cfg_if::cfg_if! { if #[cfg(feature = "threading")] { + #[allow(clippy::non_send_fields_in_send_ty)] // false positive? unsafe impl Send for PyWeak {} unsafe impl Sync for PyWeak {} } @@ -819,7 +820,7 @@ fn print_del_error(e: PyBaseExceptionRef, zelf: &PyObject, vm: &VirtualMachine) let del_method = zelf.get_class_attr("__del__").unwrap(); let repr = &del_method.repr(vm); match repr { - Ok(v) => println!("{}", v.to_string()), + Ok(v) => println!("{v}"), Err(_) => println!("{}", del_method.class().name()), } let tb_module = vm.import("traceback", None, 0).unwrap();