Allow attributes in generics of impl
This commit is contained in:
parent
8ac3fc36cc
commit
4402412b78
4 changed files with 22 additions and 2 deletions
|
@ -1512,12 +1512,16 @@ fn span_for_return(ret: &ast::FunctionRetTy) -> Span {
|
||||||
|
|
||||||
fn span_for_ty_param(ty: &ast::TyParam) -> Span {
|
fn span_for_ty_param(ty: &ast::TyParam) -> Span {
|
||||||
// Note that ty.span is the span for ty.ident, not the whole item.
|
// Note that ty.span is the span for ty.ident, not the whole item.
|
||||||
let lo = ty.span.lo;
|
let lo = if ty.attrs.is_empty() {
|
||||||
|
ty.span.lo
|
||||||
|
} else {
|
||||||
|
ty.attrs[0].span.lo
|
||||||
|
};
|
||||||
if let Some(ref def) = ty.default {
|
if let Some(ref def) = ty.default {
|
||||||
return mk_sp(lo, def.span.hi);
|
return mk_sp(lo, def.span.hi);
|
||||||
}
|
}
|
||||||
if ty.bounds.is_empty() {
|
if ty.bounds.is_empty() {
|
||||||
return ty.span;
|
return mk_sp(lo, ty.span.hi);
|
||||||
}
|
}
|
||||||
let hi = match ty.bounds[ty.bounds.len() - 1] {
|
let hi = match ty.bounds[ty.bounds.len() - 1] {
|
||||||
ast::TyParamBound::TraitTyParamBound(ref ptr, _) => ptr.span.hi,
|
ast::TyParamBound::TraitTyParamBound(ref ptr, _) => ptr.span.hi,
|
||||||
|
|
|
@ -509,6 +509,12 @@ impl Rewrite for ast::TyParamBounds {
|
||||||
impl Rewrite for ast::TyParam {
|
impl Rewrite for ast::TyParam {
|
||||||
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
|
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
|
||||||
let mut result = String::with_capacity(128);
|
let mut result = String::with_capacity(128);
|
||||||
|
// FIXME: If there are more than one attributes, this will force multiline.
|
||||||
|
let attr_str = match (&*self.attrs).rewrite(context, shape) {
|
||||||
|
Some(ref rw) if !rw.is_empty() => format!("{} ", rw),
|
||||||
|
_ => String::new(),
|
||||||
|
};
|
||||||
|
result.push_str(&attr_str);
|
||||||
result.push_str(&self.ident.to_string());
|
result.push_str(&self.ident.to_string());
|
||||||
if !self.bounds.is_empty() {
|
if !self.bounds.is_empty() {
|
||||||
if context.config.space_before_bound() {
|
if context.config.space_before_bound() {
|
||||||
|
|
|
@ -117,3 +117,8 @@ impl<ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNodeFoo> Issue1249<ConcreteTh
|
||||||
// Creates a new flow constructor.
|
// Creates a new flow constructor.
|
||||||
fn foo() {}
|
fn foo() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #1600
|
||||||
|
impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable<K, V> {
|
||||||
|
fn drop() {}
|
||||||
|
}
|
||||||
|
|
|
@ -149,3 +149,8 @@ impl<ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNodeFoo>
|
||||||
// Creates a new flow constructor.
|
// Creates a new flow constructor.
|
||||||
fn foo() {}
|
fn foo() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #1600
|
||||||
|
impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable<K, V> {
|
||||||
|
fn drop() {}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue