Skip to content

Commit

Permalink
librustc: Remove outdated reference to ~ and @
Browse files Browse the repository at this point in the history
Fix #15052
  • Loading branch information
tomjakubowski committed Jun 24, 2014
1 parent d9611da commit 0af4985
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/librustc/middle/mem_categorization.rs
Expand Up @@ -1121,7 +1121,10 @@ impl<'t,TYPER:Typer> MemCategorizationContext<'t,TYPER> {
"captured outer variable".to_string()
}
_ => {
format!("dereference of `{}`-pointer", ptr_sigil(pk))
match pk {
OwnedPtr | GcPtr => format!("dereference of `{}`", ptr_sigil(pk)),
_ => format!("dereference of `{}`-pointer", ptr_sigil(pk))
}
}
}
}
Expand Down Expand Up @@ -1291,8 +1294,8 @@ impl Repr for categorization {

pub fn ptr_sigil(ptr: PointerKind) -> &'static str {
match ptr {
OwnedPtr => "~",
GcPtr => "@",
OwnedPtr => "Box",
GcPtr => "Gc",
BorrowedPtr(ty::ImmBorrow, _) => "&",
BorrowedPtr(ty::MutBorrow, _) => "&mut",
BorrowedPtr(ty::UniqueImmBorrow, _) => "&unique",
Expand Down
22 changes: 22 additions & 0 deletions src/test/compile-fail/borrowck-borrow-immut-deref-of-box-as-mut.rs
@@ -0,0 +1,22 @@
// Copyright 2014 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.

struct A;

impl A {
fn foo(&mut self) {
}
}

pub fn main() {
let a = box A;
a.foo();
//~^ ERROR cannot borrow immutable dereference of `Box` `*a` as mutable
}
26 changes: 26 additions & 0 deletions src/test/compile-fail/borrowck-borrow-immut-deref-of-gc-as-mut.rs
@@ -0,0 +1,26 @@
// Copyright 2014 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(managed_boxes)]

use std::gc::GC;

struct A;

impl A {
fn foo(&mut self) {
}
}

pub fn main() {
let a = box(GC) A;
a.foo();
//~^ ERROR cannot borrow immutable dereference of `Gc` `*a` as mutable
}

5 comments on commit 0af4985

@bors
Copy link
Contributor

@bors bors commented on 0af4985 Jun 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at tomjakubowski@0af4985

@bors
Copy link
Contributor

@bors bors commented on 0af4985 Jun 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging tomjakubowski/rust/fix-15052 = 0af4985 into auto

@bors
Copy link
Contributor

@bors bors commented on 0af4985 Jun 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tomjakubowski/rust/fix-15052 = 0af4985 merged ok, testing candidate = c381259

@bors
Copy link
Contributor

@bors bors commented on 0af4985 Jun 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = c381259

Please sign in to comment.