Skip to content

Commit 27cd65d

Browse files
committed
[hermes] Parse Hermes attributes
gherrit-pr-id: Ib659c95874d275713cc813788024b49e87a8873d
1 parent 92a5536 commit 27cd65d

File tree

102 files changed

+3097
-2885
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+3097
-2885
lines changed

tools/hermes/src/parse.rs

Lines changed: 465 additions & 266 deletions
Large diffs are not rendered by default.

tools/hermes/src/scanner.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,28 @@ fn process_file_recursive<'a>(
188188
let mut full_path = current_prefix.clone();
189189
full_path.extend(item.module_path);
190190

191-
use parse::ParsedItem::*;
192191
match &item.item {
193192
// Unreliable syntaxes: we have no way of reliably naming
194193
// these in Charon's `--start-from` argument, so we fall
195194
// back to naming the parent module.
196-
Impl(_) | ImplItemFn(_) | TraitItemFn(_) => {
195+
parse::ParsedItem::Impl(_) => {
197196
let start_from = full_path.join("::");
198197
path_tx.send((name.clone(), start_from)).unwrap();
199198
}
199+
parse::ParsedItem::Function(f) => match &f.item {
200+
parse::FunctionItem::Impl(_) | parse::FunctionItem::Trait(_) => {
201+
let start_from = full_path.join("::");
202+
path_tx.send((name.clone(), start_from)).unwrap();
203+
}
204+
parse::FunctionItem::Free(_) => {
205+
if let Some(item_name) = item.item.name() {
206+
full_path.push(item_name);
207+
let start_from = full_path.join("::");
208+
log::debug!("Found entry point: {}", start_from);
209+
path_tx.send((name.clone(), start_from)).unwrap();
210+
}
211+
}
212+
},
200213
// Reliable syntaxes: target the specific item.
201214
_ => {
202215
if let Some(item_name) = item.item.name() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Unclosed ```lean block
1+
Unclosed Hermes block in documentation.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
/// ```lean
1+
/// ```lean, hermes
22
/// unclosed block
33
fn foo() {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// ```lean
1+
/// ```lean, hermes
22
/// theorem main_proof : True := trivial
33
/// ```
44
pub fn main_proof() {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cfg(target_os = "haiku")]
22
mod ghost {
3-
/// ```lean
3+
/// ```lean, hermes
44
/// ```
55
pub fn hidden() {}
66
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
/// ```lean
1+
/// ```lean, hermes
22
/// ```
33
fn utils_a() {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
/// ```lean
1+
/// ```lean, hermes
22
/// ```
33
fn utils_b() {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
/// ```lean
1+
/// ```lean, hermes
22
/// ```
33
fn utils_a() {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
/// ```lean
1+
/// ```lean, hermes
22
/// ```
33
fn utils_b() {}

0 commit comments

Comments
 (0)