Age | Commit message (Collapse) | Author | Files | Lines |
|
1614: intrinsics: Add rust_sorry wrapper for unimplemented intrinsics r=CohenArthur a=CohenArthur
This allows us to define intrinsics without implementing their body. This will be useful for atomic intrinsics for example, as there are a lot of them and we should work on implementing them one by one properly and slowly
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
|
|
This allows us to define intrinsics without implementing their body.
This will be useful for atomic intrinsics for example, as there are a
lot of them and we should work on implementing them one by one properly
and slowly
|
|
This renames all builtin macro functions to `<macro>_handler`. This
helps avoiding the `ifdef/undef` dance we performed for MacOS in order
to compile the `assert` method
|
|
1608: Initial support for closures r=philberty a=philberty
This patch series introduces initial support for closures. Rust's implementation
of closures is actually pretty clever, the function signatures for closures is driven
by the specific FnTrait that the closure implements, this means a CallExpr to a closure
becomes a method-call expr with the receiver type being the closure itself using the
normal autoderef mechanism to do method selection for an implicit impl block.
See https://github.com/rust-lang/rust/blob/7807a694c2f079fd3f395821bcc357eee8650071/library/core/src/ops/function.rs#L54-L71
The other implicit part of this is that arguments being passed to a closure _must_
be passed as a tuple. The down side of allowing libcore to specify the signatures
of the closure functions is that we are limited in how we pass arguments, but
using a tuple and then using similar machinery from the match-expr to restructure
the parameter access to become the tuple accessors makes it look seamless. For
example:
```rust
let closure_annotated = |i: i32| -> i32 { i + 123 };
let i = 1;
closure_annotated(i);
```
Wil generate a function and call-expr such as:
```c
i32 test::main::{{closure}} (struct {{closure}} $closure, struct (i32) args)
{
_1 = args.__0; // this is 'i'
return _1 + 123;
}
__attribute__((cdecl))
i32 test::main ()
{
struct
{
i32 __0;
} D.137;
i32 D.140;
const i32 a;
const struct{{closure}} closure_annotated;
const i32 i;
try
{
a = 1;
i = 1;
D.137.__0 = i;
_1 = test::main::{{closure}} (closure_annotated, D.137);
<...>
}
finally
{
closure_annotated = {CLOBBER(eol)};
}
}
```
Note this patch series does not implement the argument capture yet but this patch set is
good start to the implementation so far.
Addresses #195
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
1607: Improve AST Fragment class r=CohenArthur a=CohenArthur
This changes the APIs around creating AST fragments and refactors the class into its own header and source file, hopefully making it easier to use. This will also help creating "unexpanded" AST fragments for proper builtin macro expansion with the new fixed-point algorithm introduced by #1606
`@liushuyu` pinging you since you've worked extensively with the macro system. Would love your review!
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
|
|
Addresses #195
|
|
|
|
|
|
|
|
Closures's need to generate their specific function and setup their
argument passing based on the signiture specified in libcore. We can get
this information based on the specified bound on the closure.
Addresses #195
|
|
This adds the type checking for a HIR::ClosureExpr which specifies a
TyTy::ClosureType whih inherits the FnOnce trait by default. The
specialisation of the trait bound needs to be determined by the the
mutability and argument capture and moveablity rules.
The CallExpr is amended here so that we support CallExpr's for all
receivers that implement any of the FnTraits. This means closures and
generics that have the relevant type bound of FnTraits we get the same path
of type checking.
Addresses #195
|
|
|
|
We used a visitor interface to handle type checking argument passing on
method call expressions. This was completely unnessecary as all method
calls should _always_ be to TyTy::FnType's. The benifit here is that we
need to reuse this interface to handle method resolution type checking
for FnTrait calls as closure calls dont have an HIR::MethodExpr so we
need a more abstract interface so that we can specify the types directly
with relevant location info.
|
|
1549: Dump macro declarations properly r=CohenArthur a=CohenArthur
Dump `MacroRulesDef` properly
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
|
|
This is the first pass at name resolution, it simply creates a new rib for
the closure. We eventually need more checks here to enforce what things
can be included within the closure.
|
|
Move implementation into cc file from the header and remove unnessecary
new lines in the expr lowering header.
|
|
In the AST we have ClosureExprInner and ClosureExprInnerTyped the first
is the closure expression of the form:
let closure_inferred = |i| i + 1;
The second is of the form:
let closure_annotated = |i: i32| -> i32 { i + 1 };
Both of these can be seguared into a single HIR::ClosureExpr with an
optional return type and parameter types.
Addresses #195
|
|
|
|
|
|
1596: Add more implementations for TARGET_RUST_OS_INFO r=philberty a=ibuclaw
Pretty much all follow the same template as how darwin was added in the first commit, so mostly uninteresting.
The only slight deviation is with `*-*-linux*`, where rather than putting it in a common `glibc-rust.cc` file, I've instead opted to force each platform have their own source file. So Linux gets a `linux-rust.cc` file, and anyone who wants to add Hurd, kFreeBSD, or kOpenSolaris later can do so by adding a case to this switch with the appropriately named file (i.e: `gnu-rust.cc` for Hurd).
The same can also be said for MinGW targets - `winnt-rust.cc` is explicitly _not_ set for Cygwin, and I'd prefer that whoever does add Cygwin support will create a separate file for it - otherwise you've either got to modify the target headers to add whatever defines you need in order to abstract the two away, or start adding some defines to `tm_rust.h` to expose hints about the target known at configure time.
Linux is also the only implementation that has an `#ifndef` condition, as not all Linux targets include `linux-android.{h,opt}`.
Checked dumps of target_options on a plethora of target configurations, though this list is by no means exhaustive.
---
<details>
<summary>i686-dragonflybsd</summary>
```
target_pointer_width: "32"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "dragonfly"
target_family: "unix"
target_arch: "x86"
```
</details>
<details>
<summary>x86_64-dragonflybsd</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "dragonfly"
target_family: "unix"
target_feature: "fxsr"
target_feature: "sse"
target_feature: "sse2"
target_feature: "mmx"
target_arch: "x86_64"
```
</details>
<details>
<summary>aarch64-freebsd12, ia64-freebsd6, riscv64-freebsd12</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "freebsd"
target_family: "unix"
```
</details>
<details>
<summary>arm-freebsd12</summary>
```
target_pointer_width: "32"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "freebsd"
target_family: "unix"
```
</details>
<details>
<summary>i486-freebsd4, i686-freebsd6</summary>
```
target_pointer_width: "32"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "freebsd"
target_family: "unix"
target_arch: "x86"
```
</details>
<details>
<summary>powerpc-freebsd6</summary>
```
target_pointer_width: "32"
target_env: ""
target_vendor: "unknown"
target_endian: "big"
target_os: "freebsd"
target_family: "unix"
```
</details>
<details>
<summary>sparc64-freebsd6</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "big"
target_os: "freebsd"
target_family: "unix"
```
</details>
<details>
<summary>x86_64-freebsd6</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "freebsd"
target_family: "unix"
target_feature: "fxsr"
target_feature: "sse"
target_feature: "sse2"
target_feature: "mmx"
target_arch: "x86_64"
```
</details>
<details>
<summary>aarch64-fuchsia</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "fushsia"
target_family: "unix"
```
</details>
<details>
<summary>x86_64-fuchsia</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "fushsia"
target_family: "unix"
target_feature: "fxsr"
target_feature: "sse"
target_feature: "sse2"
target_feature: "mmx"
target_arch: "x86_64"
```
</details>
<details>
<summary>i686-kfreebsd-gnu</summary>
```
target_endian: "little"
target_pointer_width: "32"
target_arch: "x86"
```
</details>
<details>
<summary>arm-linux-androideabi</summary>
```
target_pointer_width: "32"
target_env: ""
target_endian: "little"
target_os: "android"
target_vendor: "unknown"
target_family: "unix"
```
</details>
<details>
<summary>aarch64-linux-gnu, alpha-linux-gnu, ia64-linux, riscv64-unknown-linux-gnu</summary>
```
target_pointer_width: "64"
target_env: "gnu"
target_endian: "little"
target_os: "linux"
target_vendor: "unknown"
target_family: "unix"
```
</details>
<details>
<summary>am33_2.0-linux-gnu, csky-linux-gnu, mips64el-st-linux-gnu, nios2-linux-gnu, powerpcle-linux, riscv32-unknown-linux-gnu, rx-linux, shle-linux, vax-linux-gnu</summary>
```
target_pointer_width: "32"
target_env: "gnu"
target_endian: "little"
target_os: "linux"
target_vendor: "unknown"
target_family: "unix"
```
</details>
<details>
<summary>arc-linux-uclibc, bfin-linux-uclibc</summary>
```
target_pointer_width: "32"
target_env: "uclibc"
target_endian: "little"
target_os: "linux"
target_vendor: "unknown"
target_family: "unix"
```
</details>
<details>
<summary>arceb-linux-uclibc, or1k-linux-uclibc</summary>
```
target_pointer_width: "32"
target_env: "uclibc"
target_endian: "big"
target_os: "linux"
target_vendor: "unknown"
target_family: "unix"
```
</details>
<details>
<summary>frv-linux, h8300-linux, hppa-linux-gnu, m68k-linux, microblaze-linux, mips64octeon-linux, mipsisa32r2-linux-gnu, mipsisa64r2-linux, mips-linux, mips-mti-linux, powerpc64-linux_altivec, powerpc-linux, s390-linux-gnu, sparc-leon3-linux-gnu, sparc-linux-gnu, xtensa-linux</summary>
```
target_pointer_width: "32"
target_env: "gnu"
target_endian: "big"
target_os: "linux"
target_vendor: "unknown"
target_family: "unix"
```
</details>
<details>
<summary>hppa64-linux-gnu, s390x-linux-gnu, sparc64-linux</summary>
```
target_pointer_width: "64"
target_env: "gnu"
target_endian: "big"
target_os: "linux"
target_vendor: "unknown"
target_family: "unix"
```
</details>
<details>
<summary>i686-pc-linux-gnu, i686-pc-linux</summary>
```
target_pointer_width: "32"
target_env: "gnu"
target_endian: "little"
target_os: "linux"
target_vendor: "unknown"
target_family: "unix"
target_arch: "x86"
```
</details>
<details>
<summary>or1k-linux-musl</summary>
```
target_pointer_width: "32"
target_env: "musl"
target_endian: "big"
target_os: "linux"
target_vendor: "unknown"
target_family: "unix"
```
</details>
<details>
<summary>i686-mingw32crt</summary>
```
target_pointer_width: "32"
target_env: "gnu"
target_vendor: "pc"
target_endian: "little"
target_os: "windows"
target_family: "windows"
target_arch: "x86"
```
</details>
<details>
<summary>x86_64-mingw32, x86_64-w64-mingw32</summary>
```
target_pointer_width: "64"
target_env: "gnu"
target_vendor: "pc"
target_endian: "little"
target_os: "windows"
target_family: "windows"
target_feature: "fxsr"
target_feature: "sse"
target_feature: "sse2"
target_feature: "mmx"
target_arch: "x86_64"
```
</details>
<details>
<summary>aarch64-netbsd, alpha-netbsd</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "netbsd"
target_family: "unix"
```
</details>
<details>
<summary>arm-netbsdelf, vax-netbsdelf</summary>
```
target_pointer_width: "32"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "netbsd"
target_family: "unix"
```
</details>
<details>
<summary>hppa-netbsd, m68k-netbsdelf, mips-netbsd, powerpc-netbsd, sh-netbsdelf, sparc-netbsdelf</summary>
```
target_pointer_width: "32"
target_env: ""
target_vendor: "unknown"
target_endian: "big"
target_os: "netbsd"
target_family: "unix"
```
</details>
<details>
<summary>i686-netbsdelf9</summary>
```
target_pointer_width: "32"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "netbsd"
target_family: "unix"
target_arch: "x86"
```
</details>
<details>
<summary>sparc64-netbsd</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "big"
target_os: "netbsd"
target_family: "unix"
```
</details>
<details>
<summary>x86_64-netbsd</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "netbsd"
target_family: "unix"
target_feature: "fxsr"
target_feature: "sse"
target_feature: "sse2"
target_feature: "mmx"
target_arch: "x86_64"
```
</details>
<details>
<summary>alpha-openbsd</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "openbsd"
target_family: "unix"
```
</details>
<details>
<summary>bfin-openbsd</summary>
```
target_pointer_width: "32"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "openbsd"
target_family: "unix"
```
</details>
<details>
<summary>i686-openbsd</summary>
```
target_pointer_width: "32"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "openbsd"
target_family: "unix"
target_arch: "x86"
```
</details>
<details>
<summary>sparc64-openbsd</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "big"
target_os: "openbsd"
target_family: "unix"
```
</details>
<details>
<summary>x86_64-openbsd</summary>
```
target_pointer_width: "64"
target_env: ""
target_vendor: "unknown"
target_endian: "little"
target_os: "openbsd"
target_family: "unix"
target_feature: "fxsr"
target_feature: "sse"
target_feature: "sse2"
target_feature: "mmx"
target_arch: "x86_64"
```
</details>
<details>
<summary>aarch64-wrs-vxworks</summary>
```
target_pointer_width: "64"
target_env: "gnu"
target_vendor: "wrs"
target_endian: "little"
target_os: "vxworks"
target_family: "unix"
```
</details>
<details>
<summary>arm-wrs-vxworks7</summary>
```
target_pointer_width: "32"
target_env: "gnu"
target_vendor: "wrs"
target_endian: "little"
target_os: "vxworks"
target_family: "unix"
```
</details>
<details>
<summary>i686-wrs-vxworks, i686-wrs-vxworksae</summary>
```
target_pointer_width: "32"
target_env: "gnu"
target_vendor: "wrs"
target_endian: "little"
target_os: "vxworks"
target_family: "unix"
target_arch: "x86"
```
</details>
<details>
<summary>mips-wrs-vxworks, powerpc-wrs-vxworksae, powerpc-wrs-vxworks, powerpc-wrs-vxworksmils, sh-wrs-vxworks, sparc-wrs-vxworks</summary>
```
target_pointer_width: "32"
target_env: "gnu"
target_vendor: "wrs"
target_endian: "big"
target_os: "vxworks"
target_family: "unix"
```
</details>
<details>
<summary>arm-uclinux_eabi, bfin-uclinux, c6x-uclinux</summary>
```
target_endian: "little"
target_pointer_width: "32"
```
</details>
<details>
<summary>lm32-uclinux, m68k-uclinux, moxie-uclinux, xtensa-uclinux</summary>
```
target_endian: "big"
target_pointer_width: "32"
```
</details>
Co-authored-by: Iain Buclaw <ibuclaw@gdcproject.org>
|
|
|
|
|
|
|
|
This adds a new RAII style TraitQueryGuard so that we can manage the query
lifetime when resolving a trait. This adds in a DefId into a set when we
begin to resolve and then finally removes it when completed. This allows
us to add in a check at the start if this DefId is already within the set
which means this is a trait cycle.
Fixes #1589
|
|
1597: ast: Module: unloaded module and inner attributes r=CohenArthur a=jdupak
Adds support for unloaded modules and dumps also inner attributes.
Resolves issue found in #1548.
Co-authored-by: Jakub Dupak <dev@jakubdupak.com>
|
|
Co-authored-by: jdupak <dev@jakubdupak.com>
|
|
1594: Refactor TraitResolver to not require a visitor r=philberty a=philberty
We used a visitor to dispatch the HIR::Item so that we could cast it directly to an HIR::Trait and then check for nullptr if it failed. This patch changes this to simply use our new enum item_type_kind to switch so we can directly static_cast.
1595: Support outer attribute handling on trait items just like normal items r=philberty a=philberty
This patch adds a proxy class ItemWrapper to be a proxy allowing us to use the same code paths for attribute handling as we have with normal items. We need this so we can grab the fn trait associated type lang item's. Which are being missed currently.
Addresses #195
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
|
|
1548: Dump module items r=CohenArthur a=CohenArthur
1593: ast: dump TypeAlias r=CohenArthur a=jdupak
Implements ast dump for TypeAlias
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Co-authored-by: Jakub Dupak <dev@jakubdupak.com>
|
|
Co-authored-by: jdupak <dev@jakubdupak.com>
|
|
1590: AST: more dump improvements r=dafaust a=dafaust
This PR adds new AST dump visitors for several nodes, and cleans up some minor formatting issues in blocks without tail expressions and if expressions.
Co-authored-by: David Faust <david.faust@oracle.com>
|
|
|
|
|
|
This patch adds a proxy class ItemWrapper to be a proxy allowing us to use
the same code paths for attribute handling as we have with normal items. We
need this so we can grab the fn trait associated type lang item's. Which
are being missed currently.
Addresses #195
|
|
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
|
|
1580: Add early name resolver r=CohenArthur a=CohenArthur
This addresses our issue with name resolution (#1576) not acting on macros early enough but does not fix it yet.
This name resolver performs the same macro name resolution as what was previously done by the AttrVisitor visitor and macro expander.
It also resolves macro expressions in builtin-macros properly, as well as expanded AST nodes when necessary.
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
|
|
We used a visitor to dispatch the HIR::Item so that we could cast it directly to an HIR::Trait and then check for nullptr if it failed. This
patch changes this to simply use our new enum item_type_kind to switch so
we can directly static_cast.
|
|
1587: Method resolution must support multiple candidates r=philberty a=philberty
This patch fixes bad method resolution in our operator_overload_9 case.
When we have a &mut reference to something and we deref we must resolve to
the mutable reference impl block. The interface we are using to resolve
methods is the can_eq interface which allows for permissive mutability
which means allowing for mutable reference being unified with an immutable
one. This meant we actual match against both the immutable and mutable
version leading to multiple candidate error.
Fixes #1588
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
1583: Support type resolution on super traits on dyn objects r=philberty a=philberty
When checking if specified bounds satisfy other bounds we must lookup the super traits. To finish the support for super traits we need to redo the computation of method addresses to support super traits.
Addresses #914
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
|
|
Adds dump for:
- BorrowExpr
- DereferenceExpr
- ErrorPropagationExpr
- NegationExpr
- TypeCastExpr
- GroupedExpr
|
|
|
|
|
|
|
|
|
|
1584: Add missing lang item mappings r=philberty a=philberty
Adds the missing fn_once lang item and the missing rust-call abi option.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
This patch fixes bad method resolution in our operator_overload_9 case.
When we have a &mut reference to something and we deref we must resolve to
the mutable reference impl block. The interface we are using to resolve
methods is the can_eq interface which allows for permissive mutability
which means allowing for mutable reference being unified with an immutable
one. This meant we actual match against both the immutable and mutable
version leading to multiple candidate error.
The fix here adds a method resolution flag to the can_eq interface so that
we enforce mutability equality. The other hack is that we do not allow
can_eq of ParamTypes to generic Slices. I think there is some subtle thing
going on for that case. The Rustc method resolver actually filters the
impl blocks for reference types based looking up the relevant lang items
we need to do this as well but is a much larger refactor to our method
resolver which should be done seperately.
Fixes #1588
|
|
gcc/ChangeLog:
* config.gcc (*linux*): Set rust target_objs, and
target_has_targetrustm,
* config/t-linux (linux-rust.o): New rule.
* config/linux-rust.cc: New file.
|
|
gcc/ChangeLog:
* config.gcc (i[34567]86-*-mingw* | x86_64-*-mingw*): Set
rust_target_objs and target_has_targetrustm.
* config/t-winnt (winnt-rust.o): New rule.
* config/winnt-rust.cc: New file.
|
|
gcc/ChangeLog:
* config.gcc (*-*-fuchsia): Set tmake_rule, rust_target_objs,
and target_has_targetrustm.
* config/fuchsia-rust.cc: New file.
* config/t-fuchsia: New file.
|