a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
35 lines
897 B
Go
35 lines
897 B
Go
package resolver
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// A selector call on a self-rooted field-access receiver
|
|
// (`self.config.line_term.as_byte()`) binds by walking the declared field
|
|
// types from the enclosing impl type down the chain: Searcher.config ->
|
|
// Config, Config.line_term -> LineTerminator, then LineTerminator.as_byte.
|
|
func TestRustScope_FieldReceiverWalk(t *testing.T) {
|
|
g := buildRustGraph(t, map[string]string{
|
|
"lib.rs": `
|
|
struct LineTerminator { b: u8 }
|
|
impl LineTerminator {
|
|
fn as_byte(&self) -> u8 { self.b }
|
|
}
|
|
|
|
struct Config { line_term: LineTerminator }
|
|
|
|
struct Searcher { config: Config }
|
|
impl Searcher {
|
|
fn run(&self) -> u8 {
|
|
self.config.line_term.as_byte()
|
|
}
|
|
}
|
|
`,
|
|
})
|
|
ResolveRustScopeCalls(g)
|
|
targets := callTargetsFromRust(g, "lib.rs::Searcher.run")
|
|
require.Contains(t, targets, "lib.rs::LineTerminator.as_byte")
|
|
}
|