Skip to content

Commit

Permalink
Update to Rust v1.83 (#4293)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda authored Nov 28, 2024
1 parent 085f912 commit 69a626c
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 37 deletions.
4 changes: 2 additions & 2 deletions crates/backend/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ struct DescribeImport<'a> {
wasm_bindgen: &'a syn::Path,
}

impl<'a> ToTokens for DescribeImport<'a> {
impl ToTokens for DescribeImport<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let f = match *self.kind {
ast::ImportKind::Function(ref f) => f,
Expand Down Expand Up @@ -1838,7 +1838,7 @@ struct Descriptor<'a, T> {
wasm_bindgen: &'a syn::Path,
}

impl<'a, T: ToTokens> ToTokens for Descriptor<'a, T> {
impl<T: ToTokens> ToTokens for Descriptor<'_, T> {
fn to_tokens(&self, tokens: &mut TokenStream) {
// It's possible for the same descriptor to be emitted in two different
// modules (aka a value imported twice in a crate, each in a separate
Expand Down
6 changes: 3 additions & 3 deletions crates/backend/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ enum LitOrExpr<'a> {
Lit(&'a str),
}

impl<'a> Encode for LitOrExpr<'a> {
impl Encode for LitOrExpr<'_> {
fn encode(&self, dst: &mut Encoder) {
match self {
LitOrExpr::Expr(expr) => {
Expand Down Expand Up @@ -468,14 +468,14 @@ impl Encode for usize {
}
}

impl<'a> Encode for &'a [u8] {
impl Encode for &[u8] {
fn encode(&self, dst: &mut Encoder) {
self.len().encode(dst);
dst.extend_from_slice(self);
}
}

impl<'a> Encode for &'a str {
impl Encode for &str {
fn encode(&self, dst: &mut Encoder) {
self.as_bytes().encode(dst);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cli-support/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn get(b: &mut &[u8]) -> u8 {
r
}

impl<'src> Deref for LitOrExpr<'src> {
impl Deref for LitOrExpr<'_> {
type Target = str;
fn deref(&self) -> &Self::Target {
self.str
Expand Down
2 changes: 1 addition & 1 deletion crates/cli-support/src/descriptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl WasmBindgenDescriptorsSection {
found: bool,
}

impl<'a> Visitor<'a> for FindDescribeClosure {
impl Visitor<'_> for FindDescribeClosure {
fn visit_call(&mut self, call: &Call) {
if call.func == self.wbindgen_describe_closure {
self.found = true;
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ impl<'a> BackgroundChild<'a> {
}
}

impl<'a> Drop for BackgroundChild<'a> {
impl Drop for BackgroundChild<'_> {
fn drop(&mut self) {
self.child.kill().unwrap();
let status = self.child.wait().unwrap();
Expand Down
10 changes: 5 additions & 5 deletions crates/js-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ pub struct ArrayIter<'a> {
array: &'a Array,
}

impl<'a> core::iter::Iterator for ArrayIter<'a> {
impl core::iter::Iterator for ArrayIter<'_> {
type Item = JsValue;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -743,7 +743,7 @@ impl<'a> core::iter::Iterator for ArrayIter<'a> {
}
}

impl<'a> core::iter::DoubleEndedIterator for ArrayIter<'a> {
impl core::iter::DoubleEndedIterator for ArrayIter<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
let index = self.range.next_back()?;
Some(self.array.get(index))
Expand All @@ -754,9 +754,9 @@ impl<'a> core::iter::DoubleEndedIterator for ArrayIter<'a> {
}
}

impl<'a> core::iter::FusedIterator for ArrayIter<'a> {}
impl core::iter::FusedIterator for ArrayIter<'_> {}

impl<'a> core::iter::ExactSizeIterator for ArrayIter<'a> {}
impl core::iter::ExactSizeIterator for ArrayIter<'_> {}

impl Array {
/// Returns an iterator over the values of the JS array.
Expand Down Expand Up @@ -2311,7 +2311,7 @@ impl<'a> IntoIterator for &'a Iterator {
}
}

impl<'a> core::iter::Iterator for Iter<'a> {
impl core::iter::Iterator for Iter<'_> {
type Item = Result<JsValue, JsValue>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
6 changes: 3 additions & 3 deletions crates/macro-support/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ trait ConvertToAst<Ctx> {
fn convert(self, context: Ctx) -> Result<Self::Target, Diagnostic>;
}

impl<'a> ConvertToAst<(&ast::Program, BindgenAttrs)> for &'a mut syn::ItemStruct {
impl ConvertToAst<(&ast::Program, BindgenAttrs)> for &mut syn::ItemStruct {
type Target = ast::Struct;

fn convert(
Expand Down Expand Up @@ -1188,7 +1188,7 @@ impl<'a> MacroParse<(Option<BindgenAttrs>, &'a mut TokenStream)> for syn::Item {
}
}

impl<'a> MacroParse<BindgenAttrs> for &'a mut syn::ItemImpl {
impl MacroParse<BindgenAttrs> for &mut syn::ItemImpl {
fn macro_parse(self, program: &mut ast::Program, opts: BindgenAttrs) -> Result<(), Diagnostic> {
if self.defaultness.is_some() {
bail_span!(
Expand Down Expand Up @@ -1292,7 +1292,7 @@ fn prepare_for_impl_recursion(
Ok(())
}

impl<'a> MacroParse<&ClassMarker> for &'a mut syn::ImplItemFn {
impl MacroParse<&ClassMarker> for &mut syn::ImplItemFn {
fn macro_parse(
self,
program: &mut ast::Program,
Expand Down
2 changes: 1 addition & 1 deletion crates/webidl/src/idl_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ impl<'a> IdlType<'a> {
}
}

impl<'a> IdentifierType<'a> {
impl IdentifierType<'_> {
/// Converts to syn type if possible.
pub(crate) fn to_syn_type(
&self,
Expand Down
4 changes: 2 additions & 2 deletions src/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ where
}

// `Closure` can only be passed by reference to imports.
impl<'a, T> IntoWasmAbi for &'a Closure<T>
impl<T> IntoWasmAbi for &Closure<T>
where
T: WasmClosure + ?Sized,
{
Expand All @@ -482,7 +482,7 @@ where
}
}

impl<'a, T> OptionIntoWasmAbi for &'a Closure<T>
impl<T> OptionIntoWasmAbi for &Closure<T>
where
T: WasmClosure + ?Sized,
{
Expand Down
8 changes: 4 additions & 4 deletions src/convert/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ stack_closures! {
(8 invoke8 invoke8_mut A a1 a2 a3 a4 B b1 b2 b3 b4 C c1 c2 c3 c4 D d1 d2 d3 d4 E e1 e2 e3 e4 F f1 f2 f3 f4 G g1 g2 g3 g4 H h1 h2 h3 h4)
}

impl<'a, 'b, A, R> IntoWasmAbi for &'a (dyn Fn(&A) -> R + 'b)
impl<A, R> IntoWasmAbi for &(dyn Fn(&A) -> R + '_)
where
A: RefFromWasmAbi,
R: ReturnWasmAbi,
Expand Down Expand Up @@ -175,7 +175,7 @@ unsafe extern "C" fn invoke1_ref<A: RefFromWasmAbi, R: ReturnWasmAbi>(
ret.return_abi().into()
}

impl<'a, A, R> WasmDescribe for dyn Fn(&A) -> R + 'a
impl<A, R> WasmDescribe for dyn Fn(&A) -> R + '_
where
A: RefFromWasmAbi,
R: ReturnWasmAbi,
Expand All @@ -191,7 +191,7 @@ where
}
}

impl<'a, 'b, A, R> IntoWasmAbi for &'a mut (dyn FnMut(&A) -> R + 'b)
impl<A, R> IntoWasmAbi for &mut (dyn FnMut(&A) -> R + '_)
where
A: RefFromWasmAbi,
R: ReturnWasmAbi,
Expand Down Expand Up @@ -232,7 +232,7 @@ unsafe extern "C" fn invoke1_mut_ref<A: RefFromWasmAbi, R: ReturnWasmAbi>(
ret.return_abi().into()
}

impl<'a, A, R> WasmDescribe for dyn FnMut(&A) -> R + 'a
impl<A, R> WasmDescribe for dyn FnMut(&A) -> R + '_
where
A: RefFromWasmAbi,
R: ReturnWasmAbi,
Expand Down
2 changes: 1 addition & 1 deletion src/convert/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl FromWasmAbi for JsValue {
}
}

impl<'a> IntoWasmAbi for &'a JsValue {
impl IntoWasmAbi for &JsValue {
type Abi = u32;

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/convert/slices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl<'a> IntoWasmAbi for &'a str {
}
}

impl<'a> OptionIntoWasmAbi for &'a str {
impl OptionIntoWasmAbi for &str {
#[inline]
fn none() -> Self::Abi {
null_slice()
Expand Down
4 changes: 2 additions & 2 deletions src/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ impl<T: WasmDescribe> WasmDescribe for [T] {
}
}

impl<'a, T: WasmDescribe + ?Sized> WasmDescribe for &'a T {
impl<T: WasmDescribe + ?Sized> WasmDescribe for &T {
#[cfg_attr(wasm_bindgen_unstable_test_coverage, coverage(off))]
fn describe() {
inform(REF);
T::describe();
}
}

impl<'a, T: WasmDescribe + ?Sized> WasmDescribe for &'a mut T {
impl<T: WasmDescribe + ?Sized> WasmDescribe for &mut T {
#[cfg_attr(wasm_bindgen_unstable_test_coverage, coverage(off))]
fn describe() {
inform(REFMUT);
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ pub mod __rt {
borrow: &'b Cell<usize>,
}

impl<'b, T: ?Sized> Deref for Ref<'b, T> {
impl<T: ?Sized> Deref for Ref<'_, T> {
type Target = T;

#[inline]
Expand All @@ -1742,14 +1742,14 @@ pub mod __rt {
}
}

impl<'b, T: ?Sized> Borrow<T> for Ref<'b, T> {
impl<T: ?Sized> Borrow<T> for Ref<'_, T> {
#[inline]
fn borrow(&self) -> &T {
self.value
}
}

impl<'b, T: ?Sized> Drop for Ref<'b, T> {
impl<T: ?Sized> Drop for Ref<'_, T> {
fn drop(&mut self) {
self.borrow.set(self.borrow.get() - 1);
}
Expand All @@ -1760,7 +1760,7 @@ pub mod __rt {
borrow: &'b Cell<usize>,
}

impl<'b, T: ?Sized> Deref for RefMut<'b, T> {
impl<T: ?Sized> Deref for RefMut<'_, T> {
type Target = T;

#[inline]
Expand All @@ -1769,28 +1769,28 @@ pub mod __rt {
}
}

impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> {
impl<T: ?Sized> DerefMut for RefMut<'_, T> {
#[inline]
fn deref_mut(&mut self) -> &mut T {
self.value
}
}

impl<'b, T: ?Sized> Borrow<T> for RefMut<'b, T> {
impl<T: ?Sized> Borrow<T> for RefMut<'_, T> {
#[inline]
fn borrow(&self) -> &T {
self.value
}
}

impl<'b, T: ?Sized> BorrowMut<T> for RefMut<'b, T> {
impl<T: ?Sized> BorrowMut<T> for RefMut<'_, T> {
#[inline]
fn borrow_mut(&mut self) -> &mut T {
self.value
}
}

impl<'b, T: ?Sized> Drop for RefMut<'b, T> {
impl<T: ?Sized> Drop for RefMut<'_, T> {
fn drop(&mut self) {
self.borrow.set(0);
}
Expand Down
1 change: 1 addition & 0 deletions tests/wasm/import_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ extern "C" {
/// dox
pub fn foo();

/// dox
pub type Options;
#[wasm_bindgen(constructor)]
fn new() -> Options;
Expand Down
2 changes: 1 addition & 1 deletion tests/wasm/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct ResetOnDrop<'a> {
flag: &'a mut bool,
}

impl<'a> Drop for ResetOnDrop<'a> {
impl Drop for ResetOnDrop<'_> {
fn drop(&mut self) {
*self.flag = false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wasm/result_jserror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct ResetOnDrop<'a> {
flag: &'a mut bool,
}

impl<'a> Drop for ResetOnDrop<'a> {
impl Drop for ResetOnDrop<'_> {
fn drop(&mut self) {
*self.flag = false;
}
Expand Down

0 comments on commit 69a626c

Please sign in to comment.