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
|
|
599: Fix assertion for trait item mappings r=philberty a=philberty
These assertions defend against duplicate/bad mappings
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
|
|
|
|
|
|
|
|
597: Add name-resolution and HIR lowering for extern blocks r=philberty a=philberty
Addresses #421
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
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
|
|
592: TypeCastExpr r=philberty a=philberty
This is the initial type casting rules more test cases will be added over time. To find gaps.
Fixes #158
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Co-authored-by: Mark Wielaard <mark@klomp.org>
|
|
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>
|
|
594: Support byte and byte string literals r=philberty a=dkm
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].
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.
|
|
590: Better union support in the parser r=philberty a=philberty
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.
Co-authored-by: Mark Wielaard <mark@klomp.org>
|
|
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
|
|
|
|
582: unsafe blocks can be used in expressions r=philberty a=philberty
This fixes an issue to allow unsafe within an expression.
Co-authored-by: Mark Wielaard <mark@klomp.org>
|
|
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
|
|
578: Remove unused code r=philberty a=philberty
Remove unused code
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
This was part of basing the rust front-end off the gccgo and this was a dup
of rust-object-export.c.
|
|
577: Initial type coercion code r=philberty a=philberty
This is the initial type coercion code. Coercions are necessary to implement
mutability on reference types and for raw pointers in general.
Fixes #576 #352
Addresses #434
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
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
|
|
572: Cleanup and add const modifiers to equlity interface r=philberty a=philberty
As part of an effort to cleanup some of the interfaces within the TyTy module
this PR adds a const visitor for accessing each type and updates the can_eq
interface to also be const as it should not require mutability.
These changes fell out of a branch for optional trait items support.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
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.
|
|
571: call accept_vis directly instead of call it after get r=philberty a=thomasyonug
call accept_vis directly instead of calling it after get().
Co-authored-by: Thomas Young <wenzhang5800@gmail.com>
|