Age | Commit message (Collapse) | Author | Files | Lines |
|
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.
|
|
|
|
579: Raw pointer support r=philberty a=philberty
We will need to add the remaining coercion calls for the relevant sites
to get the full support we need but this will serve as the initial support.
Fixes #124
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
581: HIR and GENERIC lowering for unsafe blocks r=philberty a=philberty
This wires up the code nessecary to compile an unsafe block
it does not implement any rules or checks yet.
Fixes #382
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
This does not implement the rules for unsafe this wires up the code so we
can compile unsafe blocks. No checks are being performed on the code yet.
Fixes #382
|
|
This adds the initial support for raw pointers. Pointers rely on coercion
rules to be able to coerce the raw fat pointers from a borrow expression
into a normal raw pointer.
Fixes #124
|
|
This was part of basing the rust front-end off the gccgo and this was a dup
of rust-object-export.c.
|
|
This implements the reference mutability coercion rules, where the base
types must be compatible and the base can turn a mutable reference into
a constant one.
Address #434
Fixes #576
|
|
Lets keep the same unify pattern for coercion rules to keep the code as
readable as possible.
Addresses #434
|
|
|
|
We need to track mutability on Reference Types and check wether they
actually match up.
Addresses #576
|
|
Refs refers to the reference chain used in the type checking resolution of
this type. We use to eagerly replace the Inference Vars when they unify or
are coerced or default.
Fixes #352
|
|
When we are trying to check for possible equivalence such as a simple
generic function against a substituted one we do not and should not require
mutability. This enforces some code tidy up by providing a const visitor
pattern for types.
|
|
If we keep track of the impl blocks within the crate's we can use this
as another way to stream line looking up of specific HIR::Items. This
will be used to find possible bounds for a receiver in a path probe.
|
|
This change keeps an enum for the candidate type and the parent impl block
this probed candidate originates from.
|
|
|
|
568: Add missing DefId mappings r=philberty a=philberty
DefIds need to be managed for fntypes which will help in the compilation
of optional traitt functions
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
569: Some trait items are optional and should not cause an error r=philberty a=philberty
When a trait item is optional this is not a missing trait item.
570: Add missing test case to close out unit-structs r=philberty a=philberty
This test case will catch regressions in changes to initializing unit structs.
Fixes #155
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
Unit structs can be initilized in two ways this test case will cover
future updates to catch any regressions.
Fixes #155
|
|
Some trait items can be optional such as constants with an expression or
functions with a body. This change only warns when there are non optional
items missing.
|
|
This adds the def id to trait items and nested items, this will help with
optional trait item compilation.
|
|
|
|
This adds DefId mappings for impl items, this is a building block where
the TyTy::FnType will include the DefId of the respective function, which
will simplify the backend a bit in relation to optional trait functions
with a body.
|
|
566: Further error checking for trait impl blocks r=philberty a=philberty
This PR introduces enhanced type checking for trait constants
and associated types. It also brings in the check to ensure all
mandatory trait items are implemented. Note optional trait items
cannot be referenced or used yet and will be done in a separate PR.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
If an impl block does not implement all trait-items it is an error. This
also takes into account that functions and constants may actually have
values and may not need to be implemented by the impl block.
Addresses #542
|