diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 012b6f8e52b..e09ed201a35 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -2174,7 +2174,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>( if let ast::SelfExplicit(ref ast_type, _) = explicit_self.node { let typ = ccx.icx(&method_type.predicates).to_ty(rs, &**ast_type); let base_type = match typ.sty { - ty::ty_ptr(tm) | ty::ty_rptr(_, tm) => tm.ty, + ty::ty_rptr(_, tm) => tm.ty, ty::ty_uniq(typ) => typ, _ => typ, }; @@ -2220,7 +2220,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>( ppaux::ty_to_string(tcx, required_type)) })); - // We could conceviably add more free-reion relations here, + // We could conceviably add more free-region relations here, // but since this code is just concerned with checking that // the `&Self` types etc match up, it's not really necessary. // It would just allow people to be more approximate in some diff --git a/src/test/compile-fail/issue-26194.rs b/src/test/compile-fail/issue-26194.rs new file mode 100644 index 00000000000..b5c875cc4cb --- /dev/null +++ b/src/test/compile-fail/issue-26194.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S(String); + +impl S { + fn f(self: *mut S) -> String { self.0 } + //~^ ERROR mismatched self type +} + +fn main() { S("".to_owned()).f(); }