diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2016-04-14 09:57:55 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2016-04-14 10:05:51 -0400 |
| commit | 89bbd2c8b75f31f06496158e8e309557cfeaeed5 (patch) | |
| tree | 2af1ec22d0feb907b8f2fe8a57179c7413374ea0 /src/test | |
| parent | 2c9dfafa572272a758357d6bd5d51c0b22a9fdd3 (diff) | |
| download | rust-89bbd2c8b75f31f06496158e8e309557cfeaeed5.tar.gz rust-89bbd2c8b75f31f06496158e8e309557cfeaeed5.zip | |
Be a bit more constrained in our early check
Do not require the target type to be fully known, either. This allows code like `let x: *const () = 0 as _` to work (see regression test).
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/cast-to-infer-ty.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/run-pass/cast-to-infer-ty.rs b/src/test/run-pass/cast-to-infer-ty.rs new file mode 100644 index 00000000000..2aa0d9c62fb --- /dev/null +++ b/src/test/run-pass/cast-to-infer-ty.rs @@ -0,0 +1,17 @@ +// Copyright 2012 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. + +// Check that we allow a cast to `_` so long as the target type can be +// inferred elsewhere. + +pub fn main() { + let i: *const i32 = 0 as _; + assert!(i.is_null()); +} |
