Commit Graph

192771 Commits

Author SHA1 Message Date
liushuyu 82c045ecfe
CI: do not push Docker image ...
... when the workflow is ran in a forked repository

Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2022-04-18 03:41:07 -06:00
bors[bot] 27ad3813dc
Merge #1122
1122: testsuite/rust: fix test case failure on macOS r=CohenArthur a=liushuyu

- extent `macro_return` xfail targets to three-segment triples

Co-authored-by: liushuyu <liushuyu011@gmail.com>
2022-04-16 10:05:42 +00:00
bors[bot] e76b639955
Merge #1118
1118: Add reachability visitor to Enum variants r=CohenArthur a=CohenArthur

This visits all of an enum's variants and their fields if present. To do that properly, this adds a new `EnumItemKind` enum which allows static casting when visiting each variant of the enum (kept as an `EnumItem` class which is derived three times)

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-04-16 09:37:42 +00:00
liushuyu f5f11bef14
testsuite/rust: extent xfail targets 2022-04-15 21:01:23 -06:00
bors[bot] 042c875024
Merge #1107
1107: tests: Improve timeout handling r=philberty a=liushuyu

- add a 10-second timeout for individual compile test
- add a xfail test case to ensure the timeout mechanism is working 

Co-authored-by: liushuyu <liushuyu011@gmail.com>
2022-04-15 21:08:17 +00:00
bors[bot] d17e0aa769
Merge #1116
1116: Move `cfg!()` macro to builtins. Fixes #1039 r=CohenArthur a=antego

Fixes #1039

Hey team, I need help understanding why the test fails.

Compilation succeeds, all the existing tests pass. However the test that I've added fails with the error:
```
FAIL: rust/compile/cfg_macro.rs (test for excess errors)
Excess errors:
/Users/anton/Documents/projects/gcc2/gccrs/gcc/testsuite/rust/compile/cfg_macro.rs:17:8: fatal error: Failed to lower expr: [MacroInvocation: 
 outer attributes: none
 cfg!((A))
 has semicolon: false]
compilation terminated.
```
I tried to understand what's happening using a debugger. The only thing that I understood is that the `MacroBuiltin::cfg` function runs.

Appreciate any feedback.

Thank you. 

Co-authored-by: antego <antego@users.noreply.github.com>
2022-04-15 08:54:55 +00:00
antego a9c0649503 Move cfg!() macro to builtins
Fixes #1039
2022-04-15 07:31:32 +10:00
Arthur Cohen c4443ca3b2 privacy: reachability: Visit all variants of an Enum and their fields 2022-04-14 10:50:02 +02:00
Arthur Cohen 126f7aecdc hir: Add `EnumItemKind` enum for EnumItem classes 2022-04-14 10:49:19 +02:00
Arthur Cohen 71f2cd57c6 privacy: reachability: wip: Update all base reach levels 2022-04-14 10:01:41 +02:00
bors[bot] d36a3c5752
Merge #1110
1110: Add Reachability visitors for items with generics r=CohenArthur a=CohenArthur

This factors generics' predicates visiting in the `ReachabilityVisitor` and calls the function in other items with generic parameters

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-04-14 07:27:52 +00:00
bors[bot] 73e017f7cb
Merge #1113
1113: macros: Add env! macro r=CohenArthur a=omachota

Added the `env!()` macro and relevant test cases

Fixes: #977 

Signed-off-by: Ondřej Machota <ondrejmachota@gmail.com>

Co-authored-by: Ondřej Machota <ondrejmachota@gmail.com>
2022-04-14 06:56:37 +00:00
Ondřej Machota 1e6e427696 macros: Add env! macro
Signed-off-by: Ondřej Machota <ondrejmachota@gmail.com>
2022-04-13 23:24:53 +02:00
bors[bot] 60324125c3
Merge #1088
1088: rust-session-manager: better crate name handling logic r=philberty a=liushuyu

- rust-session-manager: set and validate crate name properly
- testsuite/rust: fix the testcases and add more testcases for testing crate name handling

Co-authored-by: liushuyu <liushuyu011@gmail.com>
2022-04-13 14:17:42 +00:00
Arthur Cohen ed904fefdd privacy: reachability: Add base visitor for items with generic params
Co-authored-by: philberty <philip.herron@embecosm.com>
2022-04-13 13:15:30 +02:00
Arthur Cohen cdfb5b34ac privacy: reachability: Cleanup Struct definition visitor 2022-04-13 13:15:10 +02:00
bors[bot] 497ee70b77
Merge #1111
1111: Add AST Private Visibilities r=CohenArthur a=CohenArthur

When parsing a visibility in `parse_visibility`, it is not an error to
not have a pub token: It simply means we want to create a private
visibility. If we had C++14 or another language, we could instead
represent all visibilities as an optional<AST::Visibility> where the
Visibility class would not need to change. But I think the best course
of action for our case is to instead keep visibilities even when they
are private and have a special case in the `VisKind` enumeration.

This also enables HIR lowering of visibilities to be performed properly for private items

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-04-13 10:41:12 +00:00
bors[bot] c1639be8bb
Merge #1114
1114: rust: Use -Otarget when building and logging warnings r=philberty a=simonpcook

This will provide some synchronization for output lines, and so will
make comparisons with known warnings as part of CI more reliable.



Co-authored-by: Simon Cook <simon.cook@embecosm.com>
2022-04-13 10:10:21 +00:00
liushuyu a125901c55
rust-session-manager: address more comments
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2022-04-13 02:30:46 -06:00
Arthur Cohen 03cb435c19 visibility: Add create_private() static function
When parsing a visibility in `parse_visibility`, it is not an error to
not have a pub token: It simply means we want to create a private
visibility. If we had C++14 or another language, we could instead
represent all visibilities as an optional<AST::Visibility> where the
Visibility class would not need to change. But I think the best course
of action for our case is to instead keep visibilities even when they
are private and have a special case in the `VisKind` enumeration.
2022-04-13 09:04:26 +02:00
bors[bot] a196568774
Merge #1112
1112: rust: Clang/macOS Testing r=philberty a=simonpcook

This adds a version of the build-and-check job that runs with clang on
macOS.

Co-authored-by: Simon Cook <simon.cook@embecosm.com>
2022-04-13 06:43:54 +00:00
Simon Cook addf65ddfa rust: Use -Otarget when building and logging warnings
This will provide some synchronization for output lines, and so will
make comparisons with known warnings as part of CI more reliable.
2022-04-13 08:34:30 +02:00
liushuyu 1a7391d97f rust-session-manager: address comments ...
... also more closely match rustc's behavior

Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2022-04-12 18:37:09 -06:00
liushuyu 28769ea0ab testsuite/rust: adapt/fix the testcases ...
... so that the tests will still pass after the crate name logic change

Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2022-04-12 18:34:54 -06:00
liushuyu f50e9a27b2 rust-session-manager: set and validate crate name properly ...
... should fix #789

Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2022-04-12 18:34:54 -06:00
Simon Cook 649f6640c6 rust: Clang/macOS Testing
This adds a version of the build-and-check job that runs with clang on
macOS.
2022-04-12 18:03:58 +02:00
bors[bot] e9ab95c088
Merge #1109
1109: rust: Allow gccrs to build on x86_64-apple-darwin with clang/libc++ r=CohenArthur a=simonpcook

This makes changes to the includes such that gccrs can be built with
clang/libc++, and for x86_64-apple-darwin. Similarly, a couple of
changes have been made to creating MacroInvocations and wrapping into
ExprOrStmts for libc++ compatibility.


Co-authored-by: Simon Cook <simon.cook@embecosm.com>
2022-04-12 15:04:30 +00:00
Simon Cook 1a3f38a2b0 rust: Allow gccrs to build on x86_64-apple-darwin with clang/libc++
This makes changes to the includes such that gccrs can be built with
clang/libc++, and for x86_64-apple-darwin. Similarly, a couple of
changes have been made to creating MacroInvocations and wrapping into
ExprOrStmts for libc++ compatibility.
2022-04-12 16:45:56 +02:00
bors[bot] 7430791e0f
Merge #1082
1082: Add base for privacy visitor r=CohenArthur a=CohenArthur

This PR is extremely early and implements some building blocks for privacy visitors. I'd like to get some feedback on the architecture and, if satisfactory, merge this first "visitor" which only takes care of visiting HIR struct definitions, to make reviewing easier. We could also merge it to a different branch for now, in order to not add an incomplete pass to the compiler.

Thanks!

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-04-12 14:32:53 +00:00
bors[bot] 2076e69bf9
Merge #1108
1108: Add missing unify rules for inference variables r=philberty a=philberty

Inference variables can unify with anything so this includes these
covariant types like references/slices etc. This patch is needed for more
complex type-checking in libcore and generics.


Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-04-12 14:03:11 +00:00
bors[bot] c494f30766
Merge #1106
1106: macros: fix an infinite loop in `concat!` macro parser r=CohenArthur a=liushuyu

- Fix concat macro parser issue which caused an infinite loop when invalid token is encountered


Co-authored-by: liushuyu <liushuyu011@gmail.com>
2022-04-12 13:28:28 +00:00
Arthur Cohen 1e5126022d privacy: reachability: Visit all types of a struct's public fields 2022-04-12 15:26:11 +02:00
Arthur Cohen 3058b55328 privacy: reachability: Visit all struct generic predicates 2022-04-12 15:26:11 +02:00
Arthur Cohen 415586f0e2 typectx: Mark lookup_type() method as const 2022-04-12 15:26:11 +02:00
Arthur Cohen ece3809c50 privacy: Keep DefIds in reachability map instead
This commit also specialized `std::hash<DefId>` to be able to use it as
key in {unordered_}maps
2022-04-12 15:26:11 +02:00
Arthur Cohen a376e1939e hir: Keep BaseKind enum inside the Node class
Co-authored-by: philberty <philip.herron@embecosm.com>
2022-04-12 15:26:11 +02:00
Arthur Cohen be8f2ead95 privacy: reachability: Add base for visiting struct definitions 2022-04-12 15:26:11 +02:00
Arthur Cohen d103151143 hir: StructField: Add `get_visibility()` method 2022-04-12 15:26:11 +02:00
Arthur Cohen 6db5c9fb19 privacy: reachability: Add better implementation for StructStruct 2022-04-12 15:26:08 +02:00
Arthur Cohen 3bb4d746a0 privacy: reachability: Add `maybe_get_vis_item` helper static function 2022-04-12 15:25:37 +02:00
Philip Herron 7609dfc63e Add missing unify rules for inference variables
Inference variables can unify with anything so this includes these
covariant types like references/slices etc. This patch is needed for more
complex type-checking in libcore and generics.
2022-04-12 13:49:30 +01:00
Arthur Cohen 23fc3ff7fe privacy: ctx: Add proper implementations for insert_reachability() and
lookup_reachability()

Inserting reach levels in the reachability_map should only be done if
the existing reach level is lower than the provided one. If the node is
not yet present in the reachability map, insert it no matter what
2022-04-12 14:26:23 +02:00
Arthur Cohen dfb5f548ce hir: Visibility: Add is_public() method 2022-04-12 14:26:23 +02:00
Arthur Cohen e01a814061 privacy: reach: Rename ReachLevel enum 2022-04-12 14:20:28 +02:00
Arthur Cohen 8bf037fede privacy: Add base for privacy-related visitors 2022-04-12 14:20:21 +02:00
Arthur Cohen 5449587438 hir: Add `Kind` enum to downcast safely 2022-04-12 14:20:18 +02:00
bors[bot] a5b38698aa
Merge #1103
1103: Lower AST::Visibility to HIR::Visibility properly r=CohenArthur a=CohenArthur

Fixes #1093

This should cover every case since the previous code simply created public HIR visibilities.

The PR refactors the HIR::Visibility struct to be tinier and a desugared version of the AST one.

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-04-12 10:47:17 +00:00
bors[bot] c1a022385f
Merge #1086
1086: Slice support r=philberty a=philberty

Please see the commit a8de089969cb45199008027cd8d1b80dff25746f for
a long explanation of what's going on in the patch. Unfortunately, I have not been
able to split this patch up anymore since supporting slices exposed many bugs
in the implementation of generics in general never main the missing support for
generic associated types.

Fixes #849 

Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-04-12 09:50:56 +00:00
liushuyu 2fe4048f7f
macros: fix an infinite loop ...
... introduced in fed5a41fb1, should fix #1102

Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2022-04-12 02:18:56 -06:00
liushuyu e909e4fc7b
testsuite/rust: add a xfail test case ...
... to show case the timeout system is working
2022-04-11 17:11:50 -06:00