Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
This assertion doesn't protect against bad pointers or behaviour, when we
access the where clause it is simply a wrapper over a vector of where
clause items so we can safely iterate even when the where clause item
vector is empty.
|
|
|
|
|
|
|
|
|
|
|
|
770: TraitImpl: track the polarity of the impl r=philberty a=mathstuf
The internal representation now tracks whether a trait impl is a
positive or negative impl.
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Fixes: #732
Co-authored-by: Ben Boeckel <mathstuf@gmail.com>
|
|
Signed-off-by: Nirmal Patel <npate012@gmail.com>
|
|
The internal representation now tracks whether a trait impl is a
positive or negative impl.
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
|
|
769: LifetimeWhereClauseItem: store the location of the item r=philberty a=mathstuf
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
---
Fixes: #765
Here is a checklist to help you with your PR.
- \[x] GCC development requires copyright assignment or the Developer's Certificate of Origin sign-off, see https://gcc.gnu.org/contribute.html or https://gcc.gnu.org/dco.html
- \[x] Read contributing guidlines
- \[x] `make check-rust` passes locally
- \[x] Run `clang-format` (letting CI handle this)
- \[x] Added any relevant test cases to `gcc/testsuite/rust/`
I didn't find any ctor calls for the `HIR` type, but it's updated as well.
Co-authored-by: Ben Boeckel <mathstuf@gmail.com>
|
|
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
|
|
768: CompileExpr: fix copy pasta error message r=philberty a=mathstuf
Also downgrade from a fatal error to a compilation error.
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
---
Fixes: #702
Here is a checklist to help you with your PR.
- \[x] GCC development requires copyright assignment or the Developer's Certificate of Origin sign-off, see https://gcc.gnu.org/contribute.html or https://gcc.gnu.org/dco.html
- \[x] Read contributing guidlines
- \[x] `make check-rust` passes locally
- \[x] Run `clang-format` (letting CI handle this)
- \[ ] Added any relevant test cases to `gcc/testsuite/rust/` (I don't see any existing tests that seem to test things like this; it's a gccrs internal error about lookup up the type it seems?)
Co-authored-by: Ben Boeckel <mathstuf@gmail.com>
|
|
Also downgrade from a fatal error to a compilation error.
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
|
|
This provides a getter for the set of fields in a struct expression
rather than a visitor with a callback which is more complicated for
callers, especially static analysis.
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
|
|
764: Update GCC/Rust files per 'contrib/update-copyright.py --this-year' r=philberty a=tschwinge
As noted by `@dkm/@CohenArthur` in <https://github.com/Rust-GCC/gccrs/pull/747#issuecomment-945581716>/<https://github.com/Rust-GCC/gccrs/issues/747#issuecomment-945585735>.
Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
|
|
762: Add missing coercion site code to MethodCallExpr's r=philberty a=philberty
Arguments to methods are coercion sites and may have implicit conversions
to be performed this adds this missing code for this case.
Fixes #755
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
|
|
This evidently has originally been copied from 'gcc/go/gofrontend/go-linemap.h'
(with a bit too much 's%go%rust'). Restore the original notes, and extend
suitably.
|
|
When we have generic code the full as_string is too verbose for symbol
names. This changes the ir_symbol_names to become the name of the types
not the full debug as_string version.
Fixes #745
|
|
Arguments to methods are coercion sites and may have implicit conversions
to be performed this adds this missing code for this case.
Fixes #755
|
|
752: Bugfix ICE in trait resolution r=philberty a=philberty
This is a series of patches which need to go in order to fix the linked bugs.
- Fix type resolution of associated types in the generic context
- Ensure autoderef is applied on generic receivers
- Support generic substitutions on type-bounds
Fixes #743 #753 #744 #741
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
This adds support to managing generic arguments within type bounds. Such
as:
```rust
fn test<T: GenericBound<i32>>(a:T) { ... }
```
The interesting piece here is that for any usage of the bounds on T the
items must be substituted with the inherited arguments specified within
the bound.
This fixes the test case from #743 by removing the lifetimes and where
constraint which needs to be implemented in #442. This associated test
case will fail the rust borrow checker but we need a way to work though
bugs in the short term in some senario's.
Fixes #743
|
|
Code cleanup to extract the body out of the loop to make the code more
testable and reuseable.
|
|
|
|
This changes our TyTy::BaseType::can_eq interface to allow
ParamTypes to be compatable with everything except reference
and pointer types to ensure we apply autoderef adjustments
correctly.
Fixes #753
|
|
When we have a generic function with specified type bounds this allows rust
code to actually then look up the relevant bounds for associated types,
functions or constants. This means at code generation the relevant
associated mappings msut be setup such that we compile to the
implementaiton if available or the default implementation if possible.
The bug here was that the resolution for associated types were auto setting
up the associated type mappings even when the receiver was generic. So for
example:
```rust
pub trait Foo {
type A;
fn bar(self) -> Self::A;
}
struct S(i32);
impl Foo for S {
type A = i32;
fn bar(self) -> Self::A {
self.0
}
}
fn test_bar<T: Foo>(x: T) -> T::A {
x.bar()
}
```
The generic function of test_bar was auto resolving the T::A to A=i32 since
it found the type-bound Foo was specified and the only implementation of
Foo is on S. This is usually the correct flow to auto setup these mappings
but in the conjtext of a generic receiver this needs to still result in
a Placeholder type of the bound Foo to type check correctly.
Fixes: #744 #741
|
|
761: Squash unused parameter warning. r=philberty a=philberty
This should fix out bootstrap build again.
Fixes #750
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
Fixes #750
|
|
757: Fix TypePath resolution to iterate segments r=philberty a=philberty
Associated types in rust can be of the form:
```rust
trait Foo {
type A;
...
}
fn test<T:Foo>(a:T) -> T::A { .. }
```
Where the type-bound of Foo is applied to T this allows for a the associated type T::A to exist
which is a placeholder type within the trait definition. This path cannot be resolved at name-resolution
time and requires a path probe.
Fixes #746
758: The number of required substituions is offset from inherited ones r=philberty a=philberty
When doing HIR::GenericArgs substitutions we must offset from the already
partially substituted arguments.
759: Remove second lookup for query compiled functions r=philberty a=philberty
This cleans up the code here to make use of the query based
compilation which returns the address of the function which
removes extra lookups.
760: Cleanup lookup interfaces r=philberty a=philberty
These patches change the associated impl mapping's to use a boolean
return type for error handling, to stop looking for UNKNOWN_HIRID for
error handling which is too easy to make mistakes with.
It also updates instances of code to use TyTy::ErrorType node instead of
nullptr's for error handling.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
756: Add const to enforce ownership over pointers r=philberty a=philberty
This consify's a bunch of interfaces in the code base which helps make the ownership
over pointers more clear. These are building blocks from a wider cleanup of the type-checking
code to make it more readable.
- BaseType::get_root
- SubstitutionArgumentMappings::solve_mappings_from_receiver_for_self
- Autoderef adjustments
- GetUsedSubstArgs
- SubstitutionArg field SubstitutionParamMapping
- Backend resolve compile interface
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
|
|
This changes the lookups to return boolean if they are found rather than
default UNKNOWN_HIRID which is more ambigious.
|
|
|
|
This also changes the signiture to take a fat pointer instead of raw
pointer for the substitution.
|
|
When compiling method calls we need to compile functions in a query based
manar sometimes, recently there was a query mode api added to the relevant
functions which will return the address of the function when asked to try
and compile. This patch uses this returned address avoiding a duplicate
lookup for the compiled function
|
|
When doing HIR::GenericArgs substitutions we must offset from the already
partially substituted arguments.
|
|
TypePath's can be fully resolved at name resolution time for example a
primitive types are single segments which can be resolved. But in the event
of a generic TypeBound path such as: T::A where T is the generic type param
in a function and A is its own associated type this require's the
resolution to be split over the name resolver and type resolver.
Like PathInExpression's the name resolver is able to resolve the root
segment of 'T' but requires a path probe on the type-bounds of T to find
the associated type 'A'.
Fixes #746
|
|
The TypePath resolver is a naieve and assumes all paths are fully
resolveable at name resolution time. This is the first patch to update
this to resolve each segement in turn.
Addresses #746
|
|
|
|
|
|
|
|
This mapper class does not need mutability and can easily be made const
enforcing ownership.
|
|
Argument mappings need to reference the generic parameter they are going
to substitute this should really be const since this class does not own
the mapping pointer here.
|
|
This is a bad name for this class, but it will compile a TyTy type into a
GCC Backend::Btype* node. The class also tries to determine if we have
already compiled this node for monomorphization and canonicalization of
types which will avoid unnessecary conversion code based on type equality.
This patch simply makes this a const visitor to enforce pointer ownership
rules.
|
|
Signed-off-by: Nirmal Patel <npate012@gmail.com>
|
|
variable of unsafety enum type
Signed-off-by: Nirmal Patel <npate012@gmail.com>
|
|
747: Base v0 mangling grammar r=philberty a=CohenArthur
This PR adds base functions to deal with the v0 mangling grammar, [found here](https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html#syntax-of-mangled-names).
I have a few questions regarding this implementation:
1/ Is there any existing implementation for the base62 algorithm used here? This is directly adapted from [rustc's base_n module](https://github.com/rust-lang/rust/blob/6f53ddfa74ac3c10ceb63ad4a7a9c95e55853c87/compiler/rustc_data_structures/src/base_n.rs#L16) which I'm assuming is relatively standard and might already exist in the compiler. I haven't been able to find it however.
2/ gccrs cannot yet deal with unicode identifiers, as pointed out by `@bjorn3` in #418. This means that a big chunk of the `v0_add_identifier` implementation is missing. Should it be added in this PR too?
3/ As mentionned in zulip, it would be great to be able to create unit tests for this piece of code. It would be quite easy to generate a bunch of base62 strings and ensure that the algorithm here matches with them.
Co-authored-by: CohenArthur <arthur.cohen@epita.fr>
|
|
|
|
Added support for const fold inside of an ArrayElemsCopied expression, e.g.
`const array: [i32; 10] = [0; 10];`. I also removed a .swp file that I
accidentally merged in a previous commit and added a test for this new
functionality.
Signed-off-by: Rodrigo Valle <rdan.valle@gmail.com>
|