scryer-engine 0.3.0

Tree-sitter AST indexing and reference resolution engine for Scryer code intelligence
//! Every line marked `@ref` must produce a reference to `target` (see tests/support/recall.rs).

pub fn target() -> u32 {
    1
}

pub fn take(x: u32) -> u32 {
    x
}

pub fn c01_direct() {
    target(); // @ref target
}

pub fn c02_argument() {
    take(target()); // @ref target
}

pub fn c03_binding() {
    let _x = target(); // @ref target
}

pub fn c04_closure() {
    let _ = Some(1).map(|_| target()); // @ref target
}

pub fn c05_method_chain() {
    let _ = Some(target()).map(|x| x + 1).unwrap_or(0); // @ref target
}

pub fn c06_condition() {
    if target() > 0 {} // @ref target
}

pub fn c07_match() {
    match target() { // @ref target
        _ => {}
    }
}

pub fn c08_return() -> u32 {
    return target(); // @ref target
}

pub fn c09_binary() -> u32 {
    take(1) + target() // @ref target
}

pub fn c10_println() {
    println!("{}", target()); // @ref target phase=3
}

pub fn c11_format() {
    let _ = format!("{}", target()); // @ref target phase=3
}

pub fn c12_assert_eq() {
    assert_eq!(target(), 1); // @ref target phase=3
}

pub fn c13_vec() {
    let _ = vec![target()]; // @ref target phase=3
}

pub fn c14_matches() {
    let _ = matches!(target(), 1); // @ref target phase=3
}

pub fn c15_function_as_value() {
    let _f: fn() -> u32 = target; // @ref target role=value phase=4
}

pub trait Tr {
    fn tm(&self) -> u32;
}

pub struct Impl0;

impl Tr for Impl0 {
    fn tm(&self) -> u32 {
        1
    }
}

pub fn c16_trait_path(s: &Impl0) -> u32 {
    Tr::tm(s) // @ref tm phase=5
}

pub fn c17_generic_receiver<T: Tr>(s: &T) -> u32 {
    T::tm(s) // @ref tm phase=5
}

pub fn c18_qualified_path(s: &Impl0) -> u32 {
    <Impl0 as Tr>::tm(s) // @ref tm phase=5
}

pub const C19_CONST: u32 = 1 + helper_for_const(); // @ref helper_for_const phase=5

pub fn helper_for_const() -> u32 {
    2
}

pub struct ParamType;

pub fn c20_parameter_type(p: &ParamType) -> u32 { // @ref ParamType role=type_annotation
    let _ = p;
    0
}