Commit Graph

492 Commits

Author SHA1 Message Date
Cameron Steffen
ec82bc1996 Factor out hir::Node::Binding 2022-07-01 10:04:19 -05:00
Nicholas Nethercote
7c40661ddb Update smallvec to 1.8.1.
This pulls in https://github.com/servo/rust-smallvec/pull/282, which
gives some small wins for rustc.
2022-06-27 08:48:55 +10:00
Camille GILLOT
7437136f0e Use CreateParameter mode for closures too. 2022-06-21 21:13:43 +02:00
Camille GILLOT
32af719b07 Always create parameters for functions-like types. 2022-06-21 21:13:41 +02:00
Camille GILLOT
bc6a2c11ee Leave the responsibility to create Fresh lifetimes to lowering. 2022-06-19 22:32:43 +02:00
bors
3a8b0144c8 Auto merge of #98106 - cjgillot:split-definitions, r=michaelwoerister
Split up `Definitions` and `ResolverAstLowering`.

Split off https://github.com/rust-lang/rust/pull/95573

r? `@michaelwoerister`
2022-06-17 10:00:11 +00:00
Yuki Okushi
bfc6c90115
Rollup merge of #98119 - EdwinRy:path-parenthesized-type-error, r=estebank
Refactor path segment parameter error

This PR attempts to rewrite the error handling for an unexpected parenthesised type parameters to:
- Use provided data instead of re-parsing the whole span
- Add a multipart suggestion to reflect on the changes with an underline
- Remove the unnecessary "if" nesting
2022-06-16 07:24:43 +09:00
Camille GILLOT
ae5959f4ba Consume resolutions for lowering separately. 2022-06-15 19:42:43 +02:00
Camille GILLOT
8ffbd814af Update next_node_id. 2022-06-15 19:41:41 +02:00
Yuki Okushi
87e373e82f
Rollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011
Make `ExprKind::Closure` a struct variant.

Simple refactor since we both need it to introduce additional fields in `ExprKind::Closure`.

r? ``@Aaron1011``
2022-06-15 19:37:14 +09:00
EdwinRy
71a98e1a4e Refactor path segment parameter error 2022-06-15 02:50:34 +01:00
EdwinRy
c8b411ebf1 rename function and remove return type 2022-06-15 01:06:40 +01:00
Camille GILLOT
34e4d72929 Separate source_span and expn_that_defined from Definitions. 2022-06-14 22:45:51 +02:00
Camille GILLOT
b676edd641 Do not modify the resolver outputs. 2022-06-14 22:44:27 +02:00
Camille GILLOT
603746a35e Make ResolverAstLowering a struct. 2022-06-14 22:44:27 +02:00
Takayuki Maeda
77d6176e69 remove unnecessary to_string and String::new 2022-06-13 15:48:40 +09:00
Michael Goulet
5f7474e6dc Address comments 2022-06-11 16:38:48 -07:00
Michael Goulet
9c47afe9fa Handle empty where-clause better 2022-06-11 16:27:01 -07:00
Camille GILLOT
3039cfeb6a Make ExprKind::Closure a struct variant. 2022-06-12 00:16:27 +02:00
Santiago Pastorino
4ae69f8617
Extract lower_generic_and_bounds function 2022-06-07 18:29:07 -03:00
Santiago Pastorino
1e6ed67d37
Extract lower_generic_param_kind 2022-06-07 18:29:07 -03:00
Santiago Pastorino
a22aad32eb
Instrument important fns in AST lowering 2022-06-07 18:29:06 -03:00
Camille GILLOT
a07290047e Compute lifetimes in scope at diagnostic time. 2022-06-04 15:28:15 +02:00
bors
c3384ea35c Auto merge of #97717 - matthiaskrgr:rollup-lalaii2, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #97446 (Make hir().get_generics and generics_of consistent.)
 - #97656 (Add a suggestion to replace parentheses with angle brackets on associated trait constraint)
 - #97692 (Add `#T-types/nominated` zulip notification)
 - #97696 (Do not ICE when failing to normalize during inlining.)
 - #97702 (Remove useless LocalDefId in ImplTraitContext::Universal.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-04 02:10:35 +00:00
bors
f15370b4e4 Auto merge of #97670 - spastorino:simplify-universal-impl-trait-lowering2, r=Dylan-DPC
Make params be SmallVec as originally was

