about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-04-20 21:45:37 +0100
committerGitHub <noreply@github.com>2024-04-20 21:45:37 +0100
commit418a07861a4f8832474fee6a4afe54810fb65439 (patch)
treef906c5331b54eb4d649d892b2b5912429e45ff48 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent29ee2763680fb9a831cb33d80158f661cb508504 (diff)
parentfdf93bbde02ddaf2eb75b82a9ef4e8d5590f9c37 (diff)
downloadrust-418a07861a4f8832474fee6a4afe54810fb65439.tar.gz
rust-418a07861a4f8832474fee6a4afe54810fb65439.zip
Rollup merge of #124103 - dtolnay:metadatadebug, r=Mark-Simulacrum
Improve std::fs::Metadata Debug representation

- Remove duplication of `mode` between `file_type` and `permissions`, which both involve operating on the same mode_t integer
- Add `is_symlink`
- Add `len` in bytes
- Remove Ok wrapping around `modified`, `accessed`, `created`, which eliminates 6 useless lines

<table>
<tr><th>Before</th><th>After</th></tr>
<tr><td>

```console
Metadata {
    file_type: FileType(
        FileType {
            mode: 0o100600 (-rw-------),
        },
    ),
    is_dir: false,
    is_file: true,
    permissions: Permissions(
        FilePermissions {
            mode: 0o100600 (-rw-------),
        },
    ),
    modified: Ok(
        SystemTime {
            tv_sec: 1713402981,
            tv_nsec: 682983531,
        },
    ),
    accessed: Ok(
        SystemTime {
            tv_sec: 1713402983,
            tv_nsec: 206999623,
        },
    ),
    created: Ok(
        SystemTime {
            tv_sec: 1713402981,
            tv_nsec: 682983531,
        },
    ),
    ..
}
```
</td><td>

```console
Metadata {
    file_type: FileType {
        is_file: true,
        is_dir: false,
        is_symlink: false,
        ..
    },
    permissions: Permissions(
        FilePermissions {
            mode: 0o100600 (-rw-------),
        },
    ),
    len: 2096,
    modified: SystemTime {
        tv_sec: 1713402981,
        tv_nsec: 682983531,
    },
    accessed: SystemTime {
        tv_sec: 1713402983,
        tv_nsec: 206999623,
    },
    created: SystemTime {
        tv_sec: 1713402981,
        tv_nsec: 682983531,
    },
    ..
}

```
</td></tr></table>

Generated by:

```rust
fn main() {
    println!("{:#?}", std::fs::metadata("Cargo.toml").unwrap());
}
```
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions