profile
viewpoint
lzutao lzutao D28DBB1A0E26FEDA Legally break your Rust code.

lzutao/9cc 0

A Small C Compiler

lzutao/acpitool 0

Mirror and changes from Ubuntu acpitool source package

lzutao/advisory-db 0

Security advisory database for Rust crates published through crates.io

lzutao/alex-rustc-demangle 0

Rust symbol demangling

lzutao/api-guidelines 0

Rust API guidelines

lzutao/bat 0

A cat(1) clone with wings.

lzutao/bench-rust-float-integral 0

Benchmark between different methods to know a f64 value is also an integer

lzutao/blog.rust-lang.org 0

The Rust Programming Language Blog

lzutao/bogo-c 0

Bogo engine, reimplemented in C for portability.

pull request commentrust-lang/rust

Avoid `unwrap_or_else` in str indexing

I wonder if slice indexing has the same problem. @tmiasko Do you want to file another PR to check that?

tmiasko

comment created time in 11 hours

pull request commentrust-lang/rust

Avoid recompiling std when tests change in std::net

I am modifying things in #75110 . It is kind of painful when I only change tests but std is recompiled.

lzutao

comment created time in 16 hours

pull request commentrust-lang/rfcs

Introduce '$self' macro metavar for hygienic macro items

At first glance, I was thinking $self help us write <item>.macro!() (the suffix macro).

SergioBenitez

comment created time in 19 hours

Pull request review commentrust-lang/rust

Do not trigger `unused_braces` for `while let`

+// check-pass++#![deny(unused_braces)]++fn main() {+    let mut a = Some(3);+    // Shouldn't warn below `a`.+    while let Some(ref mut v) = {a} {

I'm kinda get it your point. Does it mean parsing unnamed structs at expr is unambiguous and allowed? Even though struct literals are forbidden.

JohnTitor

comment created time in a day

Pull request review commentrust-lang/rust

Do not trigger `unused_braces` for `while let`

+// check-pass++#![deny(unused_braces)]++fn main() {+    let mut a = Some(3);+    // Shouldn't warn below `a`.+    while let Some(ref mut v) = {a} {

But with the unused braces warning people will feel discouraged to use it.

JohnTitor

comment created time in a day

pull request commentrust-lang/rust

Use u32::from_le_bytes to fix a FIXME

Thanks for coming but to_ne_bytes returns native bytes, not network bytes like to_be_bytes.

lzutao

comment created time in a day

Pull request review commentrust-lang/rust

