profile
viewpoint

Atraxus/dit 0

Dit is a university project that builds a peer-to-peer network implementation for Git using the Rust programming language. Leveraging the Chord distributed hash table protocol, it seeks to provide a scalable and efficient solution for distributed version control.

lukas-code/cargo 0

The Rust package manager

lukas-code/diesel 0

A safe, extensible ORM and Query Builder for Rust

lukas-code/dit 0

Dit is a university project that builds a peer-to-peer network implementation for Git using the Rust programming language. Leveraging the Chord distributed hash table protocol, it seeks to provide a scalable and efficient solution for distributed version control.

lukas-code/miri 0

An interpreter for Rust's mid-level intermediate representation

lukas-code/miri-test-libstd 0

Testing the Rust standard library with Miri, continuously

lukas-code/reference 0

The Rust Reference

lukas-code/rust 0

Empowering everyone to build reliable and efficient software.

pull request commentrust-lang/rust

Document panics on unsigned wrapping_rem (#116063)

The same should also be added to wrapping_div, wrapping_div_euclid and wrapping_rem_euclid.

Colonial-Dev

comment created time in 8 days

delete branch lukas-code/rust

delete branch : format!("{r#ident}")

delete time in 13 days

issue commentrust-lang/rust

regresion: parsing failure in derive expansion?

Regression in https://github.com/rust-lang/rust/pull/114617, where the order of the variants of proc_macro::Spacing got changed.

MCVE: (playground)

extern crate proc_macro;

fn main() {
    assert_eq!(proc_macro::Spacing::Alone as u8, 0);
}

The watt crate is relying on the discriminant values here:

https://github.com/dtolnay/watt/blob/8dc8981c6c5c2a3e0ff6c9ec3830133538c78870/src/encode.rs#L108-L112

https://github.com/dtolnay/watt/blob/8dc8981c6c5c2a3e0ff6c9ec3830133538c78870/src/decode.rs#L117-L124

@rustbot label -E-needs-bisection -E-needs-mcve +S-has-mcve +A-proc-macros

Mark-Simulacrum

comment created time in 18 days

issue commentrust-lang/rust

The x86_64 extern "C" fn ABIs is wrong when packed structs are involved

struct P
{
    char i;
    float f;
} __packed__;

That's defining a global variable named __packed__ of type struct P. The correct syntax is

struct P
{
    char i;
    float f;
} __attribute__((__packed__));

The x86-64 psABI says

  • If the size of an object is larger than eight eightbytes, or it contains unaligned fields, it has class MEMORY.
  • If the class is MEMORY, pass the argument on the stack at an address respecting the arguments alignment (which might be more than its natural alignement).

Since the field f is unaligned, passing the value indirectly / on the stack is correct.

heiher

comment created time in 22 days

push eventlukas-code/rust

Lukas Markeffsky

commit sha d990eee0c8ae2ce465351b00abbdb8bfdd1caf4b

add diagnostic for raw identifiers in format string

view details

push time in 24 days

PR opened rust-lang/rust

add diagnostic for raw identifiers in format string

Format strings don't support raw identifiers (e.g. format!("{r#type}")), but they do support keywords in the format string directly (e.g. format!("{type}")). This PR improves the error output when attempting to use a raw identifier in a format string and adds a machine-applicable suggestion to remove the r#.

fixes https://github.com/rust-lang/rust/issues/115466

+146 -35

0 comment

6 changed files

pr created time in 24 days

push eventlukas-code/rust

Lukas Markeffsky

commit sha 54acc543af1b23df327e712150fc6226f55f88a4

add diagnostic for raw identifiers in format string

view details

push time in 24 days

create barnchlukas-code/rust

branch : format!("{r#ident}")

created branch time in 24 days

issue commentrust-lang/rust

Raw identifiers don't work in formatting strings

Identifiers in format strings are always "raw" and it will compile if you remove the r#:

fn main() {
    let r#type = "foobar";
    println!("It is {type}");
}

This is documented here:

But the error should probably have a better diagnostic and a suggestion to remove the r#.

alexschrod

comment created time in a month

delete branch lukas-code/rust

delete branch : u16_from_char

delete time in a month

PR closed rust-lang/rust

don't overflow the stack when printing huge types A-testsuite T-compiler S-waiting-on-author T-infra perf-regression

This PR fixes a few stack overflows by growing the stack in the appropriate places:

  • in tcx.short_ty_string when generating the the full type name has been written to '...' diagnostic
  • in tcx.resolve_vars_if_possible

fixes https://github.com/rust-lang/rust/issues/112800 fixes https://github.com/rust-lang/rust/issues/112992

+158 -12

31 comments

11 changed files

lukas-code

pr closed time in a month

pull request commentrust-lang/rust

don't overflow the stack when printing huge types

I currently don't have a clean solution for https://github.com/rust-lang/rust/pull/112998#issuecomment-1620470071. That's a stack overflow in the destructor of ImplDerivedObligationCause that happens for very deeply nested obligations, but only on Windows for some reason.

I think the correct solution involves adding some actual interning to InternedObligationCauseCode, instead of just sticking it into an Rc.

For now, I'm gonna close this as "postponed".

lukas-code

comment created time in a month

delete branch lukas-code/rust

delete branch : span-ctxt

delete time in a month

issue commentrust-lang/rust

Wide raw pointer casts let me assert marker trait bounds but not lifetime bounds

related: https://github.com/rust-lang/rust/issues/113257

RalfJung

comment created time in 2 months

issue commentrust-lang/rust

ICE: Failed to extract DefId: opt_local_def_id_to_hir_id

searched nightlies: from nightly-2023-05-13 to nightly-2023-08-13 regressed nightly: nightly-2023-05-24 searched commit range: https://github.com/rust-lang/rust/compare/8b4b20836b832e91aa605a2faf5e2a55190202c8...5ea3f0ae08c07472239a94ce55601e9b63eb1f45 regressed commit: https://github.com/rust-lang/rust/commit/f3d597b31c0f101a02c230798afa31a36bdacbc6 -> https://github.com/rust-lang/rust/pull/111807

<details> <summary>bisected with <a href='https://github.com/rust-lang/cargo-bisect-rustc'>cargo-bisect-rustc</a> v0.6.6</summary>

Host triple: x86_64-unknown-linux-gnu Reproduce with:

cargo bisect-rustc --script script.sh -- build 

script.sh:

#!/bin/sh
rm -rf incr* && rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg a && rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg b

</details>

8051Enthusiast

comment created time in 2 months

issue commentrust-lang/rust

ICE: Failed to extract DefId: opt_local_def_id_to_hir_id

Reduced:

#![allow(dead_code)]

trait Query {
    type Value;
}

struct Slot<Q>
where
    Q: Query,
{
    state: std::cell::Cell<QueryState<Q>>,
}

enum QueryState<Q>
where
    Q: Query,
{
    InProgress(Q::Value),
    Memoized(Memo<Q>),
}

struct Memo<Q>
where
    Q: Query,
{
    value: Q::Value,
    inputs: Box<()>,
}

struct HirNodeQuery;

impl Query for HirNodeQuery {
    type Value = HirNode;
}

enum HirNode {
    A,
    #[cfg(a)]
    B(()),
}

fn conjure<T>() -> T {
    todo!()
}

fn main() {
    let slot = conjure::<Slot<HirNodeQuery>>();
    slot.state.set(conjure())
}
rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg a
rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg b

@rustbot label -E-needs-mcve +S-has-mcve +A-incr-comp

8051Enthusiast

comment created time in 2 months

issue commentrust-lang/rust

Broken MIR in DropGlue when compiling anyhow with -Zvalidate-mir

cargo bisect-rustc says this but I'm not sure I believe it:

Bisect points to https://github.com/rust-lang/rust/pull/109075, because that's where this TAIT pattern got added to std.

Bisecting the reduced example points me to https://github.com/rust-lang/rust/pull/112777.

<details>

Regression in https://github.com/rust-lang-ci/rust/commit/9cf74a0f380df8ffc43534bd52e8c35e16339873

searched nightlies: from nightly-2023-06-13 to nightly-2023-08-02 regressed nightly: nightly-2023-06-20 searched commit range: https://github.com/rust-lang/rust/compare/2d0aa57684e10f7b3d3fe740ee18d431181583ad...fe7454bf439c93cbe9ac8a8f7fcfacd5a40244c2 regressed commit: https://github.com/rust-lang/rust/commit/fe7454bf439c93cbe9ac8a8f7fcfacd5a40244c2

<details> <summary>bisected with <a href='https://github.com/rust-lang/cargo-bisect-rustc'>cargo-bisect-rustc</a> v0.6.6</summary>

Host triple: x86_64-unknown-linux-gnu Reproduce with:

cargo bisect-rustc -- rustc -- -Z validate-mir 

</details>

</details>

saethlin

comment created time in 2 months

issue commentrust-lang/rust

ICE: broken mir while building rustc

Reduced:

// crate foo

#![feature(type_alias_impl_trait)]

type Tait = impl Sized;

#[allow(dead_code)]
fn constrain() -> Tait {}

struct WrapperWithDrop<T>(T);
impl<T> Drop for WrapperWithDrop<T> {
    fn drop(&mut self) {}
}

pub struct Foo(WrapperWithDrop<Tait>);
// crate bar

pub fn drop_foo(_: foo::Foo) {}

@rustbot label F-type_alias_impl_trait

matthiaskrgr

comment created time in 2 months

create barnchlukas-code/rust

branch : span-ctxt-macro-backtrace

created branch time in 2 months

push eventlukas-code/rust

Lukas Markeffsky

commit sha 3694fd08e6e9d0828369ac1c9ee205cd0de71287

introduce `Span::find_ancestor_inside_same_ctxt` and use it for function argument diagnostics

view details

Lukas Markeffsky

commit sha 37d62fbf9e5bd2010896a28d6b363bd85cbecb33

don't remove args for function calls coming from macro expansions

view details

Lukas Markeffsky

commit sha 985036b5a125ceb66e4a96bedf65a9fd69a9baad

add more tests for argument removal with wacky spans

view details

push time in 2 months

pull request commentrust-lang/reference

replace 'UB on raw ptr deref' with UB on place projection/access

fn deref_partially_dangling() {
    let x = (1, 13);
    let xptr = &x as *const _ as *const (i32, i32, i32);
    let val = unsafe { (*xptr).1 };
    assert_eq!(val, 13);
}

Have we decided that the order of the fields in the tuple (i32, i32, i32) is guaranteed? In the UCG it specifically says that tuple fields can be reordered, such that .1 could actually be the third field in memory and out-of-bounds.

RalfJung

comment created time in 2 months

Pull request review commentrust-lang/rust

Fix argument removal suggestion around macros

 impl Span {         while !outer.contains(self) {

Wouldn't that cause an infinite loop in the current implementation of find_ancestor_in_same_ctxt and find_ancestor_inside? To me the logic in macro_backtrace looks like it's just deduplicating the backtrace for self-recursive macro calls, not doing any kind of cycle check.

lukas-code

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/rust

Fix argument removal suggestion around macros

 impl Span {         while !outer.contains(self) {

We could have a new method find_ancestor_inside_same_ctxt that would call find_ancestor_in_same_ctxt and then also check that the spans overlap. I think that should be semantically equal to your first suggestion, because the chain of ctxts can't be cyclic? The new method would then be used instead of find_ancestor_inside where the span needs to be joined.

lukas-code

comment created time in 2 months

PullRequestReviewEvent

issue commentrust-lang/rust

Recursion using `extern "C"` causes miscompilation

reduced LLVM IR: https://godbolt.org/z/Yncqrjfr7

define void @foo(ptr noalias byval(i64) %x) {
start:
  %new_x = alloca i64, align 8
  %x_val = load i64, ptr %x, align 8
  %is_zero = icmp eq i64 %x_val, 0
  br i1 %is_zero, label %end, label %recurse

recurse:
  store i64 0, ptr %new_x, align 8
  call void @foo(ptr %new_x)
  br label %end

end:
  ret void
}

optimizes to

define void @foo(ptr noalias nocapture readonly byval(i64) %x) {
  %x_val = load i64, ptr %x, align 8
  %is_zero = icmp eq i64 %x_val, 0
  br i1 %is_zero, label %end, label %recurse

recurse:
  br label %recurse

end:
  ret void
}

Needs noalias + byval to reproduce. Looks like the tail call optimization pass writes into the argument, even thou it is readonly at that point.

Did not bisect, but this was probably introduced by the upgrade to LLVM 16: https://github.com/rust-lang/rust/pull/109474

@rustbot label A-llvm I-unsound

AngelicosPhosphoros

comment created time in 2 months

Pull request review commentrust-lang/rust

Small wins for formatting-related code

 pub trait Write {     /// assert_eq!(&buf, "world");     /// ```     #[stable(feature = "rust1", since = "1.0.0")]-    fn write_fmt(mut self: &mut Self, args: Arguments<'_>) -> Result {-        write(&mut self, args)+    fn write_fmt(&mut self, args: Arguments<'_>) -> Result {+        // We use a specialization for `Sized` types to avoid an indirection+        // through `&mut self`+        trait SpecWriteFmt {+            fn spec_write_fmt(self, args: Arguments<'_>) -> Result;+        }++        impl<W: Write + ?Sized> SpecWriteFmt for &mut W {+            #[inline]+            default fn spec_write_fmt(mut self, args: Arguments<'_>) -> Result {+                write(&mut self, args)+            }+        }++        impl<W: Write> SpecWriteFmt for &mut W {+            #[inline]+            fn spec_write_fmt(self, args: Arguments<'_>) -> Result {+                write(self, args)+            }+        }+

Yes, that's correct, disregard my comment.

a1phyr

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentrust-lang/rust

Small wins for formatting-related code

 pub trait Write {     /// assert_eq!(&buf, "world");     /// ```     #[stable(feature = "rust1", since = "1.0.0")]-    fn write_fmt(mut self: &mut Self, args: Arguments<'_>) -> Result {-        write(&mut self, args)+    fn write_fmt(&mut self, args: Arguments<'_>) -> Result {+        // We use a specialization for `Sized` types to avoid an indirection+        // through `&mut self`+        trait SpecWriteFmt {+            fn spec_write_fmt(self, args: Arguments<'_>) -> Result;+        }++        impl<W: Write + ?Sized> SpecWriteFmt for &mut W {+            #[inline]+            default fn spec_write_fmt(mut self, args: Arguments<'_>) -> Result {+                write(&mut self, args)+            }+        }++        impl<W: Write> SpecWriteFmt for &mut W {+            #[inline]+            fn spec_write_fmt(self, args: Arguments<'_>) -> Result {+                write(self, args)+            }+        }+

This could also have a specialization for dyn Write itself:


        impl SpecWriteFmt for &mut (dyn Write + '_) {
            #[inline]
            fn spec_write_fmt(self, args: Arguments<'_>) -> Result {
                write(self, args)
            }
        }

... and probably dyn Write + Send and dyn Write + Send + Sync as well, because those are considered different types for the sake of specialization.

a1phyr

comment created time in 2 months

PullRequestReviewEvent
more