about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-07-31 14:41:58 -0700
committerGitHub <noreply@github.com>2016-07-31 14:41:58 -0700
commit7333c4ac25648e831fb2033ee77fbbdc62ae492a (patch)
treea1a0e76e2608dfe3d6c0452675d7ca200b4ab591 /src/test
parent2b87f031e79d870f6b148339e21e5c2a3112d4af (diff)
parent0a128f325e47ae5c554ff1bcb76db142355a5919 (diff)
downloadrust-7333c4ac25648e831fb2033ee77fbbdc62ae492a.tar.gz
rust-7333c4ac25648e831fb2033ee77fbbdc62ae492a.zip
Auto merge of #35143 - arielb1:rfc447-regions, r=eddyb
typeck: use a TypeVisitor in ctp

Use a TypeVisitor in ctp instead of `ty::walk`

This fixes a few cases where a region could be projected out of a trait while not being constrained by the type parameters, violating rust-lang/rfcs#447 and breaking soundness. As such, this is a [breaking-change].

Fixes #35139

r? @eddyb
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/issue-35139.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/compile-fail/issue-35139.rs b/src/test/compile-fail/issue-35139.rs
new file mode 100644
index 00000000000..67f0e7aaf97
--- /dev/null
+++ b/src/test/compile-fail/issue-35139.rs
@@ -0,0 +1,36 @@
+// Copyright 2016 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.
+
+use std::fmt;
+
+pub trait MethodType {
+    type GetProp: ?Sized;
+}
+
+pub struct MTFn;
+
+impl<'a> MethodType for MTFn { //~ ERROR E0207
+    type GetProp = fmt::Debug + 'a;
+}
+
+fn bad(a: Box<<MTFn as MethodType>::GetProp>) -> Box<fmt::Debug+'static> {
+    a
+}
+
+fn dangling(a: &str) -> Box<fmt::Debug> {
+    bad(Box::new(a))
+}
+
+fn main() {
+    let mut s = "hello".to_string();
+    let x = dangling(&s);
+    s = String::new();
+    println!("{:?}", x);
+}