Use newtype to enforce endianess for Ipv4Addr

 impl From<u32> for Ipv4Addr {     /// ```     /// use std::net::Ipv4Addr;     ///-    /// let addr = Ipv4Addr::from(0x0d0c0b0au32);-    /// assert_eq!(Ipv4Addr::new(13, 12, 11, 10), addr);+    /// let addr = Ipv4Addr::from(0xcafebabe);+    /// assert_eq!(Ipv4Addr::new(0xca, 0xfe, 0xba, 0xbe), addr);

I find it a little easier to read. Probably should be a separate commit.

lzutao

comment created time in a day

pull request commentrust-lang/rust

Use union to cast between big endian fields of s6_addr

Thanks both. I will resolve it later. Do you have an interest to take a look at #75110 ? In that PR, I use newtype to enforce endianness for Ipv4Addr. But beware that it is a draft one and I'm figuring out how a lot of tests are falling.

lzutao

comment created time in a day

push eventlzutao/rustc

Lzu Tao

commit sha 2c5e29296c01bad8d630cdf82d63988c735b043a

Use newtype to enforce endianess for Ipv4Addr

view details

push time in a day

push eventlzutao/rustc

Lzu Tao

commit sha 083b739122c100115a697e98f76f59029a815a15

Use newtype to enforce endianess for Ipv4Addr

view details

push time in a day

push eventlzutao/rustc

Lzu Tao

commit sha 3e02f651d514c1d7805c839a58117bede557607c

Use newtype to enforce endianess for Ipv4Addr

view details

push time in a day

Pull request review commentrust-lang/rust

Use newtype to enforce endianess for Ipv4Addr

 impl SocketAddrV4 {     /// ```     #[stable(feature = "rust1", since = "1.0.0")]     pub fn ip(&self) -> &Ipv4Addr {-        unsafe { &*(&self.inner.sin_addr as *const c::in_addr as *const Ipv4Addr) }+        unsafe {+            &*(&self.inner.sin_addr as *const c::in_addr as *const super::endian::BeU32+                as *const Ipv4Addr)+        }

Is the unsafe here still correct after this PR? cc @RalfJung I need you here.

lzutao

comment created time in a day

PR opened rust-lang/rust

Use newtype to enforce endianess for Ipv4Addr

There are alot of tests are falling right now. Currently I make this PR as draft to collect ideas about implementation and safety condition in unsafe blocks. r? @ghost

+37 -8

0 comment

5 changed files

pr created time in a day

create barnchlzutao/rustc

branch : ip-endianness

created branch time in a day

PR opened rust-lang/rust

Avoid recompilation when tests change in std::net

I moved ui tests to their own files.

r? @KodrAus

+2419 -2468

0 comment

10 changed files

pr created time in a day

push eventlzutao/rustc

Lzu Tao

commit sha 6d27ccb3b040e22800957b173f892bb74490fa19

Move net::ip tests to their own files

view details

Lzu Tao

commit sha ca978917ee5219462d361eda1e1b67ad9dd15623

Move net::parser tests to their own files

view details

Lzu Tao

commit sha 3e57d89bfecdc6ffcf2958142406f07dd13988a9

Move net::udp tests to their own files

view details

Lzu Tao

commit sha b9d570f265b6112f69aad9e6c0abeacefb941517

Move net::tcp tests to their own files

view details

Lzu Tao

commit sha 632b9d86caa2066cff9cf3848a11603c9187d760

Reformat tests The reason we do it in a new commit is to avoid changing tests when moving it around.

view details

push time in a day

push eventlzutao/rustc

Vadim Petrochenkov

commit sha 0eacf02f01b4ea084a4f970e487ce6d3a6a20f90

tests: Ignore src/test/debuginfo/rc_arc.rs on Windows It requires loading pretty-printers, but GDB doesn't load them on Windows

view details

Tomasz Miąsko

commit sha 82651db9b2f6ecb16c773e8afa301c862118bb82

Fix change detection in CfgSimplifier::collapse_goto_chain Check that the old target is different from the new collapsed one, before concluding that anything changed.

view details

Tomasz Miąsko

commit sha 7f9f2ff9f40ed46a209cf232429120333fe42455

Remove redundant assignment from CfgSimplifier

view details

bors

commit sha 1b0ff9e7d0620daa86a80bf92f6b661f7699984e

Auto merge of #75068 - petrochenkov:ignore-debinfo, r=Mark-Simulacrum tests: Ignore src/test/debuginfo/rc_arc.rs on Windows It requires loading pretty-printers (`src\etc\gdb_load_rust_pretty_printers.py`), but GDB doesn't load them on Windows. Not sure how this passes through CI, due to an old GDB version perhaps?

view details

bors

commit sha dbc2ef25fb5e15445de38f19ba75547a6cf35cae

Auto merge of #75076 - tmiasko:simplify-goto, r=oli-obk Fix change detection in CfgSimplifier::collapse_goto_chain Check that the old target is different from the new collapsed one, before concluding that anything changed. Fixes #75074 Fixes #75051

view details

kennytm

commit sha fd7596c9a538b3c51f2d55c2d5f6ef881e6ba742

fix broken git commit in stdarch

view details

bors

commit sha c186aed59ab590eb586751afaf6b9e0ea9b78099

Auto merge of #75092 - kennytm:fix-75009, r=pietroalbini Fix broken git commit in stdarch Follow-up on #75009, point to the real master commit.

view details

Lzu Tao

commit sha 0bd2b49b5b6c3deadaf2107f3f200f8b664f6b73

Move net::addr tests to their own files Avoid recompiling std when tests changed

view details

Lzu Tao

commit sha 7941908470906d8a75ab7a5d9b81ba8cc6ab61c5

Move net::ip tests to their own files Avoid recompiling std when tests changed

view details

push time in a day

create barnchlzutao/rustc

branch : seprate-tests

created branch time in a day

Pull request review commentrust-lang/rust

Use u32::from_le_bytes to fix a FIXME

 impl Ipv4Addr {     #[stable(feature = "rust1", since = "1.0.0")]     #[rustc_const_stable(feature = "const_ipv4", since = "1.32.0")]     pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {-        // FIXME: should just be u32::from_be_bytes([a, b, c, d]),-        // once that method is no longer rustc_const_unstable-        Ipv4Addr {-            inner: c::in_addr {-                s_addr: u32::to_be(-                    ((a as u32) << 24) | ((b as u32) << 16) | ((c as u32) << 8) | (d as u32),-                ),-            },-        }+        Ipv4Addr { inner: c::in_addr { s_addr: u32::from_be_bytes([a, b, c, d]) } }

Yeah, judge by assembly, I think ne is the correct answer: https://rust.godbolt.org/z/e5ahnK

lzutao

comment created time in 2 days

Pull request review commentrust-lang/rust

Use u32::from_le_bytes to fix a FIXME

 impl Ipv4Addr {     #[stable(feature = "rust1", since = "1.0.0")]     #[rustc_const_stable(feature = "const_ipv4", since = "1.32.0")]     pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {-        // FIXME: should just be u32::from_be_bytes([a, b, c, d]),-        // once that method is no longer rustc_const_unstable-        Ipv4Addr {-            inner: c::in_addr {-                s_addr: u32::to_be(-                    ((a as u32) << 24) | ((b as u32) << 16) | ((c as u32) << 8) | (d as u32),-                ),-            },-        }+        Ipv4Addr { inner: c::in_addr { s_addr: u32::from_be_bytes([a, b, c, d]) } }

Those endiannesses is confusing in practice. Hope we have an way to enforce this in type system.

lzutao

comment created time in 2 days

pull request commentrust-lang/rust

Use u32::from_le_bytes to fix a FIXME

I mean, the tests pass so the current conversion is right. But I am worry about we have no guarantee about endianness of c::in_addr. But many systems assume that in_addr and in6_addr in big endian.

This PR could be merged but I think we need a issue to validate all assignments and conversions to in_addr are valid.

lzutao

comment created time in 2 days

pull request commentrust-lang/rust

Use u32::from_le_bytes to fix a FIXME

isn't ne and le the same thing?

ne is native byte order, could be le and be.

lzutao

comment created time in 2 days

pull request commentrust-lang/rust

Use u32::from_le_bytes to fix a FIXME

https://github.com/rust-lang/rust/blob/7637cbb79bad4fdc29906a21847096a997a13631/library/std/src/net/ip.rs#L383-L386

But we are talking Little Endian in this PR.

lzutao

comment created time in 2 days

Pull request review commentrust-lang/rust

Use u32::from_le_bytes to fix a FIXME

 impl Ipv4Addr {     #[stable(feature = "rust1", since = "1.0.0")]     #[rustc_const_stable(feature = "const_ipv4", since = "1.32.0")]     pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {-        // FIXME: should just be u32::from_be_bytes([a, b, c, d]),-        // once that method is no longer rustc_const_unstable-        Ipv4Addr {-            inner: c::in_addr {-                s_addr: u32::to_be(-                    ((a as u32) << 24) | ((b as u32) << 16) | ((c as u32) << 8) | (d as u32),-                ),-            },-        }+        Ipv4Addr { inner: c::in_addr { s_addr: u32::from_be_bytes([a, b, c, d]) } }

Think about it again. Do we guarantee that c::in_addr in big endian? I get the feelings that we are missing something.

lzutao

comment created time in 2 days

Pull request review commentrust-lang/rust

Use union to cast between big endian fields of s6_addr

 impl Ipv6Addr {     /// ```     #[stable(feature = "rust1", since = "1.0.0")]     #[rustc_const_stable(feature = "const_ipv6", since = "1.32.0")]+    #[allow_internal_unstable(const_fn_union)]     pub const fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> Ipv6Addr {         Ipv6Addr {             inner: c::in6_addr {-                s6_addr: [-                    (a >> 8) as u8,-                    a as u8,-                    (b >> 8) as u8,-                    b as u8,-                    (c >> 8) as u8,-                    c as u8,-                    (d >> 8) as u8,-                    d as u8,-                    (e >> 8) as u8,-                    e as u8,-                    (f >> 8) as u8,-                    f as u8,-                    (g >> 8) as u8,-                    g as u8,-                    (h >> 8) as u8,-                    h as u8,-                ],+                // SAFETY: Each element of `s6_addr16` is big edian.+                s6_addr: unsafe { in6_union { s6_addr16: [a, b, c, d, e, f, g, h] }.s6_addr },

The assumption here is wrong about arguments: (a, b, ...). Those are not guaranteed to be Big Endian.

lzutao

comment created time in 2 days

pull request commentrust-lang/rust

Use u32::from_le_bytes to fix a FIXME

Done.

lzutao

comment created time in 2 days

push eventlzutao/rustc

Lzu Tao

commit sha aca025823221f2c7d52fcc8893f69f5042edafbc

Use u32::from_le_bytes to fix a FIXME

view details

push time in 2 days

push eventlzutao/rustc

Camille GILLOT

commit sha e288d050127f0bf78b325ef4d34b8b697ce28c80

Introduce an abstraction for EvaluationCache and SelectionCache.

view details

Camille GILLOT

commit sha 2baefd3206b29b06f1cb55b91be9a2e380e7d2de

Move IntercrateAmbiguityCause to librustc_trait_selection.

view details

Camille GILLOT

commit sha 058e02145786ce50c86dd590d792271839907642

Use Lift derive proc-macro in librustc_traits.

view details

Nicholas Nethercote

commit sha d93277b9150d50fae4b086cd6efe2a006b3d88da

Remove `GCX_PTR`. We store an `ImplicitCtxt` pointer in a thread-local value (TLV). This allows implicit access to a `GlobalCtxt` and some other things. We also store a `GlobalCtxt` pointer in `GCX_PTR`. This is always the same `GlobalCtxt` as the one within the `ImplicitCtxt` pointer in TLV. `GCX_PTR` is only used in the parallel compiler's `handle_deadlock()` function. This commit does the following. - It removes `GCX_PTR`. - It also adds `ImplicitCtxt::new()`, which constructs an `ImplicitCtxt` from a `GlobalCtxt`. `ImplicitCtxt::new()` + `tls::enter_context()` is now equivalent to the old `tls::enter_global()`. - Makes `tls::get_tlv()` public for the parallel compiler, because it's now used in `handle_deadlock()`.

view details

Nicholas Nethercote

commit sha 8c78fd234be2b3adfeda8748379370e5b8433ce3

Use more appropriate `tls::with_*` methods in some places.

view details

bors

commit sha 8244b1b11488a336a485f07fd6550b973009a931

Auto merge of #74969 - nnethercote:rm-GCX_PTR, r=Mark-Simulacrum Remove `GCX_PTR`. We store an `ImplicitCtxt` pointer in a thread-local value (TLV). This allows implicit access to a `GlobalCtxt` and some other things. We also store a `GlobalCtxt` pointer in `GCX_PTR`. This is always the same `GlobalCtxt` as the one within the `ImplicitCtxt` pointer in TLV. `GCX_PTR` is only used in the parallel compiler's `handle_deadlock()` function. This commit does the following. - It removes `GCX_PTR`. - It also adds `ImplicitCtxt::new()`, which constructs an `ImplicitCtxt` from a `GlobalCtxt`. `ImplicitCtxt::new()` + `tls::enter_context()` is now equivalent to the old `tls::enter_global()`. - Makes `tls::get_tlv()` public for the parallel compiler, because it's now used in `handle_deadlock()`. r? @petrochenkov

view details

bors

commit sha 7637cbb79bad4fdc29906a21847096a997a13631

Auto merge of #75055 - cjgillot:clean-cache, r=oli-obk Introduce an abstraction for EvaluationCache and SelectionCache The small duplicated code has been moved to librustc_query_system. The remaining changes are some cleanups of structural impls.

view details

Lzu Tao

commit sha c36cef7ae38aba6ea1a8fa82bb42aa81758df05e

Use u32::from_be_bytes to fix a FIXME

view details

push time in 2 days

Pull request review commentrust-lang/rust

Use u32::from_be_bytes to fix a FIXME

 impl Ipv4Addr {     #[stable(feature = "rust1", since = "1.0.0")]     #[rustc_const_stable(feature = "const_ipv4", since = "1.32.0")]     pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {-        // FIXME: should just be u32::from_be_bytes([a, b, c, d]),-        // once that method is no longer rustc_const_unstable-        Ipv4Addr {-            inner: c::in_addr {-                s_addr: u32::to_be(-                    ((a as u32) << 24) | ((b as u32) << 16) | ((c as u32) << 8) | (d as u32),-                ),-            },-        }+        Ipv4Addr { inner: c::in_addr { s_addr: u32::from_be_bytes([a, b, c, d]) } }

Nice. Will run the test locally first and update the PR later.

lzutao

comment created time in 2 days

pull request commentrust-lang/rust

Use union to cast between big endian fields of s6_addr

Wow. Lots of tests are falling. I should reconsider this approach.

lzutao

comment created time in 2 days

pull request commentrust-lang/rust

Use u32::from_be_bytes to fix a FIXME

Eh CI is falling. I don't know if it is spurious or not.

lzutao

comment created time in 2 days

Pull request review commentrust-lang/rust

Do not trigger `unused_braces` for `while let`

+// check-pass++#![deny(unused_braces)]++fn main() {+    let mut a = Some(3);+    // Shouldn't warn below `a`.+    while let Some(ref mut v) = {a} {

Yeah, I think it kind of ambiguous in parsing. But I'm not authoritative here. so let's cc parser devs like @petrochenkov @estebank

I'm sorry for causing this noise.

JohnTitor

comment created time in 2 days

Pull request review commentrust-lang/rust

Do not trigger `unused_braces` for `while let`

+// check-pass++#![deny(unused_braces)]++fn main() {+    let mut a = Some(3);+    // Shouldn't warn below `a`.+    while let Some(ref mut v) = {a} {

Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=d28588845e2466227a28572bb6929b30

What I trying to say is that currently we don't allow struct literals in if, while-let.

struct Foo {
     a: u32
}

fn foo() {
     while let Foo { a } = Foo { a: 42} {
          ()
     }
}

By enabling around { a }, unnamed structs in the future might be hard to to used/migrate. I am not against this changes, also am not authorative. What I want is improving the precision of the lint around {( yield )}.

JohnTitor

comment created time in 2 days

push eventlzutao/rustc

Camille GILLOT

commit sha e288d050127f0bf78b325ef4d34b8b697ce28c80

Introduce an abstraction for EvaluationCache and SelectionCache.

view details

Camille GILLOT

commit sha 2baefd3206b29b06f1cb55b91be9a2e380e7d2de

Move IntercrateAmbiguityCause to librustc_trait_selection.

view details

Camille GILLOT

commit sha 058e02145786ce50c86dd590d792271839907642

Use Lift derive proc-macro in librustc_traits.

view details

Nicholas Nethercote

commit sha d93277b9150d50fae4b086cd6efe2a006b3d88da

Remove `GCX_PTR`. We store an `ImplicitCtxt` pointer in a thread-local value (TLV). This allows implicit access to a `GlobalCtxt` and some other things. We also store a `GlobalCtxt` pointer in `GCX_PTR`. This is always the same `GlobalCtxt` as the one within the `ImplicitCtxt` pointer in TLV. `GCX_PTR` is only used in the parallel compiler's `handle_deadlock()` function. This commit does the following. - It removes `GCX_PTR`. - It also adds `ImplicitCtxt::new()`, which constructs an `ImplicitCtxt` from a `GlobalCtxt`. `ImplicitCtxt::new()` + `tls::enter_context()` is now equivalent to the old `tls::enter_global()`. - Makes `tls::get_tlv()` public for the parallel compiler, because it's now used in `handle_deadlock()`.

view details

Nicholas Nethercote

commit sha 8c78fd234be2b3adfeda8748379370e5b8433ce3

Use more appropriate `tls::with_*` methods in some places.

view details

bors

commit sha 8244b1b11488a336a485f07fd6550b973009a931

Auto merge of #74969 - nnethercote:rm-GCX_PTR, r=Mark-Simulacrum Remove `GCX_PTR`. We store an `ImplicitCtxt` pointer in a thread-local value (TLV). This allows implicit access to a `GlobalCtxt` and some other things. We also store a `GlobalCtxt` pointer in `GCX_PTR`. This is always the same `GlobalCtxt` as the one within the `ImplicitCtxt` pointer in TLV. `GCX_PTR` is only used in the parallel compiler's `handle_deadlock()` function. This commit does the following. - It removes `GCX_PTR`. - It also adds `ImplicitCtxt::new()`, which constructs an `ImplicitCtxt` from a `GlobalCtxt`. `ImplicitCtxt::new()` + `tls::enter_context()` is now equivalent to the old `tls::enter_global()`. - Makes `tls::get_tlv()` public for the parallel compiler, because it's now used in `handle_deadlock()`. r? @petrochenkov

view details

bors

commit sha 7637cbb79bad4fdc29906a21847096a997a13631

Auto merge of #75055 - cjgillot:clean-cache, r=oli-obk Introduce an abstraction for EvaluationCache and SelectionCache The small duplicated code has been moved to librustc_query_system. The remaining changes are some cleanups of structural impls.

view details

Lzu Tao

commit sha 5969016433f46b0ee39863fc4d6fd749d7bdb71e

Use union to cast between big endian fields of s6_addr The old code already made the assumption to reinterpret `Ipv6Addr` as `[u16; 8]`. Glibc, Linux, FreeBSD, Win32 all makes this assumption. The main motivation of using union it to better optimize code. ref: * https://docs.microsoft.com/en-us/windows/win32/api/in6addr/ns-in6addr-in6_addr * https://github.com/freebsd/freebsd/blob/1d6e4247415d264485ee94b59fdbc12e0c566fd0/contrib/ntp/lib/isc/include/isc/ipv6.h#L63 * https://github.com/zephyrproject-rtos/zephyr/blob/8b531aa996bba254c03129658490af59597acd78/include/net/net_ip.h#L137 * https://sourceware.org/git/?p=glibc.git;a=blob;f=inet/netinet/in.h;h=f6355c7efe5192b88337b136ef687fe9a5ed648c;hb=HEAD#l216

view details

push time in 2 days

pull request commentrust-lang/rust

Use u32::from_be_bytes to fix a FIXME

Ooops, Scott seems to be busy. So r? @oli-obk as reviewer of #58392

lzutao

comment created time in 2 days

PR opened rust-lang/rust

Use u32::from_be_bytes to fix a FIXME

u32::from_be_bytes has been const stable since 1.44.

r? @scottmcm

+1 -9

0 comment

1 changed file

pr created time in 2 days

create barnchlzutao/rustc

branch : u32const

created branch time in 2 days

Pull request review commentrust-lang/rust

Prefer pattern matching over indexing

 impl Ipv6Addr {     /// ```     #[stable(feature = "rust1", since = "1.0.0")]     pub fn segments(&self) -> [u16; 8] {-        let arr = &self.inner.s6_addr;+        let [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p] = self.inner.s6_addr;

I try to casting union fields in #75085

lzutao

comment created time in 2 days

PR opened rust-lang/rust

Use union to cast between big endian fields of s6_addr

The old code already made the assumption to reinterpret Ipv6Addr as [u16; 8].

Glibc, Linux, FreeBSD, Win32 all makes this assumption. The main motivation of using union it to better optimize code. Godbolt: https://rust.godbolt.org/z/qx6naT

ref:

  • https://docs.microsoft.com/en-us/windows/win32/api/in6addr/ns-in6addr-in6_addr
  • https://github.com/freebsd/freebsd/blob/1d6e4247415d264485ee94b59fdbc12e0c566fd0/contrib/ntp/lib/isc/include/isc/ipv6.h#L63
  • https://github.com/zephyrproject-rtos/zephyr/blob/8b531aa996bba254c03129658490af59597acd78/include/net/net_ip.h#L137
  • https://sourceware.org/git/?p=glibc.git;a=blob;f=inet/netinet/in.h;h=f6355c7efe5192b88337b136ef687fe9a5ed648c;hb=HEAD#l216

r? @cuviper @rust-lang/libs

+22 -29

0 comment

2 changed files

pr created time in 2 days

push eventlzutao/rustc

Lzu Tao

commit sha 0a162dc2d5c3327e81b43b16a5aa6b61a94251ae

Use union to cast between big endian fields of s6_addr The old code already made the assumption to reinterpret `Ipv6Addr` as `[u16; 8]`. Glibc, Linux, FreeBSD, Win32 all makes this assumption. The main motivation of using union it to better optimize code. ref: * https://docs.microsoft.com/en-us/windows/win32/api/in6addr/ns-in6addr-in6_addr * https://github.com/freebsd/freebsd/blob/1d6e4247415d264485ee94b59fdbc12e0c566fd0/contrib/ntp/lib/isc/include/isc/ipv6.h#L63 * https://github.com/zephyrproject-rtos/zephyr/blob/8b531aa996bba254c03129658490af59597acd78/include/net/net_ip.h#L137 * https://sourceware.org/git/?p=glibc.git;a=blob;f=inet/netinet/in.h;h=f6355c7efe5192b88337b136ef687fe9a5ed648c;hb=HEAD#l216

view details

push time in 2 days

pull request commentrust-lang/rust

Use `insert_same` in `insert_evaluation_cache`

r? @eddyb

GabrielMajeri

comment created time in 2 days

push eventlzutao/rustc

Lzu Tao

commit sha 4f463109e9a77faa25671b6bb6ac980f96b2031e

Use union to case between big endian fields of s6_addr The old code already made the assumption to reinterpret `Ipv6Addr` as `[u16; 8]`. Glibc, Linux, FreeBSD, Win32 all makes this assumption. The main motivation of using union it to better optimize code. ref: * https://docs.microsoft.com/en-us/windows/win32/api/in6addr/ns-in6addr-in6_addr * https://github.com/freebsd/freebsd/blob/1d6e4247415d264485ee94b59fdbc12e0c566fd0/contrib/ntp/lib/isc/include/isc/ipv6.h#L63 * https://github.com/zephyrproject-rtos/zephyr/blob/8b531aa996bba254c03129658490af59597acd78/include/net/net_ip.h#L137 * https://sourceware.org/git/?p=glibc.git;a=blob;f=inet/netinet/in.h;h=f6355c7efe5192b88337b136ef687fe9a5ed648c;hb=HEAD#l216

view details

push time in 2 days

push eventlzutao/rustc

Lzu Tao

commit sha 5f41969befb91429e371c35e69969fabbd616386

Use union to case between big endian fields of s6_addr The old code already mades the assumption to reinterprep Ipv6Addr as [u16; 8]. Glibc, Linux, FreeBSD, Win32 all makes this assumption. The main motivation of using union it to better optimize code. ref: * https://docs.microsoft.com/en-us/windows/win32/api/in6addr/ns-in6addr-in6_addr * https://github.com/freebsd/freebsd/blob/1d6e4247415d264485ee94b59fdbc12e0c566fd0/contrib/ntp/lib/isc/include/isc/ipv6.h#L63 * https://github.com/zephyrproject-rtos/zephyr/blob/8b531aa996bba254c03129658490af59597acd78/include/net/net_ip.h#L137 * https://sourceware.org/git/?p=glibc.git;a=blob;f=inet/netinet/in.h;h=f6355c7efe5192b88337b136ef687fe9a5ed648c;hb=HEAD#l216

view details

push time in 2 days

push eventlzutao/rustc

Aaron Hill

commit sha ac9dfc3e7785c9bba96ebac4fd51726189e1bf91

Normalize opaque types when converting `ParamEnv` to `Reveal::All` Fixes #65918

view details

Aaron Hill

commit sha 117a60e1f5045e317d3f76ce60be28d18c694608

Erase regions in try_eval_bits

view details

Aaron Hill

commit sha 90aee14eb95ac0b9ddb7cf5db6d003155e94800c

Skip computing param_env and size if not needed

view details

Aaron Hill

commit sha 5e2e927e0107916b825b164c82be44877ac6ab54

Fix rebase fallout

view details

Pietro Albini

commit sha cb76f821942053091706b7bb2c4dc416bb09bfb9

ci: avoid symlinking the build directory on self-hosted builders

view details

Pietro Albini

commit sha fe5a40eb14f233554a30c038cf8944b2d2adf9ff

ci: add aarch64-gnu as a fallible auto builder

view details

Guillaume Gomez

commit sha 403164569170e3f5c06db8b66257ac61db7cff4b

Clean up E0728 explanation

view details

Guillaume Gomez

commit sha 1d2e3fff69b654c3dfd6a810e193db29bb1868fa

Clean up E0730 explanation

view details

Andy Russell

commit sha 0b320086425937b17bda5ee9e856ac6441d71d96

report kind of deprecated item in message This is important for fields, which are incorrectly referred to as "items".

view details

Guillaume Gomez

commit sha f22a34e84d4dba9b17bb3e68051ee82bd85f3c94

Clean up E0734 explanation

view details

Alan Somers

commit sha 013e1a6e9f73125734cb919d9b6220b3a4710d67

Enable the profiler on FreeBSD FreeBSD has been doing this in our own package builds for two months now. https://svnweb.freebsd.org/ports?view=revision&revision=535771

view details

Nathaniel McCallum

commit sha 25670749b44a9c7a4cfd3fbf780bbe3344a9a6c5

Suppress debuginfo on naked function arguments A function that has no prologue cannot be reasonably expected to support debuginfo. In fact, the existing code (before this patch) would generate invalid instructions that caused crashes. We can solve this easily by just not emitting the debuginfo in this case. Fixes https://github.com/rust-lang/rust/issues/42779 cc https://github.com/rust-lang/rust/issues/32408

view details

Michal 'vorner' Vaner

commit sha ad6d63ef01e37a1a05acdba50985b01d178d7c11

Don't use "weak count" around Weak::from_raw_ptr As `Rc/Arc::weak_count` returns 0 when having no strong counts, this could be confusing and it's better to avoid using that completely. Closes #73840.

view details

David Sonder

commit sha b5d143b126cd73c873fc8feff7dee0a0b077cc84

Enable docs on dist-x86_64-musl Add the rust-docs component to toolchain x86_64-unknown-linux-musl, which allows people using rustup on their musl-based linux distribution to download the rust-docs.

view details

Stein Somers

commit sha c4f4639e1a2eb07d17e7393a1c7f0594f0c11faf

Remove into_slices and its unsafe block

view details

Alexis Bourget

commit sha 36bb5e8a4247888c7e1ce5a06ba3aaf5dc9cafd5

Clarify the doc for MaybeUninit::zeroed on incorrect use

view details

Alex Crichton

commit sha 06d565c967bfb7c6ff52a991bbe47b4a2a25de3e

std: Switch from libbacktrace to gimli This commit is a proof-of-concept for switching the standard library's backtrace symbolication mechanism on most platforms from libbacktrace to gimli. The standard library's support for `RUST_BACKTRACE=1` requires in-process parsing of object files and DWARF debug information to interpret it and print the filename/line number of stack frames as part of a backtrace. Historically this support in the standard library has come from a library called "libbacktrace". The libbacktrace library seems to have been extracted from gcc at some point and is written in C. We've had a lot of issues with libbacktrace over time, unfortunately, though. The library does not appear to be actively maintained since we've had patches sit for months-to-years without comments. We have discovered a good number of soundness issues with the library itself, both when parsing valid DWARF as well as invalid DWARF. This is enough of an issue that the libs team has previously decided that we cannot feed untrusted inputs to libbacktrace. This also doesn't take into account the portability of libbacktrace which has been difficult to manage and maintain over time. While possible there are lots of exceptions and it's the main C dependency of the standard library right now. For years it's been the desire to switch over to a Rust-based solution for symbolicating backtraces. It's been assumed that we'll be using the Gimli family of crates for this purpose, which are targeted at safely and efficiently parsing DWARF debug information. I've been working recently to shore up the Gimli support in the `backtrace` crate. As of a few weeks ago the `backtrace` crate, by default, uses Gimli when loaded from crates.io. This transition has gone well enough that I figured it was time to start talking seriously about this change to the standard library. This commit is a preview of what's probably the best way to integrate the `backtrace` crate into the standard library with the Gimli feature turned on. While today it's used as a crates.io dependency, this commit switches the `backtrace` crate to a submodule of this repository which will need to be updated manually. This is not done lightly, but is thought to be the best solution. The primary reason for this is that the `backtrace` crate needs to do some pretty nontrivial filesystem interactions to locate debug information. Working without `std::fs` is not an option, and while it might be possible to do some sort of trait-based solution when prototyped it was found to be too unergonomic. Using a submodule allows the `backtrace` crate to build as a submodule of the `std` crate itself, enabling it to use `std::fs` and such. Otherwise this adds new dependencies to the standard library. This step requires extra attention because this means that these crates are now going to be included with all Rust programs by default. It's important to note, however, that we're already shipping libbacktrace with all Rust programs by default and it has a bunch of C code implementing all of this internally anyway, so we're basically already switching already-shipping functionality to Rust from C. * `object` - this crate is used to parse object file headers and contents. Very low-level support is used from this crate and almost all of it is disabled. Largely we're just using struct definitions as well as convenience methods internally to read bytes and such. * `addr2line` - this is the main meat of the implementation for symbolication. This crate depends on `gimli` for DWARF parsing and then provides interfaces needed by the `backtrace` crate to turn an address into a filename / line number. This crate is actually pretty small (fits in a single file almost!) and mirrors most of what `dwarf.c` does for libbacktrace. * `miniz_oxide` - the libbacktrace crate transparently handles compressed debug information which is compressed with zlib. This crate is used to decompress compressed debug sections. * `gimli` - not actually used directly, but a dependency of `addr2line`. * `adler32`- not used directly either, but a dependency of `miniz_oxide`. The goal of this change is to improve the safety of backtrace symbolication in the standard library, especially in the face of possibly malformed DWARF debug information. Even to this day we're still seeing segfaults in libbacktrace which could possibly become security vulnerabilities. This change should almost entirely eliminate this possibility whilc also paving the way forward to adding more features like split debug information. Some references for those interested are: * Original addition of libbacktrace - #12602 * OOM with libbacktrace - #24231 * Backtrace failure due to use of uninitialized value - #28447 * Possibility to feed untrusted data to libbacktrace - #21889 * Soundness fix for libbacktrace - #33729 * Crash in libbacktrace - #39468 * Support for macOS, never merged - ianlancetaylor/libbacktrace#2 * Performance issues with libbacktrace - #29293, #37477 * Update procedure is quite complicated due to how many patches we need to carry - #50955 * Libbacktrace doesn't work on MinGW with dynamic libs - #71060 * Segfault in libbacktrace on macOS - #71397 Switching to Rust will not make us immune to all of these issues. The crashes are expected to go away, but correctness and performance may still have bugs arise. The gimli and `backtrace` crates, however, are actively maintained unlike libbacktrace, so this should enable us to at least efficiently apply fixes as situations come up.

view details

Paul Sajna

commit sha 7baa87fccf2d9788530e6efc762d326d47d68617

bump libc version to 0.2.74

view details

Simon Sapin

commit sha d8bcf75206e88e07cabd95b87418fe98c5fa2b95

Make `Vec::leak` a method instead of an associated function. The reason for `Box::leak` not to be a method (`Deref` to an arbitrary `T` which might have its own, different `leak` method) does not apply.

view details

Simon Sapin

commit sha 7d759f539f363125511f1edd9ad30934367f409b

Stabilize `Vec::leak`

view details

push time in 2 days

create barnchlzutao/rustc

branch : ip_union

created branch time in 2 days

Pull request review commentrust-lang/rust

Do not trigger `unused_braces` for `while let`

+// check-pass++#![deny(unused_braces)]++fn main() {+    let mut a = Some(3);+    // Shouldn't warn below `a`.+    while let Some(ref mut v) = {a} {

So it is not linted for unnamed struct literal in the future?

JohnTitor

comment created time in 2 days

delete branch lzutao/rustc

delete branch : stalize-result-as-deref

delete time in 2 days

issue commentrust-lang/rust

Tracking Issue for `slice_strip` feature

I think it is a bit soon to stabilize this feature. It is about one month after the feature is merged and appeared on nightly. But yeah, you could send a PR to propose stabilize this feature, but it should include real usecases?

lzutao

comment created time in 2 days

pull request commentrust-lang/rust

Fix Ipv6Addr::to_ipv4

You might be interested in the discussion here: #27709

nanpuyue

comment created time in 2 days

Pull request review commentrust-lang/rust

Prefer pattern matching over indexing

 impl Ipv6Addr {     /// ```     #[stable(feature = "rust1", since = "1.0.0")]     pub fn to_ipv4(&self) -> Option<Ipv4Addr> {-        match self.segments() {-            [0, 0, 0, 0, 0, f, g, h] if f == 0 || f == 0xffff => {-                Some(Ipv4Addr::new((g >> 8) as u8, g as u8, (h >> 8) as u8, h as u8))-            }-            _ => None,+        if let [0, 0, 0, 0, 0, 0 | 0xffff, ab, cd] = self.segments() {+            let [a, b] = ab.to_be_bytes();+            let [c, d] = cd.to_be_bytes();+            return Some(Ipv4Addr::new(a, b, c, d));         }+        None

thank you. I think the current form is nicer as it doesn't require else block.

lzutao

comment created time in 2 days

issue commentrust-lang/rust

split_at fails to optimize bounds check

Anyone want to file a bug against GCC? I registered an account two days ago but they hasn't accept to create my account yet.

lcnr

comment created time in 2 days

pull request commentrust-lang/rust

Add Ipv6Addr::to_ipv4_mapped

* does not check whether the IPv4 address is a globally unique unicast address

Do you want to fix it in a different PR although the intention is to deprecate it ?

nanpuyue

comment created time in 2 days

Pull request review commentrust-lang/rust

Add Ipv6Addr::to_ipv4_mapped

 impl Ipv4Addr {     /// );     /// ```     #[stable(feature = "rust1", since = "1.0.0")]+    #[rustc_deprecated(+        since = "1.47.0",+        reason = "the current IPv6 transition mechanisms no longer use these addresses"+    )]

I think until the replacement is stable, this method couldn't be deprecated.

nanpuyue

comment created time in 3 days

Pull request review commentrust-lang/rust

Move from `log` to `tracing`

 pub fn install_ice_hook() { }  /// This allows tools to enable rust logging without having to magically match rustc's-/// log crate version+/// log crate version. pub fn init_rustc_env_logger() {-    env_logger::init_from_env("RUSTC_LOG");+    init_env_logger("RUSTC_LOG")+}++/// This allows tools to enable rust logging without having to magically match rustc's+/// log crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var+/// other than `RUSTC_LOG`.+pub fn init_env_logger(env: &str) {+    // Don't register a dispatcher if there's no filter to print anything+    match std::env::var(env) {

Not checking utf8 validity.

oli-obk

comment created time in 3 days

Pull request review commentrust-lang/rust

Add Ipv6Addr::to_ipv4_mapped

 impl Ipv6Addr {         (self.segments()[0] & 0xff00) == 0xff00     } +    /// Converts this address to an [IPv4 address]. Returns [`None`] if this address is+    /// not IPv4-mapped.+    ///+    /// ::ffff:a.b.c.d become a.b.c.d+    ///+    /// [IPv4 address]: ../../std/net/struct.Ipv4Addr.html+    /// [`None`]: ../../std/option/enum.Option.html#variant.None+    ///+    /// # Examples+    ///+    /// ```+    /// use std::net::{Ipv4Addr, Ipv6Addr};+    ///+    /// assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).to_ipv4_mapped(), None);+    /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).to_ipv4_mapped(),+    ///            Some(Ipv4Addr::new(192, 10, 2, 255)));+    /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4_mapped(), None);+    /// ```+    pub fn to_ipv4_mapped(&self) -> Option<Ipv4Addr> {

Yes, certainly.

nanpuyue

comment created time in 3 days

Pull request review commentrust-lang/rust

Do not trigger `unused_{braces,parens}` lints with `yield`

 trait UnusedDelimLint {                     ExprKind::Ret(_) | ExprKind::Break(..) => true,                     _ => parser::contains_exterior_struct_lit(&inner),                 })+            || if let ExprKind::Yield(..) = inner.kind { true } else { false }
            || matches!(inner.kind, ExprKind::Yield(..))
JohnTitor

comment created time in 3 days

Pull request review commentrust-lang/rust

Add Ipv6Addr::to_ipv4_mapped

 impl Ipv6Addr {         (self.segments()[0] & 0xff00) == 0xff00     } +    /// Converts this address to an [IPv4 address]. Returns [`None`] if this address is+    /// not IPv4-mapped.+    ///+    /// ::ffff:a.b.c.d become a.b.c.d+    ///+    /// [IPv4 address]: ../../std/net/struct.Ipv4Addr.html+    /// [`None`]: ../../std/option/enum.Option.html#variant.None+    ///+    /// # Examples+    ///+    /// ```+    /// use std::net::{Ipv4Addr, Ipv6Addr};+    ///+    /// assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).to_ipv4_mapped(), None);+    /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).to_ipv4_mapped(),+    ///            Some(Ipv4Addr::new(192, 10, 2, 255)));+    /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4_mapped(), None);+    /// ```+    pub fn to_ipv4_mapped(&self) -> Option<Ipv4Addr> {
    #[unstable(feature = "ipv4_mapped", issue = none)]
    pub fn to_ipv4_mapped(&self) -> Option<Ipv4Addr> {
nanpuyue

comment created time in 3 days

PR opened rust-lang/rust

Prefer pattern matching over indexing

Quite a bit nicer IMO.

r? @cuviper

+18 -22

0 comment

1 changed file

pr created time in 3 days

push eventlzutao/rustc

Lzu Tao

commit sha cc354bd729cdb811f2c840f2a6959bbf5c8ff5a7

prefer pattern matching over indexing

view details

push time in 3 days

push eventlzutao/rustc

Lzu Tao

commit sha eb99696a687aaa67f46a7fcef31b5cd2689c7661

prefer pattern matching over indexing

view details

push time in 3 days

pull request commentrust-lang/rust

Update elasticlunr-rs and ammonia transitive deps

Command to reproduce: cargo update -p ammonia -p elasticlunr-rs

Aaron1011

comment created time in 3 days

issue commentrust-lang/rust

On Linux, You Have To Manually Change The Shebang On x.py From Python To Python3

Do you mean that by default CentOS use python as python3?

nishantc1527

comment created time in 3 days

push eventlzutao/rustc

Lzu Tao

commit sha aeb973cb8741a31b812f141002e7bcb0acec8a1b

prefer pattern matching over indexing

view details

push time in 3 days

create barnchlzutao/rustc

branch : pat

created branch time in 3 days

Pull request review commentrust-lang/rust

Move from `log` to `tracing`

 pub fn install_ice_hook() { }  /// This allows tools to enable rust logging without having to magically match rustc's-/// log crate version+/// log crate version. pub fn init_rustc_env_logger() {-    env_logger::init_from_env("RUSTC_LOG");+    init_env_logger("RUSTC_LOG")+}++/// This allows tools to enable rust logging without having to magically match rustc's+/// log crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var+/// other than `RUSTC_LOG`.+pub fn init_env_logger(env: &str) {+    // Don't register a dispatcher if there's no filter to print anything+    match std::env::var(env) {

Should this be var_os?

oli-obk

comment created time in 3 days

Pull request review commentrust-lang/rust

Work around LLVM issues with explicit register in inline asm

 fn inline_asm_call(     } } +/// If the register is an xmm/ymm/zmm register then return its index.+fn xmm_reg_index(reg: InlineAsmReg) -> Option<u32> {+    match reg {+        InlineAsmReg::X86(reg)+            if reg as u32 >= X86InlineAsmReg::xmm0 as u32+                && reg as u32 <= X86InlineAsmReg::xmm15 as u32 =>

If it implement PartialOrd and/or PartialEq I think.

Amanieu

comment created time in 3 days

Pull request review commentrust-lang/rust

Work around LLVM issues with explicit register in inline asm

 fn inline_asm_call(     } } +/// If the register is an xmm/ymm/zmm register then return its index.+fn xmm_reg_index(reg: InlineAsmReg) -> Option<u32> {+    match reg {+        InlineAsmReg::X86(reg)+            if reg as u32 >= X86InlineAsmReg::xmm0 as u32+                && reg as u32 <= X86InlineAsmReg::xmm15 as u32 =>
        InlineAsmReg::X86(reg)
            if RangeInclusive::new(X86InlineAsmReg::xmm0, X86InlineAsmReg::xmm15).contains(&reg) =>
Amanieu

comment created time in 3 days

issue commentrust-lang/rust

Tracking issue for dropping python2 support

But how long should we support python 2?

lzutao

comment created time in 3 days

Pull request review commentrust-lang/rust

Limit I/O vector count on Linux and macOS

 const READ_LIMIT: usize = c_int::MAX as usize - 1; #[cfg(not(target_os = "macos"))] const READ_LIMIT: usize = libc::ssize_t::MAX as usize; +#[cfg(any(target_os = "linux", target_os = "macos"))]+fn max_iov() -> usize {+    static LIM: AtomicUsize = AtomicUsize::new(0);++    let mut lim = LIM.load(Ordering::Relaxed);+    if lim == 0 {+        let ret = unsafe {+            libc::sysconf(+                #[cfg(target_os = "linux")]+                libc::_SC_IOV_MAX,+                #[cfg(target_os = "macos")]+                libc::_SC_UIO_MAXIOV,+            )+        };++        // 1024 is the default value on modern Linux systems+        // and hopefully more useful than `c_int::MAX`.+        lim = if ret > 0 { ret as usize } else { 1024 };

While not explicitly check for -1?

adamreichold

comment created time in 3 days

Pull request review commentrust-lang/rust

Limit I/O vector count on Linux and macOS

 const READ_LIMIT: usize = c_int::MAX as usize - 1; #[cfg(not(target_os = "macos"))] const READ_LIMIT: usize = libc::ssize_t::MAX as usize; +#[cfg(any(target_os = "linux", target_os = "macos"))]+fn max_iov() -> usize {+    static LIM: AtomicUsize = AtomicUsize::new(0);++    let mut lim = LIM.load(Ordering::Relaxed);+    if lim == 0 {+        let ret = unsafe {+            libc::sysconf(+                #[cfg(target_os = "linux")]+                libc::_SC_IOV_MAX,+                #[cfg(target_os = "macos")]+                libc::_SC_UIO_MAXIOV,+            )+        };++        // 1024 is the default value on modern Linux systems+        // and hopefully more useful than `c_int::MAX`.+        lim = if ret > 0 { ret as usize } else { 1024 };

But while not explicitly check for -1?

adamreichold

comment created time in 3 days

Pull request review commentrust-lang/rust

Limit I/O vector count on Linux and macOS

 const READ_LIMIT: usize = c_int::MAX as usize - 1; #[cfg(not(target_os = "macos"))] const READ_LIMIT: usize = libc::ssize_t::MAX as usize; +#[cfg(any(target_os = "linux", target_os = "macos"))]+fn max_iov() -> usize {

Does it include unix as _SC_IOV_MAX declared in POSIX 1: https://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html ?

adamreichold

comment created time in 3 days

Pull request review commentrust-lang/rust

Limit I/O vector count on Linux and macOS

 const READ_LIMIT: usize = c_int::MAX as usize - 1; #[cfg(not(target_os = "macos"))] const READ_LIMIT: usize = libc::ssize_t::MAX as usize; +#[cfg(any(target_os = "linux", target_os = "macos"))]+fn max_iov() -> usize {+    static LIM: AtomicUsize = AtomicUsize::new(0);++    let mut lim = LIM.load(Ordering::Relaxed);+    if lim == 0 {+        let ret = unsafe {+            libc::sysconf(+                #[cfg(target_os = "linux")]+                libc::_SC_IOV_MAX,+                #[cfg(target_os = "macos")]+                libc::_SC_UIO_MAXIOV,+            )+        };++        // 1024 is the default value on modern Linux systems+        // and hopefully more useful than `c_int::MAX`.+        lim = if ret > 0 { ret as usize } else { 1024 };

Ref https://man7.org/linux/man-pages/man3/sysconf.3p.html#RETURN_VALUE

adamreichold

comment created time in 3 days

Pull request review commentrust-lang/rust

Limit I/O vector count on Linux and macOS

 const READ_LIMIT: usize = c_int::MAX as usize - 1; #[cfg(not(target_os = "macos"))] const READ_LIMIT: usize = libc::ssize_t::MAX as usize; +#[cfg(any(target_os = "linux", target_os = "macos"))]+fn max_iov() -> usize {+    static LIM: AtomicUsize = AtomicUsize::new(0);++    let mut lim = LIM.load(Ordering::Relaxed);+    if lim == 0 {+        let ret = unsafe {+            libc::sysconf(+                #[cfg(target_os = "linux")]+                libc::_SC_IOV_MAX,+                #[cfg(target_os = "macos")]+                libc::_SC_UIO_MAXIOV,+            )+        };++        // 1024 is the default value on modern Linux systems+        // and hopefully more useful than `c_int::MAX`.+        lim = if ret > 0 { ret as usize } else { 1024 };

Should we set errno=0 before sysconf and check it again when ret == -1?

adamreichold

comment created time in 3 days

issue openedrust-lang/rust

Tracking issue for dropping python2 support

In https://github.com/rust-lang/rust/pull/74905#issuecomment-667528649, @Mark-Simulacrum said that:

We have not established a minimum minor version for Python 3, we'd need to do some research about what is available on older (linux) systems by default (or through package managers).

Python 2 is still supported by many distros to my knowledge.

I open this issue to track when we drop python2 support. Some info about Python versions in some Linux distros Packaging status

@rustbot modify labels: T-infra cc @pickfire fyi

created time in 3 days

push eventlzutao/dotfiles

Lzu Tao

commit sha 49556309adb11d10f9131ec57652c3794ccb783a

alias: vi=vim as neovim quitting is slow

view details

Lzu Tao

commit sha 241c3623740201c55863cf27a001e5a8eba5f3de

subl: use 4 space for rust

view details

Lzu Tao

commit sha 08806e61b94ad524c192a54806f729f0df120e48

firefox: enable screenshot extension

view details

Lzu Tao

commit sha 1240e6791c53636c165fb5c82f868922ee4b56f2

add missed vim dir

view details

push time in 3 days

pull request commentrust-lang/rust

Avoid bool-like naming

IIRC, rust repo have moved to python3 for a while.

lzutao

comment created time in 4 days

issue commentjohnthagen/min-sized-rust

1.45.0 is now stable :)

They didn't forget that. Either they don't think strip flag is ready for stabilization or nobody proposes it.

h5rdly

comment created time in 4 days

issue commentjohnthagen/min-sized-rust

1.45.0 is now stable :)

Yeah. Stable rustc cannot be passed -Z flag like -Z strip=symbols. Only nightly rustc can be.

h5rdly

comment created time in 4 days

issue commentjohnthagen/min-sized-rust

1.45.0 is now stable :)

It is still a nightly option in rustc.

h5rdly

comment created time in 4 days

delete branch lzutao/rustc

delete branch : no-args

delete time in 4 days

pull request commentrust-lang/rust

add `slice::array_chunks` to std

Is this intentional? image

lcnr

comment created time in 4 days

issue openedrust-lang/rustc-dev-guide

Changes after std move to library

The first section of this chapter need to be reword: https://github.com/rust-lang/rustc-dev-guide/blob/master/src/compiler-src.md

The main Rust repository consists of a src directory, under which there live many crates. These crates contain the sources for the standard library and the compiler. This document, of course, focuses on the latter.

Could be rewritten as: The main Rust repository consists of two directory: src and library, under which there live many crates. library contain the sources for the standard library. While src is where compiler and its components live. This document, of course, focuses on the latter.

created time in 4 days

pull request commentrust-lang/rust

Remove some redundant parts from `unrolled_find_u16s`

r? @LukasKalbertodt for review or reassignment

lzutao

comment created time in 4 days

issue commentrust-lang/rust

split_at fails to optimize bounds check

Clang could do that, change N=4 in my snippet about to see. But still GCC doesn't do that.

lcnr

comment created time in 5 days

issue commentrust-lang/rust

split_at fails to optimize bounds check

So this is more as LLVM part: @rustbot modify lables: +A-LLVM Of course this might be improved with MIR-opt. But how hard it would be? I don't know.

lcnr

comment created time in 5 days

issue commentrust-lang/rust

split_at fails to optimize bounds check

There are no optimization in GCC and Clang: https://godbolt.org/z/M88ndP

#include <stddef.h>

const size_t N = 3;

int foo(size_t len) {
	size_t newlen = (len / N) * N;
	return newlen <= len;
}

Should foo be optimized to only return true?

lcnr

comment created time in 5 days

pull request commentrust-lang/rust

Run all tests if have no specified tests

cc @Mark-Simulacrum Does src/etc/test-float-parse/runtests.py trigger and run anywhere? I cannot find it in compiletest with the grep:

git grep 'py\b' src/tools/compiletest/
lzutao

comment created time in 5 days

PR opened rust-lang/rust

Run all tests if have no specified tests

The behaviour was changed in https://github.com/rust-lang/rust/pull/74905#discussion_r463259562 cc @alex if you could check it again, thank you. r? @jyn514

+5 -3

0 comment

1 changed file

pr created time in 5 days

create barnchlzutao/rustc

branch : no-args

created branch time in 5 days

issue commentrust-lang/rust

Unrelated Code Fails to Typecheck when Feature Enabled

Yeah, I can reproduce it with gfx-rs/wgpu-rs@9a9bf53 .

cwfitzgerald

comment created time in 5 days

Pull request review commentrust-lang/rust

Remove restriction on type parameters preceding consts w/ feature const-generics

 fn validate_generic_param_order<'a>(         }         let max_param = &mut max_param;         match max_param {+            Some(ParamKindOrd::Const)+                if ParamKindOrd::Type == kind && sess.features_untracked().const_generics =>+            {+                ()+            }
                if ParamKindOrd::Type == kind && sess.features_untracked().const_generics => {}
JulianKnodt

comment created time in 5 days

Pull request review commentrust-lang/rust

Stabilize `Result::as_deref` and `as_deref_mut`

 impl<T: Deref, E> Result<T, E> {     /// let y: Result<&str, &u32> = Err(&42);     /// assert_eq!(x.as_deref(), y);     /// ```+    #[stable(feature = "inner_deref", since = "1.47.0")]

About feature gate, do you in favor of renaming it to "result_as_deref" or so?

lzutao

comment created time in 5 days

push eventlzutao/rustc

Lzu Tao

commit sha 6d293ede9f0790e1a450113bfbda0998fec9e48c

Update tests

view details

push time in 5 days

push eventlzutao/rustc

Guillaume Gomez

commit sha 1d2e3fff69b654c3dfd6a810e193db29bb1868fa

Clean up E0730 explanation

view details

Guillaume Gomez

commit sha f22a34e84d4dba9b17bb3e68051ee82bd85f3c94

Clean up E0734 explanation

view details

Michal 'vorner' Vaner

commit sha ad6d63ef01e37a1a05acdba50985b01d178d7c11

Don't use "weak count" around Weak::from_raw_ptr As `Rc/Arc::weak_count` returns 0 when having no strong counts, this could be confusing and it's better to avoid using that completely. Closes #73840.

view details

David Sonder

commit sha b5d143b126cd73c873fc8feff7dee0a0b077cc84

Enable docs on dist-x86_64-musl Add the rust-docs component to toolchain x86_64-unknown-linux-musl, which allows people using rustup on their musl-based linux distribution to download the rust-docs.

view details

Alex Crichton

commit sha 06d565c967bfb7c6ff52a991bbe47b4a2a25de3e

std: Switch from libbacktrace to gimli This commit is a proof-of-concept for switching the standard library's backtrace symbolication mechanism on most platforms from libbacktrace to gimli. The standard library's support for `RUST_BACKTRACE=1` requires in-process parsing of object files and DWARF debug information to interpret it and print the filename/line number of stack frames as part of a backtrace. Historically this support in the standard library has come from a library called "libbacktrace". The libbacktrace library seems to have been extracted from gcc at some point and is written in C. We've had a lot of issues with libbacktrace over time, unfortunately, though. The library does not appear to be actively maintained since we've had patches sit for months-to-years without comments. We have discovered a good number of soundness issues with the library itself, both when parsing valid DWARF as well as invalid DWARF. This is enough of an issue that the libs team has previously decided that we cannot feed untrusted inputs to libbacktrace. This also doesn't take into account the portability of libbacktrace which has been difficult to manage and maintain over time. While possible there are lots of exceptions and it's the main C dependency of the standard library right now. For years it's been the desire to switch over to a Rust-based solution for symbolicating backtraces. It's been assumed that we'll be using the Gimli family of crates for this purpose, which are targeted at safely and efficiently parsing DWARF debug information. I've been working recently to shore up the Gimli support in the `backtrace` crate. As of a few weeks ago the `backtrace` crate, by default, uses Gimli when loaded from crates.io. This transition has gone well enough that I figured it was time to start talking seriously about this change to the standard library. This commit is a preview of what's probably the best way to integrate the `backtrace` crate into the standard library with the Gimli feature turned on. While today it's used as a crates.io dependency, this commit switches the `backtrace` crate to a submodule of this repository which will need to be updated manually. This is not done lightly, but is thought to be the best solution. The primary reason for this is that the `backtrace` crate needs to do some pretty nontrivial filesystem interactions to locate debug information. Working without `std::fs` is not an option, and while it might be possible to do some sort of trait-based solution when prototyped it was found to be too unergonomic. Using a submodule allows the `backtrace` crate to build as a submodule of the `std` crate itself, enabling it to use `std::fs` and such. Otherwise this adds new dependencies to the standard library. This step requires extra attention because this means that these crates are now going to be included with all Rust programs by default. It's important to note, however, that we're already shipping libbacktrace with all Rust programs by default and it has a bunch of C code implementing all of this internally anyway, so we're basically already switching already-shipping functionality to Rust from C. * `object` - this crate is used to parse object file headers and contents. Very low-level support is used from this crate and almost all of it is disabled. Largely we're just using struct definitions as well as convenience methods internally to read bytes and such. * `addr2line` - this is the main meat of the implementation for symbolication. This crate depends on `gimli` for DWARF parsing and then provides interfaces needed by the `backtrace` crate to turn an address into a filename / line number. This crate is actually pretty small (fits in a single file almost!) and mirrors most of what `dwarf.c` does for libbacktrace. * `miniz_oxide` - the libbacktrace crate transparently handles compressed debug information which is compressed with zlib. This crate is used to decompress compressed debug sections. * `gimli` - not actually used directly, but a dependency of `addr2line`. * `adler32`- not used directly either, but a dependency of `miniz_oxide`. The goal of this change is to improve the safety of backtrace symbolication in the standard library, especially in the face of possibly malformed DWARF debug information. Even to this day we're still seeing segfaults in libbacktrace which could possibly become security vulnerabilities. This change should almost entirely eliminate this possibility whilc also paving the way forward to adding more features like split debug information. Some references for those interested are: * Original addition of libbacktrace - #12602 * OOM with libbacktrace - #24231 * Backtrace failure due to use of uninitialized value - #28447 * Possibility to feed untrusted data to libbacktrace - #21889 * Soundness fix for libbacktrace - #33729 * Crash in libbacktrace - #39468 * Support for macOS, never merged - ianlancetaylor/libbacktrace#2 * Performance issues with libbacktrace - #29293, #37477 * Update procedure is quite complicated due to how many patches we need to carry - #50955 * Libbacktrace doesn't work on MinGW with dynamic libs - #71060 * Segfault in libbacktrace on macOS - #71397 Switching to Rust will not make us immune to all of these issues. The crashes are expected to go away, but correctness and performance may still have bugs arise. The gimli and `backtrace` crates, however, are actively maintained unlike libbacktrace, so this should enable us to at least efficiently apply fixes as situations come up.

view details

Lzu Tao

commit sha 0374006d79114824d8eec020a9d771ca8cf712ff

Avoid bool-like naming

view details

Guillaume Gomez

commit sha 759de11f534b940f090ff94cf1829935c1eb4e7d

Clean up E0740 explanation

view details

Gary Guo

commit sha 8046fea62263d50fc196ce07ccdc4534af321441

Improve diagnostics when constant pattern is too generic

view details

Gary Guo

commit sha 4e963d58c7d94270697c2765f23993e40757292f

Fix ui tests

view details

Guillaume Gomez

commit sha 89e4fe33130a17888a2add6baadd850653263242

Improve E0730 explanation

view details

jumbatm

commit sha 4da72f538752aad2ab4b77dad115ef5889365baf

Add additional clashing_extern_decl cases.

view details

jumbatm

commit sha 3eaead7d51f3d680bdae596e9c4ef00bdc03403e

Don't emit clashing decl lint for FFI-safe enums. An example of an FFI-safe enum conversion is when converting Option<NonZeroUsize> to usize. Because the Some value must be non-zero, rustc can use 0 to represent the None variant, making this conversion is safe. Furthermore, it can be relied on (and removing this optimisation already would be a breaking change).

view details

jumbatm

commit sha 5e52edca529ba5051d0bb752c751159d3057ab15

Apply suggested wording changes from code review. Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>

view details

jumbatm

commit sha 060666d0a4cb814328990d271ae9741f2d20cb0d

Address code review comments. - Make `is_repr_nullable_ptr` freestanding again to avoid usage of ImproperCTypesVisitor in ClashingExternDeclarations (and don't accidentally revert the ParamEnv::reveal_all() fix from a week earlier) - Revise match condition for 1 Adt, 1 primitive - Generalise check for non-null type so that it would also work for ranges which exclude any single value (all bits set, for example) - Make is_repr_nullable_ptr return the representable type instead of just a boolean, to avoid adding an additional, independent "source of truth" about the FFI-compatibility of Option-like enums. Also, rename to `repr_nullable_ptr`.

view details

jumbatm

commit sha 30a6f57308bf850891a2f4f47b9f1c325e2ac887

Handle structs with zst members.

view details

jumbatm

commit sha 0bd292dea1a8f6e60ac8957ac0fcd0d237034918

Fix missed same-sized member clash in ClashingExternDeclarations.

view details

bors

commit sha 6b09c37ddc240e25748e53d7a8f81f252def6dee

Auto merge of #73990 - jumbatm:clashing-extern-decl, r=nagisa Fix incorrect clashing_extern_declarations warnings. Fixes #73735, fixes #73872. Fix clashing_extern_declarations warning for `#[repr(transparent)]` structs and safely-FFI-convertible enums, and not warning for clashes of struct members of different types, but the same size. r? @nagisa

view details

Alex Crichton

commit sha cd8bdb5eb9a7440fa64500218f43b04429e64fc1

rustc: Ignore fs::canonicalize errors in metadata This commit updates the metadata location logic to ignore errors when calling `fs::canonicalize`. Canonicalization was added historically so multiple `-L` paths to the same directory don't print errors about multiple candidates (since rustc can deduplicate same-named paths), but canonicalization doesn't work on all filesystems. Cargo, for example, always uses this sort of fallback where it will opportunitistically try to canonicalize but fall back to using the input path if it otherwise doesn't work. If rustc is run on a filesystem that doesn't support canonicalization then the effect of this change will be that `-L` paths which logically point to the same directory will cause errors, but that's a rare enough occurrence it shouldn't cause much issue in practice. Otherwise rustc doesn't work at all today on those sorts of filesystem where canonicalization isn't supported!

view details

Ralf Jung

commit sha 1a2208afc5ef525649b12a9a0a01425390ca44a5

update Miri

view details

bors

commit sha 438c59f010016a8a3a11fbcc4c18ae555d7adf94

Auto merge of #74908 - RalfJung:miri, r=RalfJung update Miri Fixes https://github.com/rust-lang/rust/issues/74580 Cc @rust-lang/miri r? @ghost

view details

push time in 5 days

Pull request review commentrust-lang/rust

Avoid bool-like naming

 def main():     global MAILBOX     tests = [os.path.splitext(f)[0] for f in glob('*.rs')                                     if not f.startswith('_')]-    listed = sys.argv[1:]-    if listed:-        tests = [test for test in tests if test in listed]+    args = sys.argv[1:]+    tests = [test for test in tests if test in args]

Yeah, that's right. Will prepare another PR.

lzutao

comment created time in 5 days

delete branch lzutao/rustc

delete branch : listed

delete time in 5 days

PR opened rust-lang/rust

Stabilize `Result::as_deref` and `as_deref_mut`

FCP completed in https://github.com/rust-lang/rust/issues/50264#issuecomment-645681400.

This PR stabilizes two new APIs for std::result::Result:

fn as_deref(&self) -> Result<&T::Target, &E> where T: Deref;
fn as_deref_mut(&mut self) -> Result<&mut T::Target, &mut E> where T: DerefMut;

Also it removes two rarely used unstable APIs from Result:

fn as_deref_err(&self) -> Result<&T, &E::Target> where E: Deref;
fn as_deref_mut_err(&mut self) -> Result<&mut T, &mut E::Target> where E: DerefMut;

r? @dtolnay

+5 -74

0 comment

12 changed files

pr created time in 5 days

create barnchlzutao/rustc

branch : stalize-result-as-deref

created branch time in 5 days

issue commentrust-lang/rust

the name `AsyncRead` is defined multiple times #[cfg(feature = "xxx")] in windows normal, but in apple mac os fail

Could you push a public repo contains your exact code ? So I could clone and build it.

zhuxiujia

comment created time in 5 days

more