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
33 lines
935 B
Go
33 lines
935 B
Go
package resolver
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// A `mat.buffer()` selector call, where `mat` is a param typed with a
|
|
// generic struct (`&SinkMatch<'_>`), binds to that struct's `buffer`
|
|
// method — not to its like-named field, and not left unresolved. The
|
|
// generic resolver keys methods by their verbatim receiver
|
|
// (`SinkMatch<'b>`), which the generics-stripped inferred receiver_type
|
|
// (`SinkMatch`) misses; the scope pass' base-name alias binds it.
|
|
func TestRustScope_ReceiverTypeSelector(t *testing.T) {
|
|
g := buildRustGraph(t, map[string]string{
|
|
"lib.rs": `
|
|
struct SinkMatch<'b> { buffer: &'b [u8] }
|
|
|
|
impl<'b> SinkMatch<'b> {
|
|
fn buffer(&self) -> &'b [u8] { self.buffer }
|
|
}
|
|
|
|
fn take(mat: &SinkMatch<'_>) {
|
|
let _b = mat.buffer();
|
|
}
|
|
`,
|
|
})
|
|
ResolveRustScopeCalls(g)
|
|
targets := callTargetsFromRust(g, "lib.rs::take")
|
|
require.Contains(t, targets, "lib.rs::SinkMatch<'b>.buffer")
|
|
}
|