diff --git a/src/types.rs b/src/types.rs index 25ad587ba85..f487fbc0f5d 100644 --- a/src/types.rs +++ b/src/types.rs @@ -664,9 +664,11 @@ impl Rewrite for ast::Ty { match self.kind { ast::TyKind::TraitObject(ref bounds, tobj_syntax) => { // we have to consider 'dyn' keyword is used or not!!! - let is_dyn = tobj_syntax == ast::TraitObjectSyntax::Dyn; - // 4 is length of 'dyn ' - let shape = if is_dyn { shape.offset_left(4)? } else { shape }; + let shape = match tobj_syntax { + ast::TraitObjectSyntax::Dyn => shape.offset_left(4)?, // 4 is offset 'dyn ' + ast::TraitObjectSyntax::DynStar => shape.offset_left(5)?, // 5 is offset 'dyn* ' + ast::TraitObjectSyntax::None => shape, + }; let mut res = bounds.rewrite(context, shape)?; // We may have falsely removed a trailing `+` inside macro call. if context.inside_macro() && bounds.len() == 1 { @@ -674,10 +676,10 @@ impl Rewrite for ast::Ty { res.push('+'); } } - if is_dyn { - Some(format!("dyn {}", res)) - } else { - Some(res) + match tobj_syntax { + ast::TraitObjectSyntax::Dyn => Some(format!("dyn {}", res)), + ast::TraitObjectSyntax::DynStar => Some(format!("dyn* {}", res)), + ast::TraitObjectSyntax::None => Some(res), } } ast::TyKind::Ptr(ref mt) => { diff --git a/tests/target/issue_5542.rs b/tests/target/issue_5542.rs new file mode 100644 index 00000000000..730bb7b681a --- /dev/null +++ b/tests/target/issue_5542.rs @@ -0,0 +1,10 @@ +#![feature(dyn_star)] +#![allow(incomplete_features)] + +use core::fmt::Debug; + +fn main() { + let i = 42; + let dyn_i = i as dyn* Debug; + dbg!(dyn_i); +}