GCC Rust Weekly Status Report 41

Thanks again to Open Source Security, inc and Embecosm for their ongoing support for this project.

Milestone Progress

We are in the final few weeks to close out declarative macros by the end of the month; this should be the last prominent feature required before compiling more of an older version of libcore. We should be roughly on time, maybe a few days out, but nothing significant stands out as a roadblock right now. I imagine we might move some of the built-in macros to be part of the builtins and intrinsics ongoing milestone since some of these may require more builtins such as panic!.

To keep on track with our aggressive timeline, we want to begin investigations into achieving our crate metadata exports with GCC since we have several options available to us, such as LTO streaming, CPP modules, or roll our own system such as GCCGO’s .go_export section in object files with a simplified AST.

Monthly Community Call

We had our regular community call on 4th March 2022, please find our meeting notes over on: https://github.com/Rust-GCC/Reporting/blob/main/2022-03-04-community-call.md

Completed Activities

  • Refactor substitution context during macro expansion to be in its own file PR981
  • Enforce quites during command line cfg arguments PR983
  • Bugfix memory corruption of lexing string buffers PR988
  • Remove bad lambda from iteration of arguments on function types PR984
  • Add must_use attribute support PR990
  • Bug fix parsing macro invocation with semicolon’s during statement contexts PR985
  • Fix ICE during recursive macro invocations PR986
  • Support repetition separators in macro rules PR991
  • Refactor HIR visitor and split it up in stmt, vis-item, pattern, external-item, impl, type and expression visitors PR954

Contributors this month

Overall Task Status

CategoryLast WeekThis WeekDelta
TODO118113-5
In Progress1717
Completed297306+9
GitHub Issues

Test Cases

CategoryLast WeekThis WeekDelta
Passing60686177+109
Failed
XFAIL2121
XPASS
make check-rust

Bugs

CategoryLast WeekThis WeekDelta
TODO4038-2
In Progress56+1
Completed109112+3
GitHub Bugs

Milestones Progress

MilestoneLast WeekThis WeekDeltaStart DateCompletion DateTarget
Data Structures 1 – Core100%100%30th Nov 202027th Jan 202129th Jan 2021
Control Flow 1 – Core100%100%28th Jan 202110th Feb 202126th Feb 2021
Data Structures 2 – Generics100%100%11th Feb 202114th May 202128th May 2021
Data Structures 3 – Traits100%100%20th May 202117th Sept 202127th Aug 2021
Control Flow 2 – Pattern Matching100%100%20th Sept 20219th Dec 202129th Nov 2021
Macros and cfg expansion65%70%+5%1st Dec 202128th Mar 2022
Imports and Visibility0%0%29th Mar 202227th May 2022
Const Generics0%0%30th May 202225th Jul 2022
Intrinsics0%0%6th Sept 202130th Sept 2022
GitHub Milestones

Risks

RiskImpact (1-3)Likelihood (0-10)Risk (I * L)Mitigation
Rust Language Changes3721Keep up to date with the Rust language on a regular basis
Going over target dates2510Maintain status reports and issue tracking to stakeholders

Planned Activities

  • Continue work on macros
  • Continue work into Slices
  • Merge unused code warning fixes
  • Support the mutable context during type checking for dereference or array index operations
  • Create more good-first-pr’s

Detailed changelog

must use attribute

To support must use, the GCC CPP front-end already supports the C++ nodiscard attribute which is analogus to rust must use attribute. Rust also supports using must use on types which we still need to test/support but this is the building block to support this on functions which discard their results.

#[must_use = "TEST 1"]
fn test1() -> i32 {
    123
}

#[must_use = "TEST 2"]
fn test2() -> i32 {
    456
}

fn main() {
    let _a = test1();

    test2();
}

The error respects GCC -Wunused-result but this is turned on by default in the front-end.

<source>:14:5: warning: ignoring return value of 'example::test2', that must be used: 'TEST 2' [-Wunused-result]
   14 |     test2();
      |     ^
<source>:7:1: note: declared here
    7 | fn test2() -> i32 {
      | ^

see: https://godbolt.org/z/81j9G584e

Recursive macros using seperators

Macros can be recusive resulting in new macro invocations which need to be expanded. They also can have matchers which are like regular expressions in their matchers which require n-number of arguments delimited by a single matcher to terminate the sequence. This looks very similar to bison grammer files which is pretty impressive how expressive macros are in rust.

macro_rules! add {
        ($e:expr | $($es:expr) | *) => {
            $e + add!($($es) | *)
        };
        ($e:expr) => {
            $e
        };
    }

fn test() -> i32 {
    add!(1 | 2 | 3 | 4 | 5 | 6)
}

see: https://godbolt.org/z/TfWrEovf3

Leave a Reply

Your email address will not be published.