]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/issues/issue-21400.rs
2 // Regression test for #21400 which itself was extracted from
3 // stackoverflow.com/questions/28031155/is-my-borrow-checker-drunk/28031580
7 assert_eq
!(t
.method1("one"), Ok(1));
8 assert_eq
!(t
.method2("two"), Ok(2));
9 assert_eq
!(t
.test(), Ok(2));
15 fn method1(&mut self, _arg
: &str) -> Result
<usize, &str> {
19 fn method2(self: &mut Test
, _arg
: &str) -> Result
<usize, &str> {
23 fn test(self: &mut Test
) -> Result
<usize, &str> {
24 let s
= format
!("abcde");
25 // (Originally, this invocation of method2 was saying that `s`
26 // does not live long enough.)
27 let data
= match self.method2(&*s
) {
29 Err(e
) => return Err(e
)
35 // Below is a closer match for the original test that was failing to compile
37 pub struct GitConnect
;
40 fn command(self: &mut GitConnect
, _s
: &str) -> Result
<Vec
<Vec
<u8>>, &str> {
44 pub fn git_upload_pack(self: &mut GitConnect
) -> Result
<String
, &str> {
45 let c
= format
!("git-upload-pack");
47 let mut out
= String
::new();
48 let data
= self.command(&c
)?
;
50 for line
in data
.iter() {
51 out
.push_str(&format
!("{:?}", line
));