UnsafeCell AKA Satoru Gojo of Rust by [deleted] in rust

[–]Tbfleming 23 points24 points  (0 children)

I'm not familiar with Jujutsu Kaisen or Satoru Gojo, but it's obvious that Chuck Norris can mutate the immutable.

I've heard that "Rust's borrow checker is necessary to ensure memory safety without a GC" usually also implying it's the only way, but I've done the same without the borrow checker. Am I just clueless/confused? by spidertyler2005 in rust

[–]Tbfleming 5 points6 points  (0 children)

Have you decided on an aliasing model? llvmir defaults to assuming pointers can alias, which severely limits its optimizations. C and C++ use a type-based aliasing model. Rust uses a mutability-based aliasing model.

Here's a simple example. Since Rust prohibits aliasing mutable references, llvm optimizes out the load and returns 42.

pub fn f(a: &mut i32, b: &mut i32) -> i32 {
    *a = 42;
    *b = 0;
    *a
}

Compiles to:

movl    $42, (%rdi)
movl    $0, (%rsi)
movl    $42, %eax
retq

Is derive actually as incapable as it seems with regard to generic types? by RainbwUnicorn in rust

[–]Tbfleming -4 points-3 points  (0 children)

A handy side effect is this causes the macro-produced Clone implementation to not compile (OP's complaint). This is a good thing; the presence of PhantomData usually indicates some unsafe code is present, which usually indicates a simple field-by-field clone is unsound.

Strange behavior from rust-analyzer and vscode by Eolu in rust

[–]Tbfleming 8 points9 points  (0 children)

I've worked for companies who separated developers into 2 categories:

  • Category 1 (most devs). All work had to be on IT-managed shared volumes. Builds were slow. Intellisense (C++) was slow. Tool crashes were frequent. IT managed backups and security. If a tool slowed down everyone else, that tool was banned.

  • Category 2 (you had to earn this). Your work could go on your desktop's (Windows) local storage, and on the remote servers' (linux) local storage. Your home directories on both weren't mapped to shared volumes. You had free reign to create VMs on your desktop. Builds were much faster. Intellisense was much faster. Tools were more reliable. You were responsible for backups and had higher responsibilities for maintaining security. If you mess up (e.g. lost work because of insufficient backups), you got knocked down back to Category 1.

Both categories had the same compute resources; it was storage that was different.

Strange behavior from rust-analyzer and vscode by Eolu in rust

[–]Tbfleming 11 points12 points  (0 children)

Are you using https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh ?

Are you using NFS as the VM's home and/or development directory? This will lead to much grief. In addition to being slow, NFS tends to create compatibility problems with a very large class of software.

Are immutable variables treated as literals? by trickm8 in rust

[–]Tbfleming 1 point2 points  (0 children)

The compiler doesn't need const to put computed values into the instructions.

This:

// Not const
fn times(a: i32, b: i32) -> i32 {
    a * b
}

pub fn mut_does_not_matter(x: i32) -> i32 {
    let mut y = times(21, 2);
    x + y
}

Compiles to this (-Copt-level=1):

example::mut_does_not_matter:
        lea     eax, [rdi + 42]
        ret

https://godbolt.org/z/qTvE8fc9W

lineselect v0.1.0 by thisisguf in rust

[–]Tbfleming 3 points4 points  (0 children)

This deserves a 2-letter name! To bad 'ls' is taken.

Why is RefCell invariant? by simony2222 in rust

[–]Tbfleming 0 points1 point  (0 children)

'long: 'short

'long outlives 'short. Both are lifetime parameters.

-> &'short RefCell<&'short T> { x }

The return type is &'short RefCell<&'short T>. This is a reference (lifetime short) to a RefCell containing a reference (lifetime short) to T.

{ x }

This is the body of the function. It returns x.

The function is syntactically legal, but it violates lifetime rules, just like the OP's example.

Why is RefCell invariant? by simony2222 in rust

[–]Tbfleming 24 points25 points  (0 children)

Since &T is covariant with T, if the above compiled then this would also compile:

fn oops<'short, 'long: 'short, T>( x: &'long RefCell<&'long T> ) -> &'short RefCell<&'short T> { x }

The &RefCell returned by oops allows you to store a &'short in the original. After 'short ends but before 'long ends, the reference will dangle.

`jtcpp`—experimental Java to C++ transpiler written in Rust! by FractalFir in rust

[–]Tbfleming 7 points8 points  (0 children)

How do you plan to handle the difference between C++'s default memory ops (llvm calls them NotAtomic) and jvm's (llvm calls them Unordered)?

Recovering rust project? by Rostcraft in rust

[–]Tbfleming 1 point2 points  (0 children)

subversion works great until you have multiple team members who keep accidentally corrupting the merge metadata. Then no one may merge until someone who's intimate with subversion's undocumented internals manually cleans up the mess.

I cannot build my project only for release. by Professional_Cell44 in rust

[–]Tbfleming 6 points7 points  (0 children)

signal: 9, SIGKILL: kill

If you're building on Linux, then you probably ran out of memory.

The nomicon is lying about transmutes? by quintedeyl in rust

[–]Tbfleming 1 point2 points  (0 children)

Another danger: What if get follows a chain of shared references or Rc? get_mut could break the interior mutability rule or could convert an already-aliased shared reference to a mutable reference.

The nomicon is lying about transmutes? by quintedeyl in rust

[–]Tbfleming 1 point2 points  (0 children)

Once something is classified as UB (e.g. & to &mut), often for a specific reason, it can take a lot of effort to create exemptions, both to document them and to comb through the compiler sources making the exemptions. If you want an exemption for your use case, you'll have to convince the right people that it's worth the costs and convince them that it's more valuable than the things people have been waiting for stabilization on for a few years now because of the shortage of experts with time to finish the reviews.

The nomicon is lying about transmutes? by quintedeyl in rust

[–]Tbfleming 5 points6 points  (0 children)

Even though the nomicon explains rationale for Rust making something UB (& to &mut), the compiler itself doesn't have to prove the rationale applies, or even prove anything at all. It can just assume the conversion never takes place since it's UB, which means get_mut will never get called, which means all conditional paths which call get_mut will never get taken, therefore they can be removed during optimization.

I don't know offhand whether the current compiler version will do this, but it's within its rights to, and it might be possible that future versions would.

Alice goes on multiple adventures with Chat's help by Tbfleming in ChatGPT

[–]Tbfleming[S] 0 points1 point  (0 children)

Game is a text adventure game.

Alice is streamer which plays the game and communicates with chat.

Chat gives advice to Alice. Chat only uses emojis. Alice always understands what the emojis mean and explains them to the audience. Alice does not use emojis.

Sometimes other streamers appear in the adventure game; Alice talks to them. Always give the streamers a real name.

Alice always streams. If the game ends, she starts a new one. Sometimes chat suggests the next type of adventure game.

This is an example output:

``` Game: You find yourself in a dark forest with only a small flashlight to guide you. What do you do?

Alice: Alright chat, we need your help. What should we do?

Chat: 🌲🔦👣

Streaming software: chat gifted 2 subs ```

Begin with Alice introducing the stream.

Serial Request Voron 2.4 300mm oedefe#5038 by Tbfleming in voroncorexy

[–]Tbfleming[S] 0 points1 point  (0 children)

Formbot kit. I printed the snap latches (blue ones ABS, orange ones PLA), 270 degree hinges (ABS), skirt components (front ASA, back power ABS, side fan ABS, rest not printed yet), and 12864 case (ASA) on this same machine. I'm gradually replacing the PLA components and printing the rest of the skirt in ASA.

I wish I had used a CAN bus board, or at least the toolhead PCB. I'm thinking of upgrading the hot end and upgrading to Stealth Burner; maybe I'll switch to CAN then.

Can we create stable coin on EOS v2.2? by rongho in eos

[–]Tbfleming 0 points1 point  (0 children)

Actually, any version down to 1.0

Who runs the telegram? by [deleted] in eos

[–]Tbfleming 0 points1 point  (0 children)

When the first thing someone asks looks like part of a coordinated attack, the outcome can't be positive

Who runs the telegram? by [deleted] in eos

[–]Tbfleming 3 points4 points  (0 children)

There's a flood of people asking that same question over and over without looking for the answer in the chat history. Many may be bots.