diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-06-24 07:49:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-24 07:49:54 +0000 |
commit | 23815a535e1aaf89e256e1bb338f1bf8dcfa933c (patch) | |
tree | 29bd03a759ef63482d6770ccc02f18548949e820 | |
parent | e6b7d184d01f032efe5c41d5503945081c7a0aea (diff) | |
parent | 6e5468e256dd06eb6988a0eca37c86bc52722457 (diff) | |
parent | 67470f5d6697337808fd23061cc765173ed0825d (diff) | |
parent | 5d7841fa235cd53a807dae813d20f474362fb5c1 (diff) | |
download | gcc-23815a535e1aaf89e256e1bb338f1bf8dcfa933c.zip gcc-23815a535e1aaf89e256e1bb338f1bf8dcfa933c.tar.gz gcc-23815a535e1aaf89e256e1bb338f1bf8dcfa933c.tar.bz2 |
Merge #1327 #1329 #1330
1327: Lower const generics structures r=CohenArthur a=CohenArthur
This PR adds lowering for both the `ConstGenericParam` type and the `ConstGenericArg` one. Ideally, we should be able to avoid ambiguites (`let a: Foo<N>;` -> what is N? A type? A const?) by going through the name resolver, and resolve either to a different `AST::ConstGenericArg` either to a correct `AST::Type` or equivalent. So I think we can avoid doing the same "Ambiguous/Clear" dance in the `HIR::ConstGenericArg` type.
If that ends up not being possible, we can always add it and disambiguate during typechecking or other.
Closes #1318
1329: gccrs const folding port: start porting potential_constant_expression… r=CohenArthur a=abbasfaisal
Card: [Link](https://github.com/Rust-GCC/gccrs/projects/16#card-82300805).
Since [this](https://github.com/Rust-GCC/gccrs/blob/master/gcc/cp/constexpr.cc#L8350) is a huge function, we will start by porting chunks on which it depends as that would reduce the chance of missing something important and be easier to review.
This changeset ports over the below typedefs, structs and functions in addition to the macros:
Typedefs:
- [tsubst_flags_t](https://github.com/Rust-GCC/gccrs/blob/7eef766dc5a8abda2ca2cf8d535cdf160f40b50c/gcc/cp/cp-tree.h#L5533)
Structs:
- [lang_type](https://github.com/Rust-GCC/gccrs/blob/master/gcc/cp/cp-tree.h#L2300)
- [tree_pair_s](https://github.com/Rust-GCC/gccrs/blob/master/gcc/cp/cp-tree.h#L2281)
Functions:
- [cp_expr_loc_or_loc](https://github.com/Rust-GCC/gccrs/blob/master/gcc/cp/cp-tree.h#L8073)
- [cp_expr_loc_or_input_loc](https://github.com/Rust-GCC/gccrs/blob/master/gcc/cp/cp-tree.h#L8082)
- [cp_expr_location](https://github.com/Rust-GCC/gccrs/blob/master/gcc/cp/tree.cc#L6056)
- [is_really_empty_class](https://github.com/Rust-GCC/gccrs/blob/master/gcc/cp/class.cc#L8867)
- [is_empty_class](https://github.com/Rust-GCC/gccrs/blob/master/gcc/cp/class.cc#L8850)
- [array_type_nelts_top](https://github.com/Rust-GCC/gccrs/blob/master/gcc/cp/tree.cc#L3055)
I feel we do not need [is_really_empty_class](https://github.com/abbasfaisal/gccrs/blob/port-potential-const-expression-1-part-by-part/gcc/rust/backend/rust-tree.cc#L786) and [is_empty_class](https://github.com/abbasfaisal/gccrs/blob/port-potential-const-expression-1-part-by-part/gcc/rust/backend/rust-tree.cc#L827) as they are concerned with classes, record types and unions. The tree codes they surround come from [tree.def](https://github.com/Rust-GCC/gccrs/blob/master/gcc/tree.def). I think the class and record tree codes are not relevant to Rust. Feel free to say so and I will remove these functions or if you would like me to dig more into them.
1330: Add location to HIR::Type base class and improve privacy error reporting r=CohenArthur a=graphman65
Fix #1256
Adds location to the HIR::Type base class, removes it from all the subclasses and then use it in the `check_type_privacy` method to improve privacy error reporting.
The privacy error now looks like this (instead of what you can see in the example #1256).
```rust
gcc/testsuite/rust/compile/privacy5.rs:15:20: error: definition is private in this context
15 | fn any(a0: green::Foo, a1: green::Bar) {}
| ^
```
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Co-authored-by: Faisal Abbas <90.abbasfaisal@gmail.com>
Co-authored-by: Sebastien Lacoste <dev@graphman.fr>