]> git.lizzy.rs Git - rust.git/blob - src/librustc_allocator/lib.rs
Rollup merge of #43993 - tamird:better-wording-error, r=arielb1
[rust.git] / src / librustc_allocator / lib.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![deny(warnings)]
12
13 #![feature(rustc_private)]
14
15 extern crate rustc;
16 extern crate rustc_errors;
17 extern crate syntax;
18 extern crate syntax_pos;
19
20 pub mod expand;
21
22 pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[
23     AllocatorMethod {
24         name: "alloc",
25         inputs: &[AllocatorTy::Layout],
26         output: AllocatorTy::ResultPtr,
27     },
28     AllocatorMethod {
29         name: "oom",
30         inputs: &[AllocatorTy::AllocErr],
31         output: AllocatorTy::Bang,
32     },
33     AllocatorMethod {
34         name: "dealloc",
35         inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout],
36         output: AllocatorTy::Unit,
37     },
38     AllocatorMethod {
39         name: "usable_size",
40         inputs: &[AllocatorTy::LayoutRef],
41         output: AllocatorTy::UsizePair,
42     },
43     AllocatorMethod {
44         name: "realloc",
45         inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
46         output: AllocatorTy::ResultPtr,
47     },
48     AllocatorMethod {
49         name: "alloc_zeroed",
50         inputs: &[AllocatorTy::Layout],
51         output: AllocatorTy::ResultPtr,
52     },
53     AllocatorMethod {
54         name: "alloc_excess",
55         inputs: &[AllocatorTy::Layout],
56         output: AllocatorTy::ResultExcess,
57     },
58     AllocatorMethod {
59         name: "realloc_excess",
60         inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
61         output: AllocatorTy::ResultExcess,
62     },
63     AllocatorMethod {
64         name: "grow_in_place",
65         inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
66         output: AllocatorTy::ResultUnit,
67     },
68     AllocatorMethod {
69         name: "shrink_in_place",
70         inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
71         output: AllocatorTy::ResultUnit,
72     },
73 ];
74
75 pub struct AllocatorMethod {
76     pub name: &'static str,
77     pub inputs: &'static [AllocatorTy],
78     pub output: AllocatorTy,
79 }
80
81 pub enum AllocatorTy {
82     AllocErr,
83     Bang,
84     Layout,
85     LayoutRef,
86     Ptr,
87     ResultExcess,
88     ResultPtr,
89     ResultUnit,
90     Unit,
91     UsizePair,
92 }