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

Path resolution fixes #493

Merged
merged 3 commits into from Jun 14, 2021
Merged

Path resolution fixes #493

merged 3 commits into from Jun 14, 2021

Conversation

philberty
Copy link
Member

@philberty philberty commented Jun 14, 2021

In order to support Modules, we need to do path resolution properly. The old code assumed a basic A::B but this is not generic enough in order to support modules.

@philberty philberty requested a review from dkm June 14, 2021 13:29
@philberty philberty marked this pull request as draft June 14, 2021 13:29
@bjorn3
Copy link

bjorn3 commented Jun 14, 2021

nit: s/untill/until in the commit message

@philberty philberty marked this pull request as ready for review June 14, 2021 15:15
@philberty philberty changed the title WIP Path resolution fixes Path resolution fixes Jun 14, 2021
Name resolution tried to greedily resolve the entire CanonicalPath in one
lookup which was ok for simple paths like A::B. This changes the name
resolver to resolve each segment which allows the type resolution to
determine the root path to be up until the segment is unresolved which
will then require a PathProbe or its a failure. This will be required to
support modules which extend the resolution to be much more generic than
is assumed here.

Addresses: #432
There are cases where the name resolver can fully resolve a path such as:

```rust
struct Foo(i32);

impl Foo{
  fn new() { ... }
}

fn main() {
  let a;
  a = Foo::new();
}
```

This case does not require a PathProbe. This enhances the Path resolution
to iterate each segment untill we are unable to resolve the root segment
at that point we can fall back to a PathProbe and lookup any impl item that
might satisfy the path instead.

Addresses #432
In order to support modules the path expression will fail here since a
module is not a value and does not have a TyTy type, so this is ok to
continue the rest of resolution so long as there are more segments.

Addresses: #432
@philberty philberty added this to In progress in Data Structures 3 - Traits via automation Jun 14, 2021
@philberty philberty removed this from In progress in Data Structures 3 - Traits Jun 14, 2021
@philberty
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 14, 2021

Build succeeded:

@bors bors bot merged commit 59f8d7a into master Jun 14, 2021
@philberty philberty deleted the phil/path-resolution-fixes branch June 14, 2021 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants