Commit graph

352 commits

Author SHA1 Message Date
Florian Diebold
e0f978018a Add some tests for Chalk built-in trait impls 2020-05-22 18:52:07 +02:00
Florian Diebold
02c2beaa8c Provide Chalk well-known traits 2020-05-22 17:32:49 +02:00
Florian Diebold
e81c76a95a Use Chalk's built-in representations of primitive types
For references, we make sure Chalk actually gets a lifetime here.
2020-05-22 17:32:49 +02:00
Florian Diebold
06ed140fc7 Update Chalk
As always, this just makes compilation work, we don't use the newly available
functionality yet.
2020-05-22 16:40:42 +02:00
Aleksey Kladov
ecac5d7de2 Switch to new magic marks 2020-05-20 13:02:53 +02:00
Roland Ruckerbauer
45021cae55 Apply suggestion of @flodiebold: Get rid of multiple unwraps 2020-05-19 22:53:19 +02:00
Roland Ruckerbauer
da09f96746 loop return value inference: add tests 2020-05-19 21:52:43 +02:00
Roland Ruckerbauer
6e36ad3d91 Move false negative expr_diverges_missing_arm() to working tests 2020-05-19 21:18:43 +02:00
Roland Ruckerbauer
6eaa669da0 loop return value inference: coerce_merge branches 2020-05-19 21:06:47 +02:00
Roland Ruckerbauer
0fe876925e Infer return type of loops with value breaks. 2020-05-18 23:39:10 +02:00
bors[bot]
9bdedbbcaf
Merge #4497
4497: Create LowerCtx on the fly r=matklad a=edwin0cheng

Previously we create `LowerCtx` at the beginning of lowering, however, the hygiene content is in fact changing between macro expression expanding. 

This PR change it to create the `LowerCtx` on the fly to fix above bug.

However, #4465 is not fixed by this PR, the goto-def is still not work yet. It only fixed the infer part. 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-18 11:03:44 +00:00
Hrvoje Ban
68db49c853 Add more tests for Fn traits 2020-05-18 08:07:31 +02:00
Edwin Cheng
12a3bf3c31 Create LowerCtx on the fly 2020-05-17 23:37:30 +08:00
Florian Diebold
811d25b723 Allow calling dyn trait super trait methods without the super trait in scope
This also removes some vestiges of the old impl trait support which I think
aren't currently in use.
2020-05-16 18:37:05 +02:00
Florian Diebold
050601ef7b Chalk upgrade 2020-05-16 11:43:48 +02:00
Florian Diebold
3f42b2e837 Handle Self in values and patterns
I.e.
 - `Self(x)` or `Self` in tuple/unit struct impls
 - `Self::Variant(x)` or `Self::Variant` in enum impls
 - the same in patterns

Fixes #4454.
2020-05-15 17:25:28 +02:00
Fedor Sakharov
12bf008ab1
Adds a param_idx helper 2020-05-14 13:47:36 +03:00
bors[bot]
74e72e9afa
Merge #4394 #4414
4394: Simplify r=matklad a=Veetaha



4414: Highlighting improvements r=matklad a=matthewjasper

- `static mut`s are highlighted as `mutable`.
- The name of the macro declared by `macro_rules!` is now highlighted.

Co-authored-by: veetaha <veetaha2@gmail.com>
Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
2020-05-10 17:47:27 +00:00
Timo Freiberg
cbbbd48325 Omit default types in HirDisplay SourceCode mode 2020-05-10 18:10:15 +02:00
Matthew Jasper
11c0a5bb60 Highlight mutable statics as mutable 2020-05-10 16:25:51 +01:00
Emil Lauridsen
85d44cad45 infer: Make expected rhs type for plain assign the lhs type
This fixes an issue where the following code sample would fail to infer
the type contained in the option:
```rust
fn main() {
    let mut end = None; // TODO: Fix inference for this in RA
    loop {
        end = Some(true);
    }
}
```
2020-05-10 16:24:04 +02:00
bors[bot]
25e37e2c93
Merge #4175
4175: Introduce HirDisplay method for rendering source code & use it in add_function assist r=flodiebold a=TimoFreiberg

Next feature for #3639.

So far the only change in the new `HirDisplay` method is that paths are qualified, but more changes will be necessary (omitting the function name from function types, returning an error instead of printing `"{unknown}"`, probably more).

