Commit Graph

15833 Commits

Author SHA1 Message Date
bors[bot]
6bd0a6eef6
Merge #7930
7930: Clarify that all caps are experimental r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-09 09:03:07 +00:00
Aleksey Kladov
5b2b310827 Clarify that all caps are experimental 2021-03-09 12:02:20 +03:00
Duong Do Minh Chau
a068cedee0
Add trailing commas 2021-03-09 16:00:06 +07:00
Duong Do Minh Chau
ea835fc800
Update the test to match the change 2021-03-09 15:48:53 +07:00
Duong Do Minh Chau
5fc91058ff
Add completion to turn x.err into Err(x) 2021-03-09 15:36:41 +07:00
bors[bot]
3fdf26a6fc
Merge #7898
7898: generate_function assist: infer return type r=JoshMcguigan a=JoshMcguigan

This PR makes two changes to the generate function assist:

1. Attempt to infer an appropriate return type for the generated function
2. If a return type is inferred, and that return type is not unit, don't render the snippet

```rust
fn main() {
    let x: u32 = foo$0();
    //              ^^^ trigger the assist to generate this function
}

// BEFORE
fn foo() ${0:-> ()} {
    todo!()
}

// AFTER (only change 1)
fn foo() ${0:-> u32} {
    todo!()
}

// AFTER (change  1 and 2, note the lack of snippet around the return type)
fn foo() -> u32 {
    todo!()
}
```

These changes are made as two commits, in case we want to omit change 2. I personally feel like it is a nice change, but I could understand there being some opposition.

#### Pros of change 2
If we are able to infer a return type, and especially if that return type is not the unit type, the return type is almost as likely to be correct as the argument names/types. I think this becomes even more true as people learn how this feature works.

#### Cons of change 2

We could never be as confident about the return type as we are about the function argument types, so it is more likely a user will want to change that. Plus it is a confusing UX to sometimes have the cursor highlight the return type after triggering this assist and sometimes not have that happen.

#### Why omit unit type?

The assumption is that if we infer the return type as unit, it is likely just because of the current structure of the code rather than that actually being the desired return type. However, this is obviously just a heuristic and will sometimes be wrong. But being wrong here just means falling back to the exact behavior that existed before this PR.



Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2021-03-08 22:51:04 +00:00
Josh Mcguigan
b275e60905 generate_function assist don't render snippet if ret type inferred 2021-03-08 14:38:36 -08:00
Kirill Bulatov
778deb38fe Better strip turbofishes 2021-03-08 23:59:39 +02:00
Kirill Bulatov
5168ab16e1 Add rustdocs and use better names 2021-03-08 23:59:37 +02:00
Kirill Bulatov
dccbb38d2e Less lifetines: derive SemanticsScope in place 2021-03-08 23:59:20 +02:00
Kirill Bulatov
db61d4ea13 Rebase leftovers 2021-03-08 23:59:20 +02:00
Kirill Bulatov
c56b59d377 Cleanup 2021-03-08 23:59:20 +02:00
Kirill Bulatov
84c575a212 Restrict fuzzy qualifiers for now 2021-03-08 23:59:20 +02:00
Kirill Bulatov
6ca6f101c1 Test for fuzzy unresolved path maatch 2021-03-08 23:59:20 +02:00
Kirill Bulatov
5b7d928075 Enforce the located imports' order 2021-03-08 23:59:20 +02:00
Kirill Bulatov
24a5d3b19d Fix the completion labels and tests 2021-03-08 23:59:20 +02:00
Kirill Bulatov
33c83e72b9 Work towards better import labels 2021-03-08 23:59:20 +02:00
Kirill Bulatov
4d4ac1d4fa Profile import_assets better 2021-03-08 23:59:20 +02:00
Kirill Bulatov
821e8369d9 Update the docs 2021-03-08 23:59:20 +02:00
Kirill Bulatov
e214c3a6bd Simplify 2021-03-08 23:59:20 +02:00
Kirill Bulatov
e74c55bb4a Refactor the import location 2021-03-08 23:59:20 +02:00
Kirill Bulatov
89d410cef5 Do not propose already imported imports 2021-03-08 23:59:20 +02:00
Kirill Bulatov
9482353fa8 Properly handle turbofishes in qualifiers 2021-03-08 23:59:20 +02:00
Kirill Bulatov
d386481fac Fix some tests 2021-03-08 23:59:20 +02:00
Kirill Bulatov
582cee2cdf Return more data about located imports 2021-03-08 23:59:18 +02:00
Kirill Bulatov
309421c117 Draft the qualifier import resolution 2021-03-08 23:58:48 +02:00
Kirill Bulatov
c395c3311d Filter out path items by the qualifier 2021-03-08 23:58:33 +02:00
Kirill Bulatov
f08c0cdd2a Simplify 2021-03-08 23:58:33 +02:00
Kirill Bulatov
7584260b9a Find the code to change 2021-03-08 23:58:33 +02:00
Kirill Bulatov
005bc49d74 Test and initial refactoring 2021-03-08 23:58:32 +02:00
Joshua Nelson
c7b0914b3f Add more documentation for rustc_private 2021-03-08 16:56:42 -05:00
bors[bot]
c48478621f
Merge #7924
7924: Use upstream cov-mark r=matklad a=lnicola

