jiebi/CodeConvo huggingface dataset:
<ins> // build-pass // compile-flags: -Cdebuginfo=2 // fixes issue #94725 #![feature(allocator_api)] use std::alloc::{AllocError, Allocator, Layout}; use std::ptr::NonNull; struct ZST; unsafe impl Allocator for &ZST { fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { todo!() } unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) { todo!() } } fn main() { let _ = Box::<i32, &ZST>::new_in(43, &ZST); } </ins>
<ins> // run-pass // regression test for issue #94923 // min-llvm-version: 15.0.0 // compile-flags: -C opt-level=3 fn f0<T>(mut x: usize) -> usize { for _ in 0..1000 { x *= 123; x %= 99 } x + 321 // function composition is not just longer iteration } fn f1<T>(x: usize) -> usize { f0::<(i8, T)>(f0::<(u8, T)>(x)) } fn f2<T>(x: usize) -> usize { f1::<(i8, T)>(f1::<(u8, T)>(x)) } fn f3<T>(x: usize) -> usize { f2::<(i8, T)>(f2::<(u8, T)>(x)) } fn f4<T>(x: usize) -> usize { f3::<(i8, T)>(f3::<(u8, T)>(x)) } fn f5<T>(x: usize) -> usize { f4::<(i8, T)>(f4::<(u8, T)>(x)) } fn f6<T>(x: usize) -> usize { f5::<(i8, T)>(f5::<(u8, T)>(x)) } fn f7<T>(x: usize) -> usize { f6::<(i8, T)>(f6::<(u8, T)>(x)) } fn f8<T>(x: usize) -> usize { f7::<(i8, T)>(f7::<(u8, T)>(x)) } fn main() { let y = f8::<()>(1); assert_eq!(y, 348); } </ins>
hir::GenericParamKind::Const { ty: hir_ty, default: _ } => { let ty = tcx.type_of(tcx.hir().local_def_id(param.hir_id)); <del> let err_ty_str; let mut is_ptr = true; let err = if tcx.features().adt_const_params { match ty.peel_refs().kind() { </del> <ins> if tcx.features().adt_const_params { let err = match ty.peel_refs().kind() { </ins> ty::FnPtr(_) => Some("function pointers"), ty::RawPtr(_) => Some("raw pointers"), _ => None, <ins> }; if let Some(unsupported_type) = err { tcx.sess.span_err( hir_ty.span, &format!( "using {} as const generic parameters is forbidden", unsupported_type ), ); } if traits::search_for_structural_match_violation(param.span, tcx, ty).is_some() { // We use the same error code in both branches, because this is really the same // issue: we just special-case the message for type parameters to make it // clearer. if let ty::Param(_) = ty.peel_refs().kind() { // Const parameters may not have type parameters as their types, // because we cannot be sure that the type parameter derives `PartialEq` // and `Eq` (just implementing them is not enough for `structural_match`). struct_span_err!( tcx.sess, hir_ty.span, E0741, "`{}` is not guaranteed to `#[derive(PartialEq, Eq)]`, so may not be  used as the type of a const parameter", ty, ) .span_label( hir_ty.span, format!("`{}` may not derive both `PartialEq` and `Eq`", ty), ) .note( "it is not currently possible to use a type parameter as the type of a  const parameter", ) .emit(); } else { struct_span_err!( tcx.sess, hir_ty.span, E0741, "`{}` must be annotated with `#[derive(PartialEq, Eq)]` to be used as  the type of a const parameter", ty, ) .span_label( hir_ty.span, format!("`{}` doesn't derive both `PartialEq` and `Eq`", ty), ) .emit(); } </ins> } } else { <del> match ty.kind() { </del> <ins> let err_ty_str; let mut is_ptr = true; let err = match ty.kind() { </ins> ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Error(_) => None, ty::FnPtr(_) => Some("function pointers"), ty::RawPtr(_) => Some("raw pointers"),
err_ty_str = format!("`{}`", ty); Some(err_ty_str.as_str()) } <del> } }; if let Some(unsupported_type) = err { if is_ptr { tcx.sess.span_err( hir_ty.span, &format!( "using {} as const generic parameters is forbidden", unsupported_type ), ); } else { let mut err = tcx.sess.struct_span_err( hir_ty.span, &format!( "{} is forbidden as the type of a const generic parameter", unsupported_type ), ); err.note("the only supported types are integers, `bool` and `char`"); if tcx.sess.is_nightly_build() { err.help( </del> <ins> }; if let Some(unsupported_type) = err { if is_ptr { tcx.sess.span_err( hir_ty.span, &format!( "using {} as const generic parameters is forbidden", unsupported_type ), ); } else { let mut err = tcx.sess.struct_span_err( hir_ty.span, &format!( "{} is forbidden as the type of a const generic parameter", unsupported_type ), ); err.note("the only supported types are integers, `bool` and `char`"); if tcx.sess.is_nightly_build() { err.help( </ins> "more complex types are supported with `#![feature(adt_const_params)]`", ); <ins> } err.emit(); </ins> } <del> err.emit(); } }; if traits::search_for_structural_match_violation(param.span, tcx, ty).is_some() { // We use the same error code in both branches, because this is really the same // issue: we just special-case the message for type parameters to make it // clearer. if let ty::Param(_) = ty.peel_refs().kind() { // Const parameters may not have type parameters as their types, // because we cannot be sure that the type parameter derives `PartialEq` // and `Eq` (just implementing them is not enough for `structural_match`). struct_span_err!( tcx.sess, hir_ty.span, E0741, "`{}` is not guaranteed to `#[derive(PartialEq, Eq)]`, so may not be  used as the type of a const parameter", ty, ) .span_label( hir_ty.span, format!("`{}` may not derive both `PartialEq` and `Eq`", ty), ) .note( "it is not currently possible to use a type parameter as the type of a  const parameter", ) .emit(); } else { struct_span_err!( tcx.sess, hir_ty.span, E0741, "`{}` must be annotated with `#[derive(PartialEq, Eq)]` to be used as  the type of a const parameter", ty, ) .span_label( hir_ty.span, format!("`{}` doesn't derive both `PartialEq` and `Eq`", ty), ) .emit(); </del> } } }
= note: the only supported types are integers, `bool` and `char` = help: more complex types are supported with `#![feature(adt_const_params)]` <del> error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter --> $DIR/issue-63322-forbid-dyn.rs:9:18 | LL | fn test<const T: &'static dyn A>() { |                  ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq` error: aborting due to 2 previous errors </del> <ins> error: aborting due to previous error </ins> <del> For more information about this error, try `rustc --explain E0741`. </del>
impl A for B {} fn test<const T: &'static dyn A>() { <del> //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used </del> <ins> //[full]~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used </ins> //[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden unimplemented!() }
= note: the only supported types are integers, `bool` and `char` = help: more complex types are supported with `#![feature(adt_const_params)]` <del> error[E0015]: cannot call non-const fn `Foo::{constant#0}::Foo::<17_usize>::value` in constants --> $DIR/nested-type.rs:15:5 | LL |     Foo::<17>::value() |     ^^^^^^^^^^^^^^^^^^ | = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 2 previous errors </del> <ins> error: aborting due to previous error </ins> <del> For more information about this error, try `rustc --explain E0015`. </del>
const TAG_OS: usize = 0b10; const TAG_SIMPLE: usize = 0b11; <ins> /// The internal representation. /// /// See the module docs for more, this is just a way to hack in a check that we /// indeed are not unwind-safe. /// /// ```compile_fail,E0277 /// fn is_unwind_safe<T: core::panic::UnwindSafe>() {} /// is_unwind_safe::<std::io::Error>(); /// ``` </ins> #[repr(transparent)] <del> pub(super) struct Repr(NonNull<()>); </del> <ins> pub(super) struct Repr(NonNull<()>, PhantomData<ErrorData<Box<Custom>>>); </ins> // All the types `Repr` stores internally are Send + Sync, and so is it. unsafe impl Send for Repr {}
// box, and `TAG_CUSTOM` just... isn't zero -- it's `0b01`). Therefore, // `TAG_CUSTOM + p` isn't zero and so `tagged` can't be, and the // `new_unchecked` is safe. <del> let res = Self(unsafe { NonNull::new_unchecked(tagged) }); </del> <ins> let res = Self(unsafe { NonNull::new_unchecked(tagged) }, PhantomData); </ins> // quickly smoke-check we encoded the right thing (This generally will // only run in libstd's tests, unless the user uses -Zbuild-std) debug_assert!(matches!(res.data(), ErrorData::Custom(_)), "repr(custom) encoding failed");
pub(super) fn new_os(code: i32) -> Self { let utagged = ((code as usize) << 32) | TAG_OS; // Safety: `TAG_OS` is not zero, so the result of the `|` is not 0. <del> let res = Self(unsafe { NonNull::new_unchecked(utagged as *mut ()) }); </del> <ins> let res = Self(unsafe { NonNull::new_unchecked(utagged as *mut ()) }, PhantomData); </ins> // quickly smoke-check we encoded the right thing (This generally will // only run in libstd's tests, unless the user uses -Zbuild-std) debug_assert!(
pub(super) fn new_simple(kind: ErrorKind) -> Self { let utagged = ((kind as usize) << 32) | TAG_SIMPLE; // Safety: `TAG_SIMPLE` is not zero, so the result of the `|` is not 0. <del> let res = Self(unsafe { NonNull::new_unchecked(utagged as *mut ()) }); </del> <ins> let res = Self(unsafe { NonNull::new_unchecked(utagged as *mut ()) }, PhantomData); </ins> // quickly smoke-check we encoded the right thing (This generally will // only run in libstd's tests, unless the user uses -Zbuild-std) debug_assert!(
#[inline] pub(super) const fn new_simple_message(m: &'static SimpleMessage) -> Self { // Safety: References are never null. <del> Self(unsafe { NonNull::new_unchecked(m as *const _ as *mut ()) }) </del> <ins> Self(unsafe { NonNull::new_unchecked(m as *const _ as *mut ()) }, PhantomData) </ins> } #[inline]
let paths = builder .paths .iter() <del> .map(components_simplified) .filter_map(|path| { if path.get(0) == Some(&"compiler") { path.get(1).map(|p| p.to_owned()) } else { None } </del> <ins> .filter(|path| { let components = components_simplified(path); components.len() >= 2 && components[0] == "compiler" </ins> }) .collect::<Vec<_>>();
cargo.rustdocflag("--extern-html-root-url"); cargo.rustdocflag("ena=https://docs.rs/ena/latest/"); <del> let mut compiler_crates = HashSet::new(); if paths.is_empty() { // Find dependencies for top level crates. for root_crate in &["rustc_driver", "rustc_codegen_llvm", "rustc_codegen_ssa"] { compiler_crates.extend( builder .in_tree_crates(root_crate, Some(target)) .into_iter() .map(|krate| krate.name), ); } </del> <ins> let root_crates = if paths.is_empty() { vec![ INTERNER.intern_str("rustc_driver"), INTERNER.intern_str("rustc_codegen_llvm"), INTERNER.intern_str("rustc_codegen_ssa"), ] </ins> } else { <del> for root_crate in paths { if !builder.src.join("compiler").join(&root_crate).exists() { builder.info(&format!( "tskipping - compiler/{} (unknown compiler crate)", root_crate )); } else { compiler_crates.extend( builder .in_tree_crates(root_crate, Some(target)) .into_iter() .map(|krate| krate.name), ); } } } </del> <ins> paths.into_iter().map(|p| builder.crate_paths[p]).collect() }; // Find dependencies for top level crates. let compiler_crates = root_crates.iter().flat_map(|krate| { builder.in_tree_crates(krate, Some(target)).into_iter().map(|krate| krate.name) }); </ins> let mut to_open = None; <del> for krate in &compiler_crates { </del> <ins> for krate in compiler_crates { </ins> // Create all crate output directories first to make sure rustdoc uses // relative links. // FIXME: Cargo should probably do this itself.
ar: HashMap<TargetSelection, PathBuf>, ranlib: HashMap<TargetSelection, PathBuf>, // Miscellaneous <ins> // allow bidirectional lookups: both name -> path and path -> name </ins> crates: HashMap<Interned<String>, Crate>, <ins> crate_paths: HashMap<PathBuf, Interned<String>>, </ins> is_sudo: bool, ci_env: CiEnv, delayed_failures: RefCell<Vec<String>>,
.filter(|dep| dep.source.is_none()) .map(|dep| INTERNER.intern_string(dep.name)) .collect(); <del> build.crates.insert(name, Crate { name, deps, path }); </del> <ins> let krate = Crate { name, deps, path }; let relative_path = krate.local_path(build); build.crates.insert(name, krate); let existing_path = build.crate_paths.insert(relative_path, name); assert!(existing_path.is_none(), "multiple crates with the same path"); </ins> } } }
use crate::tool::{self, SourceType, Tool}; use crate::toolstate::ToolState; use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t}; <del> use crate::Crate as CargoCrate; </del> use crate::{envify, CLang, DocTests, GitRepo, Mode}; const ADB_TEST_DIR: &str = "/data/tmp/work";
fn make_run(run: RunConfig<'_>) { let builder = run.builder; let compiler = builder.compiler(builder.top_stage, run.build_triple()); <ins> let krate = builder.crate_paths[&run.path]; let test_kind = builder.kind.into(); </ins> <del> for krate in builder.in_tree_crates("rustc-main", Some(run.target)) { if krate.path.ends_with(&run.path) { let test_kind = builder.kind.into(); builder.ensure(CrateLibrustc { compiler, target: run.target, test_kind, krate: krate.name, }); } } </del> <ins> builder.ensure(CrateLibrustc { compiler, target: run.target, test_kind, krate }); </ins> } fn run(self, builder: &Builder<'_>) {
fn make_run(run: RunConfig<'_>) { let builder = run.builder; let compiler = builder.compiler(builder.top_stage, run.build_triple()); <ins> let test_kind = builder.kind.into(); let krate = builder.crate_paths[&run.path]; </ins> <del> let make = |mode: Mode, krate: &CargoCrate| { let test_kind = builder.kind.into(); builder.ensure(Crate { compiler, target: run.target, mode, test_kind, krate: krate.name, }); }; for krate in builder.in_tree_crates("test", Some(run.target)) { if krate.path.ends_with(&run.path) { make(Mode::Std, krate); } } </del> <ins> builder.ensure(Crate { compiler, target: run.target, mode: Mode::Std, test_kind, krate }); </ins> } /// Runs all unit tests plus documentation tests for a given crate defined
if layout_variants.iter().all(|v| v.abi.is_uninhabited()) { abi = Abi::Uninhabited; <del> } else if tag.size(dl) == size || variants.iter().all(|layout| layout.is_empty()) { // Without latter check aligned enums with custom discriminant values // Would result in ICE see the issue #92464 for more info </del> <ins> } else if tag.size(dl) == size { // Make sure we only use scalar layout when the enum is entirely its // own tag (i.e. it has no padding nor any non-ZST variant fields). </ins> abi = Abi::Scalar(tag); } else { // Try to use a ScalarPair for all tagged enums.
fn main() { let aligned = Aligned::Zero; let fo = aligned as u8; <del> println!("foo {}",fo); </del> <ins> println!("foo {}", fo); assert_eq!(fo, 0); println!("{}", tou8(Aligned::Zero)); assert_eq!(tou8(Aligned::Zero), 0); } #[inline(never)] fn tou8(al: Aligned) -> u8 { // Cast behind a function call so ConstProp does not see it // (so that we can test codegen). al as u8 </ins> }
<ins> // normalize-stderr-test "pref: Align([1-8] bytes)" -> "pref: $$PREF_ALIGN" #![crate_type = "lib"] #![feature(rustc_attrs)] // This cannot use `Scalar` abi since there is padding. #[rustc_layout(debug)] #[repr(align(8))] pub enum Aligned1 { //~ ERROR: layout_of Zero = 0, One = 1, } // This should use `Scalar` abi. #[rustc_layout(debug)] #[repr(align(1))] pub enum Aligned2 { //~ ERROR: layout_of Zero = 0, One = 1, } </ins>
<ins> error: layout_of(Aligned1) = Layout { fields: Arbitrary { offsets: [ Size(0 bytes), ], memory_index: [ 0, ], }, variants: Multiple { tag: Initialized { value: Int( I8, false, ), valid_range: 0..=1, }, tag_encoding: Direct, tag_field: 0, variants: [ Layout { fields: Arbitrary { offsets: [], memory_index: [], }, variants: Single { index: 0, }, abi: Aggregate { sized: true, }, largest_niche: None, align: AbiAndPrefAlign { abi: Align(8 bytes), pref: $PREF_ALIGN, }, size: Size(8 bytes), }, Layout { fields: Arbitrary { offsets: [], memory_index: [], }, variants: Single { index: 1, }, abi: Aggregate { sized: true, }, largest_niche: None, align: AbiAndPrefAlign { abi: Align(8 bytes), pref: $PREF_ALIGN, }, size: Size(8 bytes), }, ], }, abi: Aggregate { sized: true, }, largest_niche: Some( Niche { offset: Size(0 bytes), value: Int( I8, false, ), valid_range: 0..=1, }, ), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: $PREF_ALIGN, }, size: Size(8 bytes), } --> $DIR/issue-96185-overaligned-enum.rs:8:1 | LL | pub enum Aligned1 { | ^^^^^^^^^^^^^^^^^ error: layout_of(Aligned2) = Layout { fields: Arbitrary { offsets: [ Size(0 bytes), ], memory_index: [ 0, ], }, variants: Multiple { tag: Initialized { value: Int( I8, false, ), valid_range: 0..=1, }, tag_encoding: Direct, tag_field: 0, variants: [ Layout { fields: Arbitrary { offsets: [], memory_index: [], }, variants: Single { index: 0, }, abi: Aggregate { sized: true, }, largest_niche: None, align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, size: Size(1 bytes), }, Layout { fields: Arbitrary { offsets: [], memory_index: [], }, variants: Single { index: 1, }, abi: Aggregate { sized: true, }, largest_niche: None, align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, size: Size(1 bytes), }, ], }, abi: Scalar( Initialized { value: Int( I8, false, ), valid_range: 0..=1, }, ), largest_niche: Some( Niche { offset: Size(0 bytes), value: Int( I8, false, ), valid_range: 0..=1, }, ), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $PREF_ALIGN, }, size: Size(1 bytes), } --> $DIR/issue-96185-overaligned-enum.rs:16:1 | LL | pub enum Aligned2 { | ^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors </ins>
// so add an empty section. if file.format() == object::BinaryFormat::Coff { file.add_section(Vec::new(), ".text".into(), object::SectionKind::Text); <ins> // We handle the name decoration of COFF targets in `symbol_export.rs`, so disable the // default mangler in `object` crate. file.set_mangling(object::write::Mangling::None); </ins> } for (sym, kind) in symbols.iter() {
for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| { if info.level.is_below_threshold(export_threshold) || info.used { symbols.push(( <del> symbol_export::symbol_name_for_instance_in_crate(tcx, symbol, cnum), </del> <ins> symbol_export::linking_symbol_name_for_instance_in_crate(tcx, symbol, cnum), </ins> info.kind, )); }
use rustc_middle::ty::query::{ExternProviders, Providers}; use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::Instance; <del> use rustc_middle::ty::{SymbolName, TyCtxt}; </del> <ins> use rustc_middle::ty::{self, SymbolName, TyCtxt}; </ins> use rustc_session::config::CrateType; use rustc_target::spec::SanitizerSet;
} } <ins> /// This is the symbol name of the given instance as seen by the linker. /// /// On 32-bit Windows symbols are decorated according to their calling conventions. pub fn linking_symbol_name_for_instance_in_crate<'tcx>( tcx: TyCtxt<'tcx>, symbol: ExportedSymbol<'tcx>, instantiating_crate: CrateNum, ) -> String { use rustc_target::abi::call::Conv; let mut undecorated = symbol_name_for_instance_in_crate(tcx, symbol, instantiating_crate); let target = &tcx.sess.target; if !target.is_like_windows { // Mach-O has a global "_" suffix and `object` crate will handle it. // ELF does not have any symbol decorations. return undecorated; } let x86 = match &target.arch[..] { "x86" => true, "x86_64" => false, // Only x86/64 use symbol decorations. _ => return undecorated, }; let instance = match symbol { ExportedSymbol::NonGeneric(def_id) | ExportedSymbol::Generic(def_id, _) if tcx.is_static(def_id) => { None } ExportedSymbol::NonGeneric(def_id) => Some(Instance::mono(tcx, def_id)), ExportedSymbol::Generic(def_id, substs) => Some(Instance::new(def_id, substs)), // DropGlue always use the Rust calling convention and thus follow the target's default // symbol decoration scheme. ExportedSymbol::DropGlue(..) => None, // NoDefId always follow the target's default symbol decoration scheme. ExportedSymbol::NoDefId(..) => None, }; let (conv, args) = instance .map(|i| { tcx.fn_abi_of_instance(ty::ParamEnv::reveal_all().and((i, ty::List::empty()))) .unwrap_or_else(|_| bug!("fn_abi_of_instance({i:?}) failed")) }) .map(|fnabi| (fnabi.conv, &fnabi.args[..])) .unwrap_or((Conv::Rust, &[])); // Decorate symbols with prefices, suffices and total number of bytes of arguments. // Reference: https://docs.microsoft.com/en-us/cpp/build/reference/decorated-names?view=msvc-170 let (prefix, suffix) = match conv { Conv::X86Fastcall => ("@", "@"), Conv::X86Stdcall => ("_", "@"), Conv::X86VectorCall => ("", "@@"), _ => { if x86 { undecorated.insert(0, '_'); } return undecorated; } }; let args_in_bytes: u64 = args .iter() .map(|abi| abi.layout.size.bytes().next_multiple_of(target.pointer_width as u64 / 8)) .sum(); format!("{prefix}{undecorated}{suffix}{args_in_bytes}") } </ins> fn wasm_import_module_map(tcx: TyCtxt<'_>, cnum: CrateNum) -> FxHashMap<DefId, String> { // Build up a map from DefId to a `NativeLib` structure, where // `NativeLib` internally contains information about
<ins> // build-pass // only-x86-windows #![crate_type = "cdylib"] #![feature(abi_vectorcall)] #[no_mangle] extern "stdcall" fn foo(_: bool) {} #[no_mangle] extern "fastcall" fn bar(_: u8) {} #[no_mangle] extern "vectorcall" fn baz(_: u16) {} </ins>
.arg("--target-dir") .arg(&*target_dir.to_string_lossy()) .arg("-Zskip-rustdoc-fingerprint") <ins> .arg("-Zrustdoc-map") .rustdocflag("--extern-html-root-url") .rustdocflag("std_detect=https://docs.rs/std_detect/latest/") .rustdocflag("--extern-html-root-takes-precedence") </ins> .rustdocflag("--resource-suffix") .rustdocflag(&builder.version); for arg in extra_args {
entry.unwrap(); } } <ins> /// Test the fallback for getting the metadata of files like hiberfil.sys that /// Windows holds a special lock on, preventing normal means of querying /// metadata. See #96980. /// /// Note this fails in CI because `hiberfil.sys` does not actually exist there. /// Therefore it's marked as ignored. #[test] #[ignore] #[cfg(windows)] fn hiberfil_sys() { let hiberfil = Path::new(r"C:hiberfil.sys"); assert_eq!(true, hiberfil.try_exists().unwrap()); fs::symlink_metadata(hiberfil).unwrap(); fs::metadata(hiberfil).unwrap(); assert_eq!(true, hiberfil.exists()); } </ins>
} pub fn metadata(&self) -> io::Result<FileAttr> { <del> Ok(FileAttr { attributes: self.data.dwFileAttributes, creation_time: self.data.ftCreationTime, last_access_time: self.data.ftLastAccessTime, last_write_time: self.data.ftLastWriteTime, file_size: ((self.data.nFileSizeHigh as u64) << 32) | (self.data.nFileSizeLow as u64), reparse_tag: if self.data.dwFileAttributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0 { // reserved unless this is a reparse point self.data.dwReserved0 } else { 0 }, volume_serial_number: None, number_of_links: None, file_index: None, }) </del> <ins> Ok(self.data.into()) </ins> } }
self.file_index } } <ins> impl From<c::WIN32_FIND_DATAW> for FileAttr { fn from(wfd: c::WIN32_FIND_DATAW) -> Self { FileAttr { attributes: wfd.dwFileAttributes, creation_time: wfd.ftCreationTime, last_access_time: wfd.ftLastAccessTime, last_write_time: wfd.ftLastWriteTime, file_size: ((wfd.nFileSizeHigh as u64) << 32) | (wfd.nFileSizeLow as u64), reparse_tag: if wfd.dwFileAttributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0 { // reserved unless this is a reparse point wfd.dwReserved0 } else { 0 }, volume_serial_number: None, number_of_links: None, file_index: None, } } } </ins> fn to_u64(ft: &c::FILETIME) -> u64 { (ft.dwLowDateTime as u64) | ((ft.dwHighDateTime as u64) << 32)