зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1773399 - Update async-trait to 0.1.56. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D148733
This commit is contained in:
Родитель
28b4e8e0af
Коммит
ce1f4f658c
|
@ -192,9 +192,9 @@ source = "git+https://github.com/smol-rs/async-task?rev=f6488e35beccb26eb6e85847
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.53"
|
version = "0.1.56"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600"
|
checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
|
@ -114,7 +114,7 @@ version = "0.12.2"
|
||||||
criteria = "safe-to-deploy"
|
criteria = "safe-to-deploy"
|
||||||
|
|
||||||
[[unaudited.async-trait]]
|
[[unaudited.async-trait]]
|
||||||
version = "0.1.53"
|
version = "0.1.56"
|
||||||
criteria = "safe-to-deploy"
|
criteria = "safe-to-deploy"
|
||||||
|
|
||||||
[[unaudited.atomic]]
|
[[unaudited.atomic]]
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"files":{"Cargo.toml":"76c6c7291c8f5b93835ca4f91959f1dd4f85b53316b8de38d46cb571284c88a0","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"b733a7cddbdc409fcd5fb8eff5fe1d5692b6d1e0364568366a69bb1dd68e232c","build.rs":"e2ca6b6c6f18d5d47cb662083856d1399946bc41a272b30231c31ae8317a3ed0","src/args.rs":"6eed5497db91752b3aae597943c39e769f60406b37055304e69e4699f1f87b15","src/expand.rs":"9d3e3c0b810ec679c6caaf5b8c03f36081ec3dea73e46847d83cade4a4c05a8e","src/lib.rs":"51cd49b85c0a7662ef32f30631f1f6a2ce448f18e951725b9d13227b5a596d3e","src/lifetime.rs":"4b94740e2847ef8df128a25d264f0a1bc1d1723ea107fc53849322b98f1e6927","src/parse.rs":"cd9032fe2c6dcf41050b3a59b9fb98eb9700a29bbe2fa011ee2854014c1666b7","src/receiver.rs":"31f5ff929bb6ac061ca3f44d4efac1ca0c60273d54ef8f8f92234a69829dc88d","tests/compiletest.rs":"0a52a44786aea1c299c695bf948b2ed2081e4cc344e5c2cadceab4eb03d0010d","tests/executor/mod.rs":"3cf48614288715f625514a73ae642f649c2635a402a3ad90278bbee116a7234c","tests/test.rs":"df12d6551ce0a8e3416f83fe92686ab2a22fb0a5dadb45499f531c8822c63c3e","tests/ui/bare-trait-object.rs":"4546e8bd6682de11920fa4c768295fed61954484ef0550dfadbc5677b77f29a5","tests/ui/bare-trait-object.stderr":"1978b5afb37c55092b96bb68293f06c924fe82f0a4149e6eda94bbe2c031ee0b","tests/ui/consider-restricting.rs":"bff794222d9324241155568d541e7beac0238b66ce14039b242d4392f4e531b6","tests/ui/consider-restricting.stderr":"a153c5c67905875e5e333ce2ffc7167c75fbe1f258ca985636a15e479821bd72","tests/ui/delimiter-span.rs":"97edf38c804d5e0d4cef6f040dee113d78ff76b08bf8c49586b803caa3ce7f40","tests/ui/delimiter-span.stderr":"0f70f0bda0e86a43e6d6f6980f1ef8a1989c3e32db593bd60f920025a25728d5","tests/ui/lifetime-span.rs":"bbcaa92c2bc08e18cf0c7e9ca1f0bd8080772ebde8b067d819eb2fd662e47b3b","tests/ui/lifetime-span.stderr":"429ef1b63a242b71a904e7a277bb66baf0c600c10eb3c792b380a24e2eca074f","tests/ui/missing-async-in-impl.rs":"5a5538d08d11c145211a92af0d8973eee8b21f33b90adda85430805bd3dbbc83","tests/ui/missing-async-in-impl.stderr":"2916bc8a51e25f4dd18eaf433b916d533943eac2c1afbee64e9a89e7b928040d","tests/ui/missing-async-in-trait.rs":"dc67241593f270233ba885df92e59164126416e68d49d8d62edc251666b5db6e","tests/ui/missing-async-in-trait.stderr":"67e66e7b19358830deff3ba01f5d701a9ae05c4e6fa9c081c49c1c75efbb7ade","tests/ui/missing-body.rs":"d06c0da8c6044e7c790b924136f167e2edc0d0d3fa01f23521f3f08ca605929b","tests/ui/missing-body.stderr":"e5ee994398bf8294324d61df02467a4229f68f4113bf5acc004851c03d66ec6a","tests/ui/must-use.rs":"75090c7df984df0996464337f60371d198bd0caf3f9f44b10d1e131f15fd4fca","tests/ui/must-use.stderr":"cd7bf2fe9023021837b2b3e8cc164ffc18900b01cf704c68cde91edd07d65dc8","tests/ui/self-span.rs":"67ddde05907d7014bfb3f2c63d427b1d72d6c4369a9108a4335dac6bee5832b2","tests/ui/self-span.stderr":"7865153d1e41ecdfa64b197901e3bda57bcda0c486bbcf11dc6e9837ceb40b29","tests/ui/send-not-implemented.rs":"affbbe8bc9c3501d3db3a024e06daa9d076f1d142dba290c7aa1ea119daebd19","tests/ui/send-not-implemented.stderr":"cbe2fefbb02dd9207fb6b459549d626dc51a1aff3ce105c212bc7c07a876ab1a","tests/ui/unreachable.rs":"be0aa7cc129fe42a1fbd85e36b3f08c6a2bd16c90ed2e33fc4c50e40ce085bcd","tests/ui/unreachable.stderr":"73beb71cb74076f2cb45485271de31658cf59f4143e62daa34b9f2a8980ddfcd","tests/ui/unsupported-self.rs":"f7855bc39dab1fd2f533fb2e873a27c3757dcb9fb57001e4b19f58d3dda36d01","tests/ui/unsupported-self.stderr":"64fc5d45cb51330f0a1e85e69a28b69ddda12a109aa6a8ba3eaee1ac58d93b5f"},"package":"ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600"}
|
{"files":{"Cargo.toml":"78762afb6df9d381d10d972ca84d600f5d9d8ee2431a3a95ad303ee3bff146e7","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"b733a7cddbdc409fcd5fb8eff5fe1d5692b6d1e0364568366a69bb1dd68e232c","build.rs":"b45aa3a5c177cbeaeb4847163088924491ac27b79534f8ea4c53ed3e10c163ea","src/args.rs":"6eed5497db91752b3aae597943c39e769f60406b37055304e69e4699f1f87b15","src/expand.rs":"735530826c7921bd8d4e29e181bd7d6fef4c53a385941fd9481ba4be642739ca","src/lib.rs":"51cd49b85c0a7662ef32f30631f1f6a2ce448f18e951725b9d13227b5a596d3e","src/lifetime.rs":"421f7f7bf8e3c132450472efd6af1fdc956cfb4b64723fc724730b292a0a1c2d","src/parse.rs":"cd9032fe2c6dcf41050b3a59b9fb98eb9700a29bbe2fa011ee2854014c1666b7","src/receiver.rs":"31f5ff929bb6ac061ca3f44d4efac1ca0c60273d54ef8f8f92234a69829dc88d","tests/compiletest.rs":"022a8e400ef813d7ea1875b944549cee5125f6a995dc33e93b48cba3e1b57bd1","tests/executor/mod.rs":"3cf48614288715f625514a73ae642f649c2635a402a3ad90278bbee116a7234c","tests/test.rs":"266a88f2e09759ea731d1229b1bb4fe4952de546f81859d3d5c237be2c9a5398","tests/ui/arg-implementation-detail.rs":"7199aba887dd0a8a14c86ec16542a73a70244930f8202940f43e40a62f72d200","tests/ui/arg-implementation-detail.stderr":"c3ff1a2a9a9ca4368cb8719e2a035a6d2d45b367212bec2b1fe2712fcfbbbe5d","tests/ui/bare-trait-object.rs":"4546e8bd6682de11920fa4c768295fed61954484ef0550dfadbc5677b77f29a5","tests/ui/bare-trait-object.stderr":"1978b5afb37c55092b96bb68293f06c924fe82f0a4149e6eda94bbe2c031ee0b","tests/ui/consider-restricting.rs":"bff794222d9324241155568d541e7beac0238b66ce14039b242d4392f4e531b6","tests/ui/consider-restricting.stderr":"a153c5c67905875e5e333ce2ffc7167c75fbe1f258ca985636a15e479821bd72","tests/ui/delimiter-span.rs":"f4fd804223ce3be0d4eecdfd222afdd835c5393e2473ff4932116163943c0bc9","tests/ui/delimiter-span.stderr":"1782391f126f52ba30082ad744f9af090d522b03ceb944f5c0430b6220f429ae","tests/ui/lifetime-span.rs":"bbcaa92c2bc08e18cf0c7e9ca1f0bd8080772ebde8b067d819eb2fd662e47b3b","tests/ui/lifetime-span.stderr":"116cc29fd46134b3ede856292fa64d27b7fce8620ce1d3266576b8ebab4adb0a","tests/ui/missing-async-in-impl.rs":"5a5538d08d11c145211a92af0d8973eee8b21f33b90adda85430805bd3dbbc83","tests/ui/missing-async-in-impl.stderr":"2916bc8a51e25f4dd18eaf433b916d533943eac2c1afbee64e9a89e7b928040d","tests/ui/missing-async-in-trait.rs":"dc67241593f270233ba885df92e59164126416e68d49d8d62edc251666b5db6e","tests/ui/missing-async-in-trait.stderr":"67e66e7b19358830deff3ba01f5d701a9ae05c4e6fa9c081c49c1c75efbb7ade","tests/ui/missing-body.rs":"d06c0da8c6044e7c790b924136f167e2edc0d0d3fa01f23521f3f08ca605929b","tests/ui/missing-body.stderr":"e5ee994398bf8294324d61df02467a4229f68f4113bf5acc004851c03d66ec6a","tests/ui/must-use.rs":"75090c7df984df0996464337f60371d198bd0caf3f9f44b10d1e131f15fd4fca","tests/ui/must-use.stderr":"cd7bf2fe9023021837b2b3e8cc164ffc18900b01cf704c68cde91edd07d65dc8","tests/ui/self-span.rs":"67ddde05907d7014bfb3f2c63d427b1d72d6c4369a9108a4335dac6bee5832b2","tests/ui/self-span.stderr":"7865153d1e41ecdfa64b197901e3bda57bcda0c486bbcf11dc6e9837ceb40b29","tests/ui/send-not-implemented.rs":"affbbe8bc9c3501d3db3a024e06daa9d076f1d142dba290c7aa1ea119daebd19","tests/ui/send-not-implemented.stderr":"34bb96360487a4ee8ceb29d04d2bb70e674cb2ab57f3916a6fb9b63c108bb6c3","tests/ui/unreachable.rs":"be0aa7cc129fe42a1fbd85e36b3f08c6a2bd16c90ed2e33fc4c50e40ce085bcd","tests/ui/unreachable.stderr":"73beb71cb74076f2cb45485271de31658cf59f4143e62daa34b9f2a8980ddfcd","tests/ui/unsupported-self.rs":"f7855bc39dab1fd2f533fb2e873a27c3757dcb9fb57001e4b19f58d3dda36d01","tests/ui/unsupported-self.stderr":"64fc5d45cb51330f0a1e85e69a28b69ddda12a109aa6a8ba3eaee1ac58d93b5f"},"package":"96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716"}
|
|
@ -13,7 +13,7 @@
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
rust-version = "1.39"
|
rust-version = "1.39"
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.53"
|
version = "0.1.56"
|
||||||
authors = ["David Tolnay <dtolnay@gmail.com>"]
|
authors = ["David Tolnay <dtolnay@gmail.com>"]
|
||||||
description = "Type erasure for async trait methods"
|
description = "Type erasure for async trait methods"
|
||||||
documentation = "https://docs.rs/async-trait"
|
documentation = "https://docs.rs/async-trait"
|
||||||
|
@ -35,7 +35,7 @@ version = "1.0"
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
|
||||||
[dependencies.syn]
|
[dependencies.syn]
|
||||||
version = "1.0.84"
|
version = "1.0.96"
|
||||||
features = [
|
features = [
|
||||||
"full",
|
"full",
|
||||||
"visit-mut",
|
"visit-mut",
|
||||||
|
|
|
@ -8,6 +8,10 @@ fn main() {
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if compiler < 45 {
|
||||||
|
println!("cargo:rustc-cfg=no_span_mixed_site");
|
||||||
|
}
|
||||||
|
|
||||||
if compiler < 47 {
|
if compiler < 47 {
|
||||||
println!("cargo:rustc-cfg=self_span_hack");
|
println!("cargo:rustc-cfg=self_span_hack");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::lifetime::CollectLifetimes;
|
use crate::lifetime::{AddLifetimeToImplTrait, CollectLifetimes};
|
||||||
use crate::parse::Item;
|
use crate::parse::Item;
|
||||||
use crate::receiver::{has_self_in_block, has_self_in_sig, mut_pat, ReplaceSelf};
|
use crate::receiver::{has_self_in_block, has_self_in_sig, mut_pat, ReplaceSelf};
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::{Span, TokenStream};
|
||||||
use quote::{format_ident, quote, quote_spanned, ToTokens};
|
use quote::{format_ident, quote, quote_spanned, ToTokens};
|
||||||
use std::collections::BTreeSet as Set;
|
use std::collections::BTreeSet as Set;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -283,6 +283,7 @@ fn transform_sig(
|
||||||
let m = mut_pat(&mut arg.pat);
|
let m = mut_pat(&mut arg.pat);
|
||||||
arg.pat = parse_quote!(#m #positional);
|
arg.pat = parse_quote!(#m #positional);
|
||||||
}
|
}
|
||||||
|
AddLifetimeToImplTrait.visit_type_mut(&mut arg.ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,7 +355,11 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) {
|
||||||
} else {
|
} else {
|
||||||
let pat = &arg.pat;
|
let pat = &arg.pat;
|
||||||
let ident = positional_arg(i, pat);
|
let ident = positional_arg(i, pat);
|
||||||
quote!(let #pat = #ident;)
|
if let Pat::Wild(_) = **pat {
|
||||||
|
quote!(let #ident = #ident;)
|
||||||
|
} else {
|
||||||
|
quote!(let #pat = #ident;)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -398,8 +403,10 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn positional_arg(i: usize, pat: &Pat) -> Ident {
|
fn positional_arg(i: usize, pat: &Pat) -> Ident {
|
||||||
use syn::spanned::Spanned;
|
let span: Span = syn::spanned::Spanned::span(pat);
|
||||||
format_ident!("__arg{}", i, span = pat.span())
|
#[cfg(not(no_span_mixed_site))]
|
||||||
|
let span = span.resolved_at(Span::mixed_site());
|
||||||
|
format_ident!("__arg{}", i, span = span)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_bound(supertraits: &Supertraits, marker: &Ident) -> bool {
|
fn has_bound(supertraits: &Supertraits, marker: &Ident) -> bool {
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
use proc_macro2::Span;
|
use proc_macro2::{Span, TokenStream};
|
||||||
|
use std::mem;
|
||||||
use syn::visit_mut::{self, VisitMut};
|
use syn::visit_mut::{self, VisitMut};
|
||||||
use syn::{GenericArgument, Lifetime, Receiver, TypeReference};
|
use syn::{
|
||||||
|
parse_quote_spanned, token, Expr, GenericArgument, Lifetime, Receiver, ReturnType, Type,
|
||||||
|
TypeBareFn, TypeImplTrait, TypeParen, TypePtr, TypeReference,
|
||||||
|
};
|
||||||
|
|
||||||
pub struct CollectLifetimes {
|
pub struct CollectLifetimes {
|
||||||
pub elided: Vec<Lifetime>,
|
pub elided: Vec<Lifetime>,
|
||||||
|
@ -62,3 +66,50 @@ impl VisitMut for CollectLifetimes {
|
||||||
visit_mut::visit_generic_argument_mut(self, gen);
|
visit_mut::visit_generic_argument_mut(self, gen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct AddLifetimeToImplTrait;
|
||||||
|
|
||||||
|
impl VisitMut for AddLifetimeToImplTrait {
|
||||||
|
fn visit_type_impl_trait_mut(&mut self, ty: &mut TypeImplTrait) {
|
||||||
|
let span = ty.impl_token.span;
|
||||||
|
let lifetime = parse_quote_spanned!(span=> 'async_trait);
|
||||||
|
ty.bounds.insert(0, lifetime);
|
||||||
|
if let Some(punct) = ty.bounds.pairs_mut().next().unwrap().punct_mut() {
|
||||||
|
punct.span = span;
|
||||||
|
}
|
||||||
|
visit_mut::visit_type_impl_trait_mut(self, ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_type_reference_mut(&mut self, ty: &mut TypeReference) {
|
||||||
|
parenthesize_impl_trait(&mut ty.elem, ty.and_token.span);
|
||||||
|
visit_mut::visit_type_reference_mut(self, ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_type_ptr_mut(&mut self, ty: &mut TypePtr) {
|
||||||
|
parenthesize_impl_trait(&mut ty.elem, ty.star_token.span);
|
||||||
|
visit_mut::visit_type_ptr_mut(self, ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_type_bare_fn_mut(&mut self, ty: &mut TypeBareFn) {
|
||||||
|
if let ReturnType::Type(arrow, return_type) = &mut ty.output {
|
||||||
|
parenthesize_impl_trait(return_type, arrow.spans[0]);
|
||||||
|
}
|
||||||
|
visit_mut::visit_type_bare_fn_mut(self, ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_expr_mut(&mut self, _e: &mut Expr) {
|
||||||
|
// Do not recurse into impl Traits inside of an array length expression.
|
||||||
|
//
|
||||||
|
// fn outer(arg: [u8; { fn inner(_: impl Trait) {}; 0 }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parenthesize_impl_trait(elem: &mut Type, paren_span: Span) {
|
||||||
|
if let Type::ImplTrait(_) = *elem {
|
||||||
|
let placeholder = Type::Verbatim(TokenStream::new());
|
||||||
|
*elem = Type::Paren(TypeParen {
|
||||||
|
paren_token: token::Paren(paren_span),
|
||||||
|
elem: Box::new(mem::replace(elem, placeholder)),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#[rustversion::attr(not(nightly), ignore)]
|
#[rustversion::attr(not(nightly), ignore)]
|
||||||
|
#[cfg_attr(miri, ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
fn ui() {
|
fn ui() {
|
||||||
let t = trybuild::TestCases::new();
|
let t = trybuild::TestCases::new();
|
||||||
|
|
|
@ -1038,9 +1038,9 @@ pub mod issue106 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<P: ?Sized> ProcessPool for &P
|
impl<P> ProcessPool for &P
|
||||||
where
|
where
|
||||||
P: ProcessPool,
|
P: ?Sized + ProcessPool,
|
||||||
{
|
{
|
||||||
type ThreadPool = P::ThreadPool;
|
type ThreadPool = P::ThreadPool;
|
||||||
|
|
||||||
|
@ -1056,8 +1056,6 @@ pub mod issue106 {
|
||||||
|
|
||||||
// https://github.com/dtolnay/async-trait/issues/110
|
// https://github.com/dtolnay/async-trait/issues/110
|
||||||
pub mod issue110 {
|
pub mod issue110 {
|
||||||
#![deny(clippy::all)]
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
@ -1113,8 +1111,6 @@ pub mod issue123 {
|
||||||
|
|
||||||
// https://github.com/dtolnay/async-trait/issues/129
|
// https://github.com/dtolnay/async-trait/issues/129
|
||||||
pub mod issue129 {
|
pub mod issue129 {
|
||||||
#![deny(clippy::pedantic)]
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
@ -1378,6 +1374,23 @@ pub mod issue169 {
|
||||||
pub fn test(_t: &dyn Trait) {}
|
pub fn test(_t: &dyn Trait) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/dtolnay/async-trait/issues/177
|
||||||
|
pub mod issue177 {
|
||||||
|
use async_trait::async_trait;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
pub trait Trait {
|
||||||
|
async fn foo(&self, _callback: impl FnMut(&str) + Send) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Struct;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl Trait for Struct {
|
||||||
|
async fn foo(&self, _callback: impl FnMut(&str) + Send) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/dtolnay/async-trait/issues/183
|
// https://github.com/dtolnay/async-trait/issues/183
|
||||||
pub mod issue183 {
|
pub mod issue183 {
|
||||||
#![deny(clippy::shadow_same)]
|
#![deny(clippy::shadow_same)]
|
||||||
|
@ -1389,3 +1402,51 @@ pub mod issue183 {
|
||||||
async fn foo(_n: i32) {}
|
async fn foo(_n: i32) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/dtolnay/async-trait/issues/199
|
||||||
|
pub mod issue199 {
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use std::cell::Cell;
|
||||||
|
|
||||||
|
struct IncrementOnDrop<'a>(&'a Cell<usize>);
|
||||||
|
|
||||||
|
impl<'a> Drop for IncrementOnDrop<'a> {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
self.0.set(self.0.get() + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait(?Send)]
|
||||||
|
trait Trait {
|
||||||
|
async fn f(counter: &Cell<usize>, arg: IncrementOnDrop<'_>);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Struct;
|
||||||
|
|
||||||
|
#[async_trait(?Send)]
|
||||||
|
impl Trait for Struct {
|
||||||
|
async fn f(counter: &Cell<usize>, _: IncrementOnDrop<'_>) {
|
||||||
|
assert_eq!(counter.get(), 0); // second arg not dropped yet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test() {
|
||||||
|
let counter = Cell::new(0);
|
||||||
|
let future = Struct::f(&counter, IncrementOnDrop(&counter));
|
||||||
|
assert_eq!(counter.get(), 0);
|
||||||
|
drop(future);
|
||||||
|
assert_eq!(counter.get(), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/dtolnay/async-trait/issues/204
|
||||||
|
pub mod issue204 {
|
||||||
|
use async_trait::async_trait;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
pub trait Trait {
|
||||||
|
async fn f(arg: &impl Trait);
|
||||||
|
async fn g(arg: *const impl Trait);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
use async_trait::async_trait;
|
||||||
|
|
||||||
|
pub struct Struct;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
pub trait Trait {
|
||||||
|
async fn f((_a, _b): (Struct, Struct)) {
|
||||||
|
// Expands to something like:
|
||||||
|
//
|
||||||
|
// fn f(__arg0: (Struct, Struct)) -> … {
|
||||||
|
// Box::pin(async move {
|
||||||
|
// let (_a, _b) = __arg0;
|
||||||
|
// …
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// but user's code must not be allowed to name that temporary argument:
|
||||||
|
let _ = __arg0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,5 @@
|
||||||
|
error[E0425]: cannot find value `__arg0` in this scope
|
||||||
|
--> tests/ui/arg-implementation-detail.rs:18:17
|
||||||
|
|
|
||||||
|
18 | let _ = __arg0;
|
||||||
|
| ^^^^^^ not found in this scope
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(unused_macro_rules)]
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
||||||
macro_rules! picky {
|
macro_rules! picky {
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
error: no rules expected the token `{`
|
error: no rules expected the token `{`
|
||||||
--> tests/ui/delimiter-span.rs:17:16
|
--> tests/ui/delimiter-span.rs:19:16
|
||||||
|
|
|
|
||||||
3 | macro_rules! picky {
|
5 | macro_rules! picky {
|
||||||
| ------------------ when calling this macro
|
| ------------------ when calling this macro
|
||||||
...
|
...
|
||||||
17 | picky!({ 123, self });
|
19 | picky!({ 123, self });
|
||||||
| ^ no rules expected this token in macro call
|
| ^ no rules expected this token in macro call
|
||||||
|
|
||||||
error: no rules expected the token `{`
|
error: no rules expected the token `{`
|
||||||
--> tests/ui/delimiter-span.rs:18:16
|
--> tests/ui/delimiter-span.rs:20:16
|
||||||
|
|
|
|
||||||
3 | macro_rules! picky {
|
5 | macro_rules! picky {
|
||||||
| ------------------ when calling this macro
|
| ------------------ when calling this macro
|
||||||
...
|
...
|
||||||
18 | picky!({ 123 });
|
20 | picky!({ 123 });
|
||||||
| ^ no rules expected this token in macro call
|
| ^ no rules expected this token in macro call
|
||||||
|
|
|
@ -2,9 +2,13 @@ error[E0726]: implicit elided lifetime not allowed here
|
||||||
--> tests/ui/lifetime-span.rs:12:6
|
--> tests/ui/lifetime-span.rs:12:6
|
||||||
|
|
|
|
||||||
12 | impl Trait for A {
|
12 | impl Trait for A {
|
||||||
| ^^^^^- help: indicate the anonymous lifetime: `<'_>`
|
| ^^^^^ expected lifetime parameter
|
||||||
|
|
|
|
||||||
= note: assuming a `'static` lifetime...
|
= note: assuming a `'static` lifetime...
|
||||||
|
help: indicate the anonymous lifetime
|
||||||
|
|
|
||||||
|
12 | impl Trait<'_> for A {
|
||||||
|
| ++++
|
||||||
|
|
||||||
error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
|
error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
|
||||||
--> tests/ui/lifetime-span.rs:32:10
|
--> tests/ui/lifetime-span.rs:32:10
|
||||||
|
|
|
@ -9,7 +9,7 @@ error: future cannot be sent between threads safely
|
||||||
12 | | }
|
12 | | }
|
||||||
| |_____^ future created by async block is not `Send`
|
| |_____^ future created by async block is not `Send`
|
||||||
|
|
|
|
||||||
= help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
|
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
|
||||||
note: future is not `Send` as this value is used across an await
|
note: future is not `Send` as this value is used across an await
|
||||||
--> tests/ui/send-not-implemented.rs:11:12
|
--> tests/ui/send-not-implemented.rs:11:12
|
||||||
|
|
|
|
||||||
|
@ -33,7 +33,7 @@ error: future cannot be sent between threads safely
|
||||||
19 | | }
|
19 | | }
|
||||||
| |_____^ future created by async block is not `Send`
|
| |_____^ future created by async block is not `Send`
|
||||||
|
|
|
|
||||||
= help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
|
= help: within `impl Future<Output = bool>`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
|
||||||
note: future is not `Send` as this value is used across an await
|
note: future is not `Send` as this value is used across an await
|
||||||
--> tests/ui/send-not-implemented.rs:17:12
|
--> tests/ui/send-not-implemented.rs:17:12
|
||||||
|
|
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче