Age | Commit message (Collapse) | Author | Files | Lines |
|
see:
https://blog.rust-lang.org/2022/09/15/const-eval-safety-rule-revision.html
|
|
|
|
Statics can be assigned to a block expression meaning they need to behave
similarly to constant items.
|
|
Statics like constants need to have a singular value they are not functions
to be lazy evaluated. So to evaluate a block expr we can just reuse our
const code to resolve this to a singular value.
|
|
1528: add testcase with struct to test component_ref and constructor codes in eval_constant_expression() r=philberty a=abbasfaisal
Co-authored-by: Faisal Abbas <90.abbasfaisal@gmail.com>
|
|
|
|
eval_constant_expression()
|
|
... previously the exit condition was treated the same as the loop
condition (which is the inverse condition of the exit condition). Now
this is corrected.
|
|
eval_constant_expression()
|
|
|
|
Fixes #1518
|
|
We don't need to setup associated types when a trait does not contain any
associated types.
|
|
|
|
1505: Create canonical process of compiling constant items r=philberty a=philberty
In order to compile a block expression constant, the simplest way for us
was to reuse what code we have and to generate an artifical function which
does not get added to the translation unit. The constant then becomes
a CALL_EXPR to this artifical function which we can pass to the constexpr
evaluator to resolve the result of this artifical 'CALL_EXPR'.
Before this patch we seperated the difference between block expressions
and non block expressions in constants. So for non block expressions we
simply compiled them as if it was a simple constant but this is not
guaranteed to be the case in rust, for example coercion sites can generate
temporaries during autoderef which we let the constant evaluator resolve
for us. This makes all constants handled in the same way to simplify the
logic here.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
In order to compile a block expression constant, the simplest way for us
was to reuse what code we have and to generate an artifical function which
does not get added to the translation unit. The constant then becomes
a CALL_EXPR to this artifical function which we can pass to the constexpr
evaluator to resolve the result of this artifical 'CALL_EXPR'.
Before this patch we seperated the difference between block expressions
and non block expressions in constants. So for non block expressions we
simply compiled them as if it was a simple constant but this is not
guaranteed to be the case in rust, for example coercion sites can generate
temporaries during autoderef which we let the constant evaluator resolve
for us. This makes all constants handled in the same way to simplify the
logic here.
|
|
We are not fully setting TYPE_CANONICAL yet but we don't need to be as
strict as the C++ front-end yet. param_use_canonical_types is a command
line option we are not using either.
|
|
This allows us to enforce better error handling on unify sites
|
|
|
|
|
|
1408: Experiment: add optional error codes to diagnostics r=CohenArthur a=davidmalcolm
rustc has error codes to identify specific errors, with URLs documenting each error.
In GCC 13 I've extended GCC's diagnostic subsystem so that a diagnostic can be associated with zero or more `diagnostic_metadata::rule` instances, which have a textual description and a URL. I meant this for rules in coding standards and specifications, but it struck me that potentially gccrs could reuse the same error codes as rustc.
The following pull request implements an experimental form of this; I picked a single error at random: [E0054](https://doc.rust-lang.org/error-index.html#E0054).
With this patch, gccrs emits e.g.:
```
bad_as_bool_char.rs:8:19: error: invalid cast [u8] to [bool] [E0054]
8 | let nb = 0u8 as bool;
| ~ ^
```
where the trailing [E0054] is colorized, and, in a suitably capable terminal is a clickable URL to https://doc.rust-lang.org/error-index.html#E0054.
The error code is after the diagnostic message, whereas rustc puts it after the word "error". I could change that in gcc's diagnostic.cc, perhaps.
I'm not sure if this is a good idea (e.g. is it OK and maintainable to share error codes with rustc?), but thought it was worth sharing.
1503: Add overflow traps r=CohenArthur a=CohenArthur
Opening as a draft since the code is really ugly and some tests still fail. I am looking for feedback on the implementation and my approximative use of functions like `temporary_variable` which I feel I might be using the wrong way.
I'll open up an issue of what still needs to be done, namely:
- [x] Properly handle sub and mul operations
- [ ] Disable the check in `release` mode (`-frust-disable-overflow-checks`)
- [ ] Handle specific rust overflow attribute (needs checkup on the name)
I'll open up some PRs to clean up some parts of the backend as well.
1511: lint: Do not emit unused warnings for public items r=CohenArthur a=CohenArthur
This fixes the overzealous warnings on public items from the unused pass
Co-authored-by: David Malcolm <dmalcolm@redhat.com>
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
|
|
Co-authored-by: philberty <philip.herron@embecosm.com>
|
|
|
|
|
|
1515: transcriber: Do not infinite loop if the current parsed node is an error r=CohenArthur a=CohenArthur
1516: parser: Parse RangeFullExpr without erroring out r=CohenArthur a=CohenArthur
Previously the parser would emit the errors despite later allowing the parsed expression to be null.
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
|
|
Co-authored-by: philberty <philip.herron@embecosm.com>
|
|
|
|
|
|
|
|
|
|
|
|
1510: rustc_attrs: Allow `rustc_inherit_overflow_checks` as a builtin attribute r=CohenArthur a=CohenArthur
We cannot yet handle this attribute, but we should not reject it either.
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
|
|
|
|
|
|
attribute
We cannot yet handle this attribute, but we should not reject it either
|
|
|
|
|
|
1507: Desugar double borrows into two HIR:BorrowExpr's r=philberty a=philberty
We simply hit a gcc_unreachable() on double borrows but it seems reasonable
to just desugar the AST into a borrow of a borrow to foo. Instead of a
borrow expression with a flag to be respected.
Fixes #1506
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
|
|
|
|
1499: Constant folding in gccrs: port over rest of the code from CP frontend r=philberty a=abbasfaisal
Co-authored-by: Faisal Abbas <90.abbasfaisal@gmail.com>
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
|
|
We simply hit a gcc_unreachable() on double borrows but it seems reasonable
to just desugar the AST into a borrow of a borrow to foo. Instead of a
borrow expression with a flag to be respected.
Fixes #1506
|
|
|
|
|
|
This adds in missed ported code for handling VAR_DECLS and jump's within
statement lists.
|
|
NOP_EXPR should fall through into convert and view_convert_exprs.
|
|
- error in handling of NOP_EXPR which results in failure in make check-rust
- DECL not being marked constant inside finalize_intrinsic_block
Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com>
|
|
Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com>
|
|
|
|
|
|
cxx_eval_component_reference.
Some important parts are commented out and marked such. These will
need revisiting.
|