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
82cb88b7777f370eb0afd84459f53ded6627061b
rust/src/test/ui/issues/issue-44216-add-system-time.rs

10 lines
183 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
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: 708ms Template: 3ms
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