diff --git a/internal/lsp/source/rename_check.go b/internal/lsp/source/rename_check.go index 9cc3e5ba54..042331cc7c 100644 --- a/internal/lsp/source/rename_check.go +++ b/internal/lsp/source/rename_check.go @@ -390,7 +390,11 @@ func (r *renamer) checkStructField(from *types.Var) { // go/types offers no easy way to get from a field (or interface // method) to its declaring struct (or interface), so we must // ascend the AST. - pkg, path, _ := pathEnclosingInterval(r.fset, r.packages[from.Pkg()], from.Pos(), from.Pos()) + fromPkg, ok := r.packages[from.Pkg()] + if !ok { + return + } + pkg, path, _ := pathEnclosingInterval(r.fset, fromPkg, from.Pos(), from.Pos()) if pkg == nil || path == nil { return }