r? `@cjgillot`
It was originally a [`SmallVec`](https://github.com/rust-lang/rust/pull/97598/files#diff-0a61b538a3cec072c76fecae4635af6a12ec3256860029ac70549c2aa53ab394L1497), I've mistakenly changed it [here](https://github.com/rust-lang/rust/pull/97598/files#diff-0a61b538a3cec072c76fecae4635af6a12ec3256860029ac70549c2aa53ab394R1377) to a `Vec`
2022-06-03 23:29:30 +00:00
Matthias Krüger
a88d94b072
Rollup merge of #97702 - cjgillot:no-universal-did, r=spastorino
Remove useless LocalDefId in ImplTraitContext::Universal.
2022-06-04 00:42:52 +02:00
Matthias Krüger
401be78f2c
Rollup merge of #97656 - EdwinRy:error_ast_low_type_contraint_parentheses, r=cjgillot
Add a suggestion to replace parentheses with angle brackets on associated trait constraint

This implements a requested suggestion FIXME in [`compiler/rustc_ast_lowering/src/lib.rs` ](9598b4b594/compiler/rustc_ast_lowering/src/lib.rs (L921))

The suggestion asks for the parentheses to either be replaced with angle brackets or removed completely depending on whether there are arguments provided within.

![image](https://user-images.githubusercontent.com/20026256/171770414-ab60bfe2-ae27-44b0-964d-9ffcc32a7475.png)

![image](https://user-images.githubusercontent.com/20026256/171770383-ca8a2766-b3aa-43e3-8ba4-ae18874886ce.png)

r? `@oli-obk`
2022-06-04 00:42:50 +02:00
Camille GILLOT
4120080d66 Remove useless LocalDefId in ImplTraitContext::Universal. 2022-06-03 20:17:12 +02:00
EdwinRy
cd03fe18d8 Suggest replace parentheses with angle brackets 2022-06-03 16:48:59 +01:00
Camille GILLOT
b1294e86bb Manipulate lifetimes by LocalDefId for region resolution. 2022-06-03 12:03:20 +02:00
bors
3a90bedb33 Auto merge of #96296 - cjgillot:remove-label-lt-shadow, r=petrochenkov
Remove label/lifetime shadowing warnings

This PR removes some pre-1.0 shadowing warnings for labels and lifetimes.

The current behaviour of the compiler is to warn
* labels that shadow unrelated labels in the same function --> removed
```rust
'a: loop {}
'a: loop {} // STOP WARNING
```

* labels that shadow enclosing labels --> kept, but only if shadowing is hygienic
```rust
'a: loop {
  'a: loop {} // KEEP WARNING
}
```

* labels that shadow lifetime --> removed
```rust
fn foo<'a>() {
  'a: loop {} // STOP WARNING
}
```

* lifetimes that shadow labels --> removed
```rust
'a: loop {
  let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>; // STOP WARNING
}
```

* lifetimes that shadow lifetimes --> kept
```rust
fn foo<'a>() {
  let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>; // KEEP WARNING
}
```

Closes https://github.com/rust-lang/rust/issues/31745.

-----

From `@petrochenkov` in https://github.com/rust-lang/rust/pull/95781#issuecomment-1105199014
> I think we should remove these silly checks entirely.
> They were introduced long time ago in case some new language features appear and require this space.
> Now we have another mechanism for such language changes - editions, and if "lifetimes in expressions" or something like that needs to be introduced it could be introduced as an edition change.
> However, there was no plans to introduce anything like for years, so it's unlikely that even the edition mechanism will be necessary.

r? rust-lang/lang
2022-06-03 07:27:09 +00:00
Camille GILLOT
c75409d5e4 Do not lower generic lifetime params when AST resolution emitted an error. 2022-06-03 08:26:10 +02:00
Santiago Pastorino
b051fcaefe
Make params be SmallVec as originally was 2022-06-02 23:42:49 -03:00
bors
42bcd41d4d Auto merge of #97598 - spastorino:simplify-universal-impl-trait-lowering, r=cjgillot
Simplify universal impl trait lowering

Closes #96644

r? `@cjgillot`
2022-06-02 21:37:38 +00:00
Santiago Pastorino
15a82d6917
Always assert that impl_trait_def|bounds are empty at start 2022-06-01 15:38:37 -03:00
Santiago Pastorino
67deaf9fea
instrument lower_fn_decl 2022-06-01 15:02:15 -03:00
Santiago Pastorino
2de2520e94
Split extend + inner chain into to extend calls 2022-06-01 14:48:14 -03:00
Santiago Pastorino
b3bc438f56
Add debug_assert comment
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2022-06-01 14:43:16 -03:00
est31
0a24b9493b Remove #[rustc_box] attr during lowering 2022-06-01 02:44:12 +02:00
est31
cfc21deebd Add #[rustc_box]
This commit adds an alternative content boxing syntax,
and uses it inside alloc.

The usage inside the very performance relevant code in
liballoc is the only remaining relevant usage of box syntax
in the compiler (outside of tests, which are comparatively
easy to port).

box syntax was originally designed to be used by all Rust
developers. This introduces a replacement syntax more tailored
to only being used inside the Rust compiler, and with it,
lays the groundwork for eventually removing box syntax.
2022-06-01 02:28:34 +02:00
Santiago Pastorino
15f2b119b1
Fix lower_generics rustdocs 2022-05-31 17:40:50 -03:00
Santiago Pastorino
2ade55d908
Inline lower_generics_mut and remove GenericsCtor 2022-05-31 16:57:16 -03:00
Santiago Pastorino
d327db9319
Remove ImplTraitContext::reborrow 2022-05-31 16:49:27 -03:00
Santiago Pastorino
208ffbbe86
derive Copy, Clone, PartialEq, Eq for ImplTraitContext 2022-05-31 16:47:53 -03:00
Santiago Pastorino
bd3a097d64
Move lower_generics definition to item.rs 2022-05-31 15:33:51 -03:00
Santiago Pastorino
d5ab8b2f5b
Rename add_implicit_generics to lower_generics 2022-05-31 15:32:05 -03:00
Santiago Pastorino
e080298e35
Replace calls to lower_generics with calls to add_implicit_generics 2022-05-31 15:30:14 -03:00
Santiago Pastorino
190b4a7152
Add itctx: ImplTraitContext arg to add_implicit_generics 2022-05-31 14:55:49 -03:00
Santiago Pastorino
1a71103c93
Take and restore fields in with_hir_id_owner calls 2022-05-31 14:53:32 -03:00
Santiago Pastorino
3d6eae8cd2
Move defs and bounds from Universal to LoweringContext 2022-05-31 12:40:34 -03:00