Age | Commit message (Collapse) | Author | Files | Lines |
|
rustspec.cc was based on the Go frontend gospec.cc. Remove special
handling of math and pthread libraries and profiling option. Handle
.rs files instead of .go files. Keep support for linking with (static)
librust which is currently commented out. Add generic static-librust
option to common.opt.
|
|
TypeBounds are what make generics useful in Rust. They act in some ways
similar to interfaces in modern Java.
Fixes #583
|
|
Add Trait item mappings for trait resolving purposes. This allows us to
lookup the trait with a trait item belongs to and vice versa.
|
|
TyTy::Clone should be const to enforce compiler checks that we do not
change the object.
|
|
Resolve the type-bound to the trait.
|
|
Covariance was causing issues for the default clone on these classes. Such that the NodeId became messed up. This causes name resolution issues.
|
|
Preserve type-bounds into HIR for type resolution and code generation. This
follows the same style of classes in the AST and might need some tweaks
for where constraints.
|
|
|
|
605: Merge both module classes in one r=philberty a=CohenArthur
This PR merges both kinds of Modules (formerly `ModuleBodied` and `ModuleNoBody`) as one class with an enum. This is the [behavior used by rustc](https://github.com/rust-lang/rust/blob/2939249f294dd54a9ce78a8ee1f2922a44e7fb7c/compiler/rustc_ast/src/ast.rs#L2274), where both variants are kept in an enum with one holding a vector of items.
This change is important for multiple file parsing: An external mod (`mod foo; // defined in foo.rs or foo/mod.rs`) will see its items expanded during expansion, which occurs after parsing. This means that the previous directive will be "replaced" by `mod foo { <items> }` at the AST level. In order to achieve this, we need to be able to modify a previously parsed instance of an AST element.
In rustc, this is done [here](https://github.com/rust-lang/rust/blob/2939249f294dd54a9ce78a8ee1f2922a44e7fb7c/compiler/rustc_expand/src/expand.rs#L1427), where `mod_kind` was previously `ModKind::Unloaded` and becomes `ModKind::Loaded(parsed_items, ...)`.
Co-authored-by: CohenArthur <arthur.cohen@epita.fr>
|
|
606: Always check the result of expect_token while parsing r=dkm a=dkm
From Mark Wielaard : https://gcc.gnu.org/pipermail/gcc-rust/2021-August/000111.html
> When expect_token fails it produces an error and return a
> nullptr. Make sure to always check the result of expect_token so we
> don't use a nullptr token and crash.
>
> Resolves: https://github.com/Rust-GCC/gccrs/issues/603
Co-authored-by: Mark Wielaard <mark@klomp.org>
Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
|
|
|
|
When expect_token fails it produces an error and return a
nullptr. Make sure to always check the result of expect_token so we
don't use a nullptr token and crash.
Resolves: https://github.com/Rust-GCC/gccrs/issues/603
|
|
The backend was derived from the go backend which enables split stack
support by default. This inserts a __morestack call at the start of
each function. This is not needed for the rust backend. Remove the
split stack support code from the rust backend and spec.
|
|
|
|
|
|
|
|
|
|
|
|
602: Add locus to TupleField and pass it and union variants to HIR class r=philberty a=dkm
From Mark Wielaard : https://gcc.gnu.org/pipermail/gcc-rust/2021-August/000108.html
> TupleField was missing a Location field and we dropped to locus when
> lowering Union fields to HIR.
Co-authored-by: Mark Wielaard <mark@klomp.org>
|
|
We may then remove the '{ dg-options "-w" }' as discussed in
<http://mid.mail-archive.com/YQciMeKNpCH+ZMsJ@wildebeest.org> and #601.
|
|
TupleField was missing a Location field and we dropped to locus when
lowering Union fields to HIR.
|
|
Treat a union as a Struct variant like a tuple struct. Add an
iterator and get_identifier functions to the AST Union class. Same
for the HIR Union class, plus a get_generics_params method. Add a new
ADTKind enum and adt_kind field to the ADTType to select the
underlying abstract data type (struct struct, tuple struct or union,
with enum as possible future variant).
An union constructor can have only one field. Add an union_index field
to StructExprStruct which is set during type checking in the
TypeCheckStructExpr HIR StructExprStructFields visitor.
For the Gcc_backend class rename fill_in_struct to fill_in_fields and
use it from a new union_type method. Handle union_index in
constructor_expression (so only one field is initialized).
|
|
with block (parse_expr_with_block).
|
|
598: Hello world r=philberty a=philberty
```rust
extern "C" {
fn puts(s: *const i8);
}
fn main() {
unsafe {
let a = "Hello World\0";
let b = a as *const str;
let c = b as *const i8;
puts(c);
}
}
```
Fixes #421
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
Varadic functions are only allowed in extern functions as far as I know.
|
|
This adds extern block compilation support. It currently assumes the C abi
and does not perform any name mangling. It does not support varadic
arguments yet but its the initial support to get this working.
Fixes #421
|
|
|
|
|
|
|
|
|
|
This is the initial patch to do the ground work to support extern blocks.
Type resolution and Generic output still needs to be done to actually
support extern blocks.
Addresses #421
|
|
596: Fix crash when extern function item has no return type r=philberty a=philberty
Addresses #421
Fixes #595
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
Return types are optional in rust and extern fn items can be a ZST for the
result.
Addresses #421
Fixes #595
|
|
This gives us full explicit control for all casting. Just like other
rules. More test cases are needed to close out type-casts by the the end of
the traits milestone.
Fixes #592
|
|
|
|
This allows for type resolution for TypeCasts.
|
|
This adds name checking and lookups in side tables for the expression
and types involved in the compiler pipeline.
|
|
593: Support RangeFrom ([x..]) and RangeFromTo ([x..y]) in the parser r=philberty a=dkm
Parsing the .. (DOT_DOT) operator to get a range had two
issues. Trying to compile:
let block = [1,2,3,4,5];
let _rf = &block[1..];
let _rt = &block[..3];
let _rft = &block[2..4];
range.rs:4:23: error: found unexpected token ‘]’ in null denotation
4 | let _rf = &block[1..];
| ^
range.rs:4:24: error: expecting ‘]’ but ‘;’ found
4 | let _rf = &block[1..];
| ^
Since .. can represent either a range from or a range from-to it can
be followed by an expression or not. We do have a hack in our
pratt-parser so that it is allowed to return a nullptr. But even in
that case it will have swallowed the next token. Add another hack to
the pratt-parser so that if the next token is one that cannot start an
expression and the caller allows a nullptr return then don't skip the
token and return immediately.
After this patch we can parse the above range expressions, but we
still don't handle them fully:
range.rs:4:20: fatal error: Failed to lower expr: [1..]
4 | let _rf = &block[1..];
| ^
Ranges are actually syntactic sugar for std::ops::Range[From|To].
Co-authored-by: Mark Wielaard <mark@klomp.org>
|
|
Parsing the .. (DOT_DOT) operator to get a range had two
issues. Trying to compile:
let block = [1,2,3,4,5];
let _rf = &block[1..];
let _rt = &block[..3];
let _rft = &block[2..4];
range.rs:4:23: error: found unexpected token ‘]’ in null denotation
4 | let _rf = &block[1..];
| ^
range.rs:4:24: error: expecting ‘]’ but ‘;’ found
4 | let _rf = &block[1..];
| ^
Since .. can represent either a range from or a range from-to it can
be followed by an expression or not. We do have a hack in our
pratt-parser so that it is allowed to return a nullptr. But even in
that case it will have swallowed the next token. Add another hack to
the pratt-parser so that if the next token is one that cannot start an
expression and the caller allows a nullptr return then don't skip the
token and return immediately.
After this patch we can parse the above range expressions, but we
still don't handle them fully:
range.rs:4:20: fatal error: Failed to lower expr: [1..]
4 | let _rf = &block[1..];
| ^
Ranges are actually syntactic sugar for std::ops::Range[From|To].
|
|
A byte literal is an u8 created as a ascii char or hex escape
e.g. b'X'. A byte string literal is a string created from ascii or
hex chars. bytes are represented as u8 and byte strings as str (with
just ascii < 256 chars), but it should really be &'static [u8; n].
|
|
591: Remove error handling in parse_type_no_bounds for PLUS token r=philberty a=philberty
parse_type_no_bounds tries to be helpful and greedily looks for a PLUS
token after having parsed a typepath so it can produce an error. But
that error breaks parsing expressions that contain "as" Cast
Expressions like "a as usize + b as usize". Drop the explicit error on
seeing a PLUS token and just return the type path parsed.
Co-authored-by: Mark Wielaard <mark@klomp.org>
|
|
parse_type_no_bounds tries to be helpful and greedily looks for a PLUS
token after having parsed a typepath so it can produce an error. But
that error breaks parsing expressions that contain "as" Cast
Expressions like "a as usize + b as usize". Drop the explicit error on
seeing a PLUS token and just return the type path parsed.
|
|
union is a weak keyword which means it isn't reserved and can be used
as a generic identifier. When we see an identifier where a union could
be declared we check whether the identifier is "union", but only when
the next token is also an identifier. In parse_union we shouldn't skip
the first identifier token, because it is already skipped when we call
expect_token.
|
|
587: Add testcase to cover parse errors in unsafe expressions r=philberty a=philberty
Fixes #584
589: Support dereference of pointers r=philberty a=philberty
Dereference expressions can also be pointer types not just references.
Fixes #588
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
585: Add iterate impl_blocks helper r=philberty a=philberty
This helper will allow use to use mappings to iterate
all impl blocks within the specified crate.
586: Add mappings for trait items r=philberty a=philberty
Add mappings for trait items that can be used for
query-based compilation and type checking
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
Dereference expressions can also be pointer types not just references.
Fixes #588
|
|
We had a bug in the parser with unsafe expression this adds a test case to
cover the parser issue.
Fixes #584
|
|
|
|
To use an unsafe block expression handle it in null_denotation for the
pratt parser. Adjust parse_unsafe_block_expr to take a pratt_parse
bool that defaults to false.
|
|
|