My Journey as a Rust Contributor

Urgau

Urgau

  • Started Rust in 2020
    • became a huge fan
  • Rust contributor since 2021
  • Rust compiler member since 2024

--check-cfg

RFC3013

Request for Comments (RFC)

RFC3013

#[cfg(unix)]

#[cfg(target_os = "linux")]

#[cfg(empty = "")]

rustc --check-cfg 'values(name, "value1", "value2", ... "valueN")'
values(name) // the empty value?
rustc --check-cfg 'values(name)'
      --check-cfg 'values(name, "test")'
#[cfg(name = "test")] // expected

#[cfg(name)] // also expected?
             // ambiguity in the syntax

MCP#636

// explicit none
values(none())

Uplifting Clippy lints

more than 700 lints

lint = tool to help improve your source code think of warnings, errors

Uplift todo list

  • Find a lint name
  • Declare the new lint
  • Add lint logic
  • Add tests!
  • Add more tests!
  • Remove from clippy

all in the same PR

Nominate!

Did many of them!

rustdoc

pub enum IrTyKind<'a, I: Interner> {
    /// Doc comment for AdtKind
    AdtKind(&'a I::Adt),
    /// and another one for TyKind
    TyKind(I::Adt, I::Ty),
    // no comment
    StructKind { a: I::Adt, },
}

pub type TyKind<'a> = IrTyKind<'a, TyCtxt>;

before my change

before my change

after my change

no more  

I::

includes variants

- (stdin)

$ rustc -
$ rustdoc -

- (stdin)

$ curl code.rs | rustdoc - && \
   open doc/*/index.html

The standard library

core

alloc

std

panic_unwind

panic_abort

hashbrown

stdarch

midpoint

midpoint

/// Calculates the middle point of `self` and `rhs`.
///
/// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a
/// sufficiently-large signed integer type. This implies that the 
/// result is always rounded towards zero and that no overflow will
/// ever occur.

impl i{8,16,32,64,128,size} {
    pub const fn midpoint(self, rhs: Self) -> Self;
}

impl u{8,16,32,64,128,size} {
    pub const fn midpoint(self, rhs: Self) -> Self;
}

impl f{32,64} {
    pub const fn midpoint(self, rhs: Self) -> Self;
}
// in u32::midpoint, we use u64!
((a as u64 + b as u64) / 2) as u32
// HashMap
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized;

only one mutable reference at the time

for check-cfg we have to register 7 target cfgs for >300 targets

HashMap::get_mut

// in HashMap (will be stable in 1.86.0)
pub fn get_disjoint_mut<Q, const N: usize>(
    &mut self,
    ks: [&Q; N],
) -> [Option<&mut V>; N]
where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized;
// in check-cfg implementation
let [
    Some(values_target_abi),
    Some(values_target_arch),
    Some(values_target_endian),
    Some(values_target_env),
    Some(values_target_family),
    Some(values_target_os),
    Some(values_target_pointer_width),
    Some(values_target_vendor),
] = self.expecteds.get_disjoint_mut(VALUES)
else {
	panic!("unable to get all the check-cfg values buckets");
};

Stabilization

of check-cfg!

Crater run

Projects from:

Analysis of the results

Seeking feedback

call-for-testing

  • This week in Rust ✓

  • Rust for Linux ✓
  • Usage inside rust-lang/rust ✓

Stabilization report 🎉

after years of work!

After a few weeks

Being recognized by your peers

Come join us!

My Journey as a Rust Contributor

By urgau-1

My Journey as a Rust Contributor

  • 84