Include constness in impl blocks (#4215)

Closes #4084
This commit is contained in:
hafiz 2020-05-31 03:36:08 -05:00 committed by Caleb Cartwright
parent 17bad2b3c0
commit 269584634a
4 changed files with 26 additions and 0 deletions

View file

@ -828,6 +828,7 @@ fn format_impl_ref_and_type(
unsafety,
polarity,
defaultness,
constness,
ref generics,
of_trait: ref trait_ref,
ref self_ty,
@ -851,6 +852,7 @@ fn format_impl_ref_and_type(
};
let generics_str = rewrite_generics(context, "impl", generics, shape)?;
result.push_str(&generics_str);
result.push_str(format_constness_right(constness));
let polarity_str = match polarity {
ast::ImplPolarity::Negative(_) => "!",

View file

@ -100,6 +100,14 @@ pub(crate) fn format_constness(constness: ast::Const) -> &'static str {
}
}
#[inline]
pub(crate) fn format_constness_right(constness: ast::Const) -> &'static str {
match constness {
ast::Const::Yes(..) => " const",
ast::Const::No => "",
}
}
#[inline]
pub(crate) fn format_defaultness(defaultness: ast::Defaultness) -> &'static str {
match defaultness {

View file

@ -160,3 +160,11 @@ impl<'a, 'b, 'c> SomeThing<Something> for (&'a mut SomethingLong, &'b mut Someth
// #2746
impl<'seq1, 'seq2, 'body, 'scope, Channel> Adc12< Dual, MasterRunningDma<'seq1, 'body, 'scope, Channel>, SlaveRunningDma<'seq2, 'body, 'scope>, > where Channel: DmaChannel, {}
// #4084
impl const std::default::Default for Struct {
#[inline]
fn default() -> Self {
Self { f: 12.5 }
}
}

View file

@ -234,3 +234,11 @@ where
Channel: DmaChannel,
{
}
// #4084
impl const std::default::Default for Struct {
#[inline]
fn default() -> Self {
Self { f: 12.5 }
}
}