├── .github └── workflows │ ├── clippy.yml │ ├── rust.yml │ └── rustfmt.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── README.md ├── ar ├── Cargo.toml ├── config.toml └── src │ └── main.rs ├── arch-ops ├── Cargo.toml ├── Makefile.in └── src │ ├── clever.rs │ ├── disasm.rs │ ├── holeybytes │ ├── codec.rs │ ├── instructions.in │ └── mod.rs │ ├── lib.rs │ ├── m6502.rs │ ├── test.rs │ ├── traits.rs │ ├── w65.rs │ ├── x86.rs │ └── x86 │ ├── codegen.rs │ ├── codegen │ └── insn.rs │ ├── cpu.rs │ ├── cpu │ └── timings.rs │ ├── features.rs │ ├── insn.rs │ └── printer.rs ├── binfmt-test ├── Cargo.toml └── src │ └── main.rs ├── binfmt ├── Cargo.toml ├── config.toml └── src │ ├── aout.rs │ ├── ar.rs │ ├── ar │ └── tests │ │ ├── mod.rs │ │ └── test_archive1.a │ ├── binary.rs │ ├── coff.rs │ ├── debug.rs │ ├── elf.rs │ ├── elf │ └── tests │ │ ├── empty_exec │ │ ├── empty_rel.o │ │ ├── empty_shared.so │ │ └── mod.rs │ ├── elf32.rs │ ├── elf32 │ ├── w65.rs │ └── x86_64.rs │ ├── elf64.rs │ ├── elf64 │ ├── clever.rs │ ├── holeybytes.rs │ └── x86_64.rs │ ├── fmt.rs │ ├── howto.rs │ ├── lib.rs │ ├── macho.rs │ ├── o65.rs │ ├── pe.rs │ ├── sym.rs │ ├── traits.rs │ ├── xir.rs │ └── xo65.rs ├── clippy.toml ├── config.toml ├── dbg-info ├── Cargo.toml └── src │ ├── dwarf5.rs │ └── lib.rs ├── install_binutils_symlinks.cmake ├── lcas ├── Cargo.toml ├── build.rs ├── config.toml └── src │ ├── as_state.rs │ ├── expr.rs │ ├── lcas.rs │ ├── lex.rs │ ├── lib.rs │ ├── span.rs │ ├── sym.rs │ ├── targ.rs │ └── targ │ ├── clever.rs │ ├── holeybytes.rs │ └── w65.rs ├── lccc-mangle ├── Cargo.toml └── src │ ├── itanium.rs │ └── lib.rs ├── lcld ├── Cargo.toml ├── build │ ├── config.rs │ └── main.rs ├── config.toml └── src │ ├── driver │ ├── ld │ │ └── mod.rs │ ├── ld64 │ │ └── mod.rs │ ├── link │ │ └── mod.rs │ ├── mod.rs │ └── wasm │ │ └── mod.rs │ ├── input.rs │ ├── link.rs │ ├── lto.rs │ ├── main.rs │ ├── output.rs │ ├── script.rs │ └── targ.rs ├── lto ├── Cargo.toml └── src │ └── lib.rs ├── m4 ├── ax_prog_cc_for_build.m4 ├── bindgen.m4 ├── build_std.m4 ├── lcrust_checks.m4 └── lcrust_prog_rustc.m4 ├── objdump ├── Cargo.toml └── src │ └── main.rs ├── readobj ├── Cargo.toml └── src │ └── main.rs └── vendor ├── bytemuck ├── .cargo-checksum.json ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── LICENSE-ZLIB ├── README.md ├── changelog.md ├── rustfmt.toml ├── src │ ├── allocation.rs │ ├── contiguous.rs │ ├── lib.rs │ ├── offset_of.rs │ ├── pod.rs │ ├── transparent.rs │ └── zeroable.rs └── tests │ ├── array_tests.rs │ ├── cast_slice_tests.rs │ ├── derive.rs │ ├── doc_tests.rs │ ├── offset_of_tests.rs │ ├── std_tests.rs │ ├── transparent.rs │ └── wrapper_forgets.rs ├── bytemuck_derive ├── .cargo-checksum.json ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── LICENSE-ZLIB ├── README.md ├── changelog.md ├── src │ ├── lib.rs │ └── traits.rs └── tests │ └── basic.rs ├── either ├── .cargo-checksum.json ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README-crates.io.md ├── README.rst └── src │ ├── lib.rs │ ├── serde_untagged.rs │ └── serde_untagged_optional.rs ├── lazy_static ├── .cargo-checksum.json ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── src │ ├── core_lazy.rs │ ├── inline_lazy.rs │ └── lib.rs └── tests │ ├── no_std.rs │ └── test.rs ├── proc-macro2 ├── .cargo-checksum.json ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── build.rs ├── src │ ├── detection.rs │ ├── fallback.rs │ ├── lib.rs │ ├── marker.rs │ ├── parse.rs │ └── wrapper.rs └── tests │ ├── comments.rs │ ├── features.rs │ ├── marker.rs │ ├── test.rs │ └── test_fmt.rs ├── quote ├── .cargo-checksum.json ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── src │ ├── ext.rs │ ├── format.rs │ ├── ident_fragment.rs │ ├── lib.rs │ ├── runtime.rs │ ├── spanned.rs │ └── to_tokens.rs └── tests │ ├── compiletest.rs │ ├── test.rs │ └── ui │ ├── does-not-have-iter-interpolated-dup.rs │ ├── does-not-have-iter-interpolated.rs │ ├── does-not-have-iter-separated.rs │ ├── does-not-have-iter.rs │ ├── not-quotable.rs │ ├── not-repeatable.rs │ └── wrong-type-span.rs ├── static_assertions ├── .cargo-checksum.json ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md └── src │ ├── assert_cfg.rs │ ├── assert_eq_align.rs │ ├── assert_eq_size.rs │ ├── assert_fields.rs │ ├── assert_impl.rs │ ├── assert_obj_safe.rs │ ├── assert_trait.rs │ ├── assert_type.rs │ ├── const_assert.rs │ └── lib.rs ├── syn ├── .cargo-checksum.json ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── benches │ ├── file.rs │ └── rust.rs ├── build.rs ├── src │ ├── attr.rs │ ├── await.rs │ ├── bigint.rs │ ├── buffer.rs │ ├── custom_keyword.rs │ ├── custom_punctuation.rs │ ├── data.rs │ ├── derive.rs │ ├── discouraged.rs │ ├── error.rs │ ├── export.rs │ ├── expr.rs │ ├── ext.rs │ ├── file.rs │ ├── gen │ │ ├── clone.rs │ │ ├── debug.rs │ │ ├── eq.rs │ │ ├── fold.rs │ │ ├── hash.rs │ │ ├── visit.rs │ │ └── visit_mut.rs │ ├── gen_helper.rs │ ├── generics.rs │ ├── group.rs │ ├── ident.rs │ ├── item.rs │ ├── lib.rs │ ├── lifetime.rs │ ├── lit.rs │ ├── lookahead.rs │ ├── mac.rs │ ├── macros.rs │ ├── op.rs │ ├── parse.rs │ ├── parse_macro_input.rs │ ├── parse_quote.rs │ ├── pat.rs │ ├── path.rs │ ├── print.rs │ ├── punctuated.rs │ ├── reserved.rs │ ├── sealed.rs │ ├── span.rs │ ├── spanned.rs │ ├── stmt.rs │ ├── thread.rs │ ├── token.rs │ ├── tt.rs │ ├── ty.rs │ ├── verbatim.rs │ └── whitespace.rs └── tests │ ├── .gitignore │ ├── common │ ├── eq.rs │ ├── mod.rs │ └── parse.rs │ ├── debug │ ├── gen.rs │ └── mod.rs │ ├── macros │ └── mod.rs │ ├── repo │ ├── mod.rs │ └── progress.rs │ ├── test_asyncness.rs │ ├── test_attribute.rs │ ├── test_derive_input.rs │ ├── test_expr.rs │ ├── test_generics.rs │ ├── test_grouping.rs │ ├── test_ident.rs │ ├── test_item.rs │ ├── test_iterators.rs │ ├── test_lit.rs │ ├── test_meta.rs │ ├── test_parse_buffer.rs │ ├── test_parse_stream.rs │ ├── test_pat.rs │ ├── test_path.rs │ ├── test_precedence.rs │ ├── test_receiver.rs │ ├── test_round_trip.rs │ ├── test_shebang.rs │ ├── test_should_parse.rs │ ├── test_size.rs │ ├── test_stmt.rs │ ├── test_token_trees.rs │ ├── test_ty.rs │ ├── test_visibility.rs │ └── zzz_stable.rs ├── target-tuples-0.1.0 ├── .cargo-checksum.json ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── config.sub.1 └── src │ ├── config_sub.rs │ ├── lib.rs │ └── pieces.rs ├── target-tuples ├── .cargo-checksum.json ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── Makefile.in ├── README.md ├── aclocal.m4 ├── config.guess ├── config.sub ├── config.sub.1 ├── configure ├── configure.ac ├── install-sh ├── m4 │ └── lcrust_prog_rustc.m4 ├── run-tests.sh ├── src │ ├── config-sub.rs │ ├── lib.rs │ └── pieces.rs └── tests │ ├── config-sub.data │ └── sub_tests.rs └── unicode-xid ├── .cargo-checksum.json ├── COPYRIGHT ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── benches └── xid.rs ├── src ├── lib.rs ├── tables.rs └── tests.rs └── tests └── exhaustive_tests.rs /.github/workflows/clippy.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | rust: 11 | runs-on: ${{ matrix.os }} 12 | strategy: 13 | matrix: 14 | os: [ubuntu-latest] 15 | rust-channel: [nightly] 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Install Rustup Toolchain 20 | run: | 21 | rustup toolchain add ${{ matrix.rust-channel }} 22 | rustup default ${{ matrix.rust-channel }} 23 | rustup update 24 | rustup component add clippy 25 | - name: Build 26 | run: | 27 | cargo clippy --all-features 28 | -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | rust: 11 | runs-on: ${{ matrix.os }} 12 | strategy: 13 | matrix: 14 | os: [windows-latest, macos-latest, ubuntu-latest] 15 | rust-channel: [1.74.0, stable, beta,nightly] 16 | exclude: 17 | - os: [windows-latest, macos-latest] 18 | rust-channel: [beta, nightly] 19 | 20 | steps: 21 | - uses: actions/checkout@v2 22 | - name: Install Rustup Toolchain 23 | run: | 24 | rustup toolchain add ${{ matrix.rust-channel }} 25 | rustup default ${{ matrix.rust-channel }} 26 | rustup update 27 | - name: Build 28 | run: | 29 | cargo build --all-features 30 | cargo test --all-features -------------------------------------------------------------------------------- /.github/workflows/rustfmt.yml: -------------------------------------------------------------------------------- 1 | name: rustfmt 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | rustfmt: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Build 20 | 21 | run: | 22 | rustup toolchain add beta --component rustfmt 23 | rustup default beta 24 | rustup update 25 | cargo fmt -- --check 26 | 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | .vscode/ 3 | /a.out 4 | *.o -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | members = [ 4 | "lcld", 5 | "binfmt", 6 | "ar", 7 | "readobj", 8 | "objdump", 9 | "lto", 10 | "binfmt-test", 11 | "arch-ops", 12 | "lcas", 13 | "dbg-info", 14 | "lccc-mangle" 15 | ] 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lc-binutils 2 | Replacements for GNU Binutils, including a full linker that is compatible with unix ld, macos ld64, and windows link.exe 3 | 4 | ## Build Status 5 | 6 | ![Rust](https://github.com/LightningCreations/lcld/workflows/Rust/badge.svg) 7 | -------------------------------------------------------------------------------- /ar/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lcar" 3 | version = "0.1.0" 4 | authors = ["Connor Horman "] 5 | edition = "2021" 6 | rust-version = "1.74" 7 | license = "BSD-2-Clause-Patent" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | binfmt = {path = "../binfmt",features=["ar"]} 13 | 14 | [features] 15 | elf = ["binfmt/elf"] 16 | elf32 = ["binfmt/elf32","elf"] 17 | elf64 = ["binfmt/elf64","elf"] 18 | coff = ["binfmt/coff"] 19 | aout = ["binfmt/aout"] 20 | o65 = ["binfmt/o65"] 21 | xo65 = ["binfmt/xo65"] 22 | default-formats = ["elf32", "elf64", "coff", "o65", "xo65"] 23 | all-formats = ["aout","default-formats"] 24 | all = ["all-formats"] 25 | default = ["default-formats"] -------------------------------------------------------------------------------- /ar/config.toml: -------------------------------------------------------------------------------- 1 | [binutils.tools.ar] 2 | # default-target = "" 3 | # default-sysroot = "/" 4 | default-formats = ["elf","coff"] 5 | 6 | -------------------------------------------------------------------------------- /ar/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() {} 2 | -------------------------------------------------------------------------------- /arch-ops/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "arch-ops" 3 | version = "0.1.0" 4 | authors = ["Connor Horman ", "rdrpenguin"] 5 | description = "A library to encode and decode instructions for several architectures" 6 | edition = "2021" 7 | rust-version = "1.74" 8 | license = "BSD-2-Clause-Patent" 9 | 10 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 11 | 12 | [dependencies] 13 | delegate = "0.9" 14 | lazy_static = "1" 15 | target-tuples = "0.5.5" 16 | paste = "1" 17 | with_builtin_macros = { version = "0.0.3", optional = true } 18 | 19 | [features] 20 | x86 = [] 21 | arm = [] 22 | aarch64 = [] 23 | w65 = ["m6502"] 24 | riscv = [] 25 | propeller = [] 26 | propeller2 = [] 27 | m6502 = [] 28 | clever = [] 29 | m68k = [] 30 | z80 = [] 31 | holey-bytes = ["with_builtin_macros"] 32 | 33 | default-archs = ["x86","arm","aarch64","w65","riscv","propeller","propeller2", "m6502", "clever", "m68k", "holey-bytes"] 34 | default = ["default-archs"] 35 | all-archs = ["default-archs"] 36 | all = ["all-archs","z80"] 37 | -------------------------------------------------------------------------------- /arch-ops/src/disasm.rs: -------------------------------------------------------------------------------- 1 | use crate::traits::InsnRead; 2 | 3 | pub trait OpcodePrinter { 4 | fn print_opcode( 5 | &self, 6 | f: &mut core::fmt::Formatter, 7 | read: &mut dyn InsnRead, 8 | ) -> std::io::Result<()>; 9 | 10 | fn handle_option(&mut self, _key: &str, _value: &str) -> bool { 11 | false 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /arch-ops/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![deny(warnings, unsafe_code)] 2 | #![allow(unknown_lints, renamed_and_removed_lints)] 3 | 4 | pub mod traits; 5 | 6 | pub mod disasm; 7 | 8 | #[cfg(feature = "w65")] 9 | pub mod w65; 10 | 11 | #[cfg(feature = "m6502")] 12 | pub mod m6502; 13 | 14 | #[cfg(feature = "x86")] 15 | pub mod x86; 16 | 17 | #[cfg(feature = "clever")] 18 | pub mod clever; 19 | 20 | #[cfg(feature = "holey-bytes")] 21 | pub mod holeybytes; 22 | 23 | #[cfg(test)] 24 | pub(crate) mod test; 25 | -------------------------------------------------------------------------------- /arch-ops/src/m6502.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /arch-ops/src/test.rs: -------------------------------------------------------------------------------- 1 | use std::io::Write; 2 | 3 | use crate::traits::{Address, InsnWrite, Reloc}; 4 | 5 | pub struct TestWriter { 6 | pub inner: Vec, 7 | } 8 | 9 | impl Write for TestWriter { 10 | fn write(&mut self, buf: &[u8]) -> std::io::Result { 11 | self.inner.write(buf) 12 | } 13 | 14 | fn flush(&mut self) -> std::io::Result<()> { 15 | self.inner.flush() 16 | } 17 | } 18 | 19 | impl InsnWrite for TestWriter { 20 | fn write_addr(&mut self, size: usize, addr: Address, rel: bool) -> std::io::Result<()> { 21 | match (addr, rel) { 22 | (Address::Disp(disp), true) => self.write_all(&disp.to_le_bytes()[..(size / 8)]), 23 | (Address::Abs(addr), false) => self.write_all(&addr.to_le_bytes()[..(size / 8)]), 24 | (_, _) => panic!(), 25 | } 26 | } 27 | 28 | fn offset(&self) -> usize { 29 | self.inner.len() 30 | } 31 | 32 | fn write_reloc(&mut self, _: Reloc) -> std::io::Result<()> { 33 | panic!("Cannot write Reloc to TestWriter") 34 | } 35 | } 36 | 37 | #[test] 38 | fn test_sanity_writer_write() { 39 | let mut w = TestWriter { inner: Vec::new() }; 40 | w.write_all(&[0u8]).unwrap(); 41 | assert_eq!(&*w.inner, &[0u8]); 42 | } 43 | 44 | #[test] 45 | fn test_sanity_writer_write_many() { 46 | let mut w = TestWriter { inner: Vec::new() }; 47 | w.write_all(&[0u8, 1u8, 2u8, 3u8]).unwrap(); 48 | assert_eq!(&*w.inner, &[0u8, 1u8, 2u8, 3u8]); 49 | } 50 | 51 | #[test] 52 | fn test_sanity_writer_write_addr() { 53 | let mut w = TestWriter { inner: Vec::new() }; 54 | w.write_addr(32, Address::Disp(1), true).unwrap(); 55 | assert_eq!(&*w.inner, &[1u8, 0u8, 0u8, 0u8]); 56 | } 57 | 58 | #[test] 59 | fn test_sanity_writer_write_addr_m1() { 60 | let mut w = TestWriter { inner: Vec::new() }; 61 | w.write_addr(32, Address::Disp(-1), true).unwrap(); 62 | assert_eq!(&*w.inner, &[0xffu8, 0xffu8, 0xffu8, 0xffu8]); 63 | } 64 | 65 | #[test] 66 | fn test_sanity_writer_write_addr_abs() { 67 | let mut w = TestWriter { inner: Vec::new() }; 68 | w.write_addr(32, Address::Abs(32767), false).unwrap(); 69 | assert_eq!(&*w.inner, &[0xffu8, 0x7fu8, 0u8, 0u8]); 70 | } 71 | -------------------------------------------------------------------------------- /arch-ops/src/x86/cpu/timings.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /binfmt-test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "binfmt-test" 3 | version = "0.1.0" 4 | authors = ["Connor Horman "] 5 | edition = "2021" 6 | license = "BSD-2-Clause-Patent" 7 | rust-version = "1.74" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | binfmt = {path = "../binfmt", features = ["default-formats","default-archs"]} 13 | -------------------------------------------------------------------------------- /binfmt-test/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fs::File, 3 | io::{Seek, SeekFrom}, 4 | }; 5 | 6 | fn main() -> std::io::Result<()> { 7 | let mut args = std::env::args(); 8 | args.next().unwrap(); 9 | let fname = args.next().unwrap(); 10 | 11 | let mut file = File::open(&fname)?; 12 | 13 | let binfile = binfmt::open_file(file)?; 14 | 15 | println!("File information: {}", fname); 16 | println!("Format: {}", binfile.fmt().name()); 17 | println!("File Type: {:?}", binfile.file_type()); 18 | print!("Sections: ["); 19 | let mut sep = ""; 20 | for s in binfile.sections() { 21 | print!("{}{}", sep, s.name); 22 | sep = ", "; 23 | } 24 | println!("]"); 25 | print!("Symbols: ["); 26 | let mut sep = ""; 27 | for s in binfile.symbols() { 28 | print!("{}{}", sep, s.name()); 29 | sep = ", "; 30 | } 31 | println!("]"); 32 | 33 | Ok(()) 34 | } 35 | -------------------------------------------------------------------------------- /binfmt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "binfmt" 3 | version = "0.1.0" 4 | authors = ["Connor Horman ", "Ray Redondo "] 5 | description = "A library for reading and writing binaries" 6 | edition = "2021" 7 | rust-version = "1.74" 8 | license = "BSD-2-Clause-Patent" 9 | 10 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 11 | 12 | [dependencies] 13 | static_assertions = "1.1.0" 14 | bytemuck = {version="1.13.1",features=["derive"]} 15 | lazy_static = "1.4.0" 16 | target-tuples = "0.5.9" 17 | fake-enum = "0.1.4" 18 | arch-ops = {path="../arch-ops", version = "0.1.0"} 19 | bitflags = {version="2.5.0", features=["bytemuck"]} 20 | 21 | [lib] 22 | name = "binfmt" 23 | 24 | [features] 25 | aout = [] 26 | coff = [] 27 | elf32 = ["elf"] 28 | elf64 = ["elf"] 29 | elf = [] 30 | macho = [] 31 | pe = ["coff"] 32 | llir = [] 33 | xir = [] 34 | ar = [] 35 | xo65 = [] 36 | o65 = [] 37 | default-formats = ["coff","elf32","elf64","macho","pe","ar"] 38 | lto-formats = ["llir","xir"] 39 | all-formats = ["default-formats", "lto-formats","aout","xo65","o65"] 40 | w65 = [] 41 | x86 = [] 42 | arm = [] 43 | aarch64 = [] 44 | riscv = [] 45 | m68k = [] 46 | clever = [] 47 | z80 = [] 48 | m6502 = [] 49 | holey-bytes = [] 50 | default-archs = ["w65", "x86", "arm","riscv","m68k", "clever", "holey-bytes"] 51 | all-archs = ["default-archs", "z80", "m6502"] 52 | -------------------------------------------------------------------------------- /binfmt/config.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lccc-project/lc-binutils/fecf4f4998ec51d6977ebd8e3d0f9be7546e4032/binfmt/config.toml -------------------------------------------------------------------------------- /binfmt/src/aout.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /binfmt/src/ar/tests/mod.rs: -------------------------------------------------------------------------------- 1 | use std::ffi::OsStr; 2 | 3 | use super::Archive; 4 | 5 | #[test] 6 | #[ignore] // broken - fix later 7 | pub fn archive() { 8 | let bytes: &[u8] = include_bytes!("test_archive1.a"); 9 | let archive = Archive::read(bytes).unwrap(); 10 | let members = archive.members(); 11 | assert_eq!(members.len(), 1); 12 | let m1 = &members[0]; 13 | assert_eq!(m1.get_name(), OsStr::new("empty_rel.o")); 14 | } 15 | -------------------------------------------------------------------------------- /binfmt/src/ar/tests/test_archive1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lccc-project/lc-binutils/fecf4f4998ec51d6977ebd8e3d0f9be7546e4032/binfmt/src/ar/tests/test_archive1.a -------------------------------------------------------------------------------- /binfmt/src/binary.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | fmt::{BinaryFile, Binfmt, CallbackError, FileType, Section, SectionType}, 3 | traits::ReadSeek, 4 | }; 5 | 6 | pub struct Binary; 7 | 8 | pub fn create_format() -> Binary { 9 | Binary 10 | } 11 | 12 | impl Binfmt for Binary { 13 | fn relnum_to_howto(&self, _relnum: u32) -> Option<&dyn crate::howto::HowTo> { 14 | None 15 | } 16 | 17 | fn code_to_howto(&self, _code: crate::howto::RelocCode) -> Option<&dyn crate::howto::HowTo> { 18 | None 19 | } 20 | 21 | fn name(&self) -> &'static str { 22 | "binary" 23 | } 24 | 25 | fn create_file(&self, ty: FileType) -> crate::fmt::BinaryFile { 26 | BinaryFile::create(self, Box::new(()), ty) 27 | } 28 | 29 | fn read_file( 30 | &self, 31 | file: &mut (dyn ReadSeek + '_), 32 | ) -> std::io::Result> { 33 | let mut vec = Vec::new(); 34 | file.read_to_end(&mut vec)?; 35 | let mut file = BinaryFile::create(self, Box::new(()), FileType::Exec); 36 | let _ = file.add_section(Section { 37 | align: 1, 38 | content: vec, 39 | name: ".data".to_string(), 40 | ty: SectionType::ProgBits, 41 | relocs: Vec::new(), 42 | ..Default::default() 43 | }); 44 | 45 | Ok(Some(file)) 46 | } 47 | 48 | fn write_file( 49 | &self, 50 | file: &mut (dyn std::io::Write + '_), 51 | bfile: &crate::fmt::BinaryFile, 52 | ) -> std::io::Result<()> { 53 | for s in bfile.sections() { 54 | file.write_all(&s.content)?; 55 | } 56 | Ok(()) 57 | } 58 | 59 | fn has_sections(&self) -> bool { 60 | true 61 | } 62 | 63 | fn create_section( 64 | &self, 65 | _section: &mut crate::fmt::Section, 66 | ) -> Result<(), crate::fmt::CallbackError> { 67 | Ok(()) 68 | } 69 | 70 | fn create_symbol( 71 | &self, 72 | _sym: &mut crate::sym::Symbol, 73 | ) -> Result<(), crate::fmt::CallbackError> { 74 | Err(CallbackError::NotAccepted) 75 | } 76 | 77 | fn create_reloc( 78 | &self, 79 | _reloc: &mut crate::howto::Reloc, 80 | ) -> Result<(), crate::fmt::CallbackError> { 81 | Err(CallbackError::NotAccepted) 82 | } 83 | 84 | fn before_relocate(&self, _reloc: &mut crate::howto::Reloc, _symbol: &crate::sym::Symbol) {} 85 | 86 | fn ident_file(&self, _: &mut (dyn std::io::Read + '_)) -> std::io::Result { 87 | Ok(true) 88 | } 89 | 90 | fn file_priority(&self) -> i32 { 91 | i32::MIN 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /binfmt/src/coff.rs: -------------------------------------------------------------------------------- 1 | use bytemuck::{Pod, Zeroable}; 2 | 3 | #[repr(C)] 4 | #[derive(Copy, Clone, Debug, Zeroable, Pod)] 5 | pub struct CoffHeader { 6 | pub mach: u16, 7 | pub nsect: u16, 8 | pub timestamp: u32, 9 | pub symtab_off: u32, 10 | pub n_symtab: u32, 11 | pub opthead_size: u16, 12 | pub characteristics: u16, 13 | } 14 | 15 | bitflags::bitflags! { 16 | #[derive(Zeroable, Pod, Copy, Clone)] 17 | #[repr(transparent)] 18 | pub struct CoffCharacteristics : u16{ 19 | const IMAGE_FILE_RELOCS_STRIPPED = 0x0001; 20 | 21 | } 22 | } 23 | 24 | pub mod consts {} 25 | 26 | #[repr(C)] 27 | #[derive(Copy, Clone, Debug, Zeroable, Pod)] 28 | pub struct CoffSectionHeader { 29 | pub name: [u8; 8], 30 | pub vsize: u32, 31 | pub vaddr: u32, 32 | pub fsize: u32, 33 | pub foff: u32, 34 | pub relocoff: u32, 35 | pub lnoff: u32, 36 | pub nreloc: u16, 37 | pub nlines: u16, 38 | pub characteristics: u32, 39 | } 40 | 41 | #[repr(C)] 42 | #[derive(Copy, Clone, Debug, Zeroable, Pod)] 43 | pub struct CoffOptionalHeader { 44 | pub magic: u16, 45 | pub link_maj: u8, 46 | pub lin_min: u8, 47 | pub code_size: u32, 48 | pub init_size: u32, 49 | pub uninit_size: u32, 50 | pub entry_addr: u32, 51 | pub code_base: u32, 52 | } 53 | 54 | #[repr(C)] 55 | #[derive(Copy, Clone, Debug, Zeroable, Pod)] 56 | pub struct CoffOptionalHeader32 { 57 | pub base: CoffOptionalHeader, 58 | pub data_base: u32, 59 | } 60 | -------------------------------------------------------------------------------- /binfmt/src/debug.rs: -------------------------------------------------------------------------------- 1 | use core::fmt::LowerHex; 2 | 3 | use bytemuck::{Pod, Zeroable}; 4 | 5 | #[repr(transparent)] 6 | #[derive(Copy, Clone)] 7 | pub struct PrintHex(pub T); 8 | 9 | unsafe impl Zeroable for PrintHex {} 10 | unsafe impl Pod for PrintHex {} 11 | 12 | impl From for PrintHex { 13 | fn from(x: T) -> Self { 14 | Self(x) 15 | } 16 | } 17 | 18 | impl ::core::ops::Deref for PrintHex { 19 | type Target = T; 20 | 21 | fn deref(&self) -> &Self::Target { 22 | &self.0 23 | } 24 | } 25 | 26 | impl ::core::ops::DerefMut for PrintHex { 27 | fn deref_mut(&mut self) -> &mut Self::Target { 28 | &mut self.0 29 | } 30 | } 31 | 32 | impl ::core::fmt::Debug for PrintHex { 33 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 34 | f.write_fmt(format_args!("{:#x}", self.0)) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /binfmt/src/elf/tests/empty_exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lccc-project/lc-binutils/fecf4f4998ec51d6977ebd8e3d0f9be7546e4032/binfmt/src/elf/tests/empty_exec -------------------------------------------------------------------------------- /binfmt/src/elf/tests/empty_rel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lccc-project/lc-binutils/fecf4f4998ec51d6977ebd8e3d0f9be7546e4032/binfmt/src/elf/tests/empty_rel.o -------------------------------------------------------------------------------- /binfmt/src/elf/tests/empty_shared.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lccc-project/lc-binutils/fecf4f4998ec51d6977ebd8e3d0f9be7546e4032/binfmt/src/elf/tests/empty_shared.so -------------------------------------------------------------------------------- /binfmt/src/elf/tests/mod.rs: -------------------------------------------------------------------------------- 1 | use super::{consts, Elf32, ElfReader}; 2 | 3 | #[test] 4 | pub fn elf32_test() { 5 | let file: [u8; 52] = [ 6 | 0x7f, 0x45, 0x4C, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 7 | 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x20, 0x00, 0x00, 9 | 0x00, 0x28, 0x00, 0x00, 0x00, 0x0D, 0x00, 10 | ]; 11 | let read = ElfReader::::parse(&file).unwrap(); 12 | let hdr = read.get_header(); 13 | 14 | assert_eq!(hdr.e_ident.ei_osabi, consts::ELFOSABI_NONE); 15 | assert_eq!(hdr.e_machine, consts::EM_386); 16 | } 17 | -------------------------------------------------------------------------------- /binfmt/src/elf32.rs: -------------------------------------------------------------------------------- 1 | pub type Elf32Format = crate::elf::ElfFormat; 2 | 3 | pub use crate::elf::{consts, Elf32}; 4 | 5 | #[cfg(feature = "w65")] 6 | pub mod w65; 7 | 8 | #[cfg(feature = "x86")] 9 | pub mod x86_64; 10 | 11 | pub mod genericle { 12 | pub fn create_format() -> super::Elf32Format { 13 | super::Elf32Format::new( 14 | super::consts::EM_NONE, 15 | super::consts::ELFDATA2LSB, 16 | "elf32-genericle", 17 | None, 18 | None, 19 | ) 20 | } 21 | } 22 | 23 | pub mod genericbe { 24 | pub fn create_format() -> super::Elf32Format { 25 | super::Elf32Format::new( 26 | super::consts::EM_NONE, 27 | super::consts::ELFDATA2MSB, 28 | "elf32-genericbe", 29 | None, 30 | None, 31 | ) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /binfmt/src/elf32/x86_64.rs: -------------------------------------------------------------------------------- 1 | use crate::elf64::x86_64::Elf64X86_64HowTo; 2 | 3 | use super::consts; 4 | 5 | pub fn create_format() -> super::Elf32Format { 6 | super::Elf32Format::new( 7 | super::consts::EM_X86_64, 8 | consts::ELFDATA2LSB, 9 | "elf32-x86_64", 10 | None, 11 | None, 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /binfmt/src/elf64.rs: -------------------------------------------------------------------------------- 1 | pub type Elf64Format = crate::elf::ElfFormat; 2 | 3 | pub use crate::elf::{consts, Elf64}; 4 | 5 | #[cfg(feature = "x86")] 6 | pub mod x86_64; 7 | 8 | #[cfg(feature = "clever")] 9 | pub mod clever; 10 | 11 | #[cfg(feature = "holey-bytes")] 12 | pub mod holeybytes; 13 | 14 | pub mod genericle { 15 | pub fn create_format() -> super::Elf64Format { 16 | super::Elf64Format::new( 17 | super::consts::EM_NONE, 18 | super::consts::ELFDATA2LSB, 19 | "elf64-genericle", 20 | None, 21 | None, 22 | ) 23 | } 24 | } 25 | 26 | pub mod genericbe { 27 | pub fn create_format() -> super::Elf64Format { 28 | super::Elf64Format::new( 29 | super::consts::EM_NONE, 30 | super::consts::ELFDATA2MSB, 31 | "elf64-genericbe", 32 | None, 33 | None, 34 | ) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /binfmt/src/howto.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, Hash, PartialEq, Eq, Copy, Clone)] 2 | pub enum HowToError { 3 | SignedOverflow, 4 | UnsignedOverflow, 5 | InvalidReloc, 6 | } 7 | 8 | #[derive(Debug, Hash, PartialEq, Eq, Copy, Clone)] 9 | pub enum RelocOutput { 10 | FixedExec, 11 | RelocExec, 12 | RelocExecRelro, 13 | RelocDyn, 14 | RelocDynRelro, 15 | } 16 | 17 | pub trait HowTo { 18 | // Helpers for generic binary formats (like Elf/) 19 | fn from_relnum<'a>(num: u32) -> Option<&'a Self> 20 | where 21 | Self: Sized + 'a; 22 | fn from_reloc_code<'a>(code: RelocCode) -> Option<&'a Self> 23 | where 24 | Self: Sized + 'a; 25 | fn reloc_num(&self) -> u32; 26 | fn name(&self) -> &'static str; 27 | fn reloc_size(&self) -> usize; 28 | fn pcrel(&self) -> bool; 29 | fn is_relax(&self) -> bool; 30 | fn relax_size(&self, addr: u128, at_addr: u128) -> Option; 31 | fn apply<'a>( 32 | &self, 33 | addr: u128, 34 | at_addr: u128, 35 | region: &'a mut [u8], 36 | ) -> Result<&'a mut [u8], HowToError>; 37 | fn valid_in(&self, output_ty: RelocOutput, sym_vis: &Symbol) -> bool; 38 | } 39 | 40 | pub use arch_ops::traits::{Reloc, RelocCode}; 41 | 42 | use crate::sym::Symbol; 43 | -------------------------------------------------------------------------------- /binfmt/src/macho.rs: -------------------------------------------------------------------------------- 1 | use bytemuck::{Pod, Zeroable}; 2 | 3 | macro_rules! fake_enum{ 4 | {#[repr($t:ty)] $vis:vis enum $name:ident { 5 | $($item:ident = $expr:literal),*$(,)? 6 | }} => { 7 | #[derive(Copy,Clone,Eq,PartialEq,Zeroable,Pod)] 8 | #[repr(transparent)] 9 | $vis struct $name($t); 10 | 11 | $(#[allow(non_upper_case_globals)] $vis const $item: $name = $name($expr);)* 12 | 13 | impl ::core::fmt::Debug for $name{ 14 | #[allow(unreachable_patterns)] 15 | fn fmt(&self,f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result{ 16 | match self{ 17 | $(Self($expr) => f.write_str(::core::stringify!($item)),)* 18 | e => e.0.fmt(f) 19 | } 20 | } 21 | } 22 | } 23 | } 24 | 25 | fake_enum! { 26 | #[repr(u32)] 27 | pub enum CpuType{ 28 | Any = 0xffffffff, 29 | Vax = 1, 30 | MC68k = 6, 31 | X86 = 7, 32 | X86_64 = 0xff000007, 33 | MC98k = 10, 34 | Hppa = 11, 35 | Arm = 12, 36 | Arm64 = 0xff00000c, 37 | MC88k = 13, 38 | Sparc = 14, 39 | I860 = 15, 40 | PowerPC = 16, 41 | PowerPC64 = 0xff000010 42 | } 43 | } 44 | 45 | #[repr(C)] 46 | #[derive(Copy, Clone, Debug, Zeroable, Pod)] 47 | pub struct MachOHeader32 { 48 | magic: u32, 49 | cputype: CpuType, 50 | cpusubtype: u32, 51 | filetype: u32, 52 | ncmds: u32, 53 | sizecmds: u32, 54 | flags: u32, 55 | } 56 | 57 | #[repr(C)] 58 | #[derive(Copy, Clone, Debug, Zeroable, Pod)] 59 | pub struct MachOHeader64 { 60 | magic: u32, 61 | cputype: CpuType, 62 | cpusubtype: u32, 63 | filetype: u32, 64 | ncmds: u32, 65 | sizecmds: u32, 66 | flags: u32, 67 | reserved: u32, 68 | } 69 | 70 | pub const MH_MAGIC32: u32 = 0xfeedface; 71 | pub const MH_MAGIC64: u32 = 0xfeedfacf; 72 | pub const MH_REVERSED_MAGIC32: u32 = MH_MAGIC32.swap_bytes(); 73 | pub const MH_REVERSED_MAGIC64: u32 = MH_MAGIC64.swap_bytes(); 74 | -------------------------------------------------------------------------------- /binfmt/src/o65.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] // fixme later 2 | 3 | use bytemuck::{Pod, Zeroable}; 4 | 5 | #[repr(C)] 6 | #[derive(Zeroable, Pod, Clone, Copy)] 7 | pub struct O65FixedHeader { 8 | id1: [u8; 2], 9 | magic: [u8; 3], 10 | ver: u8, 11 | mode: u16, 12 | } 13 | 14 | #[repr(C)] 15 | #[derive(Zeroable, Pod, Clone, Copy)] 16 | pub struct O65Header16 { 17 | fixed: O65FixedHeader, 18 | tbase: u16, 19 | tsize: u16, 20 | dbase: u16, 21 | dsize: u16, 22 | bbase: u16, 23 | bsize: u16, 24 | zbase: u16, 25 | zsize: u16, 26 | stack: u16, 27 | } 28 | 29 | #[repr(C)] 30 | #[derive(Zeroable, Pod, Clone, Copy)] 31 | pub struct O65Header32 { 32 | fixed: O65FixedHeader, 33 | tbase: u32, 34 | tsize: u32, 35 | dbase: u32, 36 | dsize: u32, 37 | bbase: u32, 38 | bsize: u32, 39 | zbase: u32, 40 | zsize: u32, 41 | stack: u32, 42 | } 43 | -------------------------------------------------------------------------------- /binfmt/src/pe.rs: -------------------------------------------------------------------------------- 1 | pub use crate::coff::{CoffHeader, CoffOptionalHeader, CoffSectionHeader}; 2 | -------------------------------------------------------------------------------- /binfmt/src/sym.rs: -------------------------------------------------------------------------------- 1 | #[derive(Clone, Hash, PartialEq, Eq)] 2 | pub struct Symbol { 3 | name: String, 4 | value: Option, 5 | secno: Option, 6 | symtype: SymbolType, 7 | kind: SymbolKind, 8 | size: Option, 9 | } 10 | 11 | impl Symbol { 12 | pub fn new( 13 | name: String, 14 | section: u32, 15 | value: u128, 16 | symtype: SymbolType, 17 | kind: SymbolKind, 18 | ) -> Self { 19 | Self { 20 | name, 21 | value: Some(value), 22 | secno: Some(section), 23 | symtype, 24 | kind, 25 | size: None, 26 | } 27 | } 28 | 29 | pub fn new_undef(name: String, symtype: SymbolType, kind: SymbolKind) -> Self { 30 | Self { 31 | name, 32 | value: None, 33 | secno: None, 34 | symtype, 35 | kind, 36 | size: None, 37 | } 38 | } 39 | 40 | pub fn section(&self) -> Option { 41 | self.secno 42 | } 43 | 44 | pub fn section_mut(&mut self) -> &mut Option { 45 | &mut self.secno 46 | } 47 | 48 | pub fn name(&self) -> &str { 49 | &self.name 50 | } 51 | 52 | pub fn value(&self) -> Option { 53 | self.value 54 | } 55 | 56 | pub fn value_mut(&mut self) -> &mut Option { 57 | &mut self.value 58 | } 59 | 60 | pub fn symbol_type(&self) -> SymbolType { 61 | self.symtype 62 | } 63 | 64 | pub fn symbol_type_mut(&mut self) -> &mut SymbolType { 65 | &mut self.symtype 66 | } 67 | 68 | pub fn kind(&self) -> SymbolKind { 69 | self.kind 70 | } 71 | 72 | pub fn kind_mut(&mut self) -> &mut SymbolKind { 73 | &mut self.kind 74 | } 75 | 76 | pub fn size(&self) -> Option { 77 | self.size 78 | } 79 | 80 | pub fn size_mut(&mut self) -> &mut Option { 81 | &mut self.size 82 | } 83 | } 84 | 85 | #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] 86 | pub enum SymbolType { 87 | Null, 88 | Function, 89 | Object, 90 | File, 91 | Section, 92 | Common, 93 | Tls, 94 | FormatSpecific(u32), 95 | } 96 | 97 | #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] 98 | pub enum SymbolKind { 99 | Local, 100 | Global, 101 | Weak, 102 | FormatSpecific(u32), 103 | } 104 | -------------------------------------------------------------------------------- /binfmt/src/traits.rs: -------------------------------------------------------------------------------- 1 | use bytemuck::Pod; 2 | 3 | use crate::traits::private::Sealed; 4 | use core::{ 5 | fmt::{Debug, LowerHex}, 6 | ops::*, 7 | }; 8 | use std::io::{Read, Seek}; 9 | 10 | #[doc(hidden)] 11 | pub(crate) mod private { 12 | pub trait Sealed {} 13 | } 14 | 15 | pub trait Numeric: 16 | Add 17 | + Mul 18 | + Sub 19 | + Div 20 | + BitAnd 21 | + BitOr 22 | + BitXor 23 | + Not 24 | + Copy 25 | + Shl 26 | + Shr 27 | + Sized 28 | + Debug 29 | + LowerHex 30 | + TryInto 31 | + TryFrom 32 | + Eq 33 | + Ord 34 | + Pod 35 | + Sealed 36 | { 37 | fn zero() -> Self; 38 | fn one() -> Self; 39 | fn min() -> Self; 40 | fn max() -> Self; 41 | fn as_usize(self) -> usize; 42 | fn from_usize(x: usize) -> Self; 43 | fn as_u64(self) -> u64; 44 | fn from_u64(x: u64) -> Self; 45 | #[must_use] 46 | fn from_be(self) -> Self; 47 | #[must_use] 48 | fn from_le(self) -> Self; 49 | } 50 | 51 | #[doc(hidden)] 52 | macro_rules! impl_numeric { 53 | ($($n:ident),*) => { 54 | $( 55 | impl Sealed for $n{} 56 | impl Numeric for $n{ 57 | fn zero()->Self{ 58 | 0 as $n 59 | } 60 | fn one()->Self{ 61 | 1 as $n 62 | } 63 | fn min()->Self{ 64 | $n::min_value() 65 | } 66 | fn max()->Self{ 67 | $n::max_value() 68 | } 69 | fn as_usize(self) -> usize{ 70 | self as usize 71 | } 72 | 73 | fn from_usize(x: usize) -> Self{ 74 | x as Self 75 | } 76 | fn as_u64(self) -> u64{ 77 | self as u64 78 | } 79 | 80 | fn from_u64(x: u64) -> Self{ 81 | x as Self 82 | } 83 | 84 | fn from_be(self) -> Self{ 85 | $n::from_be(self) 86 | } 87 | 88 | fn from_le(self) -> Self{ 89 | $n::from_le(self) 90 | } 91 | } 92 | )* 93 | }; 94 | } 95 | 96 | impl_numeric!(u8, u16, u32, u64, u128, i8, i16, i32, i64, i128, usize, isize); 97 | 98 | pub trait ReadSeek: Read + Seek {} 99 | 100 | impl ReadSeek for T {} 101 | -------------------------------------------------------------------------------- /binfmt/src/xo65.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /clippy.toml: -------------------------------------------------------------------------------- 1 | msrv = "1.74" -------------------------------------------------------------------------------- /config.toml: -------------------------------------------------------------------------------- 1 | [targets] 2 | #default-target = "" 3 | 4 | [dirs] 5 | #prefix = "/usr/local" 6 | #exec_prefix = "" 7 | #bindir = "bin" 8 | #libdir = "lib" 9 | -------------------------------------------------------------------------------- /dbg-info/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dbg-info" 3 | version = "0.1.0" 4 | edition = "2021" 5 | rust-version = "1.74" 6 | license = "BSD-2-Clause-Patent" 7 | 8 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 9 | 10 | [dependencies] 11 | 12 | [features] 13 | dwarf5 = [] 14 | all-formats = ["dwarf5"] 15 | default-formats = ["dwarf5"] -------------------------------------------------------------------------------- /dbg-info/src/dwarf5.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dbg-info/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "dwarf5")] 2 | pub mod dwarf5; 3 | -------------------------------------------------------------------------------- /install_binutils_symlinks.cmake: -------------------------------------------------------------------------------- 1 | 2 | function(install_binutils_symlink name src) 3 | install(CODE "file(CREATE_LINK ${src} ${CMAKE_INSTALL_FULL_BINDIR}/${name} SYMBOLIC)") 4 | endfunction() -------------------------------------------------------------------------------- /lcas/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lcas-core" 3 | version = "0.1.0" 4 | authors = ["Connor "] 5 | edition = "2021" 6 | rust-version = "1.74" 7 | license = "BSD-2-Clause-Patent" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [features] 12 | x86 = ["arch-ops/x86","binfmt/x86"] 13 | arm = ["arch-ops/arm","binfmt/arm"] 14 | aarch64 = ["arch-ops/aarch64","binfmt/aarch64"] 15 | clever =["arch-ops/clever","binfmt/clever"] 16 | w65 = ["arch-ops/w65","binfmt/w65"] 17 | riscv = [] 18 | propeller = [] 19 | propeller2 = [] 20 | holey-bytes = ["arch-ops/holey-bytes", "binfmt/holey-bytes"] 21 | aout = ["binfmt/aout"] 22 | coff = ["binfmt/coff"] 23 | elf32 = ["binfmt/elf32","elf"] 24 | elf64 = ["binfmt/elf64","elf"] 25 | elf = ["elf32","elf64"] 26 | macho = ["binfmt/macho"] 27 | default-formats = ["coff","elf","macho"] 28 | all-formats = ["default-formats","aout"] 29 | default-archs = ["x86","arm","aarch64","clever","w65","riscv","propeller","propeller2", "holey-bytes"] 30 | default = ["default-archs","default-formats"] 31 | all-archs = ["default-archs"] 32 | all = ["all-archs","all-formats"] 33 | 34 | 35 | 36 | [dependencies] 37 | binfmt = {path = "../binfmt"} 38 | arch-ops = {path = "../arch-ops"} 39 | target-tuples = "0.5" 40 | utf = "0.1.6" 41 | 42 | [build-dependencies] 43 | serde = {version="1",features=["derive"]} 44 | toml = "0.5" 45 | target-tuples = "0.5" 46 | 47 | [[bin]] 48 | name = "lcas" 49 | path = "src/lcas.rs" 50 | -------------------------------------------------------------------------------- /lcas/build.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Deserializer}; 2 | use std::io::Read; 3 | 4 | use target_tuples::Target; 5 | 6 | fn default_target() -> Target { 7 | Target::parse(&std::env::var("TARGET").unwrap()) 8 | } 9 | 10 | fn deserialize_target<'de, De: Deserializer<'de>>(de: De) -> Result { 11 | let str = <&str>::deserialize(de)?; 12 | 13 | Ok(Target::parse(str)) 14 | } 15 | 16 | #[derive(Deserialize)] 17 | #[serde(rename_all = "kebab-case")] 18 | pub struct Targets { 19 | #[serde(default = "default_target")] 20 | #[serde(deserialize_with = "deserialize_target")] 21 | default_target: Target, 22 | } 23 | 24 | fn main() { 25 | let base_dir = std::env!("CARGO_MANIFEST_DIR"); 26 | 27 | let mut file = std::path::Path::new(base_dir).to_path_buf(); 28 | 29 | file.push("config.toml"); 30 | 31 | println!("cargo:rerun-if-changed={}", file.display()); 32 | 33 | let mut file = std::fs::File::open(file).unwrap(); 34 | 35 | let mut buf = String::with_capacity(file.metadata().map(|m| m.len() as usize).unwrap_or(1024)); 36 | 37 | file.read_to_string(&mut buf).unwrap(); 38 | 39 | let targets: Targets = toml::from_str(&buf).unwrap(); 40 | 41 | println!("cargo:rustc-env=default_target={}", targets.default_target) 42 | } 43 | -------------------------------------------------------------------------------- /lcas/config.toml: -------------------------------------------------------------------------------- 1 | [target] 2 | #default-target="" -------------------------------------------------------------------------------- /lcas/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod as_state; 2 | pub mod expr; 3 | pub mod lex; 4 | pub mod span; 5 | pub mod sym; 6 | pub mod targ; 7 | -------------------------------------------------------------------------------- /lcas/src/targ.rs: -------------------------------------------------------------------------------- 1 | use std::any::Any; 2 | 3 | use crate::as_state::AsState; 4 | 5 | use target_tuples::Architecture; 6 | 7 | pub trait TargetMachine { 8 | fn group_chars(&self) -> &[char]; 9 | fn comment_chars(&self) -> &[char]; 10 | fn extra_sym_chars(&self) -> &[char]; 11 | fn extra_sym_part_chars(&self) -> &[char]; 12 | fn extra_sigil_chars(&self) -> &[char]; 13 | 14 | fn create_data(&self) -> Box; 15 | 16 | fn int_to_bytes<'a>(&self, val: u128, buf: &'a mut [u8]) -> &'a mut [u8]; 17 | fn float_to_bytes<'a>(&self, val: f64, buf: &'a mut [u8]) -> &'a mut [u8]; 18 | 19 | fn long_width(&self) -> usize; 20 | 21 | fn assemble_insn(&self, opc: &str, state: &mut AsState) -> std::io::Result<()>; 22 | fn directive_names(&self) -> &[&str]; 23 | fn handle_directive(&self, dir: &str, state: &mut AsState) -> std::io::Result<()>; 24 | 25 | fn def_section_alignment(&self) -> u64 { 26 | 1024 27 | } 28 | 29 | /// Whether or not the target assembler cares about newlines in the token stream 30 | /// If set to false, LineTerminator tokens are stripped from the iterator. 31 | fn newline_sensitive(&self) -> bool { 32 | true 33 | } 34 | } 35 | 36 | macro_rules! targ_defs{ 37 | {$(#[cfg($cfg:meta)] arch $arch:ident;)*} => { 38 | $(#[cfg($cfg)] mod $arch;)* 39 | 40 | pub fn get_target_def(arch: Architecture) -> Option<&'static dyn TargetMachine> { 41 | match arch.canonical_name(){ 42 | $(stringify!($arch) => Some($arch :: get_target_def()),)* 43 | _ => None, 44 | } 45 | } 46 | } 47 | } 48 | 49 | targ_defs! { 50 | #[cfg(feature = "clever")] arch clever; 51 | #[cfg(feature = "w65")] arch w65; 52 | #[cfg(feature = "holey-bytes")] arch holeybytes; 53 | } 54 | -------------------------------------------------------------------------------- /lccc-mangle/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "xlang-mangle" 3 | version = "0.1.0" 4 | authors = ["Connor Horman "] 5 | edition = "2021" 6 | rust-version = "1.74" 7 | license = "BSD-2-Clause-Patent" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | -------------------------------------------------------------------------------- /lccc-mangle/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod itanium; 2 | -------------------------------------------------------------------------------- /lcld/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lcld" 3 | version = "0.1.0" 4 | authors = [ 5 | "Connor Horman ", 6 | "Ray Redondo ", 7 | ] 8 | edition = "2021" 9 | rust-version = "1.75" 10 | license = "BSD-2-Clause-Patent" 11 | build = "build/main.rs" 12 | 13 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 14 | 15 | [features] 16 | w65 = ["binfmt/w65", "arch-ops/w65"] 17 | x86 = ["binfmt/x86", "arch-ops/x86"] 18 | arm = ["binfmt/arm", "arch-ops/arm"] 19 | aarch64 = ["binfmt/aarch64", "arch-ops/aarch64"] 20 | riscv = ["binfmt/riscv", "arch-ops/riscv"] 21 | m68k = ["binfmt/aarch64", "arch-ops/aarch64"] 22 | clever = ["binfmt/clever", "arch-ops/clever"] 23 | z80 = ["binfmt/z80", "arch-ops/z80"] 24 | m6502 = ["binfmt/m6502", "arch-ops/m6502"] 25 | default-archs = ["w65", "x86", "arm", "riscv", "m68k", "clever"] 26 | all-archs = ["default-archs", "z80", "m6502"] 27 | elf = ["binfmt/elf", "elf32", "elf64"] 28 | elf32 = ["binfmt/elf32"] 29 | elf64 = ["binfmt/elf64"] 30 | coff = ["binfmt/coff"] 31 | pe = ["binfmt/pe"] 32 | macho = ["binfmt/macho"] 33 | aout = ["binfmt/aout"] 34 | o65 = ["binfmt/o65"] 35 | xo65 = ["binfmt/xo65"] 36 | llir = ["binfmt/llir"] 37 | xir = ["binfmt/xir"] 38 | default-formats = ["elf", "coff", "pe", "macho"] 39 | lto-formats = ["xir", "llir"] 40 | all-formats = ["default-formats", "aout", "o65", "xo65", "lto-formats"] 41 | default = ["default-archs", "default-formats"] 42 | all = ["all-archs", "all-formats", "sosigning"] 43 | sosigning = [] 44 | lto = ["lto-formats"] 45 | 46 | [dependencies] 47 | target-tuples = "0.5.10" 48 | binfmt = { path = "../binfmt", features = ["ar"] } 49 | arch-ops = { path = "../arch-ops" } 50 | indexmap = "2.4.0" 51 | 52 | [build-dependencies] 53 | target-tuples = "0.5.10" 54 | serde = { version = "1.0.147", features = ["derive"] } 55 | toml = "0.5" 56 | unix_path = { version = "1.0.1", features = ["serde"] } 57 | 58 | [package.metadata.install-targets.lcld] 59 | aliases = ["ld.lc", "lc-link", "ld64.lc"] 60 | -------------------------------------------------------------------------------- /lcld/build/config.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use unix_path::PathBuf; 4 | 5 | use serde::Deserialize; 6 | use target_tuples::Target; 7 | 8 | #[derive(Hash, PartialEq, Eq, Clone, Debug)] 9 | pub struct WrappedTarget(pub Target); 10 | 11 | impl<'de> Deserialize<'de> for WrappedTarget { 12 | fn deserialize(de: D) -> Result 13 | where 14 | D: serde::Deserializer<'de>, 15 | { 16 | let string = <&str as Deserialize>::deserialize(de)?; 17 | 18 | let targ = string 19 | .parse() 20 | .map_err(::custom)?; 21 | 22 | Ok(WrappedTarget(targ)) 23 | } 24 | } 25 | 26 | #[derive(Deserialize, Debug)] 27 | #[serde(rename_all = "kebab-case")] 28 | pub struct Config { 29 | pub target: Targets, 30 | } 31 | 32 | #[derive(Deserialize, Debug)] 33 | #[serde(rename_all = "kebab-case")] 34 | pub struct Targets { 35 | pub default_target: Option, 36 | pub host_target: Option, 37 | #[serde(rename = "default")] 38 | pub default_cfg: TargetConfig, 39 | #[serde(flatten)] 40 | pub targets: HashMap, 41 | } 42 | 43 | #[derive(Deserialize, Debug)] 44 | #[serde(rename_all = "kebab-case")] 45 | pub struct TargetConfig { 46 | pub paths: PathConfig, 47 | #[serde(default)] 48 | pub sysroot: PathBuf, 49 | } 50 | 51 | #[derive(Deserialize, Debug)] 52 | #[serde(rename_all = "kebab-case")] 53 | pub struct PathConfig { 54 | pub search_paths: Vec, 55 | pub libdirs: Vec, 56 | #[serde(default)] 57 | pub use_target: bool, 58 | #[serde(default)] 59 | pub find_msvc: bool, 60 | } 61 | -------------------------------------------------------------------------------- /lcld/build/main.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | io::{ErrorKind, Read, Write}, 3 | path::PathBuf, 4 | }; 5 | 6 | mod config; 7 | 8 | fn main() -> Result<(), std::io::Error> { 9 | println!("cargo:rerun-if-changed={}", "config.toml"); 10 | 11 | let mut file = std::fs::File::open("config.toml")?; 12 | 13 | let mut str = String::new(); 14 | file.read_to_string(&mut str)?; 15 | 16 | let cfg = toml::from_str::(&str) 17 | .map_err(|e| std::io::Error::new(ErrorKind::InvalidData, e))?; 18 | 19 | let host = cfg 20 | .target 21 | .host_target 22 | .map(|t| t.0) 23 | .unwrap_or_else(|| target_tuples::Target::parse(&std::env::var("TARGET").unwrap())); 24 | 25 | let target = cfg 26 | .target 27 | .default_target 28 | .map(|t| t.0) 29 | .unwrap_or_else(|| host.clone()); 30 | 31 | println!("cargo:rustc-env=HOST={}", host); 32 | println!("cargo:rustc-env=default_target={}", target); 33 | 34 | let mut targ_output = PathBuf::from(std::env::var("OUT_DIR").unwrap()); 35 | targ_output.push("targ-generated.rs"); 36 | 37 | let mut file = std::fs::File::create(&targ_output)?; 38 | 39 | writeln!( 40 | file, 41 | r#" 42 | 43 | pub fn target_config(targ: &Target) -> TargetConfig<'static>{{ 44 | target_tuples::match_targets!{{ 45 | match (targ){{ 46 | "# 47 | )?; 48 | 49 | for (id, cfg) in cfg.target.targets { 50 | writeln!(file, "{} => construct_cfg!({:?}),", id, cfg)?; 51 | } 52 | writeln!(file, "* => construct_cfg!({:?})", cfg.target.default_cfg)?; 53 | writeln!(file, "}}}}}}")?; 54 | 55 | println!( 56 | "cargo:rustc-env=config_targ_generated={}", 57 | targ_output.display() 58 | ); 59 | 60 | Ok(()) 61 | } 62 | -------------------------------------------------------------------------------- /lcld/config.toml: -------------------------------------------------------------------------------- 1 | allow-sysroot=true 2 | 3 | [target] 4 | #default-target="" 5 | #host-target="" 6 | 7 | 8 | 9 | [target.default.paths] 10 | search-paths=["/","/usr","/usr/local"] 11 | use-target=true 12 | libdirs=["lib"] 13 | 14 | [target.'x86_86-*-windows-msvc'.paths] 15 | search-paths=["/"] 16 | use-target=false 17 | libdirs=["lib"] 18 | find-msvc=true -------------------------------------------------------------------------------- /lcld/src/driver/ld64/mod.rs: -------------------------------------------------------------------------------- 1 | use std::io::{Error as IOError, ErrorKind}; 2 | 3 | pub fn main() -> Result<(), IOError> { 4 | Err(std::io::Error::new( 5 | ErrorKind::Unsupported, 6 | "darwin driver not implemented", 7 | )) 8 | } 9 | -------------------------------------------------------------------------------- /lcld/src/driver/link/mod.rs: -------------------------------------------------------------------------------- 1 | use std::io::{Error as IOError, ErrorKind}; 2 | 3 | pub fn main() -> Result<(), IOError> { 4 | Err(std::io::Error::new( 5 | ErrorKind::Unsupported, 6 | "link.exe driver not implemented", 7 | )) 8 | } 9 | -------------------------------------------------------------------------------- /lcld/src/driver/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ld; 2 | 3 | pub mod ld64; 4 | 5 | pub mod link; 6 | 7 | pub mod wasm; 8 | -------------------------------------------------------------------------------- /lcld/src/driver/wasm/mod.rs: -------------------------------------------------------------------------------- 1 | use std::io::ErrorKind; 2 | 3 | pub fn main() -> std::io::Result<()> { 4 | Err(std::io::Error::new( 5 | ErrorKind::Unsupported, 6 | "wasm driver not implemented", 7 | )) 8 | } 9 | -------------------------------------------------------------------------------- /lcld/src/input.rs: -------------------------------------------------------------------------------- 1 | use binfmt::fmt::Binfmt; 2 | 3 | use std::io::{Read, Seek, SeekFrom}; 4 | 5 | use std::fs::File; 6 | use std::path::Path; 7 | 8 | use crate::lto::LtoProvider; 9 | 10 | #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] 11 | pub enum InputFileType { 12 | Object(&'static dyn Binfmt), 13 | Archive, 14 | LtoInput(&'static dyn LtoProvider), 15 | LinkerScript, 16 | } 17 | 18 | impl core::fmt::Display for InputFileType { 19 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 20 | match self { 21 | Self::Object(fmt) => f.write_str(fmt.name()), 22 | Self::Archive => f.write_str("archive"), 23 | Self::LtoInput(prov) => { 24 | f.write_str("lto ")?; 25 | f.write_str(prov.name()) 26 | } 27 | Self::LinkerScript => f.write_str("script"), 28 | } 29 | } 30 | } 31 | 32 | #[allow(clippy::unused_io_amount)] 33 | pub fn ident_input(p: &Path) -> std::io::Result { 34 | let file = File::open(p)?; 35 | 36 | if let Some(binfmt) = binfmt::identify_file(&file)? { 37 | Ok(InputFileType::Object(binfmt)) 38 | } else { 39 | let mut arch_buf = [0u8; 8]; 40 | (&file).seek(SeekFrom::Start(0))?; 41 | (&file).read(&mut arch_buf)?; // If this doesn't complete, then `arch_buf` will not be filled with the correct value - it is not an error to be given an 6-byte file 42 | (&file).seek(SeekFrom::Start(0))?; 43 | if arch_buf == *b"!\n" { 44 | Ok(InputFileType::Archive) 45 | } else { 46 | // todo: Identify Lto Input objects 47 | Ok(InputFileType::LinkerScript) 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /lcld/src/lto.rs: -------------------------------------------------------------------------------- 1 | pub trait LtoProvider { 2 | fn name(&self) -> &'static str; 3 | } 4 | 5 | impl core::fmt::Debug for dyn LtoProvider { 6 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 7 | f.write_str(self.name()) 8 | } 9 | } 10 | 11 | impl core::cmp::PartialEq for dyn LtoProvider { 12 | fn eq(&self, other: &Self) -> bool { 13 | core::ptr::eq( 14 | self as *const _ as *const u8, 15 | other as *const _ as *const u8, 16 | ) 17 | } 18 | } 19 | 20 | impl core::cmp::Eq for dyn LtoProvider {} 21 | 22 | impl core::hash::Hash for dyn LtoProvider { 23 | fn hash(&self, state: &mut H) { 24 | core::ptr::hash(self as *const _ as *const u8, state) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lcld/src/main.rs: -------------------------------------------------------------------------------- 1 | #![deny(warnings)] 2 | 3 | use std::io::{Error as IOError, ErrorKind}; 4 | 5 | pub mod driver; 6 | pub mod input; 7 | pub mod link; 8 | pub mod lto; 9 | pub mod output; 10 | pub mod script; 11 | pub mod targ; 12 | 13 | pub enum Mode { 14 | Unix, 15 | Darwin, 16 | Windows, 17 | Wasm, 18 | } 19 | 20 | #[allow(clippy::single_match)] // May get more arms added in the future 21 | fn main() { 22 | let mut args = std::env::args(); 23 | 24 | let mut exe_name = args.next().unwrap(); 25 | 26 | if exe_name.ends_with(".exe") { 27 | exe_name.truncate(exe_name.len() - 4); 28 | } 29 | 30 | let mut driver = match &*exe_name { 31 | x if x.ends_with("ld") || x.ends_with("ld.lc") => Some(Mode::Unix), 32 | x if x.ends_with("ld64") || x.ends_with("ld64.lc") => Some(Mode::Darwin), 33 | x if x.ends_with("link") => Some(Mode::Windows), 34 | _ => None, 35 | }; 36 | 37 | match args.next().as_deref() { 38 | Some(x @ ("-flavor" | "-flavour" | "--flavor" | "--flavour" | "/flavour")) => { 39 | driver = match args.next().as_deref().unwrap_or_else(|| { 40 | eprintln!("{}: Expected an argument for {}", exe_name, x); 41 | std::process::exit(1) 42 | }) { 43 | "ld" | "ld.lc" | "gnu" | "unix" => Some(Mode::Unix), 44 | "ld64" | "ld64.lc" | "darwin" => Some(Mode::Darwin), 45 | "link" | "lc-link" | "windows" => Some(Mode::Windows), 46 | "wasm" | "wasm-ld" | "wasm-ld.lc" => Some(Mode::Wasm), 47 | x => { 48 | eprintln!("{}: Unknown flavor {}", exe_name, x); 49 | std::process::exit(1) 50 | } 51 | } 52 | } 53 | _ => {} 54 | } 55 | 56 | match driver{ 57 | Some(Mode::Unix) => { 58 | driver::ld::main() 59 | }, 60 | Some(Mode::Darwin) => { 61 | driver::ld64::main() 62 | }, 63 | Some(Mode::Windows) => { 64 | driver::link::main() 65 | }, 66 | Some(Mode::Wasm) => { 67 | driver::wasm::main() 68 | } 69 | None => { 70 | Err(IOError::new(ErrorKind::Other,"Generic driver for lcld. Run ld.lc (unix), ld64.lc (MacOS), or lc-link (Windows) for an actual driver")) 71 | } 72 | }.unwrap_or_else(|e| { 73 | println!("{}: {}",exe_name, e); 74 | std::process::exit(1); 75 | }) 76 | } 77 | -------------------------------------------------------------------------------- /lcld/src/output.rs: -------------------------------------------------------------------------------- 1 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] 2 | pub enum OutputType { 3 | Relocatable, // perform partial link 4 | StaticExecutable, // position-dependent executable 5 | PieExecutable, // position-independent executable 6 | Shared, // Shared object/dll 7 | SharedAndLink, // dll+lib 8 | } 9 | -------------------------------------------------------------------------------- /lcld/src/script.rs: -------------------------------------------------------------------------------- 1 | use std::path::PathBuf; 2 | 3 | use binfmt::fmt::Binfmt; 4 | 5 | use crate::link::{InputId, RegionId}; 6 | 7 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] 8 | pub struct ParsedScript { 9 | pub command: Vec, 10 | } 11 | 12 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] 13 | pub enum SymbolDef { 14 | Extern(Vec), 15 | } 16 | 17 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] 18 | pub enum ScriptTopCommand { 19 | Entry(String), 20 | Input(Vec), 21 | Group(Vec), 22 | Output(PathBuf), 23 | // Note: These are processed eagerly 24 | SearchPath(Vec), 25 | Startup(InputId), 26 | OutputFormat(&'static dyn Binfmt), 27 | // Note: This isn't actually used, except to set the default `OutputFormat` 28 | Target(&'static dyn Binfmt), 29 | RegionAlias(String, RegionId), 30 | } 31 | -------------------------------------------------------------------------------- /lcld/src/targ.rs: -------------------------------------------------------------------------------- 1 | use target_tuples::Target; 2 | 3 | use crate::output::OutputType; 4 | 5 | #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] 6 | pub struct TargetConfig<'a> { 7 | pub search_paths: &'a [&'a str], 8 | pub libdirs: &'a [&'a str], 9 | pub use_target: bool, 10 | pub sysroot: &'a str, 11 | pub find_msvc: bool, 12 | } 13 | 14 | #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] 15 | pub struct TargetInfo<'a> { 16 | pub objsuffix: &'a str, 17 | pub libprefix: &'a str, 18 | pub staticsuffixes: &'a [&'a str], 19 | pub dynamicsuffixes: &'a [&'a str], 20 | pub output_dynsuffix: &'a str, 21 | pub default_output: OutputType, 22 | pub need_dylib_link: bool, 23 | } 24 | 25 | macro_rules! construct_cfg{ 26 | (TargetConfig { paths: PathConfig { search_paths: [$($search_paths:expr),* $(,)?], libdirs: [$($libdirs:expr),* $(,)?], use_target: $usetarget:expr, find_msvc: $find_msvc:expr $(, $_field:ident : $_init:expr)* $(, ..)? }, sysroot: $sysroot:expr $(, $_ofield:ident : $_oinit:expr)* $(, ..)? }) => { 27 | TargetConfig{ 28 | search_paths: &[$($search_paths),*], 29 | libdirs: &[$($libdirs),*], 30 | use_target: $usetarget, 31 | sysroot: $sysroot, 32 | find_msvc: $find_msvc, 33 | } 34 | } 35 | } 36 | 37 | include!(env!("config_targ_generated")); 38 | 39 | pub static ELF_TARG: TargetInfo = TargetInfo { 40 | objsuffix: ".o", 41 | libprefix: "lib", 42 | staticsuffixes: &[".a"], 43 | dynamicsuffixes: &[".so"], 44 | output_dynsuffix: ".so", 45 | default_output: OutputType::PieExecutable, 46 | need_dylib_link: false, 47 | }; 48 | -------------------------------------------------------------------------------- /lto/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lto" 3 | version = "0.1.0" 4 | authors = ["Connor Horman "] 5 | edition = "2021" 6 | license = "BSD-2-Clause-Patent" 7 | rust-version = "1.74" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | -------------------------------------------------------------------------------- /lto/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | #[test] 4 | fn it_works() { 5 | assert_eq!(2 + 2, 4); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /m4/bindgen.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([LCRUST_PROG_BINDGEN],[ 2 | AC_REQUIRE([AC_PROG_CC]) 3 | AC_ARG_VAR([BINDGEN]) 4 | AC_PATH_PROG([BINDGEN],[bindgen]) 5 | ]) -------------------------------------------------------------------------------- /m4/build_std.m4: -------------------------------------------------------------------------------- 1 | 2 | AC_DEFUN([LCRUST_ENABLE_BUILD_STD],[ 3 | AC_REQUIRE([LCRUST_PROG_RUSTC]) 4 | AC_REQUIRE([LCRUST_RUSTC_VERSION]) 5 | 6 | AC_ARG_ENABLE([build-std],[ 7 | build_std=$enableval 8 | ],[ 9 | build_std=no 10 | ]) 11 | 12 | if test x$build_std != xno 13 | then 14 | AC_MSG_NOTICE([Checking how to build-std with $RUSTC... ]) 15 | if x$rustc_is_lccc != xno 16 | then 17 | # $RUSTC is lccc, do what we want. 18 | _buildstd_workspace_path="$($RUSTC -Z autotools-hacks --print build-std-workspace-path)" 19 | _buildstd_features="" 20 | _buildstd_env="" 21 | else 22 | _rustc_sysroot="$($RUSTC --print sysroot || echo no)" 23 | if test "$_rustc_sysroot" != "no" 24 | then 25 | _buildstd_workspace_path="$_rustc_sysroot/lib/rustlib/src/rust" 26 | if test -d "$_buildstd_workspace_path" 27 | then 28 | _buildstd_features="backtrace" 29 | _buildstd_env="RUSTC_BOOTSTRAP=1" 30 | else 31 | _buildstd_output="$($RUSTC --print build-std-info || echo no)" 32 | 33 | fi 34 | fi 35 | fi 36 | fi 37 | 38 | ]) -------------------------------------------------------------------------------- /m4/lcrust_checks.m4: -------------------------------------------------------------------------------- 1 | 2 | AC_DEFUN([LCRUST_CHECK_EDITION],[ 3 | SAVE_RUSTFLAGS="$RUSTFLAGS" 4 | RUSTFLAGS="$RUSTFLAGS --edition $1" 5 | LCRUST_TRY_COMPILE([],[ 6 | rust_edition=$1 7 | ], 8 | RUSTFLAGS="$SAVE_RUSTFLAGS" 9 | rust_edition=no 10 | $2 11 | ) 12 | ]) 13 | 14 | AC_DEFUN([LCRUST_TRY_COMPILE_WITH_FEATURES],[ 15 | LCRUST_TRY_COMPILE([$1], 16 | $3 17 | , 18 | [for feature in $2 do 19 | do 20 | LCRUST_TRY_COMPILE([#![feature($feature)] $1],[ 21 | try_compile_result=$feature 22 | feature_$feature=yes 23 | RUSTFLAGS="$RUSTFLAGS --cfg feature_$feature" 24 | $3 25 | ]) 26 | if test x$try_compile_result != xno 27 | then 28 | break 29 | fi 30 | done 31 | if test x$try_compile_result \= xno 32 | then 33 | $4 34 | fi 35 | ] 36 | ) 37 | ]) 38 | 39 | AC_DEFUN([LCRUST_CHECK_TOOL],[ 40 | LCRUST_TRY_COMPILE([#![$1 :: $2]],[ 41 | tool_$1=yes 42 | $4 43 | ],[ 44 | LCRUST_TRY_COMPILE([#![register_tool($1)] $![$1 :: $2]],[ 45 | tool_$1=register 46 | ]) 47 | ]) 48 | ]) -------------------------------------------------------------------------------- /objdump/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "objdump" 3 | version = "0.1.0" 4 | authors = ["Connor Horman "] 5 | edition = "2021" 6 | rust-version = "1.74" 7 | license = "BSD-2-Clause-Patent" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | binfmt = {path="../binfmt", features=["all-archs"]} 13 | target-tuples = "0.5.5" 14 | 15 | [features] 16 | elf = ["binfmt/elf"] 17 | elf32 = ["binfmt/elf32"] 18 | elf64 = ["binfmt/elf64"] 19 | coff = ["binfmt/coff"] 20 | pe = ["binfmt/pe"] 21 | macho = ["binfmt/macho"] 22 | aout = ["binfmt/aout"] 23 | o65 = ["binfmt/o65"] 24 | xo65 = ["binfmt/xo65"] 25 | llir = ["binfmt/llir"] 26 | xir = ["binfmt/xir"] 27 | default-formats = ["elf","coff","pe","macho"] 28 | lto-formats = ["xir","llir"] 29 | all-formats = ["default-formats","aout","o65", "xo65","lto-formats"] 30 | default = ["default-formats"] 31 | -------------------------------------------------------------------------------- /readobj/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "readobj" 3 | version = "0.1.0" 4 | authors = ["Connor Horman "] 5 | edition = "2021" 6 | rust-version = "1.74" 7 | license = "BSD-2-Clause-Patent" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | -------------------------------------------------------------------------------- /readobj/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world!"); 3 | } 4 | -------------------------------------------------------------------------------- /vendor/bytemuck/.cargo-checksum.json: -------------------------------------------------------------------------------- 1 | {"files":{"Cargo.toml":"659660f60c5644d795686448b9f46cb95de2073ad43655ff4bcc7ce78dec9824","LICENSE-APACHE":"870e20c217d15bcfcbe53d7c5867cd8fac44a4ca0b41fc1eb843557e16063eba","LICENSE-MIT":"0b2d108c9c686a74ac312990ee8377902756a2a081a7af3b0f9d68abf0a8f1a1","LICENSE-ZLIB":"682b4c81b85e83ce6cc6e1ace38fdd97aeb4de0e972bd2b44aa0916c54af8c96","README.md":"dc60ed213002ac5c27c1dd753090832d3b882ea1c9b6ce9962891572830bcfb4","changelog.md":"d22e59b354e063712367bff75f0a44284c28d5936caf67850d083f93fb73c6c1","rustfmt.toml":"f4c215534437936f924c937dbb1677f614761589300d6b389f3b518b3eb551b8","src/allocation.rs":"1f7f937d3ef6c08d982a6385d85efd236c2d1d248986bec9123af067df677696","src/contiguous.rs":"867e162651b435aa0298caad1d81f46877c22c74a2766d9e79be0ab3c615ce46","src/lib.rs":"25b2a137022002a5b89bcdd3a6d5160653dcffdcf9fa91ca0b1972485bea3520","src/offset_of.rs":"2afd190ef0462b30ade786fe813a91e7bf41cc2fa99a1d79002cbafab5964f37","src/pod.rs":"2e09ae9c6ddaa8511c3cb21b1fa76ea30ab988f3811f0d238717d82bb4818c26","src/transparent.rs":"04dfa5d947a22fbd955fc0bcb93fd499161bed4bc8264e62f3dfe8a462b960a8","src/zeroable.rs":"494b9bf7f291ef3dcbb2c392bc77b0bf5a8cd58ca1bf1334bc40a43ea3c26929","tests/array_tests.rs":"98ca7a0dcd93e65f70d4db19643e707cafae5a249561ab151998cedb89b2e036","tests/cast_slice_tests.rs":"567e4de061f9ad1eeba5abac75b3395a75d5cf48b3bd1186e740ece5c8cffd1b","tests/derive.rs":"6843d5278aa8d6a53f4b4907f84e4c1d144818b954b4e69e0f8f683de7a90ec9","tests/doc_tests.rs":"eb4ce9cb167dbc1d6742b7d5c518c0636c77ce020c7cde28802d8dd67961bd15","tests/offset_of_tests.rs":"435a92c321865ddba9f29b81fc27c23f268e1dc12955a3c8b01ff2cc0c4f5615","tests/std_tests.rs":"ba0936ed2508b109bb4d3edda1294f61cda28118f511f9909dc6916be4e59207","tests/transparent.rs":"df39457958906e7708fc59d1bbc100d55701e9777424562aac2c4e70923fe6e6","tests/wrapper_forgets.rs":"c6330546f6aa696245625056e7323b3916e3fb1a9fbecefe9c9e62d3726812d9"},"package":"72957246c41db82b8ef88a5486143830adeb8227ef9837740bdec67724cf2c5b"} -------------------------------------------------------------------------------- /vendor/bytemuck/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies 7 | # 8 | # If you believe there's an error in this file please file an 9 | # issue against the rust-lang/cargo repository. If you're 10 | # editing this file be aware that the upstream Cargo.toml 11 | # will likely look very different (and much more reasonable) 12 | 13 | [package] 14 | edition = "2018" 15 | name = "bytemuck" 16 | version = "1.7.2" 17 | authors = ["Lokathor "] 18 | exclude = ["/pedantic.bat"] 19 | description = "A crate for mucking around with piles of bytes." 20 | readme = "README.md" 21 | keywords = ["transmute", "bytes", "casting"] 22 | categories = ["encoding", "no-std"] 23 | license = "Zlib OR Apache-2.0 OR MIT" 24 | repository = "https://github.com/Lokathor/bytemuck" 25 | [package.metadata.docs.rs] 26 | features = ["derive", "extern_crate_alloc", "extern_crate_std", "zeroable_maybe_uninit", "min_const_generics"] 27 | 28 | [package.metadata.playground] 29 | features = ["derive", "extern_crate_alloc", "extern_crate_std", "zeroable_maybe_uninit", "min_const_generics"] 30 | [dependencies.bytemuck_derive] 31 | version = "1" 32 | optional = true 33 | 34 | [features] 35 | derive = ["bytemuck_derive"] 36 | extern_crate_alloc = [] 37 | extern_crate_std = ["extern_crate_alloc"] 38 | min_const_generics = [] 39 | unsound_ptr_pod_impl = [] 40 | zeroable_maybe_uninit = [] 41 | -------------------------------------------------------------------------------- /vendor/bytemuck/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Daniel "Lokathor" Gee. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/bytemuck/LICENSE-ZLIB: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Daniel "Lokathor" Gee. 2 | 3 | This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. 4 | 5 | Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 6 | 7 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 8 | 9 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 10 | 11 | 3. This notice may not be removed or altered from any source distribution. 12 | -------------------------------------------------------------------------------- /vendor/bytemuck/README.md: -------------------------------------------------------------------------------- 1 | [![License:Zlib](https://img.shields.io/badge/License-Zlib-brightgreen.svg)](https://opensource.org/licenses/Zlib) 2 | ![Minimum Rust Version](https://img.shields.io/badge/Min%20Rust-1.34-green.svg) 3 | [![crates.io](https://img.shields.io/crates/v/bytemuck.svg)](https://crates.io/crates/bytemuck) 4 | [![docs.rs](https://docs.rs/bytemuck/badge.svg)](https://docs.rs/bytemuck/) 5 | 6 | # bytemuck 7 | 8 | A crate for mucking around with piles of bytes. 9 | 10 | ## Extensions 11 | 12 | There is experimental support for the `Zeroable` trait being derived through a 13 | proc-macro. I'm not the author of that crate, please file bugs with that crate 14 | in the other repo. 15 | 16 | * https://github.com/rodrimati1992/zeroable_crates 17 | 18 | ## Stability 19 | 20 | The goal is to stay at 1.y.z until _at least_ the next edition of Rust. 21 | 22 | I consider any increase of the Minimum Rust Version to be a semver breaking change, 23 | so `rustc-1.34` will continue to be supported for at least the rest of the 24 | `bytemuck-1.y.z` series of the crate. 25 | 26 | (The secret goal is to get all of this functionality into the standard library 27 | some day so that we don't even need to import a crate to do all this fun stuff.) 28 | -------------------------------------------------------------------------------- /vendor/bytemuck/rustfmt.toml: -------------------------------------------------------------------------------- 1 | # Based on 2 | # https://github.com/rust-lang/rustfmt/blob/rustfmt-1.4.19/Configurations.md 3 | 4 | # Stable 5 | edition = "2018" 6 | fn_args_layout = "Compressed" 7 | max_width = 80 8 | tab_spaces = 2 9 | use_field_init_shorthand = true 10 | use_try_shorthand = true 11 | use_small_heuristics = "Max" 12 | 13 | # Unstable 14 | format_code_in_doc_comments = true 15 | imports_granularity = "Crate" 16 | wrap_comments = true 17 | -------------------------------------------------------------------------------- /vendor/bytemuck/tests/array_tests.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | pub fn test_cast_array() { 3 | let x = [0u32, 1u32, 2u32]; 4 | let _: [u16; 6] = bytemuck::cast(x); 5 | } 6 | 7 | #[cfg(feature = "min_const_generics")] 8 | #[test] 9 | pub fn test_cast_long_array() { 10 | let x = [0u32; 65]; 11 | let _: [u16; 130] = bytemuck::cast(x); 12 | } 13 | -------------------------------------------------------------------------------- /vendor/bytemuck/tests/derive.rs: -------------------------------------------------------------------------------- 1 | #![cfg(feature = "derive")] 2 | #![allow(dead_code)] 3 | 4 | use bytemuck::{Pod, TransparentWrapper, Zeroable}; 5 | 6 | #[derive(Copy, Clone, Pod, Zeroable)] 7 | #[repr(C)] 8 | struct Test { 9 | a: u16, 10 | b: u16, 11 | } 12 | 13 | #[derive(TransparentWrapper)] 14 | #[repr(transparent)] 15 | struct TransparentSingle { 16 | a: u16, 17 | } 18 | 19 | #[derive(TransparentWrapper)] 20 | #[repr(transparent)] 21 | #[transparent(u16)] 22 | struct TransparentWithZeroSized { 23 | a: u16, 24 | b: (), 25 | } 26 | -------------------------------------------------------------------------------- /vendor/bytemuck/tests/offset_of_tests.rs: -------------------------------------------------------------------------------- 1 | use bytemuck::{offset_of, Zeroable}; 2 | 3 | #[test] 4 | fn test_offset_of_vertex() { 5 | #[repr(C)] 6 | struct Vertex { 7 | pos: [f32; 2], 8 | uv: [u16; 2], 9 | color: [u8; 4], 10 | } 11 | unsafe impl Zeroable for Vertex {} 12 | 13 | let pos = offset_of!(Zeroable::zeroed(), Vertex, pos); 14 | let uv = offset_of!(Zeroable::zeroed(), Vertex, uv); 15 | let color = offset_of!(Zeroable::zeroed(), Vertex, color); 16 | 17 | assert_eq!(pos, 0); 18 | assert_eq!(uv, 8); 19 | assert_eq!(color, 12); 20 | } 21 | 22 | #[test] 23 | fn test_offset_of_foo() { 24 | #[derive(Default)] 25 | struct Foo { 26 | a: u8, 27 | b: &'static str, 28 | c: i32, 29 | } 30 | 31 | let a_offset = offset_of!(Default::default(), Foo, a); 32 | let b_offset = offset_of!(Default::default(), Foo, b); 33 | let c_offset = offset_of!(Default::default(), Foo, c); 34 | 35 | assert_ne!(a_offset, b_offset); 36 | assert_ne!(b_offset, c_offset); 37 | // We can't check against hardcoded values for a repr(Rust) type, 38 | // but prove to ourself this way. 39 | 40 | let foo = Foo::default(); 41 | // Note: offsets are in bytes. 42 | let as_bytes = &foo as *const _ as *const u8; 43 | 44 | // we're using wrapping_offset here because it's not worth 45 | // the unsafe block, but it would be valid to use `add` instead, 46 | // as it cannot overflow. 47 | assert_eq!( 48 | &foo.a as *const _ as usize, 49 | as_bytes.wrapping_add(a_offset) as usize 50 | ); 51 | assert_eq!( 52 | &foo.b as *const _ as usize, 53 | as_bytes.wrapping_add(b_offset) as usize 54 | ); 55 | assert_eq!( 56 | &foo.c as *const _ as usize, 57 | as_bytes.wrapping_add(c_offset) as usize 58 | ); 59 | } 60 | -------------------------------------------------------------------------------- /vendor/bytemuck/tests/std_tests.rs: -------------------------------------------------------------------------------- 1 | //! The integration tests seem to always have `std` linked, so things that would 2 | //! depend on that can go here. 3 | 4 | use bytemuck::*; 5 | 6 | #[test] 7 | fn test_transparent_vtabled() { 8 | use core::fmt::Display; 9 | 10 | #[repr(transparent)] 11 | struct DisplayTraitObj(dyn Display); 12 | 13 | unsafe impl TransparentWrapper for DisplayTraitObj {} 14 | 15 | impl Display for DisplayTraitObj { 16 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 17 | self.0.fmt(f) 18 | } 19 | } 20 | 21 | let v = DisplayTraitObj::wrap_ref(&5i32); 22 | let s = format!("{}", v); 23 | assert_eq!(s, "5"); 24 | 25 | let mut x = 100i32; 26 | let v_mut = DisplayTraitObj::wrap_mut(&mut x); 27 | let s = format!("{}", v_mut); 28 | assert_eq!(s, "100"); 29 | } 30 | 31 | #[test] 32 | #[cfg(feature = "extern_crate_alloc")] 33 | fn test_large_box_alloc() { 34 | type SuperPage = [[u8; 4096]; 4096]; 35 | let _: Box = try_zeroed_box().unwrap(); 36 | } 37 | 38 | #[test] 39 | #[cfg(feature = "extern_crate_alloc")] 40 | fn test_zero_sized_box_alloc() { 41 | #[repr(align(4096))] 42 | struct Empty; 43 | unsafe impl Zeroable for Empty {} 44 | let _: Box = try_zeroed_box().unwrap(); 45 | } 46 | -------------------------------------------------------------------------------- /vendor/bytemuck/tests/transparent.rs: -------------------------------------------------------------------------------- 1 | // Currently this test doesn't actually check the output of the functions. 2 | // It's only here for miri to check for any potential undefined behaviour. 3 | // TODO: check function results 4 | 5 | #[test] 6 | fn test_transparent_wrapper() { 7 | // An external type defined in a different crate. 8 | #[derive(Copy, Clone, Default)] 9 | struct Foreign(u8); 10 | 11 | use bytemuck::TransparentWrapper; 12 | 13 | #[derive(Copy, Clone)] 14 | #[repr(transparent)] 15 | struct Wrapper(Foreign); 16 | 17 | unsafe impl TransparentWrapper for Wrapper {} 18 | 19 | // Traits can be implemented on crate-local wrapper. 20 | unsafe impl bytemuck::Zeroable for Wrapper {} 21 | unsafe impl bytemuck::Pod for Wrapper {} 22 | 23 | let _: u8 = bytemuck::cast(Wrapper::wrap(Foreign::default())); 24 | let _: Foreign = Wrapper::peel(bytemuck::cast(u8::default())); 25 | 26 | let _: &u8 = bytemuck::cast_ref(Wrapper::wrap_ref(&Foreign::default())); 27 | let _: &Foreign = Wrapper::peel_ref(bytemuck::cast_ref(&u8::default())); 28 | 29 | let _: &mut u8 = 30 | bytemuck::cast_mut(Wrapper::wrap_mut(&mut Foreign::default())); 31 | let _: &mut Foreign = 32 | Wrapper::peel_mut(bytemuck::cast_mut(&mut u8::default())); 33 | 34 | let _: &[u8] = 35 | bytemuck::cast_slice(Wrapper::wrap_slice(&[Foreign::default()])); 36 | let _: &[Foreign] = 37 | Wrapper::peel_slice(bytemuck::cast_slice(&[u8::default()])); 38 | 39 | let _: &mut [u8] = 40 | bytemuck::cast_slice_mut(Wrapper::wrap_slice_mut( 41 | &mut [Foreign::default()], 42 | )); 43 | let _: &mut [Foreign] = 44 | Wrapper::peel_slice_mut(bytemuck::cast_slice_mut(&mut [u8::default()])); 45 | 46 | let _: &[u8] = bytemuck::bytes_of(Wrapper::wrap_ref(&Foreign::default())); 47 | let _: &Foreign = Wrapper::peel_ref(bytemuck::from_bytes(&[u8::default()])); 48 | 49 | let _: &mut [u8] = 50 | bytemuck::bytes_of_mut(Wrapper::wrap_mut(&mut Foreign::default())); 51 | let _: &mut Foreign = 52 | Wrapper::peel_mut(bytemuck::from_bytes_mut(&mut [u8::default()])); 53 | 54 | // not sure if this is the right usage 55 | let _ = 56 | bytemuck::pod_align_to::<_, u8>(Wrapper::wrap_slice(&[Foreign::default()])); 57 | // counterpart? 58 | 59 | // not sure if this is the right usage 60 | let _ = bytemuck::pod_align_to_mut::<_, u8>(Wrapper::wrap_slice_mut(&mut [ 61 | Foreign::default(), 62 | ])); 63 | // counterpart? 64 | } 65 | -------------------------------------------------------------------------------- /vendor/bytemuck/tests/wrapper_forgets.rs: -------------------------------------------------------------------------------- 1 | use bytemuck::TransparentWrapper; 2 | 3 | #[repr(transparent)] 4 | struct Wrap(Box); 5 | 6 | // SAFETY: it's #[repr(transparent)] 7 | unsafe impl TransparentWrapper> for Wrap {} 8 | 9 | fn main() { 10 | let value = Box::new(5); 11 | // This used to duplicate the wrapped value, creating a double free :( 12 | Wrap::wrap(value); 13 | } 14 | -------------------------------------------------------------------------------- /vendor/bytemuck_derive/.cargo-checksum.json: -------------------------------------------------------------------------------- 1 | {"files":{"Cargo.toml":"e3bc406eee45f74e5abc5e0935867cf7cbda2a21c9aae5b9ef5e223827f07445","LICENSE-APACHE":"e3ba223bb1423f0aad8c3dfce0fe3148db48926d41e6fbc3afbbf5ff9e1c89cb","LICENSE-MIT":"9df9ba60a11af705f2e451b53762686e615d86f76b169cf075c3237730dbd7e2","LICENSE-ZLIB":"84b34dd7608f7fb9b17bd588a6bf392bf7de504e2716f024a77d89f1b145a151","README.md":"09d8238fd7fdac39857da88e090667d8327ca9ac240768e216ef2079c2f06846","changelog.md":"5314b666a08dbabbb4a09d0cebfaba9b742e4c39fa45b96cf65638d615ca7272","src/lib.rs":"ba381a12be6aca1a9e8b255e7948d87846f382629316473f6b7cad7640d9e47a","src/traits.rs":"163308df190e889b1b68ca5dab530fbf283998e9d0e47cd9ec0e357a1addfa5a","tests/basic.rs":"dd02611e39aa53c941f39be0d10c1eba319650a31fd8222e459cbcc9f9346219"},"package":"8e215f8c2f9f79cb53c8335e687ffd07d5bfcb6fe5fc80723762d0be46e7cc54"} -------------------------------------------------------------------------------- /vendor/bytemuck_derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies 7 | # 8 | # If you believe there's an error in this file please file an 9 | # issue against the rust-lang/cargo repository. If you're 10 | # editing this file be aware that the upstream Cargo.toml 11 | # will likely look very different (and much more reasonable) 12 | 13 | [package] 14 | edition = "2018" 15 | name = "bytemuck_derive" 16 | version = "1.0.1" 17 | authors = ["Lokathor "] 18 | description = "derive proc-macros for `bytemuck`" 19 | readme = "README.md" 20 | keywords = ["transmute", "bytes", "casting"] 21 | categories = ["encoding", "no-std"] 22 | license = "Zlib OR Apache-2.0 OR MIT" 23 | repository = "https://github.com/Lokathor/bytemuck" 24 | 25 | [lib] 26 | name = "bytemuck_derive" 27 | proc-macro = true 28 | [dependencies.proc-macro2] 29 | version = "1" 30 | 31 | [dependencies.quote] 32 | version = "1" 33 | 34 | [dependencies.syn] 35 | version = "1" 36 | [dev-dependencies.bytemuck] 37 | version = "1.2" 38 | -------------------------------------------------------------------------------- /vendor/bytemuck_derive/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Daniel "Lokathor" Gee. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/bytemuck_derive/LICENSE-ZLIB: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Daniel "Lokathor" Gee. 2 | 3 | This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. 4 | 5 | Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 6 | 7 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 8 | 9 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 10 | 11 | 3. This notice may not be removed or altered from any source distribution. 12 | -------------------------------------------------------------------------------- /vendor/bytemuck_derive/README.md: -------------------------------------------------------------------------------- 1 | 2 | # bytemuck_derive 3 | 4 | Derive macros for [bytemuck](https://docs.rs/bytemuck) traits. 5 | -------------------------------------------------------------------------------- /vendor/bytemuck_derive/changelog.md: -------------------------------------------------------------------------------- 1 | 2 | ## `bytemuck_derive` changelog 3 | 4 | ## 1.0.1 5 | 6 | * [yanchith](https://github.com/yanchith) fixed the derive checks code to make clippy more happy. 7 | [PR 45](https://github.com/Lokathor/bytemuck/pull/45) 8 | 9 | ## 1.0.0 10 | 11 | * Initial stable release. 12 | -------------------------------------------------------------------------------- /vendor/bytemuck_derive/tests/basic.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | 3 | use bytemuck_derive::{Contiguous, Pod, TransparentWrapper, Zeroable}; 4 | use std::marker::PhantomData; 5 | 6 | #[derive(Copy, Clone, Pod, Zeroable)] 7 | #[repr(C)] 8 | struct Test { 9 | a: u16, 10 | b: u16, 11 | } 12 | 13 | #[derive(Zeroable)] 14 | struct ZeroGeneric { 15 | a: T, 16 | } 17 | 18 | #[derive(TransparentWrapper)] 19 | #[repr(transparent)] 20 | struct TransparentSingle { 21 | a: u16, 22 | } 23 | 24 | #[derive(TransparentWrapper)] 25 | #[repr(transparent)] 26 | #[transparent(u16)] 27 | struct TransparentWithZeroSized { 28 | a: u16, 29 | b: PhantomData, 30 | } 31 | 32 | #[repr(u8)] 33 | #[derive(Clone, Copy, Contiguous)] 34 | enum ContiguousWithValues { 35 | A = 0, 36 | B = 1, 37 | C = 2, 38 | D = 3, 39 | E = 4, 40 | } 41 | 42 | #[repr(i8)] 43 | #[derive(Clone, Copy, Contiguous)] 44 | enum ContiguousWithImplicitValues { 45 | A = -10, 46 | B, 47 | C, 48 | D, 49 | E, 50 | } 51 | -------------------------------------------------------------------------------- /vendor/either/.cargo-checksum.json: -------------------------------------------------------------------------------- 1 | {"files":{"Cargo.toml":"d4e9a8625c1740b1a8973a2e58c04ec7007c92b6b1f8be7f7dfe106f0929ffeb","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"7576269ea71f767b99297934c0b2367532690f8c4badc695edf8e04ab6a1e545","README-crates.io.md":"b775991a01ab4a0a8de6169f597775319d9ce8178f5c74ccdc634f13a286b20c","README.rst":"ce419aa43bbed11a3e25e89720227f4d8653d346cefac9dee6364e0d933f7c3f","src/lib.rs":"72193806d28cff7d994453c81c50987004168407cc4793991e2d36fef285590b","src/serde_untagged.rs":"da462e39a93abd3c9537d124354e3066a74073a275893b78a0ef5bd203bf84c2","src/serde_untagged_optional.rs":"b654b2a5c6127ca295079369ee0b7bbbb2d92699cdd3672d4b932ea292057287"},"package":"e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"} -------------------------------------------------------------------------------- /vendor/either/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies 7 | # 8 | # If you believe there's an error in this file please file an 9 | # issue against the rust-lang/cargo repository. If you're 10 | # editing this file be aware that the upstream Cargo.toml 11 | # will likely look very different (and much more reasonable) 12 | 13 | [package] 14 | name = "either" 15 | version = "1.6.1" 16 | authors = ["bluss"] 17 | description = "The enum `Either` with variants `Left` and `Right` is a general purpose sum type with two cases.\n" 18 | documentation = "https://docs.rs/either/1/" 19 | readme = "README-crates.io.md" 20 | keywords = ["data-structure", "no_std"] 21 | categories = ["data-structures", "no-std"] 22 | license = "MIT/Apache-2.0" 23 | repository = "https://github.com/bluss/either" 24 | [package.metadata.docs.rs] 25 | features = ["serde"] 26 | 27 | [package.metadata.release] 28 | no-dev-version = true 29 | tag-name = "{{version}}" 30 | [dependencies.serde] 31 | version = "1.0" 32 | features = ["derive"] 33 | optional = true 34 | [dev-dependencies.serde_json] 35 | version = "1.0.0" 36 | 37 | [features] 38 | default = ["use_std"] 39 | use_std = [] 40 | -------------------------------------------------------------------------------- /vendor/either/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /vendor/either/README-crates.io.md: -------------------------------------------------------------------------------- 1 | The enum `Either` with variants `Left` and `Right` is a general purpose 2 | sum type with two cases. 3 | 4 | Either has methods that are similar to Option and Result, and it also implements 5 | traits like `Iterator`. 6 | 7 | Includes macros `try_left!()` and `try_right!()` to use for 8 | short-circuiting logic, similar to how the `?` operator is used with `Result`. 9 | Note that `Either` is general purpose. For describing success or error, use the 10 | regular `Result`. 11 | -------------------------------------------------------------------------------- /vendor/either/src/serde_untagged.rs: -------------------------------------------------------------------------------- 1 | //! Untagged serialization/deserialization support for Either. 2 | //! 3 | //! `Either` uses default, externally-tagged representation. 4 | //! However, sometimes it is useful to support several alternative types. 5 | //! For example, we may have a field which is generally Map 6 | //! but in typical cases Vec would suffice, too. 7 | //! 8 | //! ```rust 9 | //! #[macro_use] 10 | //! extern crate serde; 11 | //! // or `use serde::{Serialize, Deserialize};` in newer rust versions. 12 | //! 13 | //! # fn main() -> Result<(), Box> { 14 | //! use either::Either; 15 | //! use std::collections::HashMap; 16 | //! 17 | //! #[derive(Serialize, Deserialize, Debug)] 18 | //! #[serde(transparent)] 19 | //! struct IntOrString { 20 | //! #[serde(with = "either::serde_untagged")] 21 | //! inner: Either, HashMap> 22 | //! }; 23 | //! 24 | //! // serialization 25 | //! let data = IntOrString { 26 | //! inner: Either::Left(vec!["Hello".to_string()]) 27 | //! }; 28 | //! // notice: no tags are emitted. 29 | //! assert_eq!(serde_json::to_string(&data)?, r#"["Hello"]"#); 30 | //! 31 | //! // deserialization 32 | //! let data: IntOrString = serde_json::from_str( 33 | //! r#"{"a": 0, "b": 14}"# 34 | //! )?; 35 | //! println!("found {:?}", data); 36 | //! # Ok(()) 37 | //! # } 38 | //! ``` 39 | 40 | use serde::{Deserialize, Deserializer, Serialize, Serializer}; 41 | 42 | #[derive(Serialize, Deserialize)] 43 | #[serde(untagged)] 44 | enum Either { 45 | Left(L), 46 | Right(R), 47 | } 48 | 49 | pub fn serialize(this: &super::Either, serializer: S) -> Result 50 | where 51 | S: Serializer, 52 | L: Serialize, 53 | R: Serialize, 54 | { 55 | let untagged = match this { 56 | &super::Either::Left(ref left) => Either::Left(left), 57 | &super::Either::Right(ref right) => Either::Right(right), 58 | }; 59 | untagged.serialize(serializer) 60 | } 61 | 62 | pub fn deserialize<'de, L, R, D>(deserializer: D) -> Result, D::Error> 63 | where 64 | D: Deserializer<'de>, 65 | L: Deserialize<'de>, 66 | R: Deserialize<'de>, 67 | { 68 | match Either::deserialize(deserializer) { 69 | Ok(Either::Left(left)) => Ok(super::Either::Left(left)), 70 | Ok(Either::Right(right)) => Ok(super::Either::Right(right)), 71 | Err(error) => Err(error), 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /vendor/either/src/serde_untagged_optional.rs: -------------------------------------------------------------------------------- 1 | //! Untagged serialization/deserialization support for Option>. 2 | //! 3 | //! `Either` uses default, externally-tagged representation. 4 | //! However, sometimes it is useful to support several alternative types. 5 | //! For example, we may have a field which is generally Map 6 | //! but in typical cases Vec would suffice, too. 7 | //! 8 | //! ```rust 9 | //! #[macro_use] 10 | //! extern crate serde; 11 | //! // or `use serde::{Serialize, Deserialize};` in newer rust versions. 12 | //! 13 | //! # fn main() -> Result<(), Box> { 14 | //! use either::Either; 15 | //! use std::collections::HashMap; 16 | //! 17 | //! #[derive(Serialize, Deserialize, Debug)] 18 | //! #[serde(transparent)] 19 | //! struct IntOrString { 20 | //! #[serde(with = "either::serde_untagged_optional")] 21 | //! inner: Option, HashMap>> 22 | //! }; 23 | //! 24 | //! // serialization 25 | //! let data = IntOrString { 26 | //! inner: Some(Either::Left(vec!["Hello".to_string()])) 27 | //! }; 28 | //! // notice: no tags are emitted. 29 | //! assert_eq!(serde_json::to_string(&data)?, r#"["Hello"]"#); 30 | //! 31 | //! // deserialization 32 | //! let data: IntOrString = serde_json::from_str( 33 | //! r#"{"a": 0, "b": 14}"# 34 | //! )?; 35 | //! println!("found {:?}", data); 36 | //! # Ok(()) 37 | //! # } 38 | //! ``` 39 | 40 | use serde::{Deserialize, Deserializer, Serialize, Serializer}; 41 | 42 | #[derive(Serialize, Deserialize)] 43 | #[serde(untagged)] 44 | enum Either { 45 | Left(L), 46 | Right(R), 47 | } 48 | 49 | pub fn serialize( 50 | this: &Option>, 51 | serializer: S, 52 | ) -> Result 53 | where 54 | S: Serializer, 55 | L: Serialize, 56 | R: Serialize, 57 | { 58 | let untagged = match this { 59 | &Some(super::Either::Left(ref left)) => Some(Either::Left(left)), 60 | &Some(super::Either::Right(ref right)) => Some(Either::Right(right)), 61 | &None => None, 62 | }; 63 | untagged.serialize(serializer) 64 | } 65 | 66 | pub fn deserialize<'de, L, R, D>(deserializer: D) -> Result>, D::Error> 67 | where 68 | D: Deserializer<'de>, 69 | L: Deserialize<'de>, 70 | R: Deserialize<'de>, 71 | { 72 | match Option::deserialize(deserializer) { 73 | Ok(Some(Either::Left(left))) => Ok(Some(super::Either::Left(left))), 74 | Ok(Some(Either::Right(right))) => Ok(Some(super::Either::Right(right))), 75 | Ok(None) => Ok(None), 76 | Err(error) => Err(error), 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /vendor/lazy_static/.cargo-checksum.json: -------------------------------------------------------------------------------- 1 | {"files":{"Cargo.toml":"05e37a4e63dc4a495998bb5133252a51d671c4e99061a6342089ed6eab43978a","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0621878e61f0d0fda054bcbe02df75192c28bde1ecc8289cbd86aeba2dd72720","README.md":"e2effacb5bbd7c01523f9a9e4a6a59c0f9b8698753b210fec5742408498197df","src/core_lazy.rs":"6b9fb6a4f553058e240756125b6b9ca43a83ed1fb72964343038ea0ea2e1af10","src/inline_lazy.rs":"f6184afbca4b477616f270790edc180263be806aa92ef0a9de681b4aac9e88c4","src/lib.rs":"99096a5d3089c0d86646f0805d1455befe2cb09683704af29c5c9d99ecab2683","tests/no_std.rs":"d68b149ee51ef5ae2b2906c0c94f5a9812d3b02811b13365c5a35e2ef90d25cf","tests/test.rs":"b3f7d805375dc5af7a2aa4b869944ad2ab4fc982b35ad718ea58f6914dc0a698"},"package":"e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"} -------------------------------------------------------------------------------- /vendor/lazy_static/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies 7 | # 8 | # If you believe there's an error in this file please file an 9 | # issue against the rust-lang/cargo repository. If you're 10 | # editing this file be aware that the upstream Cargo.toml 11 | # will likely look very different (and much more reasonable) 12 | 13 | [package] 14 | name = "lazy_static" 15 | version = "1.4.0" 16 | authors = ["Marvin Löbel "] 17 | exclude = ["/.travis.yml", "/appveyor.yml"] 18 | description = "A macro for declaring lazily evaluated statics in Rust." 19 | documentation = "https://docs.rs/lazy_static" 20 | readme = "README.md" 21 | keywords = ["macro", "lazy", "static"] 22 | categories = ["no-std", "rust-patterns", "memory-management"] 23 | license = "MIT/Apache-2.0" 24 | repository = "https://github.com/rust-lang-nursery/lazy-static.rs" 25 | [dependencies.spin] 26 | version = "0.5.0" 27 | optional = true 28 | [dev-dependencies.doc-comment] 29 | version = "0.3.1" 30 | 31 | [features] 32 | spin_no_std = ["spin"] 33 | [badges.appveyor] 34 | repository = "rust-lang-nursery/lazy-static.rs" 35 | 36 | [badges.is-it-maintained-issue-resolution] 37 | repository = "rust-lang-nursery/lazy-static.rs" 38 | 39 | [badges.is-it-maintained-open-issues] 40 | repository = "rust-lang-nursery/lazy-static.rs" 41 | 42 | [badges.maintenance] 43 | status = "passively-maintained" 44 | 45 | [badges.travis-ci] 46 | repository = "rust-lang-nursery/lazy-static.rs" 47 | -------------------------------------------------------------------------------- /vendor/lazy_static/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 The Rust Project Developers 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /vendor/lazy_static/README.md: -------------------------------------------------------------------------------- 1 | lazy-static.rs 2 | ============== 3 | 4 | A macro for declaring lazily evaluated statics in Rust. 5 | 6 | Using this macro, it is possible to have `static`s that require code to be 7 | executed at runtime in order to be initialized. 8 | This includes anything requiring heap allocations, like vectors or hash maps, 9 | as well as anything that requires non-const function calls to be computed. 10 | 11 | [![Travis-CI Status](https://travis-ci.com/rust-lang-nursery/lazy-static.rs.svg?branch=master)](https://travis-ci.com/rust-lang-nursery/lazy-static.rs) 12 | [![Latest version](https://img.shields.io/crates/v/lazy_static.svg)](https://crates.io/crates/lazy_static) 13 | [![Documentation](https://docs.rs/lazy_static/badge.svg)](https://docs.rs/lazy_static) 14 | [![License](https://img.shields.io/crates/l/lazy_static.svg)](https://github.com/rust-lang-nursery/lazy-static.rs#license) 15 | 16 | ## Minimum supported `rustc` 17 | 18 | `1.27.2+` 19 | 20 | This version is explicitly tested in CI and may only be bumped in new minor versions. Any changes to the supported minimum version will be called out in the release notes. 21 | 22 | 23 | # Getting Started 24 | 25 | [lazy-static.rs is available on crates.io](https://crates.io/crates/lazy_static). 26 | It is recommended to look there for the newest released version, as well as links to the newest builds of the docs. 27 | 28 | At the point of the last update of this README, the latest published version could be used like this: 29 | 30 | Add the following dependency to your Cargo manifest... 31 | 32 | ```toml 33 | [dependencies] 34 | lazy_static = "1.4.0" 35 | ``` 36 | 37 | ...and see the [docs](https://docs.rs/lazy_static) for how to use it. 38 | 39 | # Example 40 | 41 | ```rust 42 | #[macro_use] 43 | extern crate lazy_static; 44 | 45 | use std::collections::HashMap; 46 | 47 | lazy_static! { 48 | static ref HASHMAP: HashMap = { 49 | let mut m = HashMap::new(); 50 | m.insert(0, "foo"); 51 | m.insert(1, "bar"); 52 | m.insert(2, "baz"); 53 | m 54 | }; 55 | } 56 | 57 | fn main() { 58 | // First access to `HASHMAP` initializes it 59 | println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap()); 60 | 61 | // Any further access to `HASHMAP` just returns the computed value 62 | println!("The entry for `1` is \"{}\".", HASHMAP.get(&1).unwrap()); 63 | } 64 | ``` 65 | 66 | ## License 67 | 68 | Licensed under either of 69 | 70 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 71 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 72 | 73 | at your option. 74 | 75 | ### Contribution 76 | 77 | Unless you explicitly state otherwise, any contribution intentionally submitted 78 | for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any 79 | additional terms or conditions. 80 | -------------------------------------------------------------------------------- /vendor/lazy_static/src/core_lazy.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2016 lazy-static.rs Developers 2 | // 3 | // Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be 6 | // copied, modified, or distributed except according to those terms. 7 | 8 | extern crate spin; 9 | 10 | use self::spin::Once; 11 | 12 | pub struct Lazy(Once); 13 | 14 | impl Lazy { 15 | pub const INIT: Self = Lazy(Once::INIT); 16 | 17 | #[inline(always)] 18 | pub fn get(&'static self, builder: F) -> &T 19 | where F: FnOnce() -> T 20 | { 21 | self.0.call_once(builder) 22 | } 23 | } 24 | 25 | #[macro_export] 26 | #[doc(hidden)] 27 | macro_rules! __lazy_static_create { 28 | ($NAME:ident, $T:ty) => { 29 | static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::INIT; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/lazy_static/src/inline_lazy.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2016 lazy-static.rs Developers 2 | // 3 | // Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be 6 | // copied, modified, or distributed except according to those terms. 7 | 8 | extern crate core; 9 | extern crate std; 10 | 11 | use self::std::prelude::v1::*; 12 | use self::std::cell::Cell; 13 | use self::std::hint::unreachable_unchecked; 14 | use self::std::sync::Once; 15 | #[allow(deprecated)] 16 | pub use self::std::sync::ONCE_INIT; 17 | 18 | // FIXME: Replace Option with MaybeUninit (stable since 1.36.0) 19 | pub struct Lazy(Cell>, Once); 20 | 21 | impl Lazy { 22 | #[allow(deprecated)] 23 | pub const INIT: Self = Lazy(Cell::new(None), ONCE_INIT); 24 | 25 | #[inline(always)] 26 | pub fn get(&'static self, f: F) -> &T 27 | where 28 | F: FnOnce() -> T, 29 | { 30 | self.1.call_once(|| { 31 | self.0.set(Some(f())); 32 | }); 33 | 34 | // `self.0` is guaranteed to be `Some` by this point 35 | // The `Once` will catch and propagate panics 36 | unsafe { 37 | match *self.0.as_ptr() { 38 | Some(ref x) => x, 39 | None => { 40 | debug_assert!(false, "attempted to derefence an uninitialized lazy static. This is a bug"); 41 | 42 | unreachable_unchecked() 43 | }, 44 | } 45 | } 46 | } 47 | } 48 | 49 | unsafe impl Sync for Lazy {} 50 | 51 | #[macro_export] 52 | #[doc(hidden)] 53 | macro_rules! __lazy_static_create { 54 | ($NAME:ident, $T:ty) => { 55 | static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::INIT; 56 | }; 57 | } 58 | -------------------------------------------------------------------------------- /vendor/lazy_static/tests/no_std.rs: -------------------------------------------------------------------------------- 1 | #![cfg(feature="spin_no_std")] 2 | 3 | #![no_std] 4 | 5 | #[macro_use] 6 | extern crate lazy_static; 7 | 8 | lazy_static! { 9 | /// Documentation! 10 | pub static ref NUMBER: u32 = times_two(3); 11 | } 12 | 13 | fn times_two(n: u32) -> u32 { 14 | n * 2 15 | } 16 | 17 | #[test] 18 | fn test_basic() { 19 | assert_eq!(*NUMBER, 6); 20 | } 21 | -------------------------------------------------------------------------------- /vendor/proc-macro2/.cargo-checksum.json: -------------------------------------------------------------------------------- 1 | {"files":{"Cargo.toml":"5b5f09c7553bf08054fcab9ff40257d8e27866e9797ce7dcffa2f4be7d664bca","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"e1f9d4fc22cff2c049f166a403b41458632a94357890d31cf0e3ad83807fb430","build.rs":"74d918b5aaabeee4c557ba9e887562dac2bdcff7fe73d2d5a492889850f57b9f","src/detection.rs":"9d25d896889e65330858f2d6f6223c1b98cd1dad189813ad4161ff189fbda2b8","src/fallback.rs":"c161f65f18d7d19bcbd568f5c0bea1cfc1ce3bd9c66427b1fdb4944ad7966ce0","src/lib.rs":"8d85f264e70f5084baa468e792627d097b2f1ff6a01cd6227a2bab5c04f48983","src/marker.rs":"87fce2d0357f5b7998b6d9dfb064f4a0cbc9dabb19e33d4b514a446243ebe2e8","src/parse.rs":"b82101576fdc493793f040aa17c11267e2747964729df1f88c81fe413aed407e","src/wrapper.rs":"9b932595ff6534b1d54ed4917b1d7b63e748ac4786d5377bd6f3bc7da78c2f83","tests/comments.rs":"ea6cbe6f4c8852e6a0612893c7d4f2c144a2e6a134a6c3db641a320cbfc3c800","tests/features.rs":"a86deb8644992a4eb64d9fd493eff16f9cf9c5cb6ade3a634ce0c990cf87d559","tests/marker.rs":"652db9f25c69ffc65baa60cdca8f195aa2e254d4de0a9ddc85de4dc2470544b6","tests/test.rs":"597186c00ebf51191934c88ff970b5457ca0fb8e608bf896be1ebf8d74c17f4d","tests/test_fmt.rs":"745dfdc41d09c5308c221395eb43f2041f0a1413d2927a813bc2ad4554438fe2"},"package":"5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612"} -------------------------------------------------------------------------------- /vendor/proc-macro2/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies. 7 | # 8 | # If you are reading this file be aware that the original Cargo.toml 9 | # will likely look very different (and much more reasonable). 10 | # See Cargo.toml.orig for the original contents. 11 | 12 | [package] 13 | edition = "2018" 14 | name = "proc-macro2" 15 | version = "1.0.28" 16 | authors = ["Alex Crichton ", "David Tolnay "] 17 | description = "A substitute implementation of the compiler's `proc_macro` API to decouple\ntoken-based libraries from the procedural macro use case.\n" 18 | documentation = "https://docs.rs/proc-macro2" 19 | readme = "README.md" 20 | keywords = ["macros"] 21 | categories = ["development-tools::procedural-macro-helpers"] 22 | license = "MIT OR Apache-2.0" 23 | repository = "https://github.com/alexcrichton/proc-macro2" 24 | [package.metadata.docs.rs] 25 | rustc-args = ["--cfg", "procmacro2_semver_exempt"] 26 | rustdoc-args = ["--cfg", "procmacro2_semver_exempt", "--cfg", "doc_cfg"] 27 | targets = ["x86_64-unknown-linux-gnu"] 28 | 29 | [package.metadata.playground] 30 | features = ["span-locations"] 31 | [dependencies.unicode-xid] 32 | version = "0.2" 33 | [dev-dependencies.quote] 34 | version = "1.0" 35 | default_features = false 36 | 37 | [features] 38 | default = ["proc-macro"] 39 | nightly = [] 40 | proc-macro = [] 41 | span-locations = [] 42 | -------------------------------------------------------------------------------- /vendor/proc-macro2/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Alex Crichton 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /vendor/proc-macro2/src/detection.rs: -------------------------------------------------------------------------------- 1 | use std::panic::{self, PanicInfo}; 2 | use std::sync::atomic::*; 3 | use std::sync::Once; 4 | 5 | static WORKS: AtomicUsize = AtomicUsize::new(0); 6 | static INIT: Once = Once::new(); 7 | 8 | pub(crate) fn inside_proc_macro() -> bool { 9 | match WORKS.load(Ordering::SeqCst) { 10 | 1 => return false, 11 | 2 => return true, 12 | _ => {} 13 | } 14 | 15 | INIT.call_once(initialize); 16 | inside_proc_macro() 17 | } 18 | 19 | pub(crate) fn force_fallback() { 20 | WORKS.store(1, Ordering::SeqCst); 21 | } 22 | 23 | pub(crate) fn unforce_fallback() { 24 | initialize(); 25 | } 26 | 27 | // Swap in a null panic hook to avoid printing "thread panicked" to stderr, 28 | // then use catch_unwind to determine whether the compiler's proc_macro is 29 | // working. When proc-macro2 is used from outside of a procedural macro all 30 | // of the proc_macro crate's APIs currently panic. 31 | // 32 | // The Once is to prevent the possibility of this ordering: 33 | // 34 | // thread 1 calls take_hook, gets the user's original hook 35 | // thread 1 calls set_hook with the null hook 36 | // thread 2 calls take_hook, thinks null hook is the original hook 37 | // thread 2 calls set_hook with the null hook 38 | // thread 1 calls set_hook with the actual original hook 39 | // thread 2 calls set_hook with what it thinks is the original hook 40 | // 41 | // in which the user's hook has been lost. 42 | // 43 | // There is still a race condition where a panic in a different thread can 44 | // happen during the interval that the user's original panic hook is 45 | // unregistered such that their hook is incorrectly not called. This is 46 | // sufficiently unlikely and less bad than printing panic messages to stderr 47 | // on correct use of this crate. Maybe there is a libstd feature request 48 | // here. For now, if a user needs to guarantee that this failure mode does 49 | // not occur, they need to call e.g. `proc_macro2::Span::call_site()` from 50 | // the main thread before launching any other threads. 51 | fn initialize() { 52 | type PanicHook = dyn Fn(&PanicInfo) + Sync + Send + 'static; 53 | 54 | let null_hook: Box = Box::new(|_panic_info| { /* ignore */ }); 55 | let sanity_check = &*null_hook as *const PanicHook; 56 | let original_hook = panic::take_hook(); 57 | panic::set_hook(null_hook); 58 | 59 | let works = panic::catch_unwind(proc_macro::Span::call_site).is_ok(); 60 | WORKS.store(works as usize + 1, Ordering::SeqCst); 61 | 62 | let hopefully_null_hook = panic::take_hook(); 63 | panic::set_hook(original_hook); 64 | if sanity_check != &*hopefully_null_hook { 65 | panic!("observed race condition in proc_macro2::inside_proc_macro"); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vendor/proc-macro2/src/marker.rs: -------------------------------------------------------------------------------- 1 | use std::marker::PhantomData; 2 | use std::panic::{RefUnwindSafe, UnwindSafe}; 3 | use std::rc::Rc; 4 | 5 | // Zero sized marker with the correct set of autotrait impls we want all proc 6 | // macro types to have. 7 | pub(crate) type Marker = PhantomData; 8 | 9 | pub(crate) use self::value::*; 10 | 11 | mod value { 12 | pub(crate) use std::marker::PhantomData as Marker; 13 | } 14 | 15 | pub(crate) struct ProcMacroAutoTraits(Rc<()>); 16 | 17 | impl UnwindSafe for ProcMacroAutoTraits {} 18 | impl RefUnwindSafe for ProcMacroAutoTraits {} 19 | -------------------------------------------------------------------------------- /vendor/proc-macro2/tests/features.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | #[ignore] 3 | fn make_sure_no_proc_macro() { 4 | assert!( 5 | !cfg!(feature = "proc-macro"), 6 | "still compiled with proc_macro?" 7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /vendor/proc-macro2/tests/marker.rs: -------------------------------------------------------------------------------- 1 | use proc_macro2::*; 2 | 3 | macro_rules! assert_impl { 4 | ($ty:ident is $($marker:ident) and +) => { 5 | #[test] 6 | #[allow(non_snake_case)] 7 | fn $ty() { 8 | fn assert_implemented() {} 9 | assert_implemented::<$ty>(); 10 | } 11 | }; 12 | 13 | ($ty:ident is not $($marker:ident) or +) => { 14 | #[test] 15 | #[allow(non_snake_case)] 16 | fn $ty() { 17 | $( 18 | { 19 | // Implemented for types that implement $marker. 20 | trait IsNotImplemented { 21 | fn assert_not_implemented() {} 22 | } 23 | impl IsNotImplemented for T {} 24 | 25 | // Implemented for the type being tested. 26 | trait IsImplemented { 27 | fn assert_not_implemented() {} 28 | } 29 | impl IsImplemented for $ty {} 30 | 31 | // If $ty does not implement $marker, there is no ambiguity 32 | // in the following trait method call. 33 | <$ty>::assert_not_implemented(); 34 | } 35 | )+ 36 | } 37 | }; 38 | } 39 | 40 | assert_impl!(Delimiter is Send and Sync); 41 | assert_impl!(Spacing is Send and Sync); 42 | 43 | assert_impl!(Group is not Send or Sync); 44 | assert_impl!(Ident is not Send or Sync); 45 | assert_impl!(LexError is not Send or Sync); 46 | assert_impl!(Literal is not Send or Sync); 47 | assert_impl!(Punct is not Send or Sync); 48 | assert_impl!(Span is not Send or Sync); 49 | assert_impl!(TokenStream is not Send or Sync); 50 | assert_impl!(TokenTree is not Send or Sync); 51 | 52 | #[cfg(procmacro2_semver_exempt)] 53 | mod semver_exempt { 54 | use super::*; 55 | 56 | assert_impl!(LineColumn is Send and Sync); 57 | 58 | assert_impl!(SourceFile is not Send or Sync); 59 | } 60 | 61 | #[cfg(not(no_libprocmacro_unwind_safe))] 62 | mod unwind_safe { 63 | use super::*; 64 | use std::panic::{RefUnwindSafe, UnwindSafe}; 65 | 66 | macro_rules! assert_unwind_safe { 67 | ($($types:ident)*) => { 68 | $( 69 | assert_impl!($types is UnwindSafe and RefUnwindSafe); 70 | )* 71 | }; 72 | } 73 | 74 | assert_unwind_safe! { 75 | Delimiter 76 | Group 77 | Ident 78 | LexError 79 | Literal 80 | Punct 81 | Spacing 82 | Span 83 | TokenStream 84 | TokenTree 85 | } 86 | 87 | #[cfg(procmacro2_semver_exempt)] 88 | assert_unwind_safe! { 89 | LineColumn 90 | SourceFile 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /vendor/proc-macro2/tests/test_fmt.rs: -------------------------------------------------------------------------------- 1 | use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; 2 | use std::iter::{self, FromIterator}; 3 | 4 | #[test] 5 | fn test_fmt_group() { 6 | let ident = Ident::new("x", Span::call_site()); 7 | let inner = TokenStream::from_iter(iter::once(TokenTree::Ident(ident))); 8 | let parens_empty = Group::new(Delimiter::Parenthesis, TokenStream::new()); 9 | let parens_nonempty = Group::new(Delimiter::Parenthesis, inner.clone()); 10 | let brackets_empty = Group::new(Delimiter::Bracket, TokenStream::new()); 11 | let brackets_nonempty = Group::new(Delimiter::Bracket, inner.clone()); 12 | let braces_empty = Group::new(Delimiter::Brace, TokenStream::new()); 13 | let braces_nonempty = Group::new(Delimiter::Brace, inner.clone()); 14 | let none_empty = Group::new(Delimiter::None, TokenStream::new()); 15 | let none_nonempty = Group::new(Delimiter::None, inner.clone()); 16 | 17 | // Matches libproc_macro. 18 | assert_eq!("()", parens_empty.to_string()); 19 | assert_eq!("(x)", parens_nonempty.to_string()); 20 | assert_eq!("[]", brackets_empty.to_string()); 21 | assert_eq!("[x]", brackets_nonempty.to_string()); 22 | assert_eq!("{ }", braces_empty.to_string()); 23 | assert_eq!("{ x }", braces_nonempty.to_string()); 24 | assert_eq!("", none_empty.to_string()); 25 | assert_eq!("x", none_nonempty.to_string()); 26 | } 27 | -------------------------------------------------------------------------------- /vendor/quote/.cargo-checksum.json: -------------------------------------------------------------------------------- 1 | {"files":{"Cargo.toml":"d1e6bb8b4ac54b84f367a4e1b46e7dca3b1a744017d8f7fa2f4c11a8730e657a","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","README.md":"9209682116de84bb9cc7be6ccf44478b46b909c7857f9e186d90bcff522af864","src/ext.rs":"a9fed3a1a4c9d3f2de717ba808af99291b995db2cbf8067f4b6927c39cc62bc6","src/format.rs":"a9c3e3a333c6dacf6e330d02b4c726862e273df1c2c6be6da199049cd1e521db","src/ident_fragment.rs":"e66a63f6e9020f2639a71f120d627bc6cfd60081a6caf8a1d735b59ee2413d29","src/lib.rs":"2500b1955d139e5b467df046cda4f2837fb1edace838aa190020752ab79314c4","src/runtime.rs":"f2d1fa6084764d98f98b96344cf675886a79b46a845c592e604f96bbde9aca07","src/spanned.rs":"adc0ed742ad17327c375879472d435cea168c208c303f53eb93cb2c0f10f3650","src/to_tokens.rs":"e589c1643479a9003d4dd1d9fa63714042b106f1b16d8ea3903cfe2f73a020f5","tests/compiletest.rs":"0a52a44786aea1c299c695bf948b2ed2081e4cc344e5c2cadceab4eb03d0010d","tests/test.rs":"6eb200350fa78405d4fd920ecf71d226e258c61aa88f850750efa99e065f06d6","tests/ui/does-not-have-iter-interpolated-dup.rs":"ad13eea21d4cdd2ab6c082f633392e1ff20fb0d1af5f2177041e0bf7f30da695","tests/ui/does-not-have-iter-interpolated.rs":"83a5b3f240651adcbe4b6e51076d76d653ad439b37442cf4054f1fd3c073f3b7","tests/ui/does-not-have-iter-separated.rs":"fe413c48331d5e3a7ae5fef6a5892a90c72f610d54595879eb49d0a94154ba3f","tests/ui/does-not-have-iter.rs":"09dc9499d861b63cebb0848b855b78e2dc9497bfde37ba6339f3625ae009a62f","tests/ui/not-quotable.rs":"5759d0884943417609f28faadc70254a3e2fd3d9bd6ff7297a3fb70a77fafd8a","tests/ui/not-repeatable.rs":"a4b115c04e4e41049a05f5b69450503fbffeba031218b4189cb931839f7f9a9c","tests/ui/wrong-type-span.rs":"5f310cb7fde3ef51bad01e7f286d244e3b6e67396cd2ea7eab77275c9d902699"},"package":"c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"} -------------------------------------------------------------------------------- /vendor/quote/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies 7 | # 8 | # If you believe there's an error in this file please file an 9 | # issue against the rust-lang/cargo repository. If you're 10 | # editing this file be aware that the upstream Cargo.toml 11 | # will likely look very different (and much more reasonable) 12 | 13 | [package] 14 | edition = "2018" 15 | name = "quote" 16 | version = "1.0.9" 17 | authors = ["David Tolnay "] 18 | include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] 19 | description = "Quasi-quoting macro quote!(...)" 20 | documentation = "https://docs.rs/quote/" 21 | readme = "README.md" 22 | keywords = ["syn"] 23 | categories = ["development-tools::procedural-macro-helpers"] 24 | license = "MIT OR Apache-2.0" 25 | repository = "https://github.com/dtolnay/quote" 26 | [package.metadata.docs.rs] 27 | targets = ["x86_64-unknown-linux-gnu"] 28 | [dependencies.proc-macro2] 29 | version = "1.0.20" 30 | default-features = false 31 | [dev-dependencies.rustversion] 32 | version = "1.0" 33 | 34 | [dev-dependencies.trybuild] 35 | version = "1.0.19" 36 | features = ["diff"] 37 | 38 | [features] 39 | default = ["proc-macro"] 40 | proc-macro = ["proc-macro2/proc-macro"] 41 | -------------------------------------------------------------------------------- /vendor/quote/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 The Rust Project Developers 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /vendor/quote/src/ext.rs: -------------------------------------------------------------------------------- 1 | use super::ToTokens; 2 | 3 | use std::iter; 4 | 5 | use proc_macro2::{TokenStream, TokenTree}; 6 | 7 | /// TokenStream extension trait with methods for appending tokens. 8 | /// 9 | /// This trait is sealed and cannot be implemented outside of the `quote` crate. 10 | pub trait TokenStreamExt: private::Sealed { 11 | /// For use by `ToTokens` implementations. 12 | /// 13 | /// Appends the token specified to this list of tokens. 14 | fn append(&mut self, token: U) 15 | where 16 | U: Into; 17 | 18 | /// For use by `ToTokens` implementations. 19 | /// 20 | /// ``` 21 | /// # use quote::{quote, TokenStreamExt, ToTokens}; 22 | /// # use proc_macro2::TokenStream; 23 | /// # 24 | /// struct X; 25 | /// 26 | /// impl ToTokens for X { 27 | /// fn to_tokens(&self, tokens: &mut TokenStream) { 28 | /// tokens.append_all(&[true, false]); 29 | /// } 30 | /// } 31 | /// 32 | /// let tokens = quote!(#X); 33 | /// assert_eq!(tokens.to_string(), "true false"); 34 | /// ``` 35 | fn append_all(&mut self, iter: I) 36 | where 37 | I: IntoIterator, 38 | I::Item: ToTokens; 39 | 40 | /// For use by `ToTokens` implementations. 41 | /// 42 | /// Appends all of the items in the iterator `I`, separated by the tokens 43 | /// `U`. 44 | fn append_separated(&mut self, iter: I, op: U) 45 | where 46 | I: IntoIterator, 47 | I::Item: ToTokens, 48 | U: ToTokens; 49 | 50 | /// For use by `ToTokens` implementations. 51 | /// 52 | /// Appends all tokens in the iterator `I`, appending `U` after each 53 | /// element, including after the last element of the iterator. 54 | fn append_terminated(&mut self, iter: I, term: U) 55 | where 56 | I: IntoIterator, 57 | I::Item: ToTokens, 58 | U: ToTokens; 59 | } 60 | 61 | impl TokenStreamExt for TokenStream { 62 | fn append(&mut self, token: U) 63 | where 64 | U: Into, 65 | { 66 | self.extend(iter::once(token.into())); 67 | } 68 | 69 | fn append_all(&mut self, iter: I) 70 | where 71 | I: IntoIterator, 72 | I::Item: ToTokens, 73 | { 74 | for token in iter { 75 | token.to_tokens(self); 76 | } 77 | } 78 | 79 | fn append_separated(&mut self, iter: I, op: U) 80 | where 81 | I: IntoIterator, 82 | I::Item: ToTokens, 83 | U: ToTokens, 84 | { 85 | for (i, token) in iter.into_iter().enumerate() { 86 | if i > 0 { 87 | op.to_tokens(self); 88 | } 89 | token.to_tokens(self); 90 | } 91 | } 92 | 93 | fn append_terminated(&mut self, iter: I, term: U) 94 | where 95 | I: IntoIterator, 96 | I::Item: ToTokens, 97 | U: ToTokens, 98 | { 99 | for token in iter { 100 | token.to_tokens(self); 101 | term.to_tokens(self); 102 | } 103 | } 104 | } 105 | 106 | mod private { 107 | use proc_macro2::TokenStream; 108 | 109 | pub trait Sealed {} 110 | 111 | impl Sealed for TokenStream {} 112 | } 113 | -------------------------------------------------------------------------------- /vendor/quote/src/ident_fragment.rs: -------------------------------------------------------------------------------- 1 | use proc_macro2::{Ident, Span}; 2 | use std::borrow::Cow; 3 | use std::fmt; 4 | 5 | /// Specialized formatting trait used by `format_ident!`. 6 | /// 7 | /// [`Ident`] arguments formatted using this trait will have their `r#` prefix 8 | /// stripped, if present. 9 | /// 10 | /// See [`format_ident!`] for more information. 11 | pub trait IdentFragment { 12 | /// Format this value as an identifier fragment. 13 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result; 14 | 15 | /// Span associated with this `IdentFragment`. 16 | /// 17 | /// If non-`None`, may be inherited by formatted identifiers. 18 | fn span(&self) -> Option { 19 | None 20 | } 21 | } 22 | 23 | impl IdentFragment for &T { 24 | fn span(&self) -> Option { 25 | ::span(*self) 26 | } 27 | 28 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 29 | IdentFragment::fmt(*self, f) 30 | } 31 | } 32 | 33 | impl IdentFragment for &mut T { 34 | fn span(&self) -> Option { 35 | ::span(*self) 36 | } 37 | 38 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 39 | IdentFragment::fmt(*self, f) 40 | } 41 | } 42 | 43 | impl IdentFragment for Ident { 44 | fn span(&self) -> Option { 45 | Some(self.span()) 46 | } 47 | 48 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 49 | let id = self.to_string(); 50 | if id.starts_with("r#") { 51 | fmt::Display::fmt(&id[2..], f) 52 | } else { 53 | fmt::Display::fmt(&id[..], f) 54 | } 55 | } 56 | } 57 | 58 | impl IdentFragment for Cow<'_, T> 59 | where 60 | T: IdentFragment + ToOwned + ?Sized, 61 | { 62 | fn span(&self) -> Option { 63 | T::span(self) 64 | } 65 | 66 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 67 | T::fmt(self, f) 68 | } 69 | } 70 | 71 | // Limited set of types which this is implemented for, as we want to avoid types 72 | // which will often include non-identifier characters in their `Display` impl. 73 | macro_rules! ident_fragment_display { 74 | ($($T:ty),*) => { 75 | $( 76 | impl IdentFragment for $T { 77 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 78 | fmt::Display::fmt(self, f) 79 | } 80 | } 81 | )* 82 | } 83 | } 84 | 85 | ident_fragment_display!(bool, str, String, char); 86 | ident_fragment_display!(u8, u16, u32, u64, u128, usize); 87 | -------------------------------------------------------------------------------- /vendor/quote/src/spanned.rs: -------------------------------------------------------------------------------- 1 | use crate::ToTokens; 2 | use proc_macro2::{Span, TokenStream}; 3 | 4 | pub trait Spanned { 5 | fn __span(&self) -> Span; 6 | } 7 | 8 | impl Spanned for Span { 9 | fn __span(&self) -> Span { 10 | *self 11 | } 12 | } 13 | 14 | impl Spanned for T { 15 | fn __span(&self) -> Span { 16 | join_spans(self.into_token_stream()) 17 | } 18 | } 19 | 20 | fn join_spans(tokens: TokenStream) -> Span { 21 | let mut iter = tokens.into_iter().filter_map(|tt| { 22 | // FIXME: This shouldn't be required, since optimally spans should 23 | // never be invalid. This filter_map can probably be removed when 24 | // https://github.com/rust-lang/rust/issues/43081 is resolved. 25 | let span = tt.span(); 26 | let debug = format!("{:?}", span); 27 | if debug.ends_with("bytes(0..0)") { 28 | None 29 | } else { 30 | Some(span) 31 | } 32 | }); 33 | 34 | let first = match iter.next() { 35 | Some(span) => span, 36 | None => return Span::call_site(), 37 | }; 38 | 39 | iter.fold(None, |_prev, next| Some(next)) 40 | .and_then(|last| first.join(last)) 41 | .unwrap_or(first) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/quote/tests/compiletest.rs: -------------------------------------------------------------------------------- 1 | #[rustversion::attr(not(nightly), ignore)] 2 | #[test] 3 | fn ui() { 4 | let t = trybuild::TestCases::new(); 5 | t.compile_fail("tests/ui/*.rs"); 6 | } 7 | -------------------------------------------------------------------------------- /vendor/quote/tests/ui/does-not-have-iter-interpolated-dup.rs: -------------------------------------------------------------------------------- 1 | use quote::quote; 2 | 3 | fn main() { 4 | let nonrep = ""; 5 | 6 | // Without some protection against repetitions with no iterator somewhere 7 | // inside, this would loop infinitely. 8 | quote!(#(#nonrep #nonrep)*); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/quote/tests/ui/does-not-have-iter-interpolated.rs: -------------------------------------------------------------------------------- 1 | use quote::quote; 2 | 3 | fn main() { 4 | let nonrep = ""; 5 | 6 | // Without some protection against repetitions with no iterator somewhere 7 | // inside, this would loop infinitely. 8 | quote!(#(#nonrep)*); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/quote/tests/ui/does-not-have-iter-separated.rs: -------------------------------------------------------------------------------- 1 | use quote::quote; 2 | 3 | fn main() { 4 | quote!(#(a b),*); 5 | } 6 | -------------------------------------------------------------------------------- /vendor/quote/tests/ui/does-not-have-iter.rs: -------------------------------------------------------------------------------- 1 | use quote::quote; 2 | 3 | fn main() { 4 | quote!(#(a b)*); 5 | } 6 | -------------------------------------------------------------------------------- /vendor/quote/tests/ui/not-quotable.rs: -------------------------------------------------------------------------------- 1 | use quote::quote; 2 | use std::net::Ipv4Addr; 3 | 4 | fn main() { 5 | let ip = Ipv4Addr::LOCALHOST; 6 | let _ = quote! { #ip }; 7 | } 8 | -------------------------------------------------------------------------------- /vendor/quote/tests/ui/not-repeatable.rs: -------------------------------------------------------------------------------- 1 | use quote::quote; 2 | 3 | struct Ipv4Addr; 4 | 5 | fn main() { 6 | let ip = Ipv4Addr; 7 | let _ = quote! { #(#ip)* }; 8 | } 9 | -------------------------------------------------------------------------------- /vendor/quote/tests/ui/wrong-type-span.rs: -------------------------------------------------------------------------------- 1 | use quote::quote_spanned; 2 | 3 | fn main() { 4 | let span = ""; 5 | let x = 0; 6 | quote_spanned!(span=> #x); 7 | } 8 | -------------------------------------------------------------------------------- /vendor/static_assertions/.cargo-checksum.json: -------------------------------------------------------------------------------- 1 | {"files":{"CHANGELOG.md":"750f74f3b520672a81dd2ede5c097cfe972c0da181dd8fd010e7131a3526d4fd","Cargo.toml":"6531dbe3d557e427f9e3510e50cdf3de751a319eece11c9a937b35cfab8744c4","LICENSE-APACHE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","LICENSE-MIT":"ea084a2373ebc1f0902c09266e7bf25a05ab3814c1805bb017ffa7308f90c061","README.md":"88cc779ada8c6e1362c2d095c179284ec2755797729946ebccfe8264fcff0f8e","src/assert_cfg.rs":"ce9230bcc055d8df21ceefbed4233df5e73ecb832829ba23ac8d7f54ec457522","src/assert_eq_align.rs":"f09c4ec30e476446ab337a4a9ed950edf21c780a42ece7613f0ffc20225331ae","src/assert_eq_size.rs":"c06d2ff44e1f7af8a57b7c2fe5a9c69aa2a90d12cd41614c9d4f3ae551cdb64c","src/assert_fields.rs":"9c5baeac0215be557213eec9e80fc00de10a721d9b2c369fece743fcc6ccdc8e","src/assert_impl.rs":"fe5a2fffcbb78f60991bbc590481e74fd0d5f7ed8fa75718644599e1fae117ce","src/assert_obj_safe.rs":"88584809f3aa2dfce966b0adbeb6128191229465d653e57b68f968be001eff03","src/assert_trait.rs":"87b2d4dbd4334d9ace9880b81f3a1fbf91725c5e152b34a74c86457ca40ece30","src/assert_type.rs":"7cd942341efa7ed0b89b5e4fe1faa62bafb537ec6cf72ee6866115daee931885","src/const_assert.rs":"e0dcfe9016e34455f5efcb23500f716386d42b9fb09c6d08566d03dce8249e51","src/lib.rs":"4cbaaff38a6ac16631e774ab5a349056cbd2335ac570aeb46c5616eaf9700c3b"},"package":"a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"} -------------------------------------------------------------------------------- /vendor/static_assertions/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies 7 | # 8 | # If you believe there's an error in this file please file an 9 | # issue against the rust-lang/cargo repository. If you're 10 | # editing this file be aware that the upstream Cargo.toml 11 | # will likely look very different (and much more reasonable) 12 | 13 | [package] 14 | name = "static_assertions" 15 | version = "1.1.0" 16 | authors = ["Nikolai Vazquez"] 17 | include = ["Cargo.toml", "src/**/*.rs", "README.md", "CHANGELOG.md", "LICENSE*"] 18 | description = "Compile-time assertions to ensure that invariants are met." 19 | homepage = "https://github.com/nvzqz/static-assertions-rs" 20 | documentation = "https://docs.rs/static_assertions/" 21 | readme = "README.md" 22 | keywords = ["assert", "static", "testing"] 23 | categories = ["no-std", "rust-patterns", "development-tools::testing"] 24 | license = "MIT OR Apache-2.0" 25 | repository = "https://github.com/nvzqz/static-assertions-rs" 26 | 27 | [features] 28 | nightly = [] 29 | [badges.is-it-maintained-issue-resolution] 30 | repository = "nvzqz/static-assertions-rs" 31 | 32 | [badges.is-it-maintained-open-issues] 33 | repository = "nvzqz/static-assertions-rs" 34 | 35 | [badges.maintenance] 36 | status = "passively-maintained" 37 | 38 | [badges.travis-ci] 39 | repository = "nvzqz/static-assertions-rs" 40 | -------------------------------------------------------------------------------- /vendor/static_assertions/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Nikolai Vazquez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/static_assertions/src/assert_cfg.rs: -------------------------------------------------------------------------------- 1 | /// Asserts that a given configuration is set. 2 | /// 3 | /// # Examples 4 | /// 5 | /// A project will simply fail to compile if the given configuration is not set. 6 | /// 7 | /// ``` 8 | /// # #[macro_use] extern crate static_assertions; fn main() {} 9 | /// // We're not masochists 10 | /// # #[cfg(not(target_pointer_width = "16"))] // Just in case 11 | /// assert_cfg!(not(target_pointer_width = "16")); 12 | /// ``` 13 | /// 14 | /// If a project does not support a set of configurations, you may want to 15 | /// report why. There is the option of providing a compile error message string: 16 | /// 17 | /// ``` 18 | /// # #[macro_use] extern crate static_assertions; fn main() {} 19 | /// # #[cfg(any(unix, windows))] 20 | /// assert_cfg!(any(unix, windows), "There is only support for Unix or Windows"); 21 | /// 22 | /// // User needs to specify a database back-end 23 | /// # #[cfg(target_pointer_width = "0")] // Impossible 24 | /// assert_cfg!(all(not(all(feature = "mysql", feature = "mongodb")), 25 | /// any( feature = "mysql", feature = "mongodb")), 26 | /// "Must exclusively use MySQL or MongoDB as database back-end"); 27 | /// ``` 28 | /// 29 | /// Some configurations are impossible. For example, we can't be compiling for 30 | /// both macOS _and_ Windows simultaneously: 31 | /// 32 | /// ```compile_fail 33 | /// # #[macro_use] extern crate static_assertions; fn main() {} 34 | /// assert_cfg!(all(target_os = "macos", 35 | /// target_os = "windows"), 36 | /// "No, that's not how it works! ಠ_ಠ"); 37 | /// ``` 38 | #[macro_export] 39 | macro_rules! assert_cfg { 40 | () => {}; 41 | ($($cfg:meta)+, $msg:expr $(,)?) => { 42 | #[cfg(not($($cfg)+))] 43 | compile_error!($msg); 44 | }; 45 | ($($cfg:tt)*) => { 46 | #[cfg(not($($cfg)*))] 47 | compile_error!(concat!("Cfg does not pass: ", stringify!($($cfg)*))); 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /vendor/static_assertions/src/assert_eq_align.rs: -------------------------------------------------------------------------------- 1 | /// Asserts that types are equal in alignment. 2 | /// 3 | /// This is useful when ensuring that pointer arithmetic is done correctly, or 4 | /// when [FFI] requires a type to have the same alignment as some foreign type. 5 | /// 6 | /// # Examples 7 | /// 8 | /// A `usize` has the same alignment as any pointer type: 9 | /// 10 | /// ``` 11 | /// # #[macro_use] extern crate static_assertions; fn main() {} 12 | /// assert_eq_align!(usize, *const u8, *mut u8); 13 | /// ``` 14 | /// 15 | /// The following passes because `[i32; 4]` has the same alignment as `i32`: 16 | /// 17 | /// ``` 18 | /// # #[macro_use] extern crate static_assertions; fn main() {} 19 | /// assert_eq_align!([i32; 4], i32); 20 | /// ``` 21 | /// 22 | /// The following example fails to compile because `i32x4` explicitly has 4 23 | /// times the alignment as `[i32; 4]`: 24 | /// 25 | /// ```compile_fail 26 | /// # #[macro_use] extern crate static_assertions; fn main() {} 27 | /// # #[allow(non_camel_case_types)] 28 | /// #[repr(align(16))] 29 | /// struct i32x4([i32; 4]); 30 | /// 31 | /// assert_eq_align!(i32x4, [i32; 4]); 32 | /// ``` 33 | /// 34 | /// [FFI]: https://en.wikipedia.org/wiki/Foreign_function_interface 35 | #[macro_export] 36 | macro_rules! assert_eq_align { 37 | ($x:ty, $($xs:ty),+ $(,)?) => { 38 | const _: fn() = || { 39 | // Assigned instance must match the annotated type or else it will 40 | // fail to compile 41 | use $crate::_core::mem::align_of; 42 | $(let _: [(); align_of::<$x>()] = [(); align_of::<$xs>()];)+ 43 | }; 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /vendor/static_assertions/src/assert_fields.rs: -------------------------------------------------------------------------------- 1 | /// Asserts that the type has the given fields. 2 | /// 3 | /// # Examples 4 | /// 5 | /// One common use case is when types have fields defined multiple times as a 6 | /// result of `#[cfg]`. This can be an issue when exposing a public API. 7 | /// 8 | /// ``` 9 | /// # #[macro_use] extern crate static_assertions; 10 | /// pub struct Ty { 11 | /// #[cfg(windows)] 12 | /// pub val1: u8, 13 | /// #[cfg(not(windows))] 14 | /// pub val1: usize, 15 | /// 16 | /// #[cfg(unix)] 17 | /// pub val2: u32, 18 | /// #[cfg(not(unix))] 19 | /// pub val2: usize, 20 | /// } 21 | /// 22 | /// // Always have `val2` regardless of OS 23 | /// assert_fields!(Ty: val2); 24 | /// ``` 25 | /// 26 | /// This macro even works with `enum` variants: 27 | /// 28 | /// ``` 29 | /// # #[macro_use] extern crate static_assertions; fn main() {} 30 | /// enum Data { 31 | /// Val { 32 | /// id: i32, 33 | /// name: String, 34 | /// bytes: [u8; 128], 35 | /// }, 36 | /// Ptr(*const u8), 37 | /// } 38 | /// 39 | /// assert_fields!(Data::Val: id, bytes); 40 | /// ``` 41 | /// 42 | /// The following example fails to compile because [`Range`] does not have a field named `middle`: 43 | /// 44 | /// ```compile_fail 45 | /// # #[macro_use] extern crate static_assertions; fn main() {} 46 | /// use std::ops::Range; 47 | /// 48 | /// assert_fields!(Range: middle); 49 | /// ``` 50 | /// 51 | /// [`Range`]: https://doc.rust-lang.org/std/ops/struct.Range.html 52 | #[macro_export] 53 | macro_rules! assert_fields { 54 | ($t:ident::$v:ident: $($f:ident),+) => { 55 | #[allow(unknown_lints, unneeded_field_pattern)] 56 | const _: fn() = || { 57 | #[allow(dead_code, unreachable_patterns)] 58 | fn assert(value: $t) { 59 | match value { 60 | $($t::$v { $f: _, .. } => {},)+ 61 | _ => {} 62 | } 63 | } 64 | }; 65 | }; 66 | ($t:path: $($f:ident),+) => { 67 | #[allow(unknown_lints, unneeded_field_pattern)] 68 | const _: fn() = || { 69 | $(let $t { $f: _, .. };)+ 70 | }; 71 | }; 72 | } 73 | -------------------------------------------------------------------------------- /vendor/static_assertions/src/assert_obj_safe.rs: -------------------------------------------------------------------------------- 1 | // FIXME: Link below is required to render in index 2 | /// Asserts that the traits support dynamic dispatch 3 | /// ([object-safety](https://doc.rust-lang.org/book/ch17-02-trait-objects.html#object-safety-is-required-for-trait-objects)). 4 | /// 5 | /// This is useful for when changes are made to a trait that accidentally 6 | /// prevent it from being used as an [object]. Such a case would be adding a 7 | /// generic method and forgetting to add `where Self: Sized` after it. If left 8 | /// unnoticed, that mistake will affect crate users and break both forward and 9 | /// backward compatibility. 10 | /// 11 | /// # Examples 12 | /// 13 | /// When exposing a public API, it's important that traits that could previously 14 | /// use dynamic dispatch can still do so in future compatible crate versions. 15 | /// 16 | /// ``` 17 | /// # #[macro_use] extern crate static_assertions; fn main() {} 18 | /// trait MySafeTrait { 19 | /// fn foo(&self) -> u32; 20 | /// } 21 | /// 22 | /// assert_obj_safe!(std::fmt::Write, MySafeTrait); 23 | /// ``` 24 | /// 25 | /// Works with traits that are not in the calling module: 26 | /// 27 | /// ``` 28 | /// # #[macro_use] extern crate static_assertions; fn main() {} 29 | /// mod inner { 30 | /// pub trait BasicTrait { 31 | /// fn bar(&self); 32 | /// } 33 | /// assert_obj_safe!(BasicTrait); 34 | /// } 35 | /// 36 | /// assert_obj_safe!(inner::BasicTrait); 37 | /// ``` 38 | /// 39 | /// The following example fails to compile because raw pointers cannot be sent 40 | /// between threads safely: 41 | /// 42 | /// ```compile_fail 43 | /// # #[macro_use] extern crate static_assertions; fn main() {} 44 | /// assert_impl!(*const u8, Send); 45 | /// ``` 46 | /// 47 | /// The following example fails to compile because generics without 48 | /// `where Self: Sized` are not allowed in [object-safe][object] trait methods: 49 | /// 50 | /// ```compile_fail 51 | /// # #[macro_use] extern crate static_assertions; fn main() {} 52 | /// trait MyUnsafeTrait { 53 | /// fn baz(&self) -> T; 54 | /// } 55 | /// 56 | /// assert_obj_safe!(MyUnsafeTrait); 57 | /// ``` 58 | /// 59 | /// When we fix that, the previous code will compile: 60 | /// 61 | /// ``` 62 | /// # #[macro_use] extern crate static_assertions; fn main() {} 63 | /// trait MyUnsafeTrait { 64 | /// fn baz(&self) -> T where Self: Sized; 65 | /// } 66 | /// 67 | /// assert_obj_safe!(MyUnsafeTrait); 68 | /// ``` 69 | /// 70 | /// [object]: https://doc.rust-lang.org/book/ch17-02-trait-objects.html#object-safety-is-required-for-trait-objects 71 | #[macro_export] 72 | macro_rules! assert_obj_safe { 73 | ($($xs:path),+ $(,)?) => { 74 | $(const _: Option<&$xs> = None;)+ 75 | }; 76 | } 77 | -------------------------------------------------------------------------------- /vendor/syn/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies. 7 | # 8 | # If you are reading this file be aware that the original Cargo.toml 9 | # will likely look very different (and much more reasonable). 10 | # See Cargo.toml.orig for the original contents. 11 | 12 | [package] 13 | edition = "2018" 14 | name = "syn" 15 | version = "1.0.74" 16 | authors = ["David Tolnay "] 17 | include = ["/benches/**", "/build.rs", "/Cargo.toml", "/LICENSE-APACHE", "/LICENSE-MIT", "/README.md", "/src/**", "/tests/**"] 18 | description = "Parser for Rust source code" 19 | documentation = "https://docs.rs/syn" 20 | readme = "README.md" 21 | categories = ["development-tools::procedural-macro-helpers"] 22 | license = "MIT OR Apache-2.0" 23 | repository = "https://github.com/dtolnay/syn" 24 | [package.metadata.docs.rs] 25 | all-features = true 26 | rustdoc-args = ["--cfg", "doc_cfg"] 27 | targets = ["x86_64-unknown-linux-gnu"] 28 | 29 | [package.metadata.playground] 30 | features = ["full", "visit", "visit-mut", "fold", "extra-traits"] 31 | 32 | [[bench]] 33 | name = "rust" 34 | harness = false 35 | required-features = ["full", "parsing"] 36 | 37 | [[bench]] 38 | name = "file" 39 | required-features = ["full", "parsing"] 40 | [dependencies.proc-macro2] 41 | version = "1.0.26" 42 | default-features = false 43 | 44 | [dependencies.quote] 45 | version = "1.0" 46 | optional = true 47 | default-features = false 48 | 49 | [dependencies.unicode-xid] 50 | version = "0.2" 51 | [dev-dependencies.anyhow] 52 | version = "1.0" 53 | 54 | [dev-dependencies.flate2] 55 | version = "1.0" 56 | 57 | [dev-dependencies.insta] 58 | version = "1.0" 59 | 60 | [dev-dependencies.rayon] 61 | version = "1.0" 62 | 63 | [dev-dependencies.ref-cast] 64 | version = "1.0" 65 | 66 | [dev-dependencies.regex] 67 | version = "1.0" 68 | 69 | [dev-dependencies.reqwest] 70 | version = "0.10" 71 | features = ["blocking"] 72 | 73 | [dev-dependencies.syn-test-suite] 74 | version = "0" 75 | 76 | [dev-dependencies.tar] 77 | version = "0.4.16" 78 | 79 | [dev-dependencies.termcolor] 80 | version = "1.0" 81 | 82 | [dev-dependencies.walkdir] 83 | version = "2.1" 84 | 85 | [features] 86 | clone-impls = [] 87 | default = ["derive", "parsing", "printing", "clone-impls", "proc-macro"] 88 | derive = [] 89 | extra-traits = [] 90 | fold = [] 91 | full = [] 92 | parsing = [] 93 | printing = ["quote"] 94 | proc-macro = ["proc-macro2/proc-macro", "quote/proc-macro"] 95 | test = ["syn-test-suite/all-features"] 96 | visit = [] 97 | visit-mut = [] 98 | -------------------------------------------------------------------------------- /vendor/syn/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/syn/benches/file.rs: -------------------------------------------------------------------------------- 1 | // $ cargo bench --features full --bench file 2 | 3 | #![feature(rustc_private, test)] 4 | #![recursion_limit = "1024"] 5 | 6 | extern crate test; 7 | 8 | #[macro_use] 9 | #[path = "../tests/macros/mod.rs"] 10 | mod macros; 11 | 12 | #[path = "../tests/common/mod.rs"] 13 | mod common; 14 | #[path = "../tests/repo/mod.rs"] 15 | pub mod repo; 16 | 17 | use proc_macro2::TokenStream; 18 | use std::fs; 19 | use std::str::FromStr; 20 | use test::Bencher; 21 | 22 | const FILE: &str = "tests/rust/library/core/src/str/mod.rs"; 23 | 24 | #[bench] 25 | fn parse_file(b: &mut Bencher) { 26 | repo::clone_rust(); 27 | let content = fs::read_to_string(FILE).unwrap(); 28 | let tokens = TokenStream::from_str(&content).unwrap(); 29 | b.iter(|| syn::parse2::(tokens.clone())); 30 | } 31 | -------------------------------------------------------------------------------- /vendor/syn/build.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::process::Command; 3 | use std::str; 4 | 5 | // The rustc-cfg strings below are *not* public API. Please let us know by 6 | // opening a GitHub issue if your build environment requires some way to enable 7 | // these cfgs other than by executing our build script. 8 | fn main() { 9 | let compiler = match rustc_version() { 10 | Some(compiler) => compiler, 11 | None => return, 12 | }; 13 | 14 | if compiler.minor < 36 { 15 | println!("cargo:rustc-cfg=syn_omit_await_from_token_macro"); 16 | } 17 | 18 | if compiler.minor < 39 { 19 | println!("cargo:rustc-cfg=syn_no_const_vec_new"); 20 | } 21 | 22 | if !compiler.nightly { 23 | println!("cargo:rustc-cfg=syn_disable_nightly_tests"); 24 | } 25 | } 26 | 27 | struct Compiler { 28 | minor: u32, 29 | nightly: bool, 30 | } 31 | 32 | fn rustc_version() -> Option { 33 | let rustc = env::var_os("RUSTC")?; 34 | let output = Command::new(rustc).arg("--version").output().ok()?; 35 | let version = str::from_utf8(&output.stdout).ok()?; 36 | let mut pieces = version.split('.'); 37 | if pieces.next() != Some("rustc 1") { 38 | return None; 39 | } 40 | let minor = pieces.next()?.parse().ok()?; 41 | let nightly = version.contains("nightly"); 42 | Some(Compiler { minor, nightly }) 43 | } 44 | -------------------------------------------------------------------------------- /vendor/syn/src/await.rs: -------------------------------------------------------------------------------- 1 | // See include!("await.rs") in token.rs. 2 | export_token_macro! {[await]} 3 | -------------------------------------------------------------------------------- /vendor/syn/src/bigint.rs: -------------------------------------------------------------------------------- 1 | use std::ops::{AddAssign, MulAssign}; 2 | 3 | // For implementing base10_digits() accessor on LitInt. 4 | pub struct BigInt { 5 | digits: Vec, 6 | } 7 | 8 | impl BigInt { 9 | pub fn new() -> Self { 10 | BigInt { digits: Vec::new() } 11 | } 12 | 13 | pub fn to_string(&self) -> String { 14 | let mut repr = String::with_capacity(self.digits.len()); 15 | 16 | let mut has_nonzero = false; 17 | for digit in self.digits.iter().rev() { 18 | has_nonzero |= *digit != 0; 19 | if has_nonzero { 20 | repr.push((*digit + b'0') as char); 21 | } 22 | } 23 | 24 | if repr.is_empty() { 25 | repr.push('0'); 26 | } 27 | 28 | repr 29 | } 30 | 31 | fn reserve_two_digits(&mut self) { 32 | let len = self.digits.len(); 33 | let desired = 34 | len + !self.digits.ends_with(&[0, 0]) as usize + !self.digits.ends_with(&[0]) as usize; 35 | self.digits.resize(desired, 0); 36 | } 37 | } 38 | 39 | impl AddAssign for BigInt { 40 | // Assumes increment <16. 41 | fn add_assign(&mut self, mut increment: u8) { 42 | self.reserve_two_digits(); 43 | 44 | let mut i = 0; 45 | while increment > 0 { 46 | let sum = self.digits[i] + increment; 47 | self.digits[i] = sum % 10; 48 | increment = sum / 10; 49 | i += 1; 50 | } 51 | } 52 | } 53 | 54 | impl MulAssign for BigInt { 55 | // Assumes base <=16. 56 | fn mul_assign(&mut self, base: u8) { 57 | self.reserve_two_digits(); 58 | 59 | let mut carry = 0; 60 | for digit in &mut self.digits { 61 | let prod = *digit * base + carry; 62 | *digit = prod % 10; 63 | carry = prod / 10; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /vendor/syn/src/export.rs: -------------------------------------------------------------------------------- 1 | pub use std::clone::Clone; 2 | pub use std::cmp::{Eq, PartialEq}; 3 | pub use std::convert::From; 4 | pub use std::default::Default; 5 | pub use std::fmt::{self, Debug, Formatter}; 6 | pub use std::hash::{Hash, Hasher}; 7 | pub use std::marker::Copy; 8 | pub use std::option::Option::{None, Some}; 9 | pub use std::result::Result::{Err, Ok}; 10 | 11 | #[cfg(feature = "printing")] 12 | pub extern crate quote; 13 | 14 | pub use proc_macro2::{Span, TokenStream as TokenStream2}; 15 | 16 | pub use crate::span::IntoSpans; 17 | 18 | #[cfg(all( 19 | not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))), 20 | feature = "proc-macro" 21 | ))] 22 | pub use proc_macro::TokenStream; 23 | 24 | #[cfg(feature = "printing")] 25 | pub use quote::{ToTokens, TokenStreamExt}; 26 | 27 | #[allow(non_camel_case_types)] 28 | pub type bool = help::Bool; 29 | #[allow(non_camel_case_types)] 30 | pub type str = help::Str; 31 | 32 | mod help { 33 | pub type Bool = bool; 34 | pub type Str = str; 35 | } 36 | 37 | pub struct private(pub(crate) ()); 38 | -------------------------------------------------------------------------------- /vendor/syn/src/print.rs: -------------------------------------------------------------------------------- 1 | use proc_macro2::TokenStream; 2 | use quote::ToTokens; 3 | 4 | pub struct TokensOrDefault<'a, T: 'a>(pub &'a Option); 5 | 6 | impl<'a, T> ToTokens for TokensOrDefault<'a, T> 7 | where 8 | T: ToTokens + Default, 9 | { 10 | fn to_tokens(&self, tokens: &mut TokenStream) { 11 | match self.0 { 12 | Some(t) => t.to_tokens(tokens), 13 | None => T::default().to_tokens(tokens), 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vendor/syn/src/reserved.rs: -------------------------------------------------------------------------------- 1 | // Type for a syntax tree node that is reserved for future use. 2 | // 3 | // For example ExprReference contains a field `raw` of type Reserved. If `&raw 4 | // place` syntax becomes a thing as per https://github.com/rust-lang/rfcs/pull/2582, 5 | // we can backward compatibly change `raw`'s type to Option without 6 | // the possibility of breaking any code. 7 | 8 | use proc_macro2::Span; 9 | use std::marker::PhantomData; 10 | 11 | #[cfg(feature = "extra-traits")] 12 | use std::fmt::{self, Debug}; 13 | 14 | ast_struct! { 15 | pub struct Reserved { 16 | _private: PhantomData, 17 | } 18 | } 19 | 20 | impl Default for Reserved { 21 | fn default() -> Self { 22 | Reserved { 23 | _private: PhantomData, 24 | } 25 | } 26 | } 27 | 28 | #[cfg(feature = "clone-impls")] 29 | #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] 30 | impl Clone for Reserved { 31 | fn clone(&self) -> Self { 32 | Reserved { 33 | _private: self._private, 34 | } 35 | } 36 | } 37 | 38 | #[cfg(feature = "extra-traits")] 39 | #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] 40 | impl Debug for Reserved { 41 | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 42 | formatter.debug_struct("Reserved").finish() 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/syn/src/sealed.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "parsing")] 2 | pub mod lookahead { 3 | pub trait Sealed: Copy {} 4 | } 5 | -------------------------------------------------------------------------------- /vendor/syn/src/span.rs: -------------------------------------------------------------------------------- 1 | use proc_macro2::Span; 2 | 3 | pub trait IntoSpans { 4 | fn into_spans(self) -> S; 5 | } 6 | 7 | impl IntoSpans<[Span; 1]> for Span { 8 | fn into_spans(self) -> [Span; 1] { 9 | [self] 10 | } 11 | } 12 | 13 | impl IntoSpans<[Span; 2]> for Span { 14 | fn into_spans(self) -> [Span; 2] { 15 | [self, self] 16 | } 17 | } 18 | 19 | impl IntoSpans<[Span; 3]> for Span { 20 | fn into_spans(self) -> [Span; 3] { 21 | [self, self, self] 22 | } 23 | } 24 | 25 | impl IntoSpans<[Span; 1]> for [Span; 1] { 26 | fn into_spans(self) -> [Span; 1] { 27 | self 28 | } 29 | } 30 | 31 | impl IntoSpans<[Span; 2]> for [Span; 2] { 32 | fn into_spans(self) -> [Span; 2] { 33 | self 34 | } 35 | } 36 | 37 | impl IntoSpans<[Span; 3]> for [Span; 3] { 38 | fn into_spans(self) -> [Span; 3] { 39 | self 40 | } 41 | } 42 | 43 | #[cfg(feature = "parsing")] 44 | pub trait FromSpans: Sized { 45 | fn from_spans(spans: &[Span]) -> Self; 46 | } 47 | 48 | #[cfg(feature = "parsing")] 49 | impl FromSpans for [Span; 1] { 50 | fn from_spans(spans: &[Span]) -> Self { 51 | [spans[0]] 52 | } 53 | } 54 | 55 | #[cfg(feature = "parsing")] 56 | impl FromSpans for [Span; 2] { 57 | fn from_spans(spans: &[Span]) -> Self { 58 | [spans[0], spans[1]] 59 | } 60 | } 61 | 62 | #[cfg(feature = "parsing")] 63 | impl FromSpans for [Span; 3] { 64 | fn from_spans(spans: &[Span]) -> Self { 65 | [spans[0], spans[1], spans[2]] 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vendor/syn/src/thread.rs: -------------------------------------------------------------------------------- 1 | use std::fmt::{self, Debug}; 2 | use std::thread::{self, ThreadId}; 3 | 4 | /// ThreadBound is a Sync-maker and Send-maker that allows accessing a value 5 | /// of type T only from the original thread on which the ThreadBound was 6 | /// constructed. 7 | pub struct ThreadBound { 8 | value: T, 9 | thread_id: ThreadId, 10 | } 11 | 12 | unsafe impl Sync for ThreadBound {} 13 | 14 | // Send bound requires Copy, as otherwise Drop could run in the wrong place. 15 | unsafe impl Send for ThreadBound {} 16 | 17 | impl ThreadBound { 18 | pub fn new(value: T) -> Self { 19 | ThreadBound { 20 | value, 21 | thread_id: thread::current().id(), 22 | } 23 | } 24 | 25 | pub fn get(&self) -> Option<&T> { 26 | if thread::current().id() == self.thread_id { 27 | Some(&self.value) 28 | } else { 29 | None 30 | } 31 | } 32 | } 33 | 34 | impl Debug for ThreadBound { 35 | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 36 | match self.get() { 37 | Some(value) => Debug::fmt(value, formatter), 38 | None => formatter.write_str("unknown"), 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/syn/src/verbatim.rs: -------------------------------------------------------------------------------- 1 | use crate::parse::{ParseBuffer, ParseStream}; 2 | use proc_macro2::TokenStream; 3 | use std::iter; 4 | 5 | pub fn between<'a>(begin: ParseBuffer<'a>, end: ParseStream<'a>) -> TokenStream { 6 | let end = end.cursor(); 7 | let mut cursor = begin.cursor(); 8 | let mut tokens = TokenStream::new(); 9 | while cursor != end { 10 | let (tt, next) = cursor.token_tree().unwrap(); 11 | tokens.extend(iter::once(tt)); 12 | cursor = next; 13 | } 14 | tokens 15 | } 16 | -------------------------------------------------------------------------------- /vendor/syn/src/whitespace.rs: -------------------------------------------------------------------------------- 1 | pub fn skip(mut s: &str) -> &str { 2 | 'skip: while !s.is_empty() { 3 | let byte = s.as_bytes()[0]; 4 | if byte == b'/' { 5 | if s.starts_with("//") 6 | && (!s.starts_with("///") || s.starts_with("////")) 7 | && !s.starts_with("//!") 8 | { 9 | if let Some(i) = s.find('\n') { 10 | s = &s[i + 1..]; 11 | continue; 12 | } else { 13 | return ""; 14 | } 15 | } else if s.starts_with("/**/") { 16 | s = &s[4..]; 17 | continue; 18 | } else if s.starts_with("/*") 19 | && (!s.starts_with("/**") || s.starts_with("/***")) 20 | && !s.starts_with("/*!") 21 | { 22 | let mut depth = 0; 23 | let bytes = s.as_bytes(); 24 | let mut i = 0; 25 | let upper = bytes.len() - 1; 26 | while i < upper { 27 | if bytes[i] == b'/' && bytes[i + 1] == b'*' { 28 | depth += 1; 29 | i += 1; // eat '*' 30 | } else if bytes[i] == b'*' && bytes[i + 1] == b'/' { 31 | depth -= 1; 32 | if depth == 0 { 33 | s = &s[i + 2..]; 34 | continue 'skip; 35 | } 36 | i += 1; // eat '/' 37 | } 38 | i += 1; 39 | } 40 | return s; 41 | } 42 | } 43 | match byte { 44 | b' ' | 0x09..=0x0d => { 45 | s = &s[1..]; 46 | continue; 47 | } 48 | b if b <= 0x7f => {} 49 | _ => { 50 | let ch = s.chars().next().unwrap(); 51 | if is_whitespace(ch) { 52 | s = &s[ch.len_utf8()..]; 53 | continue; 54 | } 55 | } 56 | } 57 | return s; 58 | } 59 | s 60 | } 61 | 62 | fn is_whitespace(ch: char) -> bool { 63 | // Rust treats left-to-right mark and right-to-left mark as whitespace 64 | ch.is_whitespace() || ch == '\u{200e}' || ch == '\u{200f}' 65 | } 66 | -------------------------------------------------------------------------------- /vendor/syn/tests/.gitignore: -------------------------------------------------------------------------------- 1 | /*.pending-snap 2 | -------------------------------------------------------------------------------- /vendor/syn/tests/common/mod.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | 3 | use rayon::ThreadPoolBuilder; 4 | use std::env; 5 | 6 | pub mod eq; 7 | pub mod parse; 8 | 9 | /// Read the `ABORT_AFTER_FAILURE` environment variable, and parse it. 10 | pub fn abort_after() -> usize { 11 | match env::var("ABORT_AFTER_FAILURE") { 12 | Ok(s) => s.parse().expect("failed to parse ABORT_AFTER_FAILURE"), 13 | Err(_) => usize::max_value(), 14 | } 15 | } 16 | 17 | /// Configure Rayon threadpool. 18 | pub fn rayon_init() { 19 | let stack_size = match env::var("RUST_MIN_STACK") { 20 | Ok(s) => s.parse().expect("failed to parse RUST_MIN_STACK"), 21 | Err(_) => 20 * 1024 * 1024, 22 | }; 23 | ThreadPoolBuilder::new() 24 | .stack_size(stack_size) 25 | .build_global() 26 | .unwrap(); 27 | } 28 | -------------------------------------------------------------------------------- /vendor/syn/tests/common/parse.rs: -------------------------------------------------------------------------------- 1 | extern crate rustc_ast; 2 | extern crate rustc_expand; 3 | extern crate rustc_parse as parse; 4 | extern crate rustc_session; 5 | extern crate rustc_span; 6 | 7 | use rustc_ast::ast; 8 | use rustc_ast::ptr::P; 9 | use rustc_session::parse::ParseSess; 10 | use rustc_span::source_map::FilePathMapping; 11 | use rustc_span::FileName; 12 | use std::panic; 13 | 14 | pub fn librustc_expr(input: &str) -> Option> { 15 | match panic::catch_unwind(|| { 16 | let sess = ParseSess::new(FilePathMapping::empty()); 17 | let e = parse::new_parser_from_source_str( 18 | &sess, 19 | FileName::Custom("test_precedence".to_string()), 20 | input.to_string(), 21 | ) 22 | .parse_expr(); 23 | match e { 24 | Ok(expr) => Some(expr), 25 | Err(mut diagnostic) => { 26 | diagnostic.emit(); 27 | None 28 | } 29 | } 30 | }) { 31 | Ok(Some(e)) => Some(e), 32 | Ok(None) => None, 33 | Err(_) => { 34 | errorf!("librustc panicked\n"); 35 | None 36 | } 37 | } 38 | } 39 | 40 | pub fn syn_expr(input: &str) -> Option { 41 | match syn::parse_str(input) { 42 | Ok(e) => Some(e), 43 | Err(msg) => { 44 | errorf!("syn failed to parse\n{:?}\n", msg); 45 | None 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vendor/syn/tests/macros/mod.rs: -------------------------------------------------------------------------------- 1 | #[path = "../debug/mod.rs"] 2 | pub mod debug; 3 | 4 | use syn::parse::{Parse, Result}; 5 | 6 | #[macro_export] 7 | macro_rules! errorf { 8 | ($($tt:tt)*) => {{ 9 | use ::std::io::Write; 10 | let stderr = ::std::io::stderr(); 11 | write!(stderr.lock(), $($tt)*).unwrap(); 12 | }}; 13 | } 14 | 15 | #[macro_export] 16 | macro_rules! punctuated { 17 | ($($e:expr,)+) => {{ 18 | let mut seq = ::syn::punctuated::Punctuated::new(); 19 | $( 20 | seq.push($e); 21 | )+ 22 | seq 23 | }}; 24 | 25 | ($($e:expr),+) => { 26 | punctuated!($($e,)+) 27 | }; 28 | } 29 | 30 | #[macro_export] 31 | macro_rules! snapshot { 32 | ($($args:tt)*) => { 33 | snapshot_impl!(() $($args)*) 34 | }; 35 | } 36 | 37 | #[macro_export] 38 | macro_rules! snapshot_impl { 39 | (($expr:ident) as $t:ty, @$snapshot:literal) => { 40 | let $expr = crate::macros::Tokens::parse::<$t>($expr).unwrap(); 41 | let debug = crate::macros::debug::Lite(&$expr); 42 | insta::assert_debug_snapshot!(debug, @$snapshot); 43 | }; 44 | (($($expr:tt)*) as $t:ty, @$snapshot:literal) => {{ 45 | let syntax_tree = crate::macros::Tokens::parse::<$t>($($expr)*).unwrap(); 46 | let debug = crate::macros::debug::Lite(&syntax_tree); 47 | insta::assert_debug_snapshot!(debug, @$snapshot); 48 | syntax_tree 49 | }}; 50 | (($($expr:tt)*) , @$snapshot:literal) => {{ 51 | let syntax_tree = $($expr)*; 52 | let debug = crate::macros::debug::Lite(&syntax_tree); 53 | insta::assert_debug_snapshot!(debug, @$snapshot); 54 | syntax_tree 55 | }}; 56 | (($($expr:tt)*) $next:tt $($rest:tt)*) => { 57 | snapshot_impl!(($($expr)* $next) $($rest)*) 58 | }; 59 | } 60 | 61 | pub trait Tokens { 62 | fn parse(self) -> Result; 63 | } 64 | 65 | impl<'a> Tokens for &'a str { 66 | fn parse(self) -> Result { 67 | syn::parse_str(self) 68 | } 69 | } 70 | 71 | impl Tokens for proc_macro2::TokenStream { 72 | fn parse(self) -> Result { 73 | syn::parse2(self) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /vendor/syn/tests/repo/progress.rs: -------------------------------------------------------------------------------- 1 | use std::io::{Read, Result}; 2 | use std::time::{Duration, Instant}; 3 | 4 | pub struct Progress { 5 | bytes: usize, 6 | tick: Instant, 7 | stream: R, 8 | } 9 | 10 | impl Progress { 11 | pub fn new(stream: R) -> Self { 12 | Progress { 13 | bytes: 0, 14 | tick: Instant::now() + Duration::from_millis(2000), 15 | stream, 16 | } 17 | } 18 | } 19 | 20 | impl Read for Progress { 21 | fn read(&mut self, buf: &mut [u8]) -> Result { 22 | let num = self.stream.read(buf)?; 23 | self.bytes += num; 24 | let now = Instant::now(); 25 | if now > self.tick { 26 | self.tick = now + Duration::from_millis(500); 27 | errorf!("downloading... {} bytes\n", self.bytes); 28 | } 29 | Ok(num) 30 | } 31 | } 32 | 33 | impl Drop for Progress { 34 | fn drop(&mut self) { 35 | errorf!("done ({} bytes)\n", self.bytes); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_asyncness.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | mod macros; 3 | 4 | use syn::{Expr, Item}; 5 | 6 | #[test] 7 | fn test_async_fn() { 8 | let input = "async fn process() {}"; 9 | 10 | snapshot!(input as Item, @r###" 11 | Item::Fn { 12 | vis: Inherited, 13 | sig: Signature { 14 | asyncness: Some, 15 | ident: "process", 16 | generics: Generics, 17 | output: Default, 18 | }, 19 | block: Block, 20 | } 21 | "###); 22 | } 23 | 24 | #[test] 25 | fn test_async_closure() { 26 | let input = "async || {}"; 27 | 28 | snapshot!(input as Expr, @r###" 29 | Expr::Closure { 30 | asyncness: Some, 31 | output: Default, 32 | body: Expr::Block { 33 | block: Block, 34 | }, 35 | } 36 | "###); 37 | } 38 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_grouping.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | mod macros; 3 | 4 | use proc_macro2::{Delimiter, Group, Literal, Punct, Spacing, TokenStream, TokenTree}; 5 | use std::iter::FromIterator; 6 | use syn::Expr; 7 | 8 | #[test] 9 | fn test_grouping() { 10 | let tokens: TokenStream = TokenStream::from_iter(vec![ 11 | TokenTree::Literal(Literal::i32_suffixed(1)), 12 | TokenTree::Punct(Punct::new('+', Spacing::Alone)), 13 | TokenTree::Group(Group::new( 14 | Delimiter::None, 15 | TokenStream::from_iter(vec![ 16 | TokenTree::Literal(Literal::i32_suffixed(2)), 17 | TokenTree::Punct(Punct::new('+', Spacing::Alone)), 18 | TokenTree::Literal(Literal::i32_suffixed(3)), 19 | ]), 20 | )), 21 | TokenTree::Punct(Punct::new('*', Spacing::Alone)), 22 | TokenTree::Literal(Literal::i32_suffixed(4)), 23 | ]); 24 | 25 | assert_eq!(tokens.to_string(), "1i32 + 2i32 + 3i32 * 4i32"); 26 | 27 | snapshot!(tokens as Expr, @r###" 28 | Expr::Binary { 29 | left: Expr::Lit { 30 | lit: 1i32, 31 | }, 32 | op: Add, 33 | right: Expr::Binary { 34 | left: Expr::Group { 35 | expr: Expr::Binary { 36 | left: Expr::Lit { 37 | lit: 2i32, 38 | }, 39 | op: Add, 40 | right: Expr::Lit { 41 | lit: 3i32, 42 | }, 43 | }, 44 | }, 45 | op: Mul, 46 | right: Expr::Lit { 47 | lit: 4i32, 48 | }, 49 | }, 50 | } 51 | "###); 52 | } 53 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_ident.rs: -------------------------------------------------------------------------------- 1 | use proc_macro2::{Ident, Span, TokenStream}; 2 | use std::str::FromStr; 3 | use syn::Result; 4 | 5 | fn parse(s: &str) -> Result { 6 | syn::parse2(TokenStream::from_str(s).unwrap()) 7 | } 8 | 9 | fn new(s: &str) -> Ident { 10 | Ident::new(s, Span::call_site()) 11 | } 12 | 13 | #[test] 14 | fn ident_parse() { 15 | parse("String").unwrap(); 16 | } 17 | 18 | #[test] 19 | fn ident_parse_keyword() { 20 | parse("abstract").unwrap_err(); 21 | } 22 | 23 | #[test] 24 | fn ident_parse_empty() { 25 | parse("").unwrap_err(); 26 | } 27 | 28 | #[test] 29 | fn ident_parse_lifetime() { 30 | parse("'static").unwrap_err(); 31 | } 32 | 33 | #[test] 34 | fn ident_parse_underscore() { 35 | parse("_").unwrap_err(); 36 | } 37 | 38 | #[test] 39 | fn ident_parse_number() { 40 | parse("255").unwrap_err(); 41 | } 42 | 43 | #[test] 44 | fn ident_parse_invalid() { 45 | parse("a#").unwrap_err(); 46 | } 47 | 48 | #[test] 49 | fn ident_new() { 50 | new("String"); 51 | } 52 | 53 | #[test] 54 | fn ident_new_keyword() { 55 | new("abstract"); 56 | } 57 | 58 | #[test] 59 | #[should_panic(expected = "use Option")] 60 | fn ident_new_empty() { 61 | new(""); 62 | } 63 | 64 | #[test] 65 | #[should_panic(expected = "not a valid Ident")] 66 | fn ident_new_lifetime() { 67 | new("'static"); 68 | } 69 | 70 | #[test] 71 | fn ident_new_underscore() { 72 | new("_"); 73 | } 74 | 75 | #[test] 76 | #[should_panic(expected = "use Literal instead")] 77 | fn ident_new_number() { 78 | new("255"); 79 | } 80 | 81 | #[test] 82 | #[should_panic(expected = "\"a#\" is not a valid Ident")] 83 | fn ident_new_invalid() { 84 | new("a#"); 85 | } 86 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_iterators.rs: -------------------------------------------------------------------------------- 1 | use syn::punctuated::{Pair, Punctuated}; 2 | use syn::Token; 3 | 4 | #[macro_use] 5 | mod macros; 6 | 7 | macro_rules! check_exact_size_iterator { 8 | ($iter:expr) => {{ 9 | let iter = $iter; 10 | let size_hint = iter.size_hint(); 11 | let len = iter.len(); 12 | let count = iter.count(); 13 | assert_eq!(len, count); 14 | assert_eq!(size_hint, (count, Some(count))); 15 | }}; 16 | } 17 | 18 | #[test] 19 | fn pairs() { 20 | let mut p: Punctuated<_, Token![,]> = punctuated!(2, 3, 4); 21 | 22 | check_exact_size_iterator!(p.pairs()); 23 | check_exact_size_iterator!(p.pairs_mut()); 24 | check_exact_size_iterator!(p.into_pairs()); 25 | 26 | let mut p: Punctuated<_, Token![,]> = punctuated!(2, 3, 4); 27 | 28 | assert_eq!(p.pairs().next_back().map(Pair::into_value), Some(&4)); 29 | assert_eq!( 30 | p.pairs_mut().next_back().map(Pair::into_value), 31 | Some(&mut 4) 32 | ); 33 | assert_eq!(p.into_pairs().next_back().map(Pair::into_value), Some(4)); 34 | } 35 | 36 | #[test] 37 | fn iter() { 38 | let mut p: Punctuated<_, Token![,]> = punctuated!(2, 3, 4); 39 | 40 | check_exact_size_iterator!(p.iter()); 41 | check_exact_size_iterator!(p.iter_mut()); 42 | check_exact_size_iterator!(p.into_iter()); 43 | 44 | let mut p: Punctuated<_, Token![,]> = punctuated!(2, 3, 4); 45 | 46 | assert_eq!(p.iter().next_back(), Some(&4)); 47 | assert_eq!(p.iter_mut().next_back(), Some(&mut 4)); 48 | assert_eq!(p.into_iter().next_back(), Some(4)); 49 | } 50 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_parse_buffer.rs: -------------------------------------------------------------------------------- 1 | use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenStream, TokenTree}; 2 | use std::iter::FromIterator; 3 | use syn::parse::{discouraged::Speculative, Parse, ParseStream, Parser, Result}; 4 | use syn::{parenthesized, Token}; 5 | 6 | #[test] 7 | #[should_panic(expected = "Fork was not derived from the advancing parse stream")] 8 | fn smuggled_speculative_cursor_between_sources() { 9 | struct BreakRules; 10 | impl Parse for BreakRules { 11 | fn parse(input1: ParseStream) -> Result { 12 | let nested = |input2: ParseStream| { 13 | input1.advance_to(&input2); 14 | Ok(Self) 15 | }; 16 | nested.parse_str("") 17 | } 18 | } 19 | 20 | syn::parse_str::("").unwrap(); 21 | } 22 | 23 | #[test] 24 | #[should_panic(expected = "Fork was not derived from the advancing parse stream")] 25 | fn smuggled_speculative_cursor_between_brackets() { 26 | struct BreakRules; 27 | impl Parse for BreakRules { 28 | fn parse(input: ParseStream) -> Result { 29 | let a; 30 | let b; 31 | parenthesized!(a in input); 32 | parenthesized!(b in input); 33 | a.advance_to(&b); 34 | Ok(Self) 35 | } 36 | } 37 | 38 | syn::parse_str::("()()").unwrap(); 39 | } 40 | 41 | #[test] 42 | #[should_panic(expected = "Fork was not derived from the advancing parse stream")] 43 | fn smuggled_speculative_cursor_into_brackets() { 44 | struct BreakRules; 45 | impl Parse for BreakRules { 46 | fn parse(input: ParseStream) -> Result { 47 | let a; 48 | parenthesized!(a in input); 49 | input.advance_to(&a); 50 | Ok(Self) 51 | } 52 | } 53 | 54 | syn::parse_str::("()").unwrap(); 55 | } 56 | 57 | #[test] 58 | fn trailing_empty_none_group() { 59 | fn parse(input: ParseStream) -> Result<()> { 60 | input.parse::()?; 61 | 62 | let content; 63 | parenthesized!(content in input); 64 | content.parse::()?; 65 | 66 | Ok(()) 67 | } 68 | 69 | // `+ ( + <Ø Ø> ) <Ø <Ø Ø> Ø>` 70 | let tokens = TokenStream::from_iter(vec![ 71 | TokenTree::Punct(Punct::new('+', Spacing::Alone)), 72 | TokenTree::Group(Group::new( 73 | Delimiter::Parenthesis, 74 | TokenStream::from_iter(vec![ 75 | TokenTree::Punct(Punct::new('+', Spacing::Alone)), 76 | TokenTree::Group(Group::new(Delimiter::None, TokenStream::new())), 77 | ]), 78 | )), 79 | TokenTree::Group(Group::new(Delimiter::None, TokenStream::new())), 80 | TokenTree::Group(Group::new( 81 | Delimiter::None, 82 | TokenStream::from_iter(vec![TokenTree::Group(Group::new( 83 | Delimiter::None, 84 | TokenStream::new(), 85 | ))]), 86 | )), 87 | ]); 88 | 89 | parse.parse2(tokens).unwrap(); 90 | } 91 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_parse_stream.rs: -------------------------------------------------------------------------------- 1 | use syn::ext::IdentExt; 2 | use syn::parse::ParseStream; 3 | use syn::{Ident, Token}; 4 | 5 | #[test] 6 | fn test_peek() { 7 | let _ = |input: ParseStream| { 8 | let _ = input.peek(Ident); 9 | let _ = input.peek(Ident::peek_any); 10 | let _ = input.peek(Token![::]); 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_pat.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | mod macros; 3 | 4 | use proc_macro2::{Delimiter, Group, TokenStream, TokenTree}; 5 | use quote::quote; 6 | use std::iter::FromIterator; 7 | use syn::{Item, Pat, Stmt}; 8 | 9 | #[test] 10 | fn test_pat_ident() { 11 | match syn::parse2(quote!(self)).unwrap() { 12 | Pat::Ident(_) => (), 13 | value => panic!("expected PatIdent, got {:?}", value), 14 | } 15 | } 16 | 17 | #[test] 18 | fn test_pat_path() { 19 | match syn::parse2(quote!(self::CONST)).unwrap() { 20 | Pat::Path(_) => (), 21 | value => panic!("expected PatPath, got {:?}", value), 22 | } 23 | } 24 | 25 | #[test] 26 | fn test_leading_vert() { 27 | // https://github.com/rust-lang/rust/blob/1.43.0/src/test/ui/or-patterns/remove-leading-vert.rs 28 | 29 | syn::parse_str::("fn f() {}").unwrap(); 30 | syn::parse_str::("fn fun1(| A: E) {}").unwrap_err(); 31 | syn::parse_str::("fn fun2(|| A: E) {}").unwrap_err(); 32 | 33 | syn::parse_str::("let | () = ();").unwrap(); 34 | syn::parse_str::("let (| A): E;").unwrap(); 35 | syn::parse_str::("let (|| A): (E);").unwrap_err(); 36 | syn::parse_str::("let (| A,): (E,);").unwrap(); 37 | syn::parse_str::("let [| A]: [E; 1];").unwrap(); 38 | syn::parse_str::("let [|| A]: [E; 1];").unwrap_err(); 39 | syn::parse_str::("let TS(| A): TS;").unwrap(); 40 | syn::parse_str::("let TS(|| A): TS;").unwrap_err(); 41 | syn::parse_str::("let NS { f: | A }: NS;").unwrap(); 42 | syn::parse_str::("let NS { f: || A }: NS;").unwrap_err(); 43 | } 44 | 45 | #[test] 46 | fn test_group() { 47 | let group = Group::new(Delimiter::None, quote!(Some(_))); 48 | let tokens = TokenStream::from_iter(vec![TokenTree::Group(group)]); 49 | 50 | snapshot!(tokens as Pat, @r###" 51 | Pat::TupleStruct { 52 | path: Path { 53 | segments: [ 54 | PathSegment { 55 | ident: "Some", 56 | arguments: None, 57 | }, 58 | ], 59 | }, 60 | pat: PatTuple { 61 | elems: [ 62 | Pat::Wild, 63 | ], 64 | }, 65 | } 66 | "###); 67 | } 68 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_shebang.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | mod macros; 3 | 4 | #[test] 5 | fn test_basic() { 6 | let content = "#!/usr/bin/env rustx\nfn main() {}"; 7 | let file = syn::parse_file(content).unwrap(); 8 | snapshot!(file, @r###" 9 | File { 10 | shebang: Some("#!/usr/bin/env rustx"), 11 | items: [ 12 | Item::Fn { 13 | vis: Inherited, 14 | sig: Signature { 15 | ident: "main", 16 | generics: Generics, 17 | output: Default, 18 | }, 19 | block: Block, 20 | }, 21 | ], 22 | } 23 | "###); 24 | } 25 | 26 | #[test] 27 | fn test_comment() { 28 | let content = "#!//am/i/a/comment\n[allow(dead_code)] fn main() {}"; 29 | let file = syn::parse_file(content).unwrap(); 30 | snapshot!(file, @r###" 31 | File { 32 | attrs: [ 33 | Attribute { 34 | style: Inner, 35 | path: Path { 36 | segments: [ 37 | PathSegment { 38 | ident: "allow", 39 | arguments: None, 40 | }, 41 | ], 42 | }, 43 | tokens: TokenStream(`(dead_code)`), 44 | }, 45 | ], 46 | items: [ 47 | Item::Fn { 48 | vis: Inherited, 49 | sig: Signature { 50 | ident: "main", 51 | generics: Generics, 52 | output: Default, 53 | }, 54 | block: Block, 55 | }, 56 | ], 57 | } 58 | "###); 59 | } 60 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_should_parse.rs: -------------------------------------------------------------------------------- 1 | macro_rules! should_parse { 2 | ($name:ident, { $($in:tt)* }) => { 3 | #[test] 4 | fn $name() { 5 | // Make sure we can parse the file! 6 | syn::parse_file(stringify!($($in)*)).unwrap(); 7 | } 8 | } 9 | } 10 | 11 | should_parse!(generic_associated_type, { 12 | impl Foo { 13 | type Item = &'a i32; 14 | fn foo<'a>(&'a self) -> Self::Item<'a> {} 15 | } 16 | }); 17 | 18 | #[rustfmt::skip] 19 | should_parse!(const_generics_use, { 20 | type X = Foo<5>; 21 | type Y = Foo<"foo">; 22 | type Z = Foo; 23 | type W = Foo<{ X + 10 }>; 24 | }); 25 | 26 | should_parse!(trailing_plus_type, { 27 | type A = Box; 28 | type A = Box; 29 | type A = Box<'a + Foo>; 30 | }); 31 | 32 | should_parse!(generic_associated_type_where, { 33 | trait Foo { 34 | type Item; 35 | fn foo(&self, t: T) -> Self::Item; 36 | } 37 | }); 38 | 39 | should_parse!(match_with_block_expr, { 40 | fn main() { 41 | match false { 42 | _ => {}.a(), 43 | } 44 | } 45 | }); 46 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_size.rs: -------------------------------------------------------------------------------- 1 | #![cfg(target_pointer_width = "64")] 2 | 3 | use std::mem; 4 | use syn::*; 5 | 6 | #[test] 7 | fn test_expr_size() { 8 | assert_eq!(mem::size_of::(), 280); 9 | } 10 | 11 | #[test] 12 | fn test_item_size() { 13 | assert_eq!(mem::size_of::(), 344); 14 | } 15 | 16 | #[test] 17 | fn test_type_size() { 18 | assert_eq!(mem::size_of::(), 304); 19 | } 20 | 21 | #[test] 22 | fn test_pat_size() { 23 | assert_eq!(mem::size_of::(), 144); 24 | } 25 | 26 | #[test] 27 | fn test_lit_size() { 28 | assert_eq!(mem::size_of::(), 40); 29 | } 30 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_stmt.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | mod macros; 3 | 4 | use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; 5 | use std::iter::FromIterator; 6 | use syn::Stmt; 7 | 8 | #[test] 9 | fn test_raw_operator() { 10 | let stmt = syn::parse_str::("let _ = &raw const x;").unwrap(); 11 | 12 | snapshot!(stmt, @r###" 13 | Local(Local { 14 | pat: Pat::Wild, 15 | init: Some(Verbatim(`& raw const x`)), 16 | }) 17 | "###); 18 | } 19 | 20 | #[test] 21 | fn test_raw_variable() { 22 | let stmt = syn::parse_str::("let _ = &raw;").unwrap(); 23 | 24 | snapshot!(stmt, @r###" 25 | Local(Local { 26 | pat: Pat::Wild, 27 | init: Some(Expr::Reference { 28 | expr: Expr::Path { 29 | path: Path { 30 | segments: [ 31 | PathSegment { 32 | ident: "raw", 33 | arguments: None, 34 | }, 35 | ], 36 | }, 37 | }, 38 | }), 39 | }) 40 | "###); 41 | } 42 | 43 | #[test] 44 | fn test_raw_invalid() { 45 | assert!(syn::parse_str::("let _ = &raw x;").is_err()); 46 | } 47 | 48 | #[test] 49 | fn test_none_group() { 50 | // <Ø async fn f() {} Ø> 51 | let tokens = TokenStream::from_iter(vec![TokenTree::Group(Group::new( 52 | Delimiter::None, 53 | TokenStream::from_iter(vec![ 54 | TokenTree::Ident(Ident::new("async", Span::call_site())), 55 | TokenTree::Ident(Ident::new("fn", Span::call_site())), 56 | TokenTree::Ident(Ident::new("f", Span::call_site())), 57 | TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())), 58 | TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())), 59 | ]), 60 | ))]); 61 | 62 | snapshot!(tokens as Stmt, @r###" 63 | Item(Item::Fn { 64 | vis: Inherited, 65 | sig: Signature { 66 | asyncness: Some, 67 | ident: "f", 68 | generics: Generics, 69 | output: Default, 70 | }, 71 | block: Block, 72 | }) 73 | "###); 74 | } 75 | -------------------------------------------------------------------------------- /vendor/syn/tests/test_token_trees.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | mod macros; 3 | 4 | use proc_macro2::TokenStream; 5 | use quote::quote; 6 | use syn::Lit; 7 | 8 | #[test] 9 | fn test_struct() { 10 | let input = " 11 | #[derive(Debug, Clone)] 12 | pub struct Item { 13 | pub ident: Ident, 14 | pub attrs: Vec, 15 | } 16 | "; 17 | 18 | snapshot!(input as TokenStream, @r###" 19 | TokenStream( 20 | `# [derive (Debug , Clone)] pub struct Item { pub ident : Ident , pub attrs : Vec < Attribute >, }`, 21 | ) 22 | "###); 23 | } 24 | 25 | #[test] 26 | fn test_literal_mangling() { 27 | let code = "0_4"; 28 | let parsed: Lit = syn::parse_str(code).unwrap(); 29 | assert_eq!(code, quote!(#parsed).to_string()); 30 | } 31 | -------------------------------------------------------------------------------- /vendor/syn/tests/zzz_stable.rs: -------------------------------------------------------------------------------- 1 | #![cfg(syn_disable_nightly_tests)] 2 | 3 | use std::io::{self, Write}; 4 | use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; 5 | 6 | const MSG: &str = "\ 7 | ‖ 8 | ‖ WARNING: 9 | ‖ This is not a nightly compiler so not all tests were able to 10 | ‖ run. Syn includes tests that compare Syn's parser against the 11 | ‖ compiler's parser, which requires access to unstable librustc 12 | ‖ data structures and a nightly compiler. 13 | ‖ 14 | "; 15 | 16 | #[test] 17 | fn notice() -> io::Result<()> { 18 | let header = "WARNING"; 19 | let index_of_header = MSG.find(header).unwrap(); 20 | let before = &MSG[..index_of_header]; 21 | let after = &MSG[index_of_header + header.len()..]; 22 | 23 | let mut stderr = StandardStream::stderr(ColorChoice::Auto); 24 | stderr.set_color(ColorSpec::new().set_fg(Some(Color::Yellow)))?; 25 | write!(&mut stderr, "{}", before)?; 26 | stderr.set_color(ColorSpec::new().set_bold(true).set_fg(Some(Color::Yellow)))?; 27 | write!(&mut stderr, "{}", header)?; 28 | stderr.set_color(ColorSpec::new().set_fg(Some(Color::Yellow)))?; 29 | write!(&mut stderr, "{}", after)?; 30 | stderr.reset()?; 31 | 32 | Ok(()) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/target-tuples-0.1.0/.cargo-checksum.json: -------------------------------------------------------------------------------- 1 | {"files":{"Cargo.lock":"5f50f95be0f32b51011e35bd91037790a4e0c16d53b5e72b336684e279ec8165","Cargo.toml":"ca7c84a939e941f85d60599353a5358190a283d2fdc3852fa3057d5cb666627f","LICENSE-APACHE":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","LICENSE-MIT":"57613ec8df284b15e3817ea41d737621316d1e3c447522b6f9ba6b2b73481c92","README.md":"b8e95dbd3d235287ff85d623dcd94ba9537a20b1d2cd14449e15a2d70cfedaba","config.sub.1":"6d3def0a3d0485848263ab0ac507156e5358e33e12dbb12506629789268b8fd0","src/config_sub.rs":"51f5851ca435d86644dd43fde5a852c90fce70872f9983b09de13de639498a40","src/lib.rs":"f6ca4f02359b334ee4c9ac4ebb5c74fefe5bfb9ca214594336bea6460658af77","src/pieces.rs":"07fd654ea80ed76e7358da74d06e8d74b4676a115f38d42341e76623ef167ef6"},"package":"609fb74e26344835a0503adaccfe3f843948b4d6c37f81a866d6495081c053d5"} -------------------------------------------------------------------------------- /vendor/target-tuples-0.1.0/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "target-tuples" 5 | version = "0.1.0" 6 | -------------------------------------------------------------------------------- /vendor/target-tuples-0.1.0/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies 7 | # 8 | # If you believe there's an error in this file please file an 9 | # issue against the rust-lang/cargo repository. If you're 10 | # editing this file be aware that the upstream Cargo.toml 11 | # will likely look very different (and much more reasonable) 12 | 13 | [package] 14 | edition = "2018" 15 | name = "target-tuples" 16 | version = "0.1.0" 17 | authors = ["Connor Horman "] 18 | description = " A library to parse target tuples of the form --, similar to those used by autoconf.\n" 19 | readme = "README.md" 20 | license = "Apache-2.0 AND MIT" 21 | repository = "https://github.com/chorman0773/rust-target-tuples" 22 | [package.metadata.install-targets.config-sub] 23 | installed-path = "config.sub" 24 | 25 | [package.metadata.install-targets.config-sub-man] 26 | installed-path = "/man1/config.sub.1" 27 | target-file = "config.sub.1" 28 | type = "man" 29 | 30 | [[bin]] 31 | name = "config-sub" 32 | path = "src/config_sub.rs" 33 | 34 | [dependencies] 35 | -------------------------------------------------------------------------------- /vendor/target-tuples-0.1.0/LICENSE-APACHE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lccc-project/lc-binutils/fecf4f4998ec51d6977ebd8e3d0f9be7546e4032/vendor/target-tuples-0.1.0/LICENSE-APACHE -------------------------------------------------------------------------------- /vendor/target-tuples-0.1.0/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (C) 2020 Connor Horman 2 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 3 | 4 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 5 | 6 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /vendor/target-tuples-0.1.0/README.md: -------------------------------------------------------------------------------- 1 | # rust target-tuples 2 | 3 | Implements parsing of target tuples. Additionally provides a small program that implements config.sub. 4 | 5 | ## Copyright 6 | 7 | Copyright (C) 2020 Connor Horman 8 | 9 | This program is dual-licensed under the terms of the MIT and Apache v2 licenses. 10 | See and for details. 11 | 12 | Persuant to the Apache v2 License, if you contribute to this software, 13 | you agree to allow the copyright holder to dual-license those contributions as above. 14 | 15 | 16 | -------------------------------------------------------------------------------- /vendor/target-tuples-0.1.0/config.sub.1: -------------------------------------------------------------------------------- 1 | .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.16. 2 | .TH CONFIG.SUB "1" "December 2020" "Connor Horman" "User Commands" 3 | .SH NAME 4 | config.sub \- Canonicalizes a target tuple 5 | .SH SYNOPSIS 6 | .B config.sub 7 | [\fI\,OPTION\/\fR]\fI\,|\/\fR 8 | .SH DESCRIPTION 9 | Converts a target tuple into canonical form 10 | Options: 11 | .HP 12 | \fB\-\-help\fR: Prints this message, and exits 13 | .HP 14 | \fB\-\-version\fR: Prints version information, and exists 15 | .SH COPYRIGHT 16 | Copyright \(co 2020 Connor Horman, this program is a free software, dual\-licensed under the terms of the Apache v2 and the MIT license 17 | This program is provided AS\-IS, without any warranty. 18 | -------------------------------------------------------------------------------- /vendor/target-tuples-0.1.0/src/config_sub.rs: -------------------------------------------------------------------------------- 1 | use target_tuples::*; 2 | 3 | pub fn main() { 4 | let mut args = std::env::args(); 5 | let bin = args.next().unwrap(); 6 | if let Some(name) = args.next() { 7 | match &*name { 8 | "--help" => { 9 | println!("Usage: {} [OPTION]|", bin); 10 | println!("Converts a target tuple into canonical form"); 11 | println!("Options:"); 12 | println!("\t--help: Prints this message, and exits"); 13 | println!("\t--version: Prints version information, and exists"); 14 | } 15 | "--version" => { 16 | println!("config.sub v{}", env!("CARGO_PKG_VERSION")); 17 | println!("Copyright (C) 2020 Connor Horman, this program is a free software, dual-licensed under the terms of the Apache v2 and the MIT license"); 18 | println!("This program is provided AS-IS, without any warranty."); 19 | } 20 | x => { 21 | if let Ok(t) = x.parse::() { 22 | println!("{}", t); 23 | } else { 24 | std::process::exit(1); 25 | } 26 | } 27 | } 28 | } else { 29 | std::process::exit(1); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/target-tuples-0.1.0/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![deny(warnings)] 2 | 3 | mod pieces; 4 | 5 | pub use pieces::*; 6 | 7 | #[cfg(test)] 8 | pub mod test { 9 | use crate::Architecture; 10 | 11 | #[test] 12 | pub fn x86_name_i386() { 13 | let x86 = Architecture::X86; 14 | let i386: Architecture = "i386".parse().unwrap(); 15 | assert_eq!(x86, i386); 16 | } 17 | 18 | #[test] 19 | pub fn x86_name_i486() { 20 | let x86 = Architecture::X86; 21 | let i486: Architecture = "i486".parse().unwrap(); 22 | assert_eq!(x86, i486); 23 | } 24 | #[test] 25 | pub fn x86_name_i586() { 26 | let x86 = Architecture::X86; 27 | let i586: Architecture = "i586".parse().unwrap(); 28 | assert_eq!(x86, i586); 29 | } 30 | 31 | #[test] 32 | pub fn x86_name_i686() { 33 | let x86 = Architecture::X86; 34 | let i386: Architecture = "i686".parse().unwrap(); 35 | assert_eq!(x86, i386); 36 | } 37 | 38 | #[test] 39 | pub fn x86_name_i786() { 40 | let x86 = Architecture::X86; 41 | let i386: Architecture = "i786".parse().unwrap(); 42 | assert_eq!(x86, i386); 43 | } 44 | #[test] 45 | pub fn x86_name_i886() { 46 | let x86 = Architecture::X86; 47 | let i386: Architecture = "i886".parse().unwrap(); 48 | assert_eq!(x86, i386); 49 | } 50 | #[test] 51 | pub fn x86_name_i986() { 52 | let x86 = Architecture::X86; 53 | let i386: Architecture = "i986".parse().unwrap(); 54 | assert_eq!(x86, i386); 55 | } 56 | 57 | #[test] 58 | pub fn x86_name_canonical() { 59 | assert_eq!(Architecture::X86.canonical_name(), "i386"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vendor/target-tuples/.cargo-checksum.json: -------------------------------------------------------------------------------- 1 | {"files":{"Cargo.lock":"e703acdfa258302e0a012a773027684cdd53481057333deef90c4f2840db5afb","Cargo.toml":"69c50ca306b2d644de07384723ce1aa1755f2a8d58d3a180b693727af821e418","LICENSE-APACHE":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","LICENSE-MIT":"57613ec8df284b15e3817ea41d737621316d1e3c447522b6f9ba6b2b73481c92","Makefile.in":"d62c306e0bcf60efd3db6bead9a8f5cfd0bc6ef6b4d2f6295ae0d7b02325b9e3","README.md":"b8e95dbd3d235287ff85d623dcd94ba9537a20b1d2cd14449e15a2d70cfedaba","aclocal.m4":"a26093944b5ad2103cf81f8f3e919206fb397ea21e87fc1c9719ad70bf1d8c3c","config.guess":"19c12bb2ca19e68724c2854ed0512469518df19b0710cc2011a5ca540810979c","config.sub":"f7197ddfb309e86d5fbd7d3b440a5ababfbd4aac1e1f53b492e28e54db58b222","config.sub.1":"6d3def0a3d0485848263ab0ac507156e5358e33e12dbb12506629789268b8fd0","configure":"be3c5f0ba322d96c25fc1894c40043aafacb2f112b55d6a960b1bab6fc780bbc","configure.ac":"c1018510147f598754a880ae12577d2fb654e018cf41054b0164456444924436","install-sh":"3d7488bebd0cfc9b5c440c55d5b44f1c6e2e3d3e19894821bae4a27f9307f1d2","m4/lcrust_prog_rustc.m4":"1edafd2cf2b9bd1d68d980476b44c19a948761d40550932598939a705c1668c1","run-tests.sh":"6301cdd717d770d946503076778ccd7fecb712acaadc6379372cf35740a5b5a9","src/config-sub.rs":"73311c6a3c354aa52364575ea8da7d50ce4e3beef9428a5075d091cf5f1014cc","src/lib.rs":"95db81db24858b2594f24c603a2f3f11843d4c4f9733368db59817892003c7fa","src/pieces.rs":"05746016b4119493769c04aa38a02cb8b30effeb6de041e098594e71e6f83c68","tests/config-sub.data":"c4f36f535d1300314a27b97ae5e690138a5bcbf5c5cddc4d8bf344e0f9f0eeaf","tests/sub_tests.rs":"0c75901d86352c522c43b8e4545f5cd52a7c03f2760130c36c56ddbb3d6fd19e"},"package":"b262cb4578cd65bd15b85997464263734826b85a28cc267300339c8f4937b5cf"} -------------------------------------------------------------------------------- /vendor/target-tuples/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "target-tuples" 7 | version = "0.2.3" 8 | -------------------------------------------------------------------------------- /vendor/target-tuples/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies 7 | # 8 | # If you believe there's an error in this file please file an 9 | # issue against the rust-lang/cargo repository. If you're 10 | # editing this file be aware that the upstream Cargo.toml 11 | # will likely look very different (and much more reasonable) 12 | 13 | [package] 14 | edition = "2018" 15 | name = "target-tuples" 16 | version = "0.2.3" 17 | authors = ["Connor Horman "] 18 | description = " A library to parse target tuples of the form --, similar to those used by autoconf.\n" 19 | readme = "README.md" 20 | license = "Apache-2.0 AND MIT" 21 | repository = "https://github.com/chorman0773/rust-target-tuples" 22 | [package.metadata.install-targets.config-sub] 23 | installed-path = "config.sub" 24 | 25 | [package.metadata.install-targets.config-sub-man] 26 | installed-path = "/man1/config.sub.1" 27 | target-file = "config.sub.1" 28 | type = "man" 29 | 30 | [[bin]] 31 | name = "config-sub" 32 | path = "src/config-sub.rs" 33 | 34 | [dependencies] 35 | -------------------------------------------------------------------------------- /vendor/target-tuples/LICENSE-APACHE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lccc-project/lc-binutils/fecf4f4998ec51d6977ebd8e3d0f9be7546e4032/vendor/target-tuples/LICENSE-APACHE -------------------------------------------------------------------------------- /vendor/target-tuples/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (C) 2020 Connor Horman 2 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 3 | 4 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 5 | 6 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /vendor/target-tuples/README.md: -------------------------------------------------------------------------------- 1 | # rust target-tuples 2 | 3 | Implements parsing of target tuples. Additionally provides a small program that implements config.sub. 4 | 5 | ## Copyright 6 | 7 | Copyright (C) 2020 Connor Horman 8 | 9 | This program is dual-licensed under the terms of the MIT and Apache v2 licenses. 10 | See and for details. 11 | 12 | Persuant to the Apache v2 License, if you contribute to this software, 13 | you agree to allow the copyright holder to dual-license those contributions as above. 14 | 15 | 16 | -------------------------------------------------------------------------------- /vendor/target-tuples/aclocal.m4: -------------------------------------------------------------------------------- 1 | # generated automatically by aclocal 1.16.3 -*- Autoconf -*- 2 | 3 | # Copyright (C) 1996-2020 Free Software Foundation, Inc. 4 | 5 | # This file is free software; the Free Software Foundation 6 | # gives unlimited permission to copy and/or distribute it, 7 | # with or without modifications, as long as this notice is preserved. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 11 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12 | # PARTICULAR PURPOSE. 13 | 14 | m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) 15 | m4_include([m4/lcrust_prog_rustc.m4]) 16 | -------------------------------------------------------------------------------- /vendor/target-tuples/config.sub.1: -------------------------------------------------------------------------------- 1 | .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.16. 2 | .TH CONFIG.SUB "1" "December 2020" "Connor Horman" "User Commands" 3 | .SH NAME 4 | config.sub \- Canonicalizes a target tuple 5 | .SH SYNOPSIS 6 | .B config.sub 7 | [\fI\,OPTION\/\fR]\fI\,|\/\fR 8 | .SH DESCRIPTION 9 | Converts a target tuple into canonical form 10 | Options: 11 | .HP 12 | \fB\-\-help\fR: Prints this message, and exits 13 | .HP 14 | \fB\-\-version\fR: Prints version information, and exists 15 | .SH COPYRIGHT 16 | Copyright \(co 2020 Connor Horman, this program is a free software, dual\-licensed under the terms of the Apache v2 and the MIT license 17 | This program is provided AS\-IS, without any warranty. 18 | -------------------------------------------------------------------------------- /vendor/target-tuples/configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT 2 | 3 | AC_CONFIG_MACRO_DIRS([m4/]) 4 | 5 | AC_CANONICAL_BUILD 6 | AC_CANONICAL_HOST 7 | 8 | AC_PROG_CC 9 | 10 | AC_PROG_INSTALL 11 | 12 | LCRUST_PROG_RUSTC 13 | 14 | AC_SUBST([detected_cfg]) 15 | AC_CONFIG_FILES([Makefile]) 16 | 17 | AC_OUTPUT -------------------------------------------------------------------------------- /vendor/target-tuples/run-tests.sh: -------------------------------------------------------------------------------- 1 | for s in $* 2 | do 3 | $s 4 | done -------------------------------------------------------------------------------- /vendor/target-tuples/src/config-sub.rs: -------------------------------------------------------------------------------- 1 | use target_tuples::*; 2 | 3 | pub fn main() { 4 | let mut args = std::env::args(); 5 | let bin = args.next().unwrap(); 6 | if let Some(name) = args.next() { 7 | match &*name { 8 | "--help" => { 9 | println!("Usage: {} [OPTION]|", bin); 10 | println!("Converts a target tuple into canonical form"); 11 | println!("Options:"); 12 | println!("\t--help: Prints this message, and exits"); 13 | println!("\t--version: Prints version information, and exists"); 14 | } 15 | "--version" => { 16 | println!("config.sub v{}", env!("CARGO_PKG_VERSION")); 17 | println!("Copyright (C) 2020 Connor Horman, this program is a free software, dual-licensed under the terms of the Apache v2 and the MIT license"); 18 | println!("This program is provided AS-IS, without any warranty."); 19 | } 20 | x => { 21 | if let Ok(t) = x.parse::() { 22 | println!("{}", t); 23 | } else { 24 | eprintln!("Unsupported target {}", x); 25 | std::process::exit(1); 26 | } 27 | } 28 | } 29 | } else { 30 | std::process::exit(1); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/target-tuples/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![deny(warnings, unsafe_code)] 2 | 3 | mod pieces; 4 | 5 | pub use pieces::*; 6 | 7 | #[cfg(test)] 8 | pub mod test { 9 | use crate::Architecture; 10 | 11 | #[test] 12 | pub fn x86_name_i386() { 13 | let x86 = Architecture::X86; 14 | let i386: Architecture = "i386".parse().unwrap(); 15 | assert_eq!(x86, i386); 16 | } 17 | 18 | #[test] 19 | pub fn x86_name_i486() { 20 | let x86 = Architecture::X86; 21 | let i486: Architecture = "i486".parse().unwrap(); 22 | assert_eq!(x86, i486); 23 | } 24 | #[test] 25 | pub fn x86_name_i586() { 26 | let x86 = Architecture::X86; 27 | let i586: Architecture = "i586".parse().unwrap(); 28 | assert_eq!(x86, i586); 29 | } 30 | 31 | #[test] 32 | pub fn x86_name_i686() { 33 | let x86 = Architecture::X86; 34 | let i386: Architecture = "i686".parse().unwrap(); 35 | assert_eq!(x86, i386); 36 | } 37 | 38 | #[test] 39 | pub fn x86_name_i786() { 40 | let x86 = Architecture::X86; 41 | let i386: Architecture = "i786".parse().unwrap(); 42 | assert_eq!(x86, i386); 43 | } 44 | #[test] 45 | pub fn x86_name_i886() { 46 | let x86 = Architecture::X86; 47 | let i386: Architecture = "i886".parse().unwrap(); 48 | assert_eq!(x86, i386); 49 | } 50 | #[test] 51 | pub fn x86_name_i986() { 52 | let x86 = Architecture::X86; 53 | let i386: Architecture = "i986".parse().unwrap(); 54 | assert_eq!(x86, i386); 55 | } 56 | 57 | #[test] 58 | pub fn x86_name_canonical() { 59 | assert_eq!(Architecture::X86.canonical_name(), "i386"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vendor/target-tuples/tests/config-sub.data: -------------------------------------------------------------------------------- 1 | x86_64-pc-linux-gnu|x86_64-pc-linux-gnu 2 | x86_64-linux-musl|x86_64-pc-linux-musl 3 | x86_64-unknown-linux-gnux32|x86_64-unknown-linux-gnux32 4 | i386-phantom-kernel|i386-pc-phantom-kernel 5 | i486-windows-msvc|i386-pc-win32-msvc 6 | wc65c816-elf|w65-wdc-elf 7 | 65816-snes-elf|w65-wdc-snes-elf -------------------------------------------------------------------------------- /vendor/target-tuples/tests/sub_tests.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | 3 | use std::io::{BufRead, BufReader}; 4 | 5 | use target_tuples::Target; 6 | 7 | #[test] 8 | fn test_many_config_subs() -> std::io::Result<()> { 9 | let f = BufReader::new(File::open(concat!( 10 | env!("CARGO_MANIFEST_DIR"), 11 | "/tests/config-sub.data" 12 | ))?); 13 | for s in f.lines() { 14 | let s = s?; 15 | if s.trim().is_empty() { 16 | continue; 17 | } 18 | let mut s = s.split('|'); 19 | let (k, v) = (s.next().unwrap(), s.next().unwrap()); 20 | let targ = Target::parse(k); 21 | assert_eq!(targ.to_string(), v); 22 | } 23 | 24 | Ok(()) 25 | } 26 | 27 | #[test] 28 | fn test_idempotency() -> std::io::Result<()> { 29 | let f = BufReader::new(File::open(concat!( 30 | env!("CARGO_MANIFEST_DIR"), 31 | "/tests/config-sub.data" 32 | ))?); 33 | for s in f.lines() { 34 | let s = s?; 35 | let s = s.trim(); 36 | if s.is_empty() || s.starts_with('#') { 37 | continue; 38 | } 39 | let mut s = s.split('|'); 40 | let (_, v) = (s.next().unwrap(), s.next().unwrap()); 41 | let targ = Target::parse(v); 42 | assert_eq!(targ.to_string(), v); 43 | } 44 | 45 | Ok(()) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/unicode-xid/.cargo-checksum.json: -------------------------------------------------------------------------------- 1 | {"files":{"COPYRIGHT":"23860c2a7b5d96b21569afedf033469bab9fe14a1b24a35068b8641c578ce24d","Cargo.toml":"49c1612c2c7e8032afc9ed76331020a1886d11dc9f538400d96efa5359925a2c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"7b63ecd5f1902af1b63729947373683c32745c16a10e8e6292e2e2dcd7e90ae0","README.md":"8fde6fcab0ea13c3abffd8a042f286078a7d88b524dd59db3f26889eb470a5a4","benches/xid.rs":"a2986ce1df5d93bff51e73dc234bffb341d4fe5d749247296f02396dde16a72b","src/lib.rs":"3cdd204115af45e9ece70db737d711e1798eac40eaa6cc4e8280bb3342e1408e","src/tables.rs":"895c4e1199b7987fbf058a4dbd2b1145fa212136d2fc75fd5ac49059192796af","src/tests.rs":"b866f890acd631e667635785c34b1723709f10a9515ca525b41de8a062c7b204","tests/exhaustive_tests.rs":"ec91e9124d61e5b3e2fbbbf37a2fd30d6c7a8fa22639d6720b416d9ebc1007c5"},"package":"8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"} -------------------------------------------------------------------------------- /vendor/unicode-xid/COPYRIGHT: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 2 | or the MIT 4 | license , 5 | at your option. All files in the project carrying such 6 | notice may not be copied, modified, or distributed except 7 | according to those terms. 8 | -------------------------------------------------------------------------------- /vendor/unicode-xid/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies 7 | # 8 | # If you believe there's an error in this file please file an 9 | # issue against the rust-lang/cargo repository. If you're 10 | # editing this file be aware that the upstream Cargo.toml 11 | # will likely look very different (and much more reasonable) 12 | 13 | [package] 14 | name = "unicode-xid" 15 | version = "0.2.2" 16 | authors = ["erick.tryzelaar ", "kwantam ", "Manish Goregaokar "] 17 | exclude = ["/scripts/*", "/.travis.yml"] 18 | description = "Determine whether characters have the XID_Start\nor XID_Continue properties according to\nUnicode Standard Annex #31.\n" 19 | homepage = "https://github.com/unicode-rs/unicode-xid" 20 | documentation = "https://unicode-rs.github.io/unicode-xid" 21 | readme = "README.md" 22 | keywords = ["text", "unicode", "xid"] 23 | license = "MIT OR Apache-2.0" 24 | repository = "https://github.com/unicode-rs/unicode-xid" 25 | 26 | [[bench]] 27 | name = "xid" 28 | harness = false 29 | [dev-dependencies.criterion] 30 | version = "0.3" 31 | 32 | [features] 33 | bench = [] 34 | default = [] 35 | no_std = [] 36 | [badges.travis-ci] 37 | repository = "unicode-rs/unicode-xid" 38 | -------------------------------------------------------------------------------- /vendor/unicode-xid/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 The Rust Project Developers 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /vendor/unicode-xid/README.md: -------------------------------------------------------------------------------- 1 | # unicode-xid 2 | 3 | Determine if a `char` is a valid identifier for a parser and/or lexer according to 4 | [Unicode Standard Annex #31](http://www.unicode.org/reports/tr31/) rules. 5 | 6 | [![Build Status](https://travis-ci.org/unicode-rs/unicode-xid.svg)](https://travis-ci.org/unicode-rs/unicode-xid) 7 | 8 | [Documentation](https://unicode-rs.github.io/unicode-xid/unicode_xid/index.html) 9 | 10 | ```rust 11 | extern crate unicode_xid; 12 | 13 | use unicode_xid::UnicodeXID; 14 | 15 | fn main() { 16 | let ch = 'a'; 17 | println!("Is {} a valid start of an identifier? {}", ch, UnicodeXID::is_xid_start(ch)); 18 | } 19 | ``` 20 | 21 | # features 22 | 23 | unicode-xid supports a `no_std` feature. This eliminates dependence 24 | on std, and instead uses equivalent functions from core. 25 | 26 | 27 | # changelog 28 | 29 | ## 0.2.2 30 | 31 | - Add an ASCII fast-path 32 | 33 | ## 0.2.1 34 | 35 | - Update to Unicode 13.0.0 36 | - Speed up lookup 37 | 38 | ## 0.2.0 39 | 40 | - Update to Unicode 12.1.0. 41 | 42 | ## 0.1.0 43 | 44 | - Initial release. 45 | -------------------------------------------------------------------------------- /vendor/unicode-xid/benches/xid.rs: -------------------------------------------------------------------------------- 1 | extern crate criterion; 2 | extern crate unicode_xid; 3 | 4 | use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; 5 | use unicode_xid::UnicodeXID; 6 | 7 | fn bench_unicode_xid(c: &mut Criterion) { 8 | let unicode_chars = chars(1..0x3000); 9 | let ascii_chars = chars(1..0x80); 10 | 11 | let mut group = c.benchmark_group("UnicodeXID"); 12 | group.throughput(Throughput::Bytes(unicode_chars.len() as u64)); 13 | group.bench_with_input( 14 | BenchmarkId::new("is_xid_start", "unicode"), 15 | &unicode_chars, 16 | |b, chars| b.iter(|| chars.iter().copied().map(UnicodeXID::is_xid_start).last()), 17 | ); 18 | group.throughput(Throughput::Bytes(ascii_chars.len() as u64)); 19 | group.bench_with_input( 20 | BenchmarkId::new("is_xid_start", "ascii"), 21 | &ascii_chars, 22 | |b, chars| b.iter(|| chars.iter().copied().map(UnicodeXID::is_xid_start).last()), 23 | ); 24 | group.throughput(Throughput::Bytes(unicode_chars.len() as u64)); 25 | group.bench_with_input( 26 | BenchmarkId::new("is_xid_continue", "unicode"), 27 | &unicode_chars, 28 | |b, chars| { 29 | b.iter(|| { 30 | chars 31 | .iter() 32 | .copied() 33 | .map(UnicodeXID::is_xid_continue) 34 | .last() 35 | }) 36 | }, 37 | ); 38 | group.throughput(Throughput::Bytes(ascii_chars.len() as u64)); 39 | group.bench_with_input( 40 | BenchmarkId::new("is_xid_continue", "ascii"), 41 | &ascii_chars, 42 | |b, chars| { 43 | b.iter(|| { 44 | chars 45 | .iter() 46 | .copied() 47 | .map(UnicodeXID::is_xid_continue) 48 | .last() 49 | }) 50 | }, 51 | ); 52 | group.finish(); 53 | } 54 | 55 | fn chars(range: std::ops::Range) -> Vec { 56 | range.filter_map(|i| std::char::from_u32(i)).collect() 57 | } 58 | 59 | criterion_group!(benches, bench_unicode_xid); 60 | criterion_main!(benches); 61 | -------------------------------------------------------------------------------- /vendor/unicode-xid/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2012-2015 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 or the MIT license 7 | // , at your 8 | // option. This file may not be copied, modified, or distributed 9 | // except according to those terms. 10 | 11 | //! Determine if a `char` is a valid identifier for a parser and/or lexer according to 12 | //! [Unicode Standard Annex #31](http://www.unicode.org/reports/tr31/) rules. 13 | //! 14 | //! ```rust 15 | //! extern crate unicode_xid; 16 | //! 17 | //! use unicode_xid::UnicodeXID; 18 | //! 19 | //! fn main() { 20 | //! let ch = 'a'; 21 | //! println!("Is {} a valid start of an identifier? {}", ch, UnicodeXID::is_xid_start(ch)); 22 | //! } 23 | //! ``` 24 | //! 25 | //! # features 26 | //! 27 | //! unicode-xid supports a `no_std` feature. This eliminates dependence 28 | //! on std, and instead uses equivalent functions from core. 29 | //! 30 | 31 | #![forbid(unsafe_code)] 32 | #![deny(missing_docs)] 33 | #![doc( 34 | html_logo_url = "https://unicode-rs.github.io/unicode-rs_sm.png", 35 | html_favicon_url = "https://unicode-rs.github.io/unicode-rs_sm.png" 36 | )] 37 | #![no_std] 38 | #![cfg_attr(feature = "bench", feature(test, unicode_internals))] 39 | 40 | #[cfg(test)] 41 | #[macro_use] 42 | extern crate std; 43 | 44 | #[cfg(feature = "bench")] 45 | extern crate test; 46 | 47 | use tables::derived_property; 48 | pub use tables::UNICODE_VERSION; 49 | 50 | mod tables; 51 | 52 | #[cfg(test)] 53 | mod tests; 54 | 55 | /// Methods for determining if a character is a valid identifier character. 56 | pub trait UnicodeXID { 57 | /// Returns whether the specified character satisfies the 'XID_Start' 58 | /// Unicode property. 59 | /// 60 | /// 'XID_Start' is a Unicode Derived Property specified in 61 | /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications), 62 | /// mostly similar to ID_Start but modified for closure under NFKx. 63 | fn is_xid_start(self) -> bool; 64 | 65 | /// Returns whether the specified `char` satisfies the 'XID_Continue' 66 | /// Unicode property. 67 | /// 68 | /// 'XID_Continue' is a Unicode Derived Property specified in 69 | /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications), 70 | /// mostly similar to 'ID_Continue' but modified for closure under NFKx. 71 | fn is_xid_continue(self) -> bool; 72 | } 73 | 74 | impl UnicodeXID for char { 75 | #[inline] 76 | fn is_xid_start(self) -> bool { 77 | // Fast-path for ascii idents 78 | ('a' <= self && self <= 'z') 79 | || ('A' <= self && self <= 'Z') 80 | || (self > '\x7f' && derived_property::XID_Start(self)) 81 | } 82 | 83 | #[inline] 84 | fn is_xid_continue(self) -> bool { 85 | // Fast-path for ascii idents 86 | ('a' <= self && self <= 'z') 87 | || ('A' <= self && self <= 'Z') 88 | || ('0' <= self && self <= '9') 89 | || self == '_' 90 | || (self > '\x7f' && derived_property::XID_Continue(self)) 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /vendor/unicode-xid/src/tests.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2012-2015 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 or the MIT license 7 | // , at your 8 | // option. This file may not be copied, modified, or distributed 9 | // except according to those terms. 10 | 11 | #[cfg(feature = "bench")] 12 | use std::iter; 13 | #[cfg(feature = "bench")] 14 | use std::prelude::v1::*; 15 | #[cfg(feature = "bench")] 16 | use test::Bencher; 17 | 18 | #[cfg(feature = "bench")] 19 | use UnicodeXID; 20 | 21 | #[cfg(feature = "bench")] 22 | #[bench] 23 | fn cargo_is_xid_start(b: &mut Bencher) { 24 | let string = iter::repeat('a').take(4096).collect::(); 25 | 26 | b.bytes = string.len() as u64; 27 | b.iter(|| string.chars().all(super::UnicodeXID::is_xid_start)); 28 | } 29 | 30 | #[cfg(feature = "bench")] 31 | #[bench] 32 | fn stdlib_is_xid_start(b: &mut Bencher) { 33 | let string = iter::repeat('a').take(4096).collect::(); 34 | 35 | b.bytes = string.len() as u64; 36 | b.iter(|| string.chars().all(char::is_xid_start)); 37 | } 38 | 39 | #[cfg(feature = "bench")] 40 | #[bench] 41 | fn cargo_xid_continue(b: &mut Bencher) { 42 | let string = iter::repeat('a').take(4096).collect::(); 43 | 44 | b.bytes = string.len() as u64; 45 | b.iter(|| string.chars().all(super::UnicodeXID::is_xid_continue)); 46 | } 47 | 48 | #[cfg(feature = "bench")] 49 | #[bench] 50 | fn stdlib_xid_continue(b: &mut Bencher) { 51 | let string = iter::repeat('a').take(4096).collect::(); 52 | 53 | b.bytes = string.len() as u64; 54 | b.iter(|| string.chars().all(char::is_xid_continue)); 55 | } 56 | 57 | #[test] 58 | fn test_is_xid_start() { 59 | let chars = ['A', 'Z', 'a', 'z', '\u{1000d}', '\u{10026}']; 60 | 61 | for ch in &chars { 62 | assert!(super::UnicodeXID::is_xid_start(*ch), "{}", ch); 63 | } 64 | } 65 | 66 | #[test] 67 | fn test_is_not_xid_start() { 68 | let chars = [ 69 | '\x00', '\x01', '0', '9', ' ', '[', '<', '{', '(', '\u{02c2}', '\u{ffff}', 70 | ]; 71 | 72 | for ch in &chars { 73 | assert!(!super::UnicodeXID::is_xid_start(*ch), "{}", ch); 74 | } 75 | } 76 | 77 | #[test] 78 | fn test_is_xid_continue() { 79 | let chars = ['0', '9', 'A', 'Z', 'a', 'z', '_', '\u{1000d}', '\u{10026}']; 80 | 81 | for ch in &chars { 82 | assert!(super::UnicodeXID::is_xid_continue(*ch), "{}", ch); 83 | } 84 | } 85 | 86 | #[test] 87 | fn test_is_not_xid_continue() { 88 | let chars = [ 89 | '\x00', '\x01', ' ', '[', '<', '{', '(', '\u{02c2}', '\u{ffff}', 90 | ]; 91 | 92 | for &ch in &chars { 93 | assert!(!super::UnicodeXID::is_xid_continue(ch), "{}", ch); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /vendor/unicode-xid/tests/exhaustive_tests.rs: -------------------------------------------------------------------------------- 1 | extern crate unicode_xid; 2 | use unicode_xid::UnicodeXID; 3 | /// A `char` in Rust is a Unicode Scalar Value 4 | /// 5 | /// See: http://www.unicode.org/glossary/#unicode_scalar_value 6 | fn all_valid_chars() -> impl Iterator { 7 | (0u32..=0xD7FF).chain(0xE000u32..=0x10FFFF).map(|u| { 8 | core::convert::TryFrom::try_from(u) 9 | .expect("The selected range should be infallible if the docs match impl") 10 | }) 11 | } 12 | 13 | #[test] 14 | fn all_valid_chars_do_not_panic_for_is_xid_start() { 15 | for c in all_valid_chars() { 16 | let _ = UnicodeXID::is_xid_start(c); 17 | } 18 | } 19 | 20 | #[test] 21 | fn all_valid_chars_do_not_panic_for_is_xid_continue() { 22 | for c in all_valid_chars() { 23 | let _ = UnicodeXID::is_xid_continue(c); 24 | } 25 | } 26 | --------------------------------------------------------------------------------