Skip to content

Commit

Permalink
Merge pull request #170 from compiler-errors/master
Browse files Browse the repository at this point in the history
Allow fully elaborated `::core::marker::Trait` supertraits
  • Loading branch information
dtolnay authored Jul 29, 2021
2 parents bf9099e + c0b0d5a commit 1db22bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ proc-macro = true
[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0.61", features = ["full", "visit-mut"] }
syn = { version = "1.0.61", features = ["full", "visit-mut", "extra-traits"] }

[dev-dependencies]
futures = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ fn positional_arg(i: usize, pat: &Pat) -> Ident {
fn has_bound(supertraits: &Supertraits, marker: &Ident) -> bool {
for bound in supertraits {
if let TypeParamBound::Trait(bound) = bound {
if bound.path.is_ident(marker) {
if bound.path.is_ident(marker) || bound.path == parse_quote!(::core::marker::#marker) {
return true;
}
}
Expand Down
13 changes: 13 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1363,3 +1363,16 @@ pub mod issue161 {
}
}
}

// https://github.com/dtolnay/async-trait/issues/169
#[deny(where_clauses_object_safety)]
pub mod issue169 {
use async_trait::async_trait;

#[async_trait]
pub trait Trait: ::core::marker::Sync {
async fn f(&self) {}
}

pub fn test(_t: &dyn Trait) {}
}

0 comments on commit 1db22bb

Please sign in to comment.