Fix #[derive(Default)]
on a generic #[default]
enum adding unnecessary Default
bounds
This commit is contained in:
parent
5b4bd154de
commit
cb86c38cdb
12 changed files with 35 additions and 1 deletions
|
@ -172,6 +172,7 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
|||
use rustc_span::Span;
|
||||
use std::cell::RefCell;
|
||||
use std::iter;
|
||||
use std::ops::Not;
|
||||
use std::vec;
|
||||
use thin_vec::thin_vec;
|
||||
use ty::{Bounds, Path, Ref, Self_, Ty};
|
||||
|
@ -185,6 +186,9 @@ pub struct TraitDef<'a> {
|
|||
/// Path of the trait, including any type parameters
|
||||
pub path: Path,
|
||||
|
||||
/// Whether to skip adding the current trait as a bound to the type parameters of the type.
|
||||
pub skip_path_as_bound: bool,
|
||||
|
||||
/// Additional bounds required of any type parameters of the type,
|
||||
/// other than the current trait
|
||||
pub additional_bounds: Vec<Ty>,
|
||||
|
@ -594,7 +598,7 @@ impl<'a> TraitDef<'a> {
|
|||
cx.trait_bound(p.to_path(cx, self.span, type_ident, generics))
|
||||
}).chain(
|
||||
// require the current trait
|
||||
iter::once(cx.trait_bound(trait_path.clone()))
|
||||
self.skip_path_as_bound.not().then(|| cx.trait_bound(trait_path.clone()))
|
||||
).chain(
|
||||
// also add in any bounds from the declaration
|
||||
param.bounds.iter().cloned()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue