mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-22 03:44:24 +00:00
add more tests
This commit is contained in:
parent
da2ee5dcb2
commit
a174f2ab7c
22
src/test/compile-fail/auxiliary/some-panic-impl.rs
Normal file
22
src/test/compile-fail/auxiliary/some-panic-impl.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// no-prefer-dynamic
|
||||
|
||||
#![crate_type = "rlib"]
|
||||
#![feature(panic_implementation)]
|
||||
#![no_std]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
#[panic_implementation]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
22
src/test/compile-fail/panic-implementation-std.rs
Normal file
22
src/test/compile-fail/panic-implementation-std.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: duplicate lang item found: `panic_impl`.
|
||||
|
||||
#![feature(panic_implementation)]
|
||||
|
||||
use std::panic::PanicInfo;
|
||||
|
||||
#[panic_implementation]
|
||||
fn panic(info: PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn main() {}
|
29
src/test/compile-fail/panic-implementation-twice.rs
Normal file
29
src/test/compile-fail/panic-implementation-twice.rs
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:some-panic-impl.rs
|
||||
|
||||
#![feature(panic_implementation)]
|
||||
#![feature(lang_items)]
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
extern crate some_panic_impl;
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
#[panic_implementation]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
//~^ error duplicate lang item found: `panic_impl`
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
fn eh() {}
|
7
src/test/run-make/panic-impl-transitive/Makefile
Normal file
7
src/test/run-make/panic-impl-transitive/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
-include ../../run-make-fulldeps/tools.mk
|
||||
|
||||
# NOTE we use --emit=llvm-ir to avoid running the linker (linking will fail because there's no main
|
||||
# in this crate)
|
||||
all:
|
||||
$(RUSTC) panic-impl-provider.rs
|
||||
$(RUSTC) panic-impl-consumer.rs -C panic=abort --emit=llvm-ir -L $(TMPDIR)
|
@ -0,0 +1,15 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
// this crate provides the `panic_impl` lang item so we don't need to define it here
|
||||
extern crate panic_impl_provider;
|
@ -0,0 +1,20 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![crate_type = "rlib"]
|
||||
#![feature(panic_implementation)]
|
||||
#![no_std]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
#[panic_implementation]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user