Is that approach okay?

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-05-09 09:29:11 +00:00
Florian Diebold
a3d866e776 Handle coercing function types to function pointers in match
E.g. in
```rust
match x {
    1 => function1,
    2 => function2,
}
```
we need to try coercing both to pointers. Turns out this is a special case in
rustc as well (see the link in the comment).
2020-05-08 22:14:01 +02:00
Florian Diebold
d0129c4ddb Add diagnostic for break outside of loop 2020-05-08 19:48:03 +02:00
Florian Diebold
f8bf94a4b9 Use matches! 2020-05-08 19:30:02 +02:00
Florian Diebold
b60970fd20 Handle break somewhat better
Still no break-with-value or labels, but at least we know that `loop { break; }`
doesn't diverge.
2020-05-08 18:28:01 +02:00
Florian Diebold
fe7bf993aa Implement better handling of divergence
Divergence here means that for some reason, the end of a block will not be
reached. We tried to model this just using the never type, but that doesn't work
fully (e.g. in `let x = { loop {}; "foo" };` x should still have type `&str`);
so this introduces a `diverges` flag that the type checker keeps track of, like
rustc does.
2020-05-08 18:15:24 +02:00
Timo Freiberg
fe93675e8a New HirDisplay method for displaying sourcecode 2020-05-08 17:12:18 +02:00
Florian Diebold
f5177f91ae Fix type of byte literals
They're `&[u8; N]`, not `&[u8]` (see #4374).
2020-05-08 15:18:33 +02:00
Mikail Bagishov
7c94fa7d01
Fix usefulness check for never type 2020-05-06 17:59:27 +03:00
Edwin Cheng
92665358cd Rename ImplItem to AssocItem 2020-05-05 23:56:10 +08:00
bors[bot]
756e91732b
Merge #4305
4305: Favor types for record type struct in name resolution r=matklad a=edwin0cheng

Fixed #4235

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-05 15:06:41 +00:00
Edwin Cheng
204c8de3bf Add test for issue 2020-05-05 00:29:47 +08:00
bors[bot]
57f285d0eb
Merge #4283
4283: Support macro for trait items r=matklad a=edwin0cheng

Fixed  #4039

r? @flodiebold 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Co-authored-by: Edwin Cheng <edwin@m-inverse.com>
2020-05-04 10:49:24 +00:00
Benjamin Coenen
bed115d6e1 add support of cfg attributes on enum variants #4279
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-03 17:56:45 +02:00
Edwin Cheng
73ed2f2e90 Remove whitespaces 2020-05-03 22:15:07 +08:00
Edwin Cheng
8b6216df05 Support macro for trait items 2020-05-03 22:08:39 +08:00
bors[bot]
fb8fb65131
Merge #4234
4234: Support local_inner_macros r=jonas-schievink a=edwin0cheng

This PR implements `#[macro_export(local_inner_macros)]` support. 

Note that the rustc implementation is quite [hacky][1] too. :)

[1]: 614f273e93/src/librustc_resolve/macros.rs (L456)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-02 10:30:49 +00:00
Aleksey Kladov
b58dfd24f1 Add smoke test for decorated blocks 2020-05-02 11:27:28 +02:00
Aleksey Kladov
fd030f9450 Revert "Merge #4233"
This reverts commit a5f2b16366, reversing
changes made to c96b2180c1.
2020-05-02 01:12:37 +02:00
bors[bot]
3232fd5179
Merge #4220 #4240
4220: Introduce LowerCtx r=matklad a=edwin0cheng

This PR introduces `LowerCtx` for path lowering. 

After this PR, there are only 2 places remains for using deprecated `Path::from_ast`, which is related to `AstTransform` I am not familiar. I would like to change these in another PR by others ;)

related disscusiion:  https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Path.3A.3Afrom_src

And also fixed part of https://github.com/rust-analyzer/rust-analyzer/issues/4176#issuecomment-620672930

4240: Bump deps r=matklad a=lnicola



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-01 20:16:25 +00:00
Laurențiu Nicola
1e20467c3a Bump deps 2020-05-01 15:29:03 +03:00
Edwin Cheng
1635d22a35 Add test 2020-05-01 20:01:17 +08:00
Edwin Cheng
e4267967a8 Support local_inner_macros 2020-05-01 11:23:03 +08:00
Aleksey Kladov
14126349be Kill more zombies 2020-04-30 22:58:26 +02:00
Jonas Schievink
3cb73da949 Rename to associated_type_shorthand_candidates 2020-04-30 00:10:30 +02:00
Jonas Schievink
8c2670026a Complete assoc. items on type parameters 2020-04-30 00:10:30 +02:00
bors[bot]
da1f316b02
Merge #4173
4173: Use core instead of std for builtin derive macros r=edwin0cheng a=edwin0cheng

Fixed #4087.

We can't use `$crate` here right now because : 

1. We have to able to detect `macro` 2.0 in collecting phase for finding `rustc_builtin_macro` attrs.
2. And we have to make hygiene works for builtin derive macro.

r= @flodiebold 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-27 20:12:27 +00:00
Edwin Cheng
6d3b0af900 Use empty-deps tricks to detect it is core 2020-04-28 03:32:47 +08:00
Edwin Cheng
213d208e2d Add test 2020-04-28 02:10:17 +08:00