rust: upgrade to Rust 1.68.2 · Rust-for-Linux/linux@3ed03f4 (original) (raw)

`@@ -22,21 +22,24 @@ use core:📑:Destruct;

`

22

22

`mod tests;

`

23

23

``

24

24

`extern "Rust" {

`

25

``

`-

// These are the magic symbols to call the global allocator. rustc generates

`

``

25

`+

// These are the magic symbols to call the global allocator. rustc generates

`

26

26

`` // them to call __rg_alloc etc. if there is a #[global_allocator] attribute

``

27

27

`// (the code expanding that attribute macro generates those functions), or to call

`

28

``

`` -

// the default implementations in libstd (__rdl_alloc etc. in library/std/src/alloc.rs)

``

``

28

`` +

// the default implementations in std (__rdl_alloc etc. in library/std/src/alloc.rs)

``

29

29

`// otherwise.

`

30

``

`-

// The rustc fork of LLVM also special-cases these function names to be able to optimize them

`

``

30

`+

// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them

`

31

31

`` // like malloc, realloc, and free, respectively.

``

32

32

`#[rustc_allocator]

`

33

``

`-

#[rustc_allocator_nounwind]

`

``

33

`+

#[rustc_nounwind]

`

34

34

`fn __rust_alloc(size: usize, align: usize) -> *mut u8;

`

35

``

`-

#[rustc_allocator_nounwind]

`

``

35

`+

#[rustc_deallocator]

`

``

36

`+

#[rustc_nounwind]

`

36

37

`fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);

`

37

``

`-

#[rustc_allocator_nounwind]

`

``

38

`+

#[rustc_reallocator]

`

``

39

`+

#[rustc_nounwind]

`

38

40

`fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8;

`

39

``

`-

#[rustc_allocator_nounwind]

`

``

41

`+

#[rustc_allocator_zeroed]

`

``

42

`+

#[rustc_nounwind]

`

40

43

`fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;

`

41

44

`}

`

42

45

``

`@@ -72,11 +75,14 @@ pub use std::alloc::Global;

`

72

75

`/// # Examples

`

73

76

`///

`

74

77

```` /// ```

````

75

``

`-

/// use std::alloc::{alloc, dealloc, Layout};

`

``

78

`+

/// use std::alloc::{alloc, dealloc, handle_alloc_error, Layout};

`

76

79

`///

`

77

80

`/// unsafe {

`

78

81

`/// let layout = Layout:🆕:();

`

79

82

`/// let ptr = alloc(layout);

`

``

83

`+

/// if ptr.is_null() {

`

``

84

`+

/// handle_alloc_error(layout);

`

``

85

`+

/// }

`

80

86

`///

`

81

87

`/// *(ptr as *mut u16) = 42;

`

82

88

`/// assert_eq!(*(ptr as *mut u16), 42);

`

`@@ -349,7 +355,7 @@ pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Dest

`

349

355

``

350

356

`#[cfg(not(no_global_oom_handling))]

`

351

357

`extern "Rust" {

`

352

``

`-

// This is the magic symbol to call the global alloc error handler. rustc generates

`

``

358

`+

// This is the magic symbol to call the global alloc error handler. rustc generates

`

353

359

`` // it to call __rg_oom if there is a #[alloc_error_handler], or to call the

``

354

360

`` // default implementations below (__rdl_oom) otherwise.

``

355

361

`fn __rust_alloc_error_handler(size: usize, align: usize) -> !;

`

`@@ -394,25 +400,24 @@ pub use std::alloc::handle_alloc_error;

`

394

400

`#[allow(unused_attributes)]

`

395

401

`#[unstable(feature = "alloc_internals", issue = "none")]

`

396

402

`pub mod __alloc_error_handler {

`

397

``

`-

use crate::alloc::Layout;

`

398

``

-

399

``

`` -

// called via generated __rust_alloc_error_handler

``

400

``

-

401

``

`` -

// if there is no #[alloc_error_handler]

``

``

403

`` +

// called via generated __rust_alloc_error_handler if there is no

``

``

404

`` +

// #[alloc_error_handler].

``

402

405

`#[rustc_std_internal_symbol]

`

403

``

`-

pub unsafe extern "C-unwind" fn __rdl_oom(size: usize, _align: usize) -> ! {

`

404

``

`-

panic!("memory allocation of {size} bytes failed")

`

405

``

`-

}

`

406

``

-

407

``

`` -

// if there is an #[alloc_error_handler]

``

408

``

`-

#[rustc_std_internal_symbol]

`

409

``

`-

pub unsafe extern "C-unwind" fn __rg_oom(size: usize, align: usize) -> ! {

`

410

``

`-

let layout = unsafe { Layout::from_size_align_unchecked(size, align) };

`

``

406

`+

pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {

`

411

407

`extern "Rust" {

`

412

``

`-

#[lang = "oom"]

`

413

``

`-

fn oom_impl(layout: Layout) -> !;

`

``

408

`+

// This symbol is emitted by rustc next to __rust_alloc_error_handler.

`

``

409

`+

// Its value depends on the -Zoom={panic,abort} compiler option.

`

``

410

`+

static __rust_alloc_error_handler_should_panic: u8;

`

``

411

`+

}

`

``

412

+

``

413

`+

#[allow(unused_unsafe)]

`

``

414

`+

if unsafe { __rust_alloc_error_handler_should_panic != 0 } {

`

``

415

`+

panic!("memory allocation of {size} bytes failed")

`

``

416

`+

} else {

`

``

417

`+

core::panicking::panic_nounwind_fmt(format_args!(

`

``

418

`+

"memory allocation of {size} bytes failed"

`

``

419

`+

))

`

414

420

`}

`

415

``

`-

unsafe { oom_impl(layout) }

`

416

421

`}

`

417

422

`}

`

418

423

``