Skip to content

Commit 2b8239d

Browse files
giacomocavalierilpil
authored andcommitted
Make sure formatter doesn't remove internal annotation
1 parent 3a591ca commit 2b8239d

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Formatter
6+
7+
- Fixed a bug where the `@internal` annotation wouldn't be displayed.
8+
39
## v1.1.0-rc2 - 2024-04-10
410

511
### Compiler

compiler-core/src/format.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,8 @@ impl<'a> Documentable<'a> for &'a ArgNames {
21752175
fn pub_(publicity: Publicity) -> Document<'static> {
21762176
match publicity {
21772177
Publicity::Public => "pub ".to_doc(),
2178-
Publicity::Private | Publicity::Internal => nil(),
2178+
Publicity::Private => nil(),
2179+
Publicity::Internal => "@internal".to_doc().append(line()).append("pub "),
21792180
}
21802181
}
21812182

compiler-core/src/format/tests.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5905,3 +5905,32 @@ fn comments_inside_binop_chain() {
59055905
"#
59065906
);
59075907
}
5908+
5909+
#[test]
5910+
fn internal_attribute_on_function() {
5911+
assert_format!(
5912+
r#"@internal
5913+
pub fn main() {
5914+
todo
5915+
}
5916+
"#
5917+
);
5918+
}
5919+
5920+
#[test]
5921+
fn internal_attribute_on_type() {
5922+
assert_format!(
5923+
r#"@internal
5924+
pub type Type
5925+
"#
5926+
);
5927+
}
5928+
5929+
#[test]
5930+
fn internal_attribute_on_const() {
5931+
assert_format!(
5932+
r#"@internal
5933+
pub const wibble = 1
5934+
"#
5935+
);
5936+
}

0 commit comments

Comments
 (0)