1
Fork 0

libsyntax: Remove pub impl from the language

This commit is contained in:
Patrick Walton 2013-06-03 16:56:35 -07:00
parent 9873f67e94
commit 16086ecff7
6 changed files with 25 additions and 27 deletions

View file

@ -57,7 +57,7 @@ pub struct Terminal {
} }
#[cfg(not(target_os = "win32"))] #[cfg(not(target_os = "win32"))]
pub impl Terminal { impl Terminal {
pub fn new(out: @io::Writer) -> Result<Terminal, ~str> { pub fn new(out: @io::Writer) -> Result<Terminal, ~str> {
let term = os::getenv("TERM"); let term = os::getenv("TERM");
if term.is_none() { if term.is_none() {
@ -81,7 +81,7 @@ pub impl Terminal {
return Ok(Terminal {out: out, ti: inf, color_supported: cs}); return Ok(Terminal {out: out, ti: inf, color_supported: cs});
} }
fn fg(&self, color: u8) { pub fn fg(&self, color: u8) {
if self.color_supported { if self.color_supported {
let s = expand(*self.ti.strings.find_equiv(&("setaf")).unwrap(), let s = expand(*self.ti.strings.find_equiv(&("setaf")).unwrap(),
[Number(color as int)], [], []); [Number(color as int)], [], []);
@ -92,7 +92,7 @@ pub impl Terminal {
} }
} }
} }
fn bg(&self, color: u8) { pub fn bg(&self, color: u8) {
if self.color_supported { if self.color_supported {
let s = expand(*self.ti.strings.find_equiv(&("setab")).unwrap(), let s = expand(*self.ti.strings.find_equiv(&("setab")).unwrap(),
[Number(color as int)], [], []); [Number(color as int)], [], []);
@ -103,7 +103,7 @@ pub impl Terminal {
} }
} }
} }
fn reset(&self) { pub fn reset(&self) {
if self.color_supported { if self.color_supported {
let s = expand(*self.ti.strings.find_equiv(&("op")).unwrap(), [], [], []); let s = expand(*self.ti.strings.find_equiv(&("op")).unwrap(), [], [], []);
if s.is_ok() { if s.is_ok() {
@ -116,17 +116,17 @@ pub impl Terminal {
} }
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
pub impl Terminal { impl Terminal {
pub fn new(out: @io::Writer) -> Result<Terminal, ~str> { pub fn new(out: @io::Writer) -> Result<Terminal, ~str> {
return Ok(Terminal {out: out, color_supported: false}); return Ok(Terminal {out: out, color_supported: false});
} }
fn fg(&self, color: u8) { pub fn fg(&self, color: u8) {
} }
fn bg(&self, color: u8) { pub fn bg(&self, color: u8) {
} }
fn reset(&self) { pub fn reset(&self) {
} }
} }

View file

@ -35,8 +35,8 @@ pub struct PkgId {
version: Version version: Version
} }
pub impl PkgId { impl PkgId {
fn new(s: &str) -> PkgId { pub fn new(s: &str) -> PkgId {
use conditions::bad_pkg_id::cond; use conditions::bad_pkg_id::cond;
let p = Path(s); let p = Path(s);
@ -57,13 +57,13 @@ pub impl PkgId {
} }
} }
fn hash(&self) -> ~str { pub fn hash(&self) -> ~str {
fmt!("%s-%s-%s", self.remote_path.to_str(), fmt!("%s-%s-%s", self.remote_path.to_str(),
hash(self.remote_path.to_str() + self.version.to_str()), hash(self.remote_path.to_str() + self.version.to_str()),
self.version.to_str()) self.version.to_str())
} }
fn short_name_with_version(&self) -> ~str { pub fn short_name_with_version(&self) -> ~str {
fmt!("%s-%s", self.short_name, self.version.to_str()) fmt!("%s-%s", self.short_name, self.version.to_str())
} }
} }

View file

@ -440,8 +440,8 @@ pub struct expr {
span: span, span: span,
} }
pub impl expr { impl expr {
fn get_callee_id(&self) -> Option<node_id> { pub fn get_callee_id(&self) -> Option<node_id> {
match self.node { match self.node {
expr_method_call(callee_id, _, _, _, _, _) | expr_method_call(callee_id, _, _, _, _, _) |
expr_index(callee_id, _, _) | expr_index(callee_id, _, _) |

View file

@ -49,7 +49,7 @@ pub enum ObsoleteSyntax {
ObsoleteTraitBoundSeparator, ObsoleteTraitBoundSeparator,
ObsoleteMutOwnedPointer, ObsoleteMutOwnedPointer,
ObsoleteMutVector, ObsoleteMutVector,
ObsoleteTraitImplVisibility, ObsoleteImplVisibility,
ObsoleteRecordType, ObsoleteRecordType,
ObsoleteRecordPattern, ObsoleteRecordPattern,
ObsoletePostFnTySigil, ObsoletePostFnTySigil,
@ -158,11 +158,10 @@ impl Parser {
in a mutable location, like a mutable local variable or an \ in a mutable location, like a mutable local variable or an \
`@mut` box" `@mut` box"
), ),
ObsoleteTraitImplVisibility => ( ObsoleteImplVisibility => (
"visibility-qualified trait implementation", "visibility-qualified implementation",
"`pub` or `priv` is meaningless for trait implementations, \ "`pub` or `priv` goes on individual functions; remove the \
because the `impl...for...` form defines overloads for \ `pub` or `priv`"
methods that already exist; remove the `pub` or `priv`"
), ),
ObsoleteRecordType => ( ObsoleteRecordType => (
"structural record type", "structural record type",

View file

@ -76,7 +76,7 @@ use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove, ObsoleteSwap};
use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds}; use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds};
use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax}; use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer}; use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer};
use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility}; use parse::obsolete::{ObsoleteMutVector, ObsoleteImplVisibility};
use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern}; use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern};
use parse::obsolete::{ObsoletePostFnTySigil}; use parse::obsolete::{ObsoletePostFnTySigil};
use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum}; use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum};
@ -3305,10 +3305,9 @@ impl Parser {
None None
}; };
// Do not allow visibility to be specified in `impl...for...`. It is // Do not allow visibility to be specified.
// meaningless. if visibility != ast::inherited {
if opt_trait.is_some() && visibility != ast::inherited { self.obsolete(*self.span, ObsoleteImplVisibility);
self.obsolete(*self.span, ObsoleteTraitImplVisibility);
} }
let mut meths = ~[]; let mut meths = ~[];

View file

@ -34,7 +34,7 @@ pub mod sub_foo {
unused_str: ~str unused_str: ~str
} }
pub impl Boz { impl Boz {
pub fn boz(i: int) -> bool { pub fn boz(i: int) -> bool {
i > 0 i > 0
} }
@ -45,7 +45,7 @@ pub mod sub_foo {
Bort2 Bort2
} }
pub impl Bort { impl Bort {
pub fn bort() -> ~str { pub fn bort() -> ~str {
~"bort()" ~"bort()"
} }