Expand const-if-const trait bounds correctly

This commit is contained in:
Michael Goulet 2023-02-07 20:22:42 +00:00
parent e1eaa2d5d4
commit 56bf28d4f4
4 changed files with 23 additions and 5 deletions

View file

@ -1567,8 +1567,18 @@ impl<'a> State<'a> {
match bound {
GenericBound::Trait(tref, modifier) => {
if modifier == &TraitBoundModifier::Maybe {
self.word("?");
match modifier {
TraitBoundModifier::None => {}
TraitBoundModifier::Maybe => {
self.word("?");
}
TraitBoundModifier::MaybeConst => {
self.word_space("~const");
}
TraitBoundModifier::MaybeConstMaybe => {
self.word_space("~const");
self.word("?");
}
}
self.print_poly_trait_ref(tref);
}

View file

@ -626,7 +626,7 @@ fn test_item() {
stringify_item!(
impl ~const Struct {}
),
"impl Struct {}", // FIXME
"impl ~const Struct {}",
);
// ItemKind::MacCall
@ -838,7 +838,7 @@ fn test_ty() {
assert_eq!(stringify_ty!(dyn Send + 'a), "dyn Send + 'a");
assert_eq!(stringify_ty!(dyn 'a + Send), "dyn 'a + Send");
assert_eq!(stringify_ty!(dyn ?Sized), "dyn ?Sized");
assert_eq!(stringify_ty!(dyn ~const Clone), "dyn Clone"); // FIXME
assert_eq!(stringify_ty!(dyn ~const Clone), "dyn ~const Clone");
assert_eq!(stringify_ty!(dyn for<'a> Send), "dyn for<'a> Send");
// TyKind::ImplTrait
@ -846,7 +846,7 @@ fn test_ty() {
assert_eq!(stringify_ty!(impl Send + 'a), "impl Send + 'a");
assert_eq!(stringify_ty!(impl 'a + Send), "impl 'a + Send");
assert_eq!(stringify_ty!(impl ?Sized), "impl ?Sized");
assert_eq!(stringify_ty!(impl ~const Clone), "impl Clone"); // FIXME
assert_eq!(stringify_ty!(impl ~const Clone), "impl ~const Clone");
assert_eq!(stringify_ty!(impl for<'a> Send), "impl for<'a> Send");
// TyKind::Paren

View file

@ -0,0 +1,4 @@
// compile-flags: -Zunpretty=normal
// check-pass
fn foo() where T: ~const Bar {}

View file

@ -0,0 +1,4 @@
// compile-flags: -Zunpretty=normal
// check-pass
fn foo() where T: ~const Bar {}