Closes #7922

But doesn't remove any dependency, unfortunately.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-03-08 21:19:31 +00:00
Laurențiu Nicola
fc9eed4836 Use upstream cov-mark 2021-03-08 22:19:44 +02:00
bors[bot]
c5189a22cc
Merge #7923
7923: Remove useless code_model indirection r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-08 19:16:05 +00:00
Aleksey Kladov
9faf8dd69a Hygiene is an internal implementation detail of the compiler 2021-03-08 22:14:52 +03:00
Aleksey Kladov
e346a9c5e1 Remove useless code_model indirection 2021-03-08 22:08:30 +03:00
bors[bot]
8b7e82b012
Merge #7918
7918: Generalize file ensuring infrastructure r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-08 18:52:08 +00:00
Aleksey Kladov
d2bb2268d3 Minor 2021-03-08 21:49:25 +03:00
Aleksey Kladov
c0943f84fd Cleanup the error message 2021-03-08 21:45:43 +03:00
Aleksey Kladov
e89c0e3961 Remove now dead code 2021-03-08 21:45:43 +03:00
Aleksey Kladov
095b9110b5 Unused params 2021-03-08 21:45:43 +03:00
Aleksey Kladov
1eb61203b7 Make code generation just work
Contributors don't need to learn about `cargo xtask codegen` if `cargo
test` just does the right thing.
2021-03-08 21:45:37 +03:00
Aleksey Kladov
abb6b8f14c Use the same name in xtask and test utils 2021-03-08 21:45:06 +03:00
Aleksey Kladov
b6ba0dec0c Generalize file ensuring infrastructure 2021-03-08 21:45:06 +03:00
Aleksey Kladov
0f6f458cc1 Make working with codegen less annoying
We probably should look into removing `xtask codegen` altogether. The
test workflow works perfectly for package.json config.

There are two things preventing that:

* Lint completions are generated on demand.
* Docs are not committed to the repository.
2021-03-08 21:45:06 +03:00
bors[bot]
071dde1c1d
Merge #7921
7921: Don't punish every crate with serde-json r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-08 17:37:43 +00:00
Aleksey Kladov
da73c93c7f Don't punish every crate with serde-json 2021-03-08 20:37:20 +03:00
bors[bot]
d57c9f7980
Merge #7891
7891: Improve handling of rustc_private r=matklad a=DJMcNab

This PR changes how `rust-analyzer` handles `rustc_private`. In particular, packages now must opt-in to using `rustc_private` in `Cargo.toml`, by adding:
```toml
[package.metadata.rust-analyzer]
rustc_private=true
```

This means that depending on crates which also use `rustc_private` will be significantly improved, since their dependencies on the `rustc_private` crates will be resolved properly.

A similar approach could be used in #6714 to allow annotating that your package uses the `test` crate, although I have not yet handled that in this PR.

Additionally, we now only index the crates which are transitive dependencies of `rustc_driver` in the `rustcSource` directory. This should not cause any change in behaviour when using `rustcSource: "discover"`, as the source used then will only be a partial clone. However, if `rustcSource` pointing at a local checkout of rustc, this should significantly improve the memory usage and lower indexing time. This is because we avoids indexing all crates in `src/tools/`, which includes `rust-analyzer` itself.

Furthermore, we also prefer named dependencies over dependencies from `rustcSource`. This ensures that feature resolution for crates which are depended on by both `rustc` and your crate uses the correct set for analysing your crate.

See also [introductory zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates/near/229086673)

I have tested this in [priroda](https://github.com/oli-obk/priroda/), and it provides a significant improvement to the development experience (once I give `miri` the required data in `Cargo.toml`)

Todo:
- [ ] Documentation

This is ready to review, and I will add documentation if this would be accepted (or if I get time to do so anyway)

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2021-03-08 16:51:20 +00:00
Daniel McNab
20007fd3a8 Document rustc_private in metadata 2021-03-08 16:47:40 +00:00
Daniel McNab
d0a51d710e Never run cargo check on the rustc source 2021-03-08 16:42:18 +00:00