Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust: first draft of canonical paths rework (WIP) #18223

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

redsun82
Copy link
Contributor

@redsun82 redsun82 commented Dec 5, 2024

First go at making canonical paths more semantic.

What works:

  • identity at the DB level of extracted canonical paths
  • distinguishing trait implementations for incompatible instantiations of the same generic type (which was broken until now)

What needs to be done:

  • caching of path extractions: currently state of the PR redoes the trap emission for every single path and every single prefix of the paths
  • adapt the QL library and queries to the new paths
  • removing old path extraction methods (currently they are there to let QL compile, but come out empty from the extractor, wreaking havoc in tests)

What might be broken without changing how we use rust-analyzer or upstreaming changes to it:

  • const parameters of types are not easily visible

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Dec 5, 2024
}

impl<T> GenericTrait<T> for GenericStruct<i32, T> {
fn generic_method(&self, t: T) {}

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'self' is not used.
}

impl<T> GenericTrait<T> for GenericStruct<i32, T> {
fn generic_method(&self, t: T) {}

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 't' is not used.
}

impl GenericTrait<i32> for GenericStruct<&str, i32> {
fn generic_method(&self, t: i32) {}

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'self' is not used.
}

impl GenericTrait<i32> for GenericStruct<&str, i32> {
fn generic_method(&self, t: i32) {}

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 't' is not used.
}

impl<T> GenericTrait<T> for GenericTupleStruct<i32, T> {
fn generic_method(&self, t: T) {}

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'self' is not used.
}

impl GenericTrait<i32> for GenericTupleStruct<&str, i32> {
fn generic_method(&self, t: i32) {}

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 't' is not used.
}

impl<T> GenericTrait<T> for GenericEnum<i32, T> {
fn generic_method(&self, t: T) {}

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'self' is not used.
}

impl<T> GenericTrait<T> for GenericEnum<i32, T> {
fn generic_method(&self, t: T) {}

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 't' is not used.
}

impl GenericTrait<i32> for GenericEnum<&str, i32> {
fn generic_method(&self, t: i32) {}

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'self' is not used.
}

impl GenericTrait<i32> for GenericEnum<&str, i32> {
fn generic_method(&self, t: i32) {}

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 't' is not used.
@@ -177,3 +177,22 @@
import codeql.rust.elements.WildcardPat
import codeql.rust.elements.YeetExpr
import codeql.rust.elements.YieldExpr
import codeql.rust.elements.canonical_paths.BuiltinTypeCanonicalPath
import codeql.rust.elements.canonical_paths.CanonicalPath

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.Addressable
.
Redundant import, the module is already imported inside
codeql.rust.elements.Resolvable
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.ImplItemCanonicalPath
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.ModuleItemCanonicalPath
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.Namespace
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.ParametrizedCanonicalPath
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.TypeCanonicalPath
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.TypeItemCanonicalPath
.
@@ -177,3 +177,22 @@
import codeql.rust.elements.WildcardPat
import codeql.rust.elements.YeetExpr
import codeql.rust.elements.YieldExpr
import codeql.rust.elements.canonical_paths.BuiltinTypeCanonicalPath
import codeql.rust.elements.canonical_paths.CanonicalPath
import codeql.rust.elements.canonical_paths.CanonicalPathElement

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.CanonicalPath
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.CrateRoot
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.TypeGenericArg
.
import codeql.rust.elements.canonical_paths.CanonicalPathElement
import codeql.rust.elements.canonical_paths.ConcreteTypeCanonicalPath
import codeql.rust.elements.canonical_paths.ConstGenericTypeArg
import codeql.rust.elements.canonical_paths.CrateRoot

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.LangCrateRoot
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.Namespace
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.RepoCrateRoot
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.RustcCrateRoot
.
import codeql.rust.elements.canonical_paths.DerivedTypeCanonicalPath
import codeql.rust.elements.canonical_paths.ImplItemCanonicalPath
import codeql.rust.elements.canonical_paths.LangCrateRoot
import codeql.rust.elements.canonical_paths.ModuleItemCanonicalPath

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.ParametrizedCanonicalPath
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.TypeItemCanonicalPath
.
import codeql.rust.elements.canonical_paths.ImplItemCanonicalPath
import codeql.rust.elements.canonical_paths.LangCrateRoot
import codeql.rust.elements.canonical_paths.ModuleItemCanonicalPath
import codeql.rust.elements.canonical_paths.Namespace

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.ModuleItemCanonicalPath
.
import codeql.rust.elements.canonical_paths.RepoCrateRoot
import codeql.rust.elements.canonical_paths.RustcCrateRoot
import codeql.rust.elements.canonical_paths.TypeCanonicalPath
import codeql.rust.elements.canonical_paths.TypeGenericArg

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.ConstGenericTypeArg
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.ParametrizedCanonicalPath
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.TypeGenericTypeArg
.
*/

private import internal.ImplItemCanonicalPathImpl
import codeql.rust.elements.canonical_paths.CanonicalPath

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.ParametrizedCanonicalPath
.
Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.TypeCanonicalPath
.
*/

private import internal.ModuleItemCanonicalPathImpl
import codeql.rust.elements.canonical_paths.CanonicalPath

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.Namespace
.
*/

private import internal.ParametrizedCanonicalPathImpl
import codeql.rust.elements.canonical_paths.CanonicalPath

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.ModuleItemCanonicalPath
.
*/

private import internal.TypeItemCanonicalPathImpl
import codeql.rust.elements.canonical_paths.CanonicalPath

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.canonical_paths.ModuleItemCanonicalPath
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant