Age | Commit message (Collapse) | Author | Files | Lines |
|
We still have bugs handling unit-structs but this allows for Tuple Structs
and normal named field structs to be declared within a block and referenced
lexically. This allows rust statements to follow the correct grammar.
Fixes #519
|
|
518: Token strings r=philberty a=tromey
This series implements a couple of small changes to improve the handling
of strings attached to Token.
Co-authored-by: Tom Tromey <tom@tromey.com>
|
|
RAIIFile's implementation of operator= can leak a file, because it
doesn't handle the case where the assignee holds an open file handle.
|
|
This avoids some string copies by changing the Token constructors to
require any std::string argument to be transferred via std::move.
|
|
Token currently uses a "std::string *". There's a comment proposing
that perhaps this should be changed; but meanwhile, it's slightly
cleaner to use unique_ptr rather than have Token manage the string's
lifetime manually.
|
|
514: Rename tuple field names r=philberty a=tromey
Tuples currently use plain integer field names in the DWARF. However,
rustc prefixes these with "__", and GDB understands this convention.
This patch changes gccrs to match, and adds an explanatory comment.
Co-authored-by: Tom Tromey <tom@tromey.com>
|
|
Tuples currently use plain integer field names in the DWARF. However,
rustc prefixes these with "__", and GDB understands this convention.
This patch changes gccrs to match, and adds an explanatory comment.
|
|
Fix warnings mainly coming from ` being used instead of %< and %>.
Also fixing occurences of :
../../gcc/rust/lex/rust-token.cc:126:40: warning: unquoted sequence of 2 consecutive punctuation characters ‘',’ in format [-Wformat-diag]
126 | "attempted to get string for '%s', which has no string. "
| ^~
../../gcc/rust/lex/rust-token.cc:127:39: warning: spurious trailing punctuation sequence ‘.’ in format [-Wformat-diag]
127 | "returning empty string instead.",
| ^
../../gcc/rust/lex/rust-token.cc:126:37: warning: unterminated quote character ‘'’ in format [-Wformat-diag]
126 | "attempted to get string for '%s', which has no string. "
| ^
and various occurences of :
../../gcc/rust/lex/rust-lex.cc:1326:11: warning: unquoted keyword ‘char’ in format [-Wformat-diag]
1326 | "byte char %<%c%> out of range", byte_char);
| ^~~~
Also using full word for arguments, integer, character, declaration, variable,
floting-point instead of args, int, char, decl, var, float when applicable.
|
|
Mark Wielaard pointed out that the i8u8.rs test that I recently
introduced has a bug: it checks the DW_AT_language attribute, not
DW_AT_encoding.
Sorry about this.
This patch fixes this problem. I've verified that this notices the
failure after temporarily backing out the corresponding GCC change.
This patch also fixes another problem that he found, namely that it's
possible for these tests to find the wrong answer, because the hex
value that is checked for might be a prefix of some longer value.
This patch also adds a whitespace check to avoid this potential
problem.
|
|
506: Fix: do not use object after it has been moved r=philberty a=dkm
After std::move(mapping), mapping is unspecified
<!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE IT
Thank you for making Rust GCC better!
If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.
Here is a checklist to help you with your PR.
- \[ ] GCC code require copyright assignment: https://gcc.gnu.org/contribute.html
- \[ ] Read contributing guidlines
- \[ ] `make check-rust` passes locally
- \[ ] Run `clang-format`
- \[ ] Added any relevant test cases to `gcc/testsuite/rust/`
Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
---
-->
507: Add more info in HIR dump for struct r=philberty a=dkm
Make struct fields more visible in dumps and add the mapping in the dump string.
<!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE IT
Thank you for making Rust GCC better!
If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.
Here is a checklist to help you with your PR.
- \[ ] GCC code require copyright assignment: https://gcc.gnu.org/contribute.html
- \[ ] Read contributing guidlines
- \[ ] `make check-rust` passes locally
- \[ ] Run `clang-format`
- \[ ] Added any relevant test cases to `gcc/testsuite/rust/`
Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
---
-->
508: Make 3 error messages slightly more informational r=philberty a=dkm
Add more context to some internal error messages (ie. not intended for user)
<!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE IT
Thank you for making Rust GCC better!
If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.
Here is a checklist to help you with your PR.
- \[ ] GCC code require copyright assignment: https://gcc.gnu.org/contribute.html
- \[ ] Read contributing guidlines
- \[ ] `make check-rust` passes locally
- \[ ] Run `clang-format`
- \[ ] Added any relevant test cases to `gcc/testsuite/rust/`
Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
---
-->
Co-authored-by: Marc Poulhiès <dkm@kataplop.net>
|
|
Make struct fields more visible in dumps and add the mapping in the dump string.
|
|
Add more context to some internal error messages (ie. not intended for user)
|
|
After std::move(mapping), mapping is unspecified
|
|
The Rust 'char' type should use the DWARF DW_ATE_UTF encoding.
|
|
Currently, the i8 and u8 types use the DWARF character encoding, like:
<1><113>: Abbrev Number: 3 (DW_TAG_base_type)
<114> DW_AT_byte_size : 1
<115> DW_AT_encoding : 8 (unsigned char)
<116> DW_AT_name : u8
This happens because gccrs uses signed_char_type_node and
unsigned_char_type_node for i8 and u8, respectively.
This patch fixes this problem by arranging to use a custom integer
type instead. Another option is to clear TYPE_STRING_FLAG on these
types, but it was unclear to me whether this would impact other parts
of GCC.
|
|
This changes the GCC DWARF emitterto use DW_LANG_Rust or
DW_LANG_Rust_old as appropriate.
|
|
This adds a macro wrapper over rust_debug_loc to inject a default location
so calls can maintain printf specifier checks.
|
|
|
|
498: Remove HIR::TraitItemMethod, this can be represented by TraitItemFunction r=philberty a=philberty
Canonicalizing the paths of the compiler to treat functions and methods
the same way will ensure we avoid duplication.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
Methods are simply functions with a self param, this simplifies the paths
in HIR to avoid duplication as much as possible.
|
|
497: Avoid abort macro override the abort of std r=philberty a=thomasyonug
Fixing the build issue in macos by avoiding abort macro override the abort call of std.
Co-authored-by: Thomas Young <wenzhang5800@gmail.com>
|
|
|
|
496: TraitImpl blocks have a different CanonicalPath to normal impl blocks r=philberty a=philberty
TraitImpls have a canonical path which is a trait projection such as
```rust
pub trait Trait { // ::a::Trait
fn f(&self); // ::a::Trait::f
}
impl Trait for Struct {
fn f(&self) {} // <::a::Struct as ::a::Trait>::f
}
```
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
TraitImpls have a canonical path which is a trait projection such as
```rust
pub trait Trait { // ::a::Trait
fn f(&self); // ::a::Trait::f
}
impl Trait for Struct {
fn f(&self) {} // <::a::Struct as ::a::Trait>::f
}
```
|
|
This refactors Type HIR lowering to extract TypePath AST -> HIR lowering
function, as Trait References are simply TypePaths.
|
|
This folds the abstract Impl class directly into HIR::ImplBlock since the
TraitImplBlock is removed. It also refactors InherentImplItem to become
simply ImplItem.
|
|
HIR should desugar the AST as best it can. Trait impl blocks are just impl
blocks. The HIR impl block can just have an optional<TraitRef> in order to
represent a trait impl block.
|
|
|
|
492: HIR should not contain any macros r=philberty a=philberty
This removes the macros tree's from HIR. HIR should be an expanded and
simplifed representation of the compilation unit.
Fixes #70
493: Path resolution fixes r=philberty a=philberty
In order to support Modules, we need to do path resolution properly. The old code assumed a basic A::B but this is not generic enough in order to support modules.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
In order to support modules the path expression will fail here since a
module is not a value and does not have a TyTy type, so this is ok to
continue the rest of resolution so long as there are more segments.
Addresses: #432
|
|
There are cases where the name resolver can fully resolve a path such as:
```rust
struct Foo(i32);
impl Foo{
fn new() { ... }
}
fn main() {
let a;
a = Foo::new();
}
```
This case does not require a PathProbe. This enhances the Path resolution
to iterate each segment untill we are unable to resolve the root segment
at that point we can fall back to a PathProbe and lookup any impl item that
might satisfy the path instead.
Addresses #432
|
|
Name resolution tried to greedily resolve the entire CanonicalPath in one
lookup which was ok for simple paths like A::B. This changes the name
resolver to resolve each segment which allows the type resolution to
determine the root path to be up until the segment is unresolved which
will then require a PathProbe or its a failure. This will be required to
support modules which extend the resolution to be much more generic than
is assumed here.
Addresses: #432
|
|
This removes the macros tree's from HIR. HIR should be an expanded and
simplifed representation of the compilation unit.
Fixes #70
|
|
|
|
|
|
484: Trait impls and initial start of traits work r=philberty a=philberty
This does not start enforcing anything to do with traits. in order to
implement the traits milestone we need to be able to implement a
trait first.
This makes the Trait impls follow a normal impl block. As the starting
point.
Fixes #395 #472
485: All toplevel items must respect the prefix for their path r=philberty a=philberty
The commit message has a more detailed explanation as to why.
But some toplevel items were not respecting their prefix which is
important for module support.
486: Use PRIx64 to print 64bit hex values in legacy_hash r=philberty a=philberty
* gcc/rust/backend/rust-compile.cc (legacy_hash): lo and hi are uint64_t use
PRIx64 to print them as hex values instead of %lx which is target specific.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Co-authored-by: Mark Wielaard <mark@klomp.org>
|
|
* gcc/rust/backend/rust-compile.cc (legacy_hash): lo and hi are uint64_t use
PRIx64 to print them as hex values instead of %lx which is target specific.
|
|
Name resolution is split into two parts, one for the toplevel canonical
paths and then a second to actually drill down into new scopes for blocks
for example.
Consider a rust program:
```rust
fn foo() -> bar { ... }
struct bar(..);
```
In that example the function foo references bar which is declared later on.
The compiler is partly query based in that we use ids to get away from
looking up things via strings as quickly as possible.
The toplevel scan follows the rust documentation over on:
This assigns canonical names for all toplevel items but ignore the details
like return types, or body.
So the name resolver ends up with:
::foo
::bar
Then we can drill down into foo and check the return type and see that
::bar is already defined.
The prefix is important for the case of modules for example. This should
be a toplevel scan within the same scope.
Addresses: #432
|
|
We can compile TraitImpls, since before we can actually start checking
trait obligations we need to be able to implement the trait first.
More desugaring is needed in HIR to make TraitImpls contain normal impl
items to avoid seperation in how impl blocks are handled.
Fixes #395 #472
|
|
This will change to desugar trait-impls to be just like a normal impl block
later on. This will simplify things for method resolution. This is the
initial building block so we can move forward and refactor as the
trait resolution evolves.
Addresses #395 #472
|
|
We need to add name resolution for traits and trait impls. We cannot start
working with trait obligations untill we can actually implment a basic trait first.
Addresses: #395
|
|
NodeMappings are used to map HIR items into the type system and back to
NodeIds as part of name Resolution. LocalDefId signify local crate
defintions and DefId are cratenum + localdefids for cross crate
definitions.
Addresses: #395
|
|
NodeIds are ids to map back to the AST from HIR. This is the building block
to begin name resolution for traits.
Addresses #395
|
|
482: arm: Override TARGET_RUST_OS_INFO in bpabi.h r=tschwinge a=glaubitz
Similar to PowerPC, 32-bit ARM has the issue that TARGET_RUST_OS_INFO
is defined in two separate headers, namely config/arm/bpabi.h and
config/arm/linux-elf.h. We can apply the same fix that was already
used for PowerPC.
gcc/ChangeLog:
2021-06-04 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
* config/arm/bpabi.h: Undefine TARGET_RUST_OS_INFO before
defining it.
Co-authored-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
|
|
Similar to PowerPC, 32-bit ARM has the issue that TARGET_RUST_OS_INFO
is defined in two separate headers, namely config/arm/bpabi.h and
config/arm/linux-elf.h. We can apply the same fix that was already
used for PowerPC.
gcc/ChangeLog:
2021-06-04 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
* config/arm/bpabi.h: Undefine TARGET_RUST_OS_INFO before
defining it.
|
|
... as discussed in #479, and elsewhere.
|
|
This is no longer necessary after #466 "Expose rust debug and use it", where
commit 665df329a2ad60580ab593f6cbd646aa55927a37 "rust_debug: Replace fprintf
(stderr) with rust_debug" turned all 'fprintf' to 'stderr' into standard GCC
'inform' ('note: [...]') diagnostics -- which do get pruned by default.
Adjust the testsuite: instead of 'dg-excess-errors', spell out the additional
diagnostics now seen.
|
|
466: Expose rust debug and use it r=tschwinge a=CohenArthur
Fixes #464
@philberty I've checked and rust_debug does output on stderr correctly :)
This PR exposes the rust_debug prototype and replaces debug printfs (`fprintf (stderr, ...)`) with calls to rust_debug. This also removes the extra newlines that were added at the end of the fprintf format strings, since calling rust_debug already adds one. Without this, the tests fail due to blank lines in the output.
I have used a template to overload the rust_debug function and pass variadic arguments to the complete version. While the code looks cleaner than using `va_args`, it's also heavier C++. I'm open to changing it and definitely not attached to this implementation.
Most of the PR was made using sed and then clang-format
Co-authored-by: CohenArthur <arthur.cohen@epita.fr>
|
|
Co-authored-by: tschwinge <thomas@schwinge.name>
|
|
Co-authored-by: tschwinge <thomas@schwinge.name>
|