}
impl Digest for Sha1 {
- pub fn reset(&mut self) {
+ fn reset(&mut self) {
self.length_bits = 0;
self.h[0] = 0x67452301u32;
self.h[1] = 0xEFCDAB89u32;
self.buffer.reset();
self.computed = false;
}
- pub fn input(&mut self, msg: &[u8]) { add_input(self, msg); }
- pub fn result(&mut self, out: &mut [u8]) { return mk_result(self, out); }
- pub fn output_bits(&self) -> uint { 160 }
+ fn input(&mut self, msg: &[u8]) { add_input(self, msg); }
+ fn result(&mut self, out: &mut [u8]) { return mk_result(self, out); }
+ fn output_bits(&self) -> uint { 160 }
}
#[cfg(test)]
/// An iterface for casting C-like enum to uint and back.
pub trait CLike {
/// Converts C-like enum to uint.
- pub fn to_uint(&self) -> uint;
+ fn to_uint(&self) -> uint;
/// Converts uint to C-like enum.
- pub fn from_uint(uint) -> Self;
+ fn from_uint(uint) -> Self;
}
fn bit<E:CLike>(e: E) -> uint {
}
impl CLike for Foo {
- pub fn to_uint(&self) -> uint {
+ fn to_uint(&self) -> uint {
*self as uint
}
- pub fn from_uint(v: uint) -> Foo {
+ fn from_uint(v: uint) -> Foo {
unsafe { cast::transmute(v) }
}
}
impl FromStrRadix for BigUint {
/// Creates and initializes an BigUint.
- pub fn from_str_radix(s: &str, radix: uint)
+ fn from_str_radix(s: &str, radix: uint)
-> Option<BigUint> {
BigUint::parse_bytes(s.as_bytes(), radix)
}
pub struct MetricMap(TreeMap<~str,Metric>);
impl Clone for MetricMap {
- pub fn clone(&self) -> MetricMap {
+ fn clone(&self) -> MetricMap {
MetricMap((**self).clone())
}
}
}
impl<T: TotalOrd, Iter: Iterator<T>> FromIterator<T, Iter> for TreeSet<T> {
- pub fn from_iterator(iter: &mut Iter) -> TreeSet<T> {
+ fn from_iterator(iter: &mut Iter) -> TreeSet<T> {
let mut set = TreeSet::new();
set.extend(iter);
set
}
impl ToStr for Url {
- pub fn to_str(&self) -> ~str {
+ fn to_str(&self) -> ~str {
to_str(self)
}
}
// Do not check privacy inside items with the resolve_unexported
// attribute. This is used for the test runner.
if !attr::contains_name(item.attrs, "!resolve_unexported") {
+ check_sane_privacy(tcx, item);
oldvisit::visit_item(item, (method_map, visitor));
}
},
});
oldvisit::visit_crate(crate, (method_map, visitor));
}
+
+/// Validates all of the visibility qualifers placed on the item given. This
+/// ensures that there are no extraneous qualifiers that don't actually do
+/// anything. In theory these qualifiers wouldn't parse, but that may happen
+/// later on down the road...
+fn check_sane_privacy(tcx: ty::ctxt, item: @ast::item) {
+ match item.node {
+ // implementations of traits don't need visibility qualifiers because
+ // that's controlled by having the trait in scope.
+ ast::item_impl(_, Some(*), _, ref methods) => {
+ for m in methods.iter() {
+ match m.vis {
+ ast::private | ast::public => {
+ tcx.sess.span_err(m.span, "unnecessary visibility")
+ }
+ ast::inherited => {}
+ }
+ }
+ }
+
+ ast::item_enum(ref def, _) => {
+ for v in def.variants.iter() {
+ match v.node.vis {
+ ast::public => {
+ if item.vis == ast::public {
+ tcx.sess.span_err(v.span, "unnecessary `pub` \
+ visibility");
+ }
+ }
+ ast::private => {
+ if item.vis != ast::public {
+ tcx.sess.span_err(v.span, "unnecessary `priv` \
+ visibility");
+ }
+ }
+ ast::inherited => {}
+ }
+ }
+ }
+
+ ast::item_struct(ref def, _) => {
+ for f in def.fields.iter() {
+ match f.node.kind {
+ ast::named_field(_, ast::public) => {
+ tcx.sess.span_err(f.span, "unnecessary `pub` \
+ visibility");
+ }
+ ast::named_field(_, ast::private) => {
+ // Fields should really be private by default...
+ }
+ ast::named_field(*) | ast::unnamed_field => {}
+ }
+ }
+ }
+
+ ast::item_trait(_, _, ref methods) => {
+ for m in methods.iter() {
+ match *m {
+ ast::provided(ref m) => {
+ match m.vis {
+ ast::private | ast::public => {
+ tcx.sess.span_err(m.span, "unnecessary \
+ visibility");
+ }
+ ast::inherited => {}
+ }
+ }
+ // this is warned about in the parser
+ ast::required(*) => {}
+ }
+ }
+ }
+
+ ast::item_impl(*) | ast::item_static(*) | ast::item_foreign_mod(*) |
+ ast::item_fn(*) | ast::item_mod(*) | ast::item_ty(*) |
+ ast::item_mac(*) => {}
+ }
+}
#[unsafe_destructor]
impl<'self> Drop for StatRecorder<'self> {
- pub fn drop(&self) {
+ fn drop(&self) {
if self.ccx.sess.trans_stats() {
let end = time::precise_time_ns();
let elapsed = ((end - self.start) / 1_000_000) as uint;
}
impl CLike for BuiltinBound {
- pub fn to_uint(&self) -> uint {
+ fn to_uint(&self) -> uint {
*self as uint
}
- pub fn from_uint(v: uint) -> BuiltinBound {
+ fn from_uint(v: uint) -> BuiltinBound {
unsafe { cast::transmute(v) }
}
}
}
pub trait ExprTyProvider {
- pub fn expr_ty(&self, ex: &ast::expr) -> t;
- pub fn ty_ctxt(&self) -> ctxt;
+ fn expr_ty(&self, ex: &ast::expr) -> t;
+ fn ty_ctxt(&self) -> ctxt;
}
impl ExprTyProvider for ctxt {
- pub fn expr_ty(&self, ex: &ast::expr) -> t {
+ fn expr_ty(&self, ex: &ast::expr) -> t {
expr_ty(*self, ex)
}
- pub fn ty_ctxt(&self) -> ctxt {
+ fn ty_ctxt(&self) -> ctxt {
*self
}
}
}
impl ExprTyProvider for FnCtxt {
- pub fn expr_ty(&self, ex: &ast::expr) -> ty::t {
+ fn expr_ty(&self, ex: &ast::expr) -> ty::t {
self.expr_ty(ex)
}
- pub fn ty_ctxt(&self) -> ty::ctxt {
+ fn ty_ctxt(&self) -> ty::ctxt {
self.ccx.tcx
}
}
use util::ppaux::note_and_explain_region;
pub trait ErrorReporting {
- pub fn report_region_errors(@mut self,
- errors: &OptVec<RegionResolutionError>);
+ fn report_region_errors(@mut self,
+ errors: &OptVec<RegionResolutionError>);
- pub fn report_and_explain_type_error(@mut self,
- trace: TypeTrace,
- terr: &ty::type_err);
+ fn report_and_explain_type_error(@mut self,
+ trace: TypeTrace,
+ terr: &ty::type_err);
fn values_str(@mut self, values: &ValuePairs) -> Option<~str>;
impl ErrorReporting for InferCtxt {
- pub fn report_region_errors(@mut self,
- errors: &OptVec<RegionResolutionError>) {
+ fn report_region_errors(@mut self,
+ errors: &OptVec<RegionResolutionError>) {
for error in errors.iter() {
match *error {
ConcreteFailure(origin, sub, sup) => {
}
}
- pub fn report_and_explain_type_error(@mut self,
+ fn report_and_explain_type_error(@mut self,
trace: TypeTrace,
terr: &ty::type_err) {
let tcx = self.tcx;
}
impl get_and_find_region for isr_alist {
- pub fn get(&self, br: ty::bound_region) -> ty::Region {
+ fn get(&self, br: ty::bound_region) -> ty::Region {
self.find(br).unwrap()
}
- pub fn find(&self, br: ty::bound_region) -> Option<ty::Region> {
+ fn find(&self, br: ty::bound_region) -> Option<ty::Region> {
let mut ret = None;
do list::each(*self) |isr| {
let (isr_br, isr_r) = *isr;
#[deriving(Clone, Eq)]
pub enum OutputFormat {
/// Markdown
- pub Markdown,
+ Markdown,
/// HTML, via markdown and pandoc
- pub PandocHtml
+ PandocHtml
}
/// How to organize the output
#[deriving(Clone, Eq)]
pub enum OutputStyle {
/// All in a single document
- pub DocPerCrate,
+ DocPerCrate,
/// Each module in its own document
- pub DocPerMod
+ DocPerMod
}
/// The configuration for a rustdoc session
impl_num_cast!(float, to_float)
pub trait ToStrRadix {
- pub fn to_str_radix(&self, radix: uint) -> ~str;
+ fn to_str_radix(&self, radix: uint) -> ~str;
}
pub trait FromStrRadix {
- pub fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
+ fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
}
/// Calculates a power to a given radix, optimized for uint `pow` and `radix`.
/// Add an integer value to a pointer to get an offset pointer.
/// Is calculated according to the size of the type pointed to.
#[inline]
- pub fn add(&self, rhs: &I) -> *T {
+ fn add(&self, rhs: &I) -> *T {
self.offset(rhs.to_int() as int)
}
}
/// Subtract an integer value from a pointer to get an offset pointer.
/// Is calculated according to the size of the type pointed to.
#[inline]
- pub fn sub(&self, rhs: &I) -> *T {
+ fn sub(&self, rhs: &I) -> *T {
self.offset(-rhs.to_int() as int)
}
}
/// Add an integer value to a pointer to get an offset pointer.
/// Is calculated according to the size of the type pointed to.
#[inline]
- pub fn add(&self, rhs: &I) -> *mut T {
+ fn add(&self, rhs: &I) -> *mut T {
self.offset(rhs.to_int() as int)
}
}
/// Subtract an integer value from a pointer to get an offset pointer.
/// Is calculated according to the size of the type pointed to.
#[inline]
- pub fn sub(&self, rhs: &I) -> *mut T {
+ fn sub(&self, rhs: &I) -> *mut T {
self.offset(-rhs.to_int() as int)
}
}
/// A random number generator
pub trait Rng {
/// Return the next random integer
- pub fn next(&mut self) -> u32;
+ fn next(&mut self) -> u32;
}
/// A value with a particular weight compared to other values
impl Rng for XorShiftRng {
#[inline]
- pub fn next(&mut self) -> u32 {
+ fn next(&mut self) -> u32 {
let x = self.x;
let t = x ^ (x << 11);
self.x = self.y;
}
impl<C: GenericChan<~[u8]>> Writer for ChanWriter<C> {
- pub fn write(&mut self, _buf: &[u8]) { fail!() }
+ fn write(&mut self, _buf: &[u8]) { fail!() }
- pub fn flush(&mut self) { fail!() }
+ fn flush(&mut self) { fail!() }
}
struct ReaderPort<R>;
/// A type that wraps a native handle
pub trait NativeHandle<T> {
- pub fn from_native_handle(T) -> Self;
- pub fn native_handle(&self) -> T;
+ fn from_native_handle(T) -> Self;
+ fn native_handle(&self) -> T;
}
impl Loop {
impl<H, W: Watcher + NativeHandle<*H>> WatcherInterop for W {
/// Get the uv event loop from a Watcher
- pub fn event_loop(&self) -> Loop {
+ fn event_loop(&self) -> Loop {
unsafe {
let handle = self.native_handle();
let loop_ = uvll::get_loop_for_uv_handle(handle);
}
}
- pub fn install_watcher_data(&mut self) {
+ fn install_watcher_data(&mut self) {
unsafe {
let data = ~WatcherData {
read_cb: None,
}
}
- pub fn get_watcher_data<'r>(&'r mut self) -> &'r mut WatcherData {
+ fn get_watcher_data<'r>(&'r mut self) -> &'r mut WatcherData {
unsafe {
let data = uvll::get_data_for_uv_handle(self.native_handle());
let data = transmute::<&*c_void, &mut ~WatcherData>(&data);
}
}
- pub fn drop_watcher_data(&mut self) {
+ fn drop_watcher_data(&mut self) {
unsafe {
let data = uvll::get_data_for_uv_handle(self.native_handle());
let _data = transmute::<*c_void, ~WatcherData>(data);
#[allow(missing_doc)]
pub trait StrVector {
- pub fn concat(&self) -> ~str;
- pub fn connect(&self, sep: &str) -> ~str;
+ fn concat(&self) -> ~str;
+ fn connect(&self, sep: &str) -> ~str;
}
impl<'self, S: Str> StrVector for &'self [S] {
/// Concatenate a vector of strings.
- pub fn concat(&self) -> ~str {
+ fn concat(&self) -> ~str {
if self.is_empty() { return ~""; }
let len = self.iter().map(|s| s.as_slice().len()).sum();
}
/// Concatenate a vector of strings, placing a given separator between each.
- pub fn connect(&self, sep: &str) -> ~str {
+ fn connect(&self, sep: &str) -> ~str {
if self.is_empty() { return ~""; }
// concat is faster
/// # Return value
///
/// The original string with all occurances of `from` replaced with `to`
- pub fn replace(&self, from: &str, to: &str) -> ~str {
+ fn replace(&self, from: &str, to: &str) -> ~str {
let mut result = ~"";
let mut last_end = 0;
for (start, end) in self.matches_index_iter(from) {
/// * s - A string
/// * n - The number of bytes to reserve space for
#[inline]
- pub fn reserve(&mut self, n: uint) {
+ fn reserve(&mut self, n: uint) {
unsafe {
let v: &mut ~[u8] = cast::transmute(self);
(*v).reserve(n);
pub trait VectorVector<T> {
// FIXME #5898: calling these .concat and .connect conflicts with
// StrVector::con{cat,nect}, since they have generic contents.
- pub fn concat_vec(&self) -> ~[T];
- pub fn connect_vec(&self, sep: &T) -> ~[T];
+ fn concat_vec(&self) -> ~[T];
+ fn connect_vec(&self, sep: &T) -> ~[T];
}
impl<'self, T:Clone> VectorVector<T> for &'self [~[T]] {
/// Flattens a vector of slices of T into a single vector of T.
- pub fn concat_vec(&self) -> ~[T] {
+ fn concat_vec(&self) -> ~[T] {
self.flat_map(|inner| (*inner).clone())
}
/// Concatenate a vector of vectors, placing a given separator between each.
- pub fn connect_vec(&self, sep: &T) -> ~[T] {
+ fn connect_vec(&self, sep: &T) -> ~[T] {
let mut r = ~[];
let mut first = true;
for inner in self.iter() {
impl<'self,T:Clone> VectorVector<T> for &'self [&'self [T]] {
/// Flattens a vector of slices of T into a single vector of T.
- pub fn concat_vec(&self) -> ~[T] {
+ fn concat_vec(&self) -> ~[T] {
self.flat_map(|&inner| inner.to_owned())
}
/// Concatenate a vector of slices, placing a given separator between each.
- pub fn connect_vec(&self, sep: &T) -> ~[T] {
+ fn connect_vec(&self, sep: &T) -> ~[T] {
let mut r = ~[];
let mut first = true;
for &inner in self.iter() {
* Remove consecutive repeated elements from a vector; if the vector is
* sorted, this removes all duplicates.
*/
- pub fn dedup(&mut self) {
+ fn dedup(&mut self) {
unsafe {
// Although we have a mutable reference to `self`, we cannot make
// *arbitrary* changes. There exists the possibility that this
/// A trait for operations on mutable operations on `[u8]`
pub trait MutableByteVector {
/// Sets all bytes of the receiver to the given value.
- pub fn set_memory(self, value: u8);
+ fn set_memory(self, value: u8);
}
impl<'self> MutableByteVector for &'self mut [u8] {
}
pub trait EachViewItem {
- pub fn each_view_item(&self, f: @fn(&ast::view_item) -> bool) -> bool;
+ fn each_view_item(&self, f: @fn(&ast::view_item) -> bool) -> bool;
}
struct EachViewItemData {
}
}
- pub fn name_str_pair(&self) -> Option<(@str, @str)> {
+ fn name_str_pair(&self) -> Option<(@str, @str)> {
self.value_str().map_move(|s| (self.name(), s))
}
}
impl AttributeMethods for Attribute {
/// Extract the MetaItem from inside this Attribute.
- pub fn meta(&self) -> @MetaItem {
+ fn meta(&self) -> @MetaItem {
self.node.value
}
/// Convert self to a normal #[doc="foo"] comment, if it is a
/// comment like `///` or `/** */`. (Returns self unchanged for
/// non-sugared doc attributes.)
- pub fn desugar_doc(&self) -> Attribute {
+ fn desugar_doc(&self) -> Attribute {
if self.node.is_sugared_doc {
let comment = self.value_str().unwrap();
let meta = mk_name_value_item_str(@"doc",
// represents the origin of a file:
pub enum FileSubstr {
// indicates that this is a normal standalone file:
- pub FssNone,
+ FssNone,
// indicates that this "file" is actually a substring
// of another file that appears earlier in the codemap
- pub FssInternal(span),
+ FssInternal(span),
}
/// Identifies an offset of a multi-byte character in a FileMap
id: cx.next_id(),
span: span,
self_id: cx.next_id(),
- vis: ast::public
+ vis: ast::inherited,
}
}
pub use codemap::{BytePos, span, dummy_spanned};
pub trait ToTokens {
- pub fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree];
+ fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree];
}
impl ToTokens for ~[token_tree] {
- pub fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree] {
+ fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree] {
(*self).clone()
}
}
pub trait ToSource {
// Takes a thing and generates a string containing rust code for it.
- pub fn to_source(&self) -> @str;
+ fn to_source(&self) -> @str;
}
impl ToSource for ast::ident {
}
impl<A:Eq> Eq for OptVec<A> {
- pub fn eq(&self, other: &OptVec<A>) -> bool {
+ fn eq(&self, other: &OptVec<A>) -> bool {
// Note: cannot use #[deriving(Eq)] here because
// (Empty, Vec(~[])) ought to be equal.
match (self, other) {
}
}
- pub fn ne(&self, other: &OptVec<A>) -> bool {
+ fn ne(&self, other: &OptVec<A>) -> bool {
!self.eq(other)
}
}
ObsoleteExternVisibility,
ObsoleteUnsafeExternFn,
ObsoletePrivVisibility,
+ ObsoleteTraitFuncVisibility,
}
impl to_bytes::IterBytes for ObsoleteSyntax {
impl ParserObsoleteMethods for Parser {
/// Reports an obsolete syntax non-fatal error.
- pub fn obsolete(&self, sp: span, kind: ObsoleteSyntax) {
+ fn obsolete(&self, sp: span, kind: ObsoleteSyntax) {
let (kind_str, desc) = match kind {
ObsoleteLet => (
"`let` in field declaration",
"`priv` not necessary",
"an item without a visibility qualifier is private by default"
),
+ ObsoleteTraitFuncVisibility => (
+ "visibility not necessary",
+ "trait functions inherit the visibility of the trait itself"
+ ),
};
self.report(sp, kind, kind_str, desc);
// Reports an obsolete syntax non-fatal error, and returns
// a placeholder expression
- pub fn obsolete_expr(&self, sp: span, kind: ObsoleteSyntax) -> @expr {
+ fn obsolete_expr(&self, sp: span, kind: ObsoleteSyntax) -> @expr {
self.obsolete(sp, kind);
self.mk_expr(sp.lo, sp.hi, expr_lit(@respan(sp, lit_nil)))
}
}
}
- pub fn token_is_obsolete_ident(&self, ident: &str, token: &Token)
+ fn token_is_obsolete_ident(&self, ident: &str, token: &Token)
-> bool {
match *token {
token::IDENT(sid, _) => {
}
}
- pub fn is_obsolete_ident(&self, ident: &str) -> bool {
+ fn is_obsolete_ident(&self, ident: &str) -> bool {
self.token_is_obsolete_ident(ident, self.token)
}
- pub fn eat_obsolete_ident(&self, ident: &str) -> bool {
+ fn eat_obsolete_ident(&self, ident: &str) -> bool {
if self.is_obsolete_ident(ident) {
self.bump();
true
}
}
- pub fn try_parse_obsolete_struct_ctor(&self) -> bool {
+ fn try_parse_obsolete_struct_ctor(&self) -> bool {
if self.eat_obsolete_ident("new") {
self.obsolete(*self.last_span, ObsoleteStructCtor);
self.parse_fn_decl();
}
}
- pub fn try_parse_obsolete_with(&self) -> bool {
+ fn try_parse_obsolete_with(&self) -> bool {
if *self.token == token::COMMA
&& self.look_ahead(1,
|t| self.token_is_obsolete_ident("with", t)) {
}
}
- pub fn try_parse_obsolete_priv_section(&self, attrs: &[Attribute])
+ fn try_parse_obsolete_priv_section(&self, attrs: &[Attribute])
-> bool {
if self.is_keyword(keywords::Priv) &&
self.look_ahead(1, |t| *t == token::LBRACE) {
use parse::common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed};
use parse::lexer::reader;
use parse::lexer::TokenAndSpan;
-use parse::obsolete::{ObsoleteClassTraits};
-use parse::obsolete::{ObsoleteLet, ObsoleteFieldTerminator};
-use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove, ObsoleteSwap};
-use parse::obsolete::ObsoleteSyntax;
-use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
-use parse::obsolete::{ObsoleteMutOwnedPointer};
-use parse::obsolete::{ObsoleteMutVector, ObsoleteImplVisibility};
-use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern};
-use parse::obsolete::{ObsoletePostFnTySigil};
-use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum};
-use parse::obsolete::ObsoleteMode;
-use parse::obsolete::{ObsoleteLifetimeNotation, ObsoleteConstManagedPointer};
-use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod};
-use parse::obsolete::{ObsoleteConstItem, ObsoleteFixedLengthVectorType};
-use parse::obsolete::{ObsoleteNamedExternModule, ObsoleteMultipleLocalDecl};
-use parse::obsolete::{ObsoleteMutWithMultipleBindings};
-use parse::obsolete::{ObsoleteExternVisibility, ObsoleteUnsafeExternFn};
-use parse::obsolete::{ParserObsoleteMethods, ObsoletePrivVisibility};
+use parse::obsolete::*;
use parse::token::{can_begin_expr, get_ident_interner, ident_to_str, is_ident};
use parse::token::{is_ident_or_path};
use parse::token::{is_plain_ident, INTERPOLATED, keywords, special_idents};
debug!("parse_trait_methods(): parsing required method");
// NB: at the moment, visibility annotations on required
// methods are ignored; this could change.
+ if vis != ast::inherited {
+ self.obsolete(*self.last_span,
+ ObsoleteTraitFuncVisibility);
+ }
required(TypeMethod {
ident: ident,
attrs: attrs,
pub enum Foo {
- pub Bar,
+ Bar,
priv Baz,
}
pub use sub_foo::Bort;
pub trait Bar {
- pub fn bar() -> Self;
+ fn bar() -> Self;
}
impl Bar for int {
- pub fn bar() -> int { 84 }
+ fn bar() -> int { 84 }
}
pub mod sub_foo {
pub trait Foo {
- pub fn foo() -> Self;
+ fn foo() -> Self;
}
impl Foo for int {
- pub fn foo() -> int { 42 }
+ fn foo() -> int { 42 }
}
pub struct Boz {
struct Foo {
a: int,
priv b: int,
- pub c: int, // doesn't matter, Foo is private
}
pub struct PubFoo { //~ ERROR: missing documentation
a: int, //~ ERROR: missing documentation
priv b: int,
- pub c: int, //~ ERROR: missing documentation
}
#[allow(missing_doc)]
pub struct PubFoo2 {
a: int,
- pub c: int,
+ c: int,
}
/// dox
trait Bar {
/// dox
- pub fn foo();
+ fn foo();
fn foo2(); //~ ERROR: missing documentation
- pub fn foo3(); //~ ERROR: missing documentation
+ fn foo3(); //~ ERROR: missing documentation
}
impl Foo {
#[allow(missing_doc)]
trait F {
- pub fn a();
+ fn a();
fn b(&self);
}
// should need to redefine documentation for implementations of traits
impl F for Foo {
- pub fn a() {}
+ fn a() {}
fn b(&self) {}
}
--- /dev/null
+// Copyright 2013 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 { pub i: int } //~ ERROR: unnecessary `pub`
+struct B { priv i: int } // don't warn b/c B can still be returned
+pub enum C { pub Variant } //~ ERROR: unnecessary `pub`
+enum D { priv Variant2 } //~ ERROR: unnecessary `priv`
+
+pub trait E {
+ pub fn foo() {} //~ ERROR: unnecessary visibility
+}
+trait F { pub fn foo() {} } //~ ERROR: unnecessary visibility
+
+impl E for A {
+ pub fn foo() {} //~ ERROR: unnecessary visibility
+}
+
+fn main() {}
--- /dev/null
+// Copyright 2013 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.
+
+pub trait E {
+ pub fn foo(); //~ ERROR: obsolete syntax
+}
+trait F { pub fn foo(); } //~ ERROR: obsolete syntax
+
+struct B;
+impl E for B {
+ priv fn foo() {} //~ ERROR: obsolete syntax
+}
// except according to those terms.
pub trait Foo<T> {
- pub fn func1<U>(&self, t: U);
+ fn func1<U>(&self, t: U);
- pub fn func2<U>(&self, t: U) {
+ fn func2<U>(&self, t: U) {
self.func1(t);
}
}
// compile-flags:-Z debug-info
pub trait TraitWithDefaultMethod {
- pub fn method(self) {
+ fn method(self) {
()
}
}
mod a {
pub trait Foo {
- pub fn foo() -> Self;
+ fn foo() -> Self;
}
impl Foo for int {
- pub fn foo() -> int {
+ fn foo() -> int {
3
}
}
impl Foo for uint {
- pub fn foo() -> uint {
+ fn foo() -> uint {
5u
}
}