about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-07-31 11:20:16 +0000
committerbors <bors@rust-lang.org>2018-07-31 11:20:16 +0000
commited8d14db99fc79909274454c02073bc5bd0c0df2 (patch)
treea767dfeb41318038e44751322e15cf1c3c2e36d9 /src/test
parent896113201034946c7f49c1049288665fa2a56e32 (diff)
parent56016cb1e02ece29f25c619b297f9c9797db821c (diff)
downloadrust-ed8d14db99fc79909274454c02073bc5bd0c0df2.tar.gz
rust-ed8d14db99fc79909274454c02073bc5bd0c0df2.zip
Auto merge of #50267 - humanenginuity:master, r=alexcrichton
Implement inner deref for Option and Result

tracking issue: #50264
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/issue-50264-inner-deref-trait/option_deref.rs16
-rw-r--r--src/test/compile-fail/issue-50264-inner-deref-trait/result_deref.rs16
-rw-r--r--src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_err.rs16
-rw-r--r--src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_ok.rs16
4 files changed, 64 insertions, 0 deletions
diff --git a/src/test/compile-fail/issue-50264-inner-deref-trait/option_deref.rs b/src/test/compile-fail/issue-50264-inner-deref-trait/option_deref.rs
new file mode 100644
index 00000000000..4c67fb3bef1
--- /dev/null
+++ b/src/test/compile-fail/issue-50264-inner-deref-trait/option_deref.rs
@@ -0,0 +1,16 @@
+// 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.
+
+#![feature(inner_deref)]
+
+fn main() {
+    let _result = &Some(42).deref();
+//~^ ERROR no method named `deref` found for type `std::option::Option<{integer}>`
+}
diff --git a/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref.rs b/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref.rs
new file mode 100644
index 00000000000..73bdf0b9209
--- /dev/null
+++ b/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref.rs
@@ -0,0 +1,16 @@
+// 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.
+
+#![feature(inner_deref)]
+
+fn main() {
+    let _result = &Ok(42).deref();
+//~^ ERROR no method named `deref` found
+}
diff --git a/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_err.rs b/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_err.rs
new file mode 100644
index 00000000000..5d1e7472d8f
--- /dev/null
+++ b/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_err.rs
@@ -0,0 +1,16 @@
+// 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.
+
+#![feature(inner_deref)]
+
+fn main() {
+    let _result = &Err(41).deref_err();
+//~^ ERROR no method named `deref_err` found
+}
diff --git a/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_ok.rs b/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_ok.rs
new file mode 100644
index 00000000000..bee8e0c062b
--- /dev/null
+++ b/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_ok.rs
@@ -0,0 +1,16 @@
+// 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.
+
+#![feature(inner_deref)]
+
+fn main() {
+    let _result = &Ok(42).deref_ok();
+//~^ ERROR no method named `deref_ok` found
+}