Squash danusha2345's PR #1511 at d282f9e8 onto main 8c9c4761,
preserving its nine non-merge commits and main's existing Unreleased notes.
Calls in Kotlin, Java, TS/JS, Scala, Rust and Python declaration initializers
now retain the owner established by the upstream regression expectations.
Include the upstream CFML, dynamic-dispatch summary and viewer follow-ups.
Linux fail-to-pass validation (Node 22.19.0, rebuilt dist and native kernel):
- Before: TS load belonged to file:app.ts; Python/Kotlin/Scala/Rust calls
vanished; Java lost the field-lambda, anonymous override and eager calls.
- After: all six languages PASS; 12 native/WASM LF/CRLF parity checks PASS.
- Focused initializer regressions: 10 passed with CODEGRAPH_KERNEL=0 and
10 passed with the kernel enabled; Kotlin's grammar fallback is recorded.
- Related regression suites: 879 passed, 1 skipped across 15 test files.
- Evidence: /workspace/cg-1510-repro/before and /workspace/cg-1510-repro/after
(combined test output: after/vitest.log).
Fixes #1510
Supersedes #1511
Co-authored-by: Colby McHenry <colbymchenry@users.noreply.github.com>
Co-authored-by: danusha2345 <ewidusoc498@gmail.com>
299 lines
5.2 KiB
Rust
299 lines
5.2 KiB
Rust
//! Torture fixture for the rust kernel walker (R7b) — every quirk in
|
|
//! docs/design/rust-lang-kernel-port-checklist.md, parse-clean.
|
|
|
|
use std::fmt;
|
|
use crate::mod_a::Item;
|
|
use crate::mod_b::{A, B as C, sub::D};
|
|
use a::{b::{c, d}};
|
|
use foo_single;
|
|
use std::collections::*;
|
|
|
|
/// Widget docs.
|
|
pub struct Widget {
|
|
pub n: u32,
|
|
name: String,
|
|
field: Deep,
|
|
}
|
|
|
|
pub struct Unit;
|
|
|
|
pub struct Pair(u32, u32);
|
|
|
|
/// Doc broken by the attribute below — must yield NO docstring.
|
|
#[derive(Debug)]
|
|
pub struct Doc {
|
|
x: u32,
|
|
}
|
|
|
|
pub struct Deep {
|
|
z: u32,
|
|
}
|
|
|
|
pub enum Shape {
|
|
Circle(f32),
|
|
Rect { w: f32, h: f32 },
|
|
Empty,
|
|
}
|
|
|
|
pub type Alias = Vec<Widget>;
|
|
|
|
/// Render trait docs.
|
|
pub trait Render: Base + fmt::Debug {
|
|
fn render(&self);
|
|
fn hint(&self) -> Size {
|
|
Size::default()
|
|
}
|
|
const CAP: usize = init_cap();
|
|
type Output;
|
|
}
|
|
|
|
pub trait Base {}
|
|
|
|
pub trait Super2: Producer<u32> {}
|
|
|
|
pub trait Owned: for<'de> Deserialize<'de> {}
|
|
|
|
impl Render for Widget {
|
|
fn render(&self) {
|
|
draw(self);
|
|
}
|
|
}
|
|
|
|
impl fmt::Display for Widget {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
write!(f, "w{}", self.n)
|
|
}
|
|
}
|
|
|
|
impl Widget {
|
|
const SCALE: usize = 3;
|
|
|
|
fn area(&self) -> u32 {
|
|
self.n * mul()
|
|
}
|
|
|
|
/// Receiver shapes (#1585): only `self.<field>.<method>()` keeps the
|
|
/// owner-field prefix; deeper / parenthesized / call / bare-self collapse.
|
|
fn via_field(&self) -> u32 {
|
|
self.field.deep_call();
|
|
self.field.z.clone();
|
|
self.method_a().chain_b();
|
|
(self.field).deep_call();
|
|
self.area()
|
|
}
|
|
|
|
fn clone_self(&self) -> Self {
|
|
Self::assoc();
|
|
Widget {
|
|
n: self.n,
|
|
name: String::new(),
|
|
field: Deep { z: 0 },
|
|
}
|
|
}
|
|
|
|
fn borrow_widget(&self) -> &Widget {
|
|
self
|
|
}
|
|
|
|
fn outer(&self) -> u32 {
|
|
fn inner_helper(v: u32) -> u32 {
|
|
v
|
|
}
|
|
inner_helper(self.n)
|
|
}
|
|
}
|
|
|
|
pub struct Container<T> {
|
|
item: T,
|
|
}
|
|
|
|
impl<T> Container<T> {
|
|
fn unwrap(self) -> T {
|
|
self.item
|
|
}
|
|
}
|
|
|
|
impl Render for Container<u32> {
|
|
fn render(&self) {}
|
|
}
|
|
|
|
/// Receiver = the impl_item's `type` field (#1588): generic, lifetime,
|
|
/// reference, scoped, and generic-trait impls all qualify by the TYPE.
|
|
pub trait Source {
|
|
fn read(&mut self) -> usize;
|
|
}
|
|
|
|
pub struct FileSource {
|
|
pub n: usize,
|
|
}
|
|
|
|
impl Source for FileSource {
|
|
fn read(&mut self) -> usize {
|
|
self.n
|
|
}
|
|
}
|
|
|
|
pub struct BufSource<T> {
|
|
pub inner: T,
|
|
}
|
|
|
|
impl<T> Source for BufSource<T> {
|
|
fn read(&mut self) -> usize {
|
|
0
|
|
}
|
|
}
|
|
|
|
pub struct Parents<'a> {
|
|
cur: &'a u32,
|
|
}
|
|
|
|
impl<'a> Iterator for Parents<'a> {
|
|
type Item = u32;
|
|
fn next(&mut self) -> Option<u32> {
|
|
None
|
|
}
|
|
}
|
|
|
|
impl<T: Clone> Container<T> {
|
|
fn dup(&self) -> T {
|
|
self.item.clone()
|
|
}
|
|
}
|
|
|
|
impl Base for &Widget {}
|
|
|
|
impl<T> Render for &mut BufSource<T> {
|
|
fn render(&self) {}
|
|
}
|
|
|
|
impl Base for self::Deep {}
|
|
|
|
impl From<u32> for FileSource {
|
|
fn from(n: u32) -> Self {
|
|
FileSource { n: n as usize }
|
|
}
|
|
}
|
|
|
|
impl Base for (u32, u32) {}
|
|
|
|
impl Render for dyn Base {
|
|
fn render(&self) {}
|
|
}
|
|
|
|
impl Base for u32 {}
|
|
|
|
impl Later {
|
|
fn touch(&self) {}
|
|
}
|
|
|
|
pub struct Later {
|
|
z: u32,
|
|
}
|
|
|
|
/* Block-doc for an async fn — isAsync must stay FALSE (dead-code hook). */
|
|
pub async fn fetch_data(url: &str) -> Result<Response, Error> {
|
|
let body = get(url).await;
|
|
client.request().await.send();
|
|
body
|
|
}
|
|
|
|
pub fn nested_ret() -> Result<Vec<Widget>, Error> {
|
|
make_result()
|
|
}
|
|
|
|
pub fn vec_ret(w: &Widget) -> Vec<Widget> {
|
|
build_list(w)
|
|
}
|
|
|
|
pub(crate) fn crate_fn() {}
|
|
|
|
fn caller() {
|
|
let w = Widget {
|
|
n: 1,
|
|
name: make_name(),
|
|
field: Deep { z: 1 },
|
|
};
|
|
let v = m::Widget { n: 2 };
|
|
let r = Foo::new().bar();
|
|
let x = w.method_a().chain_b();
|
|
let y = w.field.deep_call();
|
|
let s = "lit".len();
|
|
let f = 5.0_f64.floor();
|
|
helper();
|
|
m::helper2();
|
|
let t = helper::<u32>(3);
|
|
(helper)(1);
|
|
takes(Widget {
|
|
n: 3,
|
|
name: n2(),
|
|
field: Deep { z: 2 },
|
|
});
|
|
}
|
|
|
|
fn handler() {}
|
|
fn handler2() {}
|
|
fn cb_a() {}
|
|
fn cb_b() {}
|
|
fn invoke_all(fns: [fn(); 2]) {}
|
|
|
|
fn register(f: fn()) {
|
|
f();
|
|
}
|
|
|
|
pub struct Holder {
|
|
cb: fn(),
|
|
}
|
|
|
|
fn wiring(mut o: Holder) {
|
|
register(handler);
|
|
o.cb = handler2;
|
|
let h = Holder { cb: cb_a };
|
|
let arr = [cb_a, cb_b];
|
|
let local = handler;
|
|
let (t1, t2) = (cb_a, cb_b);
|
|
invoke_all(arr);
|
|
invoke(foo_single);
|
|
}
|
|
|
|
static CB: fn() = handler;
|
|
|
|
const MAX_LIMIT: u32 = OTHER_LIMIT;
|
|
const OTHER_LIMIT: u32 = 99;
|
|
|
|
fn reads_limits() -> u32 {
|
|
MAX_LIMIT + OTHER_LIMIT
|
|
}
|
|
|
|
fn shadowed_read() {
|
|
let MAX_LIMIT = 5;
|
|
let _ = MAX_LIMIT;
|
|
}
|
|
|
|
mod inner {
|
|
pub fn helper_pub() {}
|
|
fn hidden() {}
|
|
pub struct Item2 {
|
|
pub v: u32,
|
|
}
|
|
}
|
|
|
|
fn mount() {
|
|
let r = routes![a::b::index_h, health_h];
|
|
let c = catchers![not_found_h];
|
|
let skipped = rocket::routes![a::x];
|
|
}
|
|
|
|
routes![top_level_h];
|
|
|
|
// Initializer walks attributed to the declared symbol (#693).
|
|
const INIT_CONST: usize = compute_len();
|
|
static INIT_LAZY: Lazy<Cfg> = Lazy::new(|| build_cfg());
|
|
static INIT_ALIAS: fn() = free_fn;
|
|
|
|
pub union Reg {
|
|
pub raw: u32,
|
|
pub halves: [u16; 2],
|
|
}
|
|
|
|
impl Base for Reg {}
|