aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2021-10-27TyTy add bounds in debug stringPhilip Herron1-1/+1
2021-10-27Remove assertion for has_where_clausePhilip Herron2-65/+22
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.
2021-10-27Add HIR lowering for where clause itemsPhilip Herron3-7/+140
2021-10-27Add WhereClauseItem::ItemType specifier to differentiate between itemsPhilip Herron1-0/+18
2021-10-27Add name resolution to higher ranked trait boundsPhilip Herron2-1/+77
2021-10-26Add missing node mappings to HIR::WhereClauseItemsPhilip Herron1-21/+40
2021-10-26Add missing NodeId to where clause itemsPhilip Herron1-21/+29
2021-10-26Merge #770bors[bot]3-20/+29
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>
2021-10-25Converted FnType preprocessor defines into constantsNirmal Patel5-26/+29
Signed-off-by: Nirmal Patel <npate012@gmail.com>
2021-10-25TraitImpl: track the polarity of the implBen Boeckel3-20/+29
The internal representation now tracks whether a trait impl is a positive or negative impl. Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
2021-10-25Merge #769bors[bot]3-7/+11
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>
2021-10-25LifetimeWhereClauseItem: store the location of the itemBen Boeckel3-7/+11
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
2021-10-25Merge #768bors[bot]1-2/+2
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>
2021-10-25CompileExpr: fix copy pasta error messageBen Boeckel1-2/+2
Also downgrade from a fatal error to a compilation error. Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
2021-10-25gccrs: StructExprStructFields: remove `iterate` methodBen Boeckel3-20/+13
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>
2021-10-22Merge #764bors[bot]160-163/+164
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>
2021-10-22Merge #762bors[bot]2-6/+65
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>
2021-10-22Update GCC/Rust files per 'contrib/update-copyright.py --this-year'Thomas Schwinge160-161/+160
2021-10-22Fix copyright/licensing information in 'gcc/rust/rust-linemap.h'Thomas Schwinge1-3/+5
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.
2021-10-22Cleanup IR symbol names in gimplePhilip Herron2-2/+16
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
2021-10-22Add missing coercion site code to MethodCallExpr'sPhilip Herron2-6/+65
Arguments to methods are coercion sites and may have implicit conversions to be performed this adds this missing code for this case. Fixes #755
2021-10-22Merge #752bors[bot]17-256/+778
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>
2021-10-22Support generic arguments on TypeBoundsPhilip Herron5-20/+247
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
2021-10-22Decouple the loop from processing a potential candidate in a pathPhilip Herron1-80/+75
Code cleanup to extract the body out of the loop to make the code more testable and reuseable.
2021-10-22Extract const helper method is_receiver_generic for path probes.Philip Herron1-10/+9
2021-10-22Ensure autoderef for generic recivers in method callsPhilip Herron12-161/+323
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
2021-10-22Fix ICE when trying to resolve associated type from type boundsPhilip Herron6-6/+145
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
2021-10-22Merge #761bors[bot]1-1/+1
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>
2021-10-22Squash unused parameter warning.Philip Herron1-1/+1
Fixes #750
2021-10-22Merge #757 #758 #759 #760bors[bot]17-161/+491
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>
2021-10-22Merge #756bors[bot]10-92/+96
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>
2021-10-22Add FIXME comment for inheriting boundsPhilip Herron1-0/+3
2021-10-22Cleanup interfaces for associated impl mappingsPhilip Herron3-21/+30
This changes the lookups to return boolean if they are found rather than default UNKNOWN_HIRID which is more ambigious.
2021-10-22Error handling is done via the TyTy::ErrorType instead of nullptr'sPhilip Herron1-1/+1
2021-10-22Refactor fill_param_ty into cc filePhilip Herron2-25/+28
This also changes the signiture to take a fat pointer instead of raw pointer for the substitution.
2021-10-22Remove second lookup for query compiled functionsPhilip Herron1-42/+28
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
2021-10-22The number of required substituions is offset from the already substitutedPhilip Herron1-5/+4
When doing HIR::GenericArgs substitutions we must offset from the already partially substituted arguments.
2021-10-22BugFix: TypePath resolution to handle associated typesPhilip Herron11-58/+396
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
2021-10-22Remove bad prefix from RelativeTypePath resolutionPhilip Herron1-9/+1
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
2021-10-22Constify BaseType::get_root since this should not change ownershipPhilip Herron7-29/+33
2021-10-22Constify SubstitutionArgumentMappings::solve_mappings_from_receiver_for_selfPhilip Herron2-3/+3
2021-10-22Constify autoderef ajustments expected type fieldPhilip Herron1-3/+3
2021-10-22Constify GetUsedSubstArgsPhilip Herron2-26/+26
This mapper class does not need mutability and can easily be made const enforcing ownership.
2021-10-22Constify SubstitutionArg field SubstitutionParamMappingPhilip Herron1-4/+4
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.
2021-10-22Constify the Backend resolve compile interfacePhilip Herron2-27/+27
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.
2021-10-21Fixed formatting issuesNirmal Patel2-3/+3
Signed-off-by: Nirmal Patel <npate012@gmail.com>
2021-10-20Implement unsafety enum and replaced boolean variable has_unsafe with a ↵Nirmal Patel7-18/+30
variable of unsafety enum type Signed-off-by: Nirmal Patel <npate012@gmail.com>
2021-10-18Merge #747bors[bot]4-0/+148
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>
2021-10-18util: Add rust-base62 implementation from rustcCohenArthur4-23/+85
2021-10-17Const fold ArrayElemsCopiedRodrigo Valle4-1/+36
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>