Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
283522400b5c13dfdf2b7e608e63a70ee8e3d7af
rust/src/test/ui/issues/issue-44216-sub-system-time.rs

11 lines
217 B
Rust
Raw Normal View History

Move tests from `test/run-fail` to UI
2020-04-16 15:50:32 +09:00
// run-fail
Relaxed error pattern, and add test for SystemTime as well.
2017-09-10 01:48:43 +08:00
// error-pattern:overflow
Skip tests on emscripten
2020-05-08 00:39:02 +09:00
// ignore-emscripten no processes
Properly detect overflow in Instance +/- Duration. Avoid unchecked cast from `u64` to `i64`. Use `try_into()` for checked cast. (On Unix, cast to `time_t` instead of `i64`.)
2017-09-01 01:16:24 +08:00
Relaxed error pattern, and add test for SystemTime as well.
2017-09-10 01:48:43 +08:00
use std::time::{Duration, SystemTime};
Properly detect overflow in Instance +/- Duration. Avoid unchecked cast from `u64` to `i64`. Use `try_into()` for checked cast. (On Unix, cast to `time_t` instead of `i64`.)
2017-09-01 01:16:24 +08:00
fn main() {
Relaxed error pattern, and add test for SystemTime as well.
2017-09-10 01:48:43 +08:00
let now = SystemTime::now();
Properly detect overflow in Instance +/- Duration. Avoid unchecked cast from `u64` to `i64`. Use `try_into()` for checked cast. (On Unix, cast to `time_t` instead of `i64`.)
2017-09-01 01:16:24 +08:00
let _ = now - Duration::from_secs(u64::max_value());
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 472ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API