Skip to content

Commit c381259

Browse files
committed
auto merge of #15071 : tomjakubowski/rust/fix-15052, r=alexcrichton
Fix #15052
2 parents 82ec1ae + 0af4985 commit c381259

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

src/librustc/middle/mem_categorization.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,10 @@ impl<'t,TYPER:Typer> MemCategorizationContext<'t,TYPER> {
11211121
"captured outer variable".to_string()
11221122
}
11231123
_ => {
1124-
format!("dereference of `{}`-pointer", ptr_sigil(pk))
1124+
match pk {
1125+
OwnedPtr | GcPtr => format!("dereference of `{}`", ptr_sigil(pk)),
1126+
_ => format!("dereference of `{}`-pointer", ptr_sigil(pk))
1127+
}
11251128
}
11261129
}
11271130
}
@@ -1291,8 +1294,8 @@ impl Repr for categorization {
12911294

12921295
pub fn ptr_sigil(ptr: PointerKind) -> &'static str {
12931296
match ptr {
1294-
OwnedPtr => "~",
1295-
GcPtr => "@",
1297+
OwnedPtr => "Box",
1298+
GcPtr => "Gc",
12961299
BorrowedPtr(ty::ImmBorrow, _) => "&",
12971300
BorrowedPtr(ty::MutBorrow, _) => "&mut",
12981301
BorrowedPtr(ty::UniqueImmBorrow, _) => "&unique",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct A;
12+
13+
impl A {
14+
fn foo(&mut self) {
15+
}
16+
}
17+
18+
pub fn main() {
19+
let a = box A;
20+
a.foo();
21+
//~^ ERROR cannot borrow immutable dereference of `Box` `*a` as mutable
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(managed_boxes)]
12+
13+
use std::gc::GC;
14+
15+
struct A;
16+
17+
impl A {
18+
fn foo(&mut self) {
19+
}
20+
}
21+
22+
pub fn main() {
23+
let a = box(GC) A;
24+
a.foo();
25+
//~^ ERROR cannot borrow immutable dereference of `Gc` `*a` as mutable
26+
}

0 commit comments

Comments
 (0)