Age | Commit message (Collapse) | Author | Files | Lines |
|
With the type system we can check for equality explicitly which is useful.
When it comes to TypeParameters or Placeholders can_eq allows for:
fn bla<T>() -> <T>
fn bla() -> i32
The type parameter can be subsituted which means the generic function can
equal the subsituted one if it was given the right substituion arguments.
This can emit errors such as expected [X] got [Y] or we might want to
have silent errors so we can filter impl items such as the impl item
overlapping pass
|
|
This is used in Traits with associated types that can contain TypeBounds
but provides an ability to reuse out type system to check that trait items
are compatible with their respective ImplBlock Items
|
|
This adds the associated NodeId into each CanonicalPath segment which
references their respective TypePathSegment or PathExprSegment.
|
|
TypeAliases can be contained within ImplBlocks and need their full
canonical path to be resolved.
|
|
This lowers TypeAliases into ImplItem for HIR::ImplBlocks.
|
|
When we translate AST::InherentImplItems or AST::TraitImplItem's these get
lowered into a generic ImplBlock with ImplItems these must be non null.
TraitImpl blocks can contains associated types but normal InherentImpl's
do not this unifies the path to turn both into an HIR::ImplBlock
|
|
|
|
|
|
|
|
|
|
548: Fix bad naming of primitive types such as u64 which ended up as usize r=philberty a=philberty
In #547 it was found that u64's ended up as usize in gimple which confuses
debugging sessions. This take the original implementation of named type
from gccgo showing it was the TYPE_NAME tree getting confused.
Addresses #547
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
|
|
The lexer deals with the UTF-8 BOM and the parser cannot detect
whether there is or isn't a BOM at the start of a file. The flag isn't
relevant or useful in the AST and HIR Crate classes.
|
|
The very first thing in a rust source file might be the optional UTF-8
BOM. This is the 3 bytes 0xEF 0xBB 0xBF. They can simply be skipped,
they just mark the file as UTF-8. Add some testcases to show we now
handle such files.
|
|
546: shebang handling r=philberty a=dkm
Mark Wielaard:
> Shebang handling, the first line starting with #! was not done fully
> correct and it isn't necessary to keep track of the shebang line in
> the AST or HIR Crate classes.
>
> Because an inner attribute also starts with #! the first line isn't
> regarded as a shebang line if the #! is followed by (optional)
> whitespace and comments and a [. In that case the #! is seen as the
> start of an inner attribute.
>
> I added various testcases that hopefully show the funny things you can
> get when the first line starts with #!.
Co-authored-by: Mark Wielaard <mark@klomp.org>
|
|
There was a bad port over of the gccgo named_type implementation to try
be simple but this ended up overwriting the names of other primitive types
leading to confusing gimple debug sessions.
In debugging this I have added a set of ids which are the builtin primitive
types ids and we assert that this range of ids will never be overriten by
other types during compilation.
|
|
The lexer deals with the shebang and the parser cannot detect whether
there is or isn't a shebang line. The flag isn't relevant or useful in
the AST and HIR Crate classes.
|
|
The lexer tried to handle the shebang line but used loc directly,
instead of the current_column. And it assumed a '/' should immediately
follow the "#!". But if the "#!" is followed by whitespace and/or
comments and a '[' character, then the first line isn't see as a
shebang line (even if the kernel or shell would) but as the start of
an inner attribute.
Add various tests for when the first line starting with "#!" is seen
as a shebang line (and should be skipped). And some tests there is a
'[' character following some whitespace and/or comments and the "#!"
is seen as part of an inner attribute.
|
|
|
|
|
|
|
|
|
|
Methods are just functions with a self param. This simplifies typecheck
and GENERIC generation code.
Addresses #470 #473
|
|
Self is actually an implicit inherited type parameter on Trait
declarations. This adds this akin to impl blocks, and substitutes the
actual impl self type into the trait-impl item for type checking.
Fixes #473
|
|
|
|
536: Revert change to ScanUnused to not scan Types r=philberty a=philberty
The scan dead-code pass will take over this role, but let's keep both
running for a while and then we can update ScanUnused to only scan for
unused labels and variables. Dead Code pass is important as it is not possible
to rely on name resolution to know what symbols are used or not used.
Further resolution occurs during type resolution and the dead code pass runs after type resolution.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
It isn't necessary to know whether there are more segments while
iteration through the expression segments.
|
|
The default_ty_param was set, but not used. We do need to call TypeCheckType::Resolve
on the default param, but don't need the result.
|
|
The scan dead-code pass will take over this role, but lets keep both
running for a while and then we can update ScanUnused to only scan for
unused labels and variables. Its not possible to rely on name resolution
to know what symbols are used or not used. Further resolution occurs during
type resolution and the dead code pass runs after type resolution.
|
|
535: Suppress warning in rust-ast-lower-type.h ASTLowerGenericParam.visit. r=philberty a=dkm
Translating the AST LifetimeType to the HIR LifetimeType causes a warning:
warning: ‘ltt’ may be used uninitialized
Add a default clause to the switch statement calling gcc_unreachable.
This will suppress the warning and make sure that if the AST lifetime type
is invalid or a new unknown type we immediately know when lowering the AST.
Co-authored-by: Mark Wielaard <mark@klomp.org>
|
|
Comment iterate_type_ribs of UnusedScan in order to resolve multiple struct unused report.
|
|
Translating the AST LifetimeType to the HIR LifetimeType causes a warning:
warning: ‘ltt’ may be used uninitialized
Add a default clause to the switch statement calling gcc_unreachable.
This will suppress the warning and make sure that if the AST lifetime type
is invalid or a new unknown type we immediately know when lowering the AST.
|
|
530: Fix inner attribute parsing r=philberty a=dkm
parse_inner_attribute tried to skip the right square token twice. This caused odd error
messages in case there were multiple inner attributes. This bug masked another bug in
parse_attr_input where when the (optional) attr input was an assignment to a literal
the parser failed to skip the literal.
The existing top_attr.rs testcase relied on the two bugs cancelling each other out.
Add a new testcase inner_attributes.rs for the first bug.
Resolves: https://github.com/Rust-GCC/gccrs/issues/510
Co-authored-by: Mark Wielaard <mark@klomp.org>
|
|
502: Trait Obligations building block r=philberty a=philberty
This is a building block for actually enforcing the obligations of a trait.
It includes a query-based lookup of the trait to avoid reloading it so
we only do the hard work once. Then provides the enforcement for
basic functions. Constants, methods and associated types are still
WIP.
Addresses: #440
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
When we create an impl for a trait each item must be part of the trait,
these are the obligations of the trait. This means we know this type
definetly implements the trait.
This only supports functions so far. Methods, constants and associated
types are still in progress. This is an isolated building block that can
be merged without any regression so far.
Addresses #440
|
|
parse_inner_attribute tried to skip the right square token twice. This caused odd error
messages in case there were multiple inner attributes. This bug masked another bug in
parse_attr_input where when the (optional) attr input was an assignment to a literal
the parser failed to skip the literal.
The existing top_attr.rs testcase relied on the two bugs cancelling each other out.
Add a new testcase inner_attributes.rs for the first bug.
Resolves: https://github.com/Rust-GCC/gccrs/issues/510
|
|
|
|
|
|
|
|
|
|
|
|
527: Reject non-pure decimal tuple indexes. r=philberty a=dkm
Tuple indexes should be pure decimal integer literals. But the parser just sees an
integer literal. Fix this by introducing a new type hint CORETYPE_PURE_DECIMAL. This
doesn't conflict with any existing type hints since a pure decimal doesn't have a
type suffix.
Introduce a new method is_pure_decimal that the parser can use in parse_tuple_index_expr.
get_type_hint will return CORETYPE_UNKNOWN for pure decimals.
parse_decimal_int_or_float will check whether there are no execissive leading zeros.
parse_in_decimal checks the literal doesn't contain any underscores.
Add two testcases. bad_tuple_index.rs with all variants of integer literals which aren't
pure decimals. And tuple_index.rs with various correct tuple indexes.
Resolves: https://github.com/Rust-GCC/gccrs/issues/511
Co-authored-by: Mark Wielaard <mark@klomp.org>
|
|
|
|
|
|
|
|
|
|
|
|
Tuple indexes should be pure decimal integer literals. But the parser just sees an
integer literal. Fix this by introducing a new type hint CORETYPE_PURE_DECIMAL. This
doesn't conflict with any existing type hints since a pure decimal doesn't have a
type suffix.
Introduce a new method is_pure_decimal that the parser can use in parse_tuple_index_expr.
get_type_hint will return CORETYPE_UNKNOWN for pure decimals.
parse_decimal_int_or_float will check whether there are no execissive leading zeros.
parse_in_decimal checks the literal doesn't contain any underscores.
Add two testcases. bad_tuple_index.rs with all variants of integer literals which aren't
pure decimals. And tuple_index.rs with various correct tuple indexes.
Resolves: https://github.com/Rust-GCC/gccrs/issues/511
|
|
Rust supports unit struct initilization such as S{} this takes this tree
and resolves it fully. This should really be all desugared via HIR but that
is in progress in another PR.
|
|
IdentifierExpr's can reference types like a unit-struct, referencing other
structs actually form a function item type which is not supported yet.
|