Skip to content

Commit

Permalink
Merge pull request 123 from tyranron/remove-defaults-from-typarams-in…
Browse files Browse the repository at this point in the history
…-traits
  • Loading branch information
dtolnay committed Aug 28, 2020
2 parents 7e82be9 + eace8dd commit 6d67b02
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ fn transform_block(
};

let mut outer_generics = generics.clone();
for p in &mut outer_generics.params {
match p {
GenericParam::Type(t) => {
let _ = t.default.take();
}
GenericParam::Const(c) => {
let _ = c.default.take();
}
GenericParam::Lifetime(_) => {}
}
}
if !has_self {
if let Some(mut where_clause) = outer_generics.where_clause {
where_clause.predicates = where_clause
Expand Down
26 changes: 22 additions & 4 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ pub mod issue92 {
}

// https://github.com/dtolnay/async-trait/issues/104
mod issue104 {
pub mod issue104 {
use async_trait::async_trait;

#[async_trait]
Expand All @@ -909,7 +909,7 @@ mod issue104 {
}

// https://github.com/dtolnay/async-trait/issues/106
mod issue106 {
pub mod issue106 {
use async_trait::async_trait;
use std::future::Future;

Expand Down Expand Up @@ -941,7 +941,7 @@ mod issue106 {
}

// https://github.com/dtolnay/async-trait/issues/110
mod issue110 {
pub mod issue110 {
#![deny(clippy::all)]

use async_trait::async_trait;
Expand All @@ -963,7 +963,7 @@ mod issue110 {
}

// https://github.com/dtolnay/async-trait/issues/120
mod issue120 {
pub mod issue120 {
#![deny(clippy::trivially_copy_pass_by_ref)]

use async_trait::async_trait;
Expand All @@ -978,3 +978,21 @@ mod issue120 {
async fn f(&self) {}
}
}

// https://github.com/dtolnay/async-trait/issues/123
pub mod issue123 {
use async_trait::async_trait;

#[async_trait]
trait Trait<T = ()> {
async fn f(&self) -> &str
where
T: 'async_trait,
{
"default"
}
}

#[async_trait]
impl<T> Trait<T> for () {}
}

0 comments on commit 6d67b02

Please sign in to comment.