rustc_typeck: do not overlap a borrow of TypeckTables with method lookup.
If trait selection is reached, it could potentially request a closure signature, which will have to borrow the `TypeckTables` of the current function, and so those tables *should not* be mutably borrowed.
Fixes #42463.
r? @nikomatsakis
use std::collections::HashSet;
use std::env;
use std::fmt;
-use std::fs;
+use std::fs::{self, File};
use std::path::{PathBuf, Path};
use std::process::Command;
+use std::io::Read;
use build_helper::output;
while let Some(p) = stack.pop() {
if p.is_dir() {
- stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
+ stack.extend(t!(p.read_dir()).map(|p| t!(p).path()).filter(|p| {
+ p.extension().and_then(|s| s.to_str()) == Some("md") &&
+ // The nostarch directory in the book is for no starch, and so isn't guaranteed to
+ // build. We don't care if it doesn't build, so skip it.
+ p.to_str().map_or(true, |p| !p.contains("nostarch"))
+ }));
continue
}
- if p.extension().and_then(|s| s.to_str()) != Some("md") {
- continue
- }
-
- // The nostarch directory in the book is for no starch, and so isn't guaranteed to build.
- // we don't care if it doesn't build, so skip it.
- use std::ffi::OsStr;
- let path: &OsStr = p.as_ref();
- if let Some(path) = path.to_str() {
- if path.contains("nostarch") {
- continue;
- }
- }
-
- println!("doc tests for: {}", p.display());
markdown_test(build, compiler, &p);
}
}
}
fn markdown_test(build: &Build, compiler: &Compiler, markdown: &Path) {
+ let mut file = t!(File::open(markdown));
+ let mut contents = String::new();
+ t!(file.read_to_string(&mut contents));
+ if !contents.contains("```") {
+ return;
+ }
+
+ println!("doc tests for: {}", markdown.display());
let mut cmd = Command::new(build.rustdoc(compiler));
build.add_rustc_lib_path(compiler, &mut cmd);
build.add_rust_test_threads(&mut cmd);
if build.is_rust_llvm(target) {
cargo.env("LLVM_RUSTLLVM", "1");
}
+ if let Some(ref cfg_file) = build.flags.config {
+ let cfg_path = t!(PathBuf::from(cfg_file).canonicalize());
+ cargo.env("CFG_LLVM_TOML", cfg_path.into_os_string());
+ }
cargo.env("LLVM_CONFIG", build.llvm_config(target));
let target_config = build.config.target_config.get(target);
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
/// # Examples
///
/// ```
+ /// use std::ascii::AsciiExt;
/// use std::borrow::Cow;
///
- /// let mut cow: Cow<[_]> = Cow::Owned(vec![1, 2, 3]);
+ /// let mut cow = Cow::Borrowed("foo");
+ /// cow.to_mut().make_ascii_uppercase();
///
- /// let hello = cow.to_mut();
- ///
- /// assert_eq!(hello, &[1, 2, 3]);
+ /// assert_eq!(
+ /// cow,
+ /// Cow::Owned(String::from("FOO")) as Cow<str>
+ /// );
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned {
///
/// # Examples
///
+ /// Calling `into_owned` on a `Cow::Borrowed` clones the underlying data
+ /// and becomes a `Cow::Owned`:
+ ///
/// ```
/// use std::borrow::Cow;
///
- /// let cow: Cow<[_]> = Cow::Owned(vec![1, 2, 3]);
+ /// let s = "Hello world!";
+ /// let cow = Cow::Borrowed(s);
+ ///
+ /// assert_eq!(
+ /// cow.into_owned(),
+ /// Cow::Owned(String::from(s))
+ /// );
+ /// ```
+ ///
+ /// Calling `into_owned` on a `Cow::Owned` is a no-op:
+ ///
+ /// ```
+ /// use std::borrow::Cow;
///
- /// let hello = cow.into_owned();
+ /// let s = "Hello world!";
+ /// let cow: Cow<str> = Cow::Owned(String::from(s));
///
- /// assert_eq!(vec![1, 2, 3], hello);
+ /// assert_eq!(
+ /// cow.into_owned(),
+ /// Cow::Owned(String::from(s))
+ /// );
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn into_owned(self) -> <B as ToOwned>::Owned {
/// This will invoke the [`panic!`] macro if the provided expression cannot be
/// evaluated to `true` at runtime.
///
+/// # Uses
+///
/// Assertions are always checked in both debug and release builds, and cannot
/// be disabled. See [`debug_assert!`] for assertions that are not enabled in
/// release builds by default.
/// Other use-cases of `assert!` include [testing] and enforcing run-time
/// invariants in safe code (whose violation cannot result in unsafety).
///
-/// This macro has a second version, where a custom panic message can
+/// # Custom Messages
+///
+/// This macro has a second form, where a custom panic message can
/// be provided with or without arguments for formatting.
///
/// [`panic!`]: macro.panic.html
);
}
-/// Asserts that two expressions are equal to each other.
+/// Asserts that two expressions are equal to each other (using [`PartialEq`]).
///
/// On panic, this macro will print the values of the expressions with their
/// debug representations.
///
-/// Like [`assert!`], this macro has a second version, where a custom
+/// Like [`assert!`], this macro has a second form, where a custom
/// panic message can be provided.
///
+/// [`PartialEq`]: cmp/trait.PartialEq.html
/// [`assert!`]: macro.assert.html
///
/// # Examples
});
}
-/// Asserts that two expressions are not equal to each other.
+/// Asserts that two expressions are not equal to each other (using [`PartialEq`]).
///
/// On panic, this macro will print the values of the expressions with their
/// debug representations.
///
-/// Like `assert!()`, this macro has a second version, where a custom
+/// Like [`assert!`], this macro has a second form, where a custom
/// panic message can be provided.
///
+/// [`PartialEq`]: cmp/trait.PartialEq.html
/// [`assert!`]: macro.assert.html
///
/// # Examples
/// Like [`assert!`], this macro also has a second version, where a custom panic
/// message can be provided.
///
+/// # Uses
+///
/// Unlike [`assert!`], `debug_assert!` statements are only enabled in non
/// optimized builds by default. An optimized build will omit all
/// `debug_assert!` statements unless `-C debug-assertions` is passed to the
/// but not `Copy`.
///
/// [`Clone`] is a supertrait of `Copy`, so everything which is `Copy` must also implement
-/// [`Clone`]. If a type is `Copy` then its [`Clone`] implementation need only return `*self`
+/// [`Clone`]. If a type is `Copy` then its [`Clone`] implementation only needs to return `*self`
/// (see the example above).
///
/// ## When can my type be `Copy`?
started: https://doc.rust-lang.org/book/
"##,
+E0602: r##"
+An unknown lint was used on the command line.
+
+Erroneous example:
+
+```ignore
+rustc -D bogus omse_file.rs
+```
+
+Maybe you just misspelled the lint name or the lint doesn't exist anymore.
+Either way, try to update/remove it in order to fix the error.
+"##,
+
}
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum CtorKind {
- // Constructor function automatically created by a tuple struct/variant.
+ /// Constructor function automatically created by a tuple struct/variant.
Fn,
- // Constructor constant automatically created by a unit struct/variant.
+ /// Constructor constant automatically created by a unit struct/variant.
Const,
- // Unusable name in value namespace created by a struct variant.
+ /// Unusable name in value namespace created by a struct variant.
Fictive,
}
}
}
-// Definition mapping
+/// Definition mapping
pub type DefMap = NodeMap<PathResolution>;
-// This is the replacement export map. It maps a module to all of the exports
-// within.
+
+/// This is the replacement export map. It maps a module to all of the exports
+/// within.
pub type ExportMap = NodeMap<Vec<Export>>;
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
pub struct Export {
- pub ident: ast::Ident, // The name of the target.
- pub def: Def, // The definition of the target.
- pub span: Span, // The span of the target definition.
+ /// The name of the target.
+ pub ident: ast::Ident,
+ /// The definition of the target.
+ pub def: Def,
+ /// The span of the target definition.
+ pub span: Span,
}
impl CtorKind {
}
}
+ /// A human readable kind name
pub fn kind_name(&self) -> &'static str {
match *self {
Def::Fn(..) => "function",
impl DefId {
+ /// Make a local `DefId` with the given index.
pub fn local(index: DefIndex) -> DefId {
DefId { krate: LOCAL_CRATE, index: index }
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// Lowers the AST to the HIR.
-//
-// Since the AST and HIR are fairly similar, this is mostly a simple procedure,
-// much like a fold. Where lowering involves a bit more work things get more
-// interesting and there are some invariants you should know about. These mostly
-// concern spans and ids.
-//
-// Spans are assigned to AST nodes during parsing and then are modified during
-// expansion to indicate the origin of a node and the process it went through
-// being expanded. Ids are assigned to AST nodes just before lowering.
-//
-// For the simpler lowering steps, ids and spans should be preserved. Unlike
-// expansion we do not preserve the process of lowering in the spans, so spans
-// should not be modified here. When creating a new node (as opposed to
-// 'folding' an existing one), then you create a new id using `next_id()`.
-//
-// You must ensure that ids are unique. That means that you should only use the
-// id from an AST node in a single HIR node (you can assume that AST node ids
-// are unique). Every new node must have a unique id. Avoid cloning HIR nodes.
-// If you do, you must then set the new node's id to a fresh one.
-//
-// Spans are used for error messages and for tools to map semantics back to
-// source code. It is therefore not as important with spans as ids to be strict
-// about use (you can't break the compiler by screwing up a span). Obviously, a
-// HIR node can only have a single span. But multiple nodes can have the same
-// span and spans don't need to be kept in order, etc. Where code is preserved
-// by lowering, it should have the same span as in the AST. Where HIR nodes are
-// new it is probably best to give a span for the whole AST node being lowered.
-// All nodes should have real spans, don't use dummy spans. Tools are likely to
-// get confused if the spans from leaf AST nodes occur in multiple places
-// in the HIR, especially for multiple identifiers.
+//! Lowers the AST to the HIR.
+//!
+//! Since the AST and HIR are fairly similar, this is mostly a simple procedure,
+//! much like a fold. Where lowering involves a bit more work things get more
+//! interesting and there are some invariants you should know about. These mostly
+//! concern spans and ids.
+//!
+//! Spans are assigned to AST nodes during parsing and then are modified during
+//! expansion to indicate the origin of a node and the process it went through
+//! being expanded. Ids are assigned to AST nodes just before lowering.
+//!
+//! For the simpler lowering steps, ids and spans should be preserved. Unlike
+//! expansion we do not preserve the process of lowering in the spans, so spans
+//! should not be modified here. When creating a new node (as opposed to
+//! 'folding' an existing one), then you create a new id using `next_id()`.
+//!
+//! You must ensure that ids are unique. That means that you should only use the
+//! id from an AST node in a single HIR node (you can assume that AST node ids
+//! are unique). Every new node must have a unique id. Avoid cloning HIR nodes.
+//! If you do, you must then set the new node's id to a fresh one.
+//!
+//! Spans are used for error messages and for tools to map semantics back to
+//! source code. It is therefore not as important with spans as ids to be strict
+//! about use (you can't break the compiler by screwing up a span). Obviously, a
+//! HIR node can only have a single span. But multiple nodes can have the same
+//! span and spans don't need to be kept in order, etc. Where code is preserved
+//! by lowering, it should have the same span as in the AST. Where HIR nodes are
+//! new it is probably best to give a span for the whole AST node being lowered.
+//! All nodes should have real spans, don't use dummy spans. Tools are likely to
+//! get confused if the spans from leaf AST nodes occur in multiple places
+//! in the HIR, especially for multiple identifiers.
use hir;
use hir::map::{Definitions, DefKey, REGULAR_SPACE};
pub struct LoweringContext<'a> {
crate_root: Option<&'static str>,
+
// Use to assign ids to hir nodes that do not directly correspond to an ast node
sess: &'a Session,
+
// As we walk the AST we must keep track of the current 'parent' def id (in
// the form of a DefIndex) so that if we create a new node which introduces
// a definition, then we can properly create the def id.
}
pub trait Resolver {
- // Resolve a hir path generated by the lowerer when expanding `for`, `if let`, etc.
+ /// Resolve a hir path generated by the lowerer when expanding `for`, `if let`, etc.
fn resolve_hir_path(&mut self, path: &mut hir::Path, is_value: bool);
- // Obtain the resolution for a node id
+ /// Obtain the resolution for a node id
fn get_resolution(&mut self, id: NodeId) -> Option<PathResolution>;
- // We must keep the set of definitions up to date as we add nodes that weren't in the AST.
- // This should only return `None` during testing.
+ /// We must keep the set of definitions up to date as we add nodes that weren't in the AST.
+ /// This should only return `None` during testing.
fn definitions(&mut self) -> &mut Definitions;
}
Region(ty::RegionKind),
}
-// type Edge = Constraint;
#[derive(Clone, PartialEq, Eq, Debug, Copy)]
enum Edge<'tcx> {
Constraint(Constraint<'tcx>),
mod graphviz;
-// A constraint that influences the inference process.
+/// A constraint that influences the inference process.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum Constraint<'tcx> {
- // One region variable is subregion of another
+ /// One region variable is subregion of another
ConstrainVarSubVar(RegionVid, RegionVid),
- // Concrete region is subregion of region variable
+ /// Concrete region is subregion of region variable
ConstrainRegSubVar(Region<'tcx>, RegionVid),
- // Region variable is subregion of concrete region. This does not
- // directly affect inference, but instead is checked after
- // inference is complete.
+ /// Region variable is subregion of concrete region. This does not
+ /// directly affect inference, but instead is checked after
+ /// inference is complete.
ConstrainVarSubReg(RegionVid, Region<'tcx>),
- // A constraint where neither side is a variable. This does not
- // directly affect inference, but instead is checked after
- // inference is complete.
+ /// A constraint where neither side is a variable. This does not
+ /// directly affect inference, but instead is checked after
+ /// inference is complete.
ConstrainRegSubReg(Region<'tcx>, Region<'tcx>),
}
-// VerifyGenericBound(T, _, R, RS): The parameter type `T` (or
-// associated type) must outlive the region `R`. `T` is known to
-// outlive `RS`. Therefore verify that `R <= RS[i]` for some
-// `i`. Inference variables may be involved (but this verification
-// step doesn't influence inference).
+/// VerifyGenericBound(T, _, R, RS): The parameter type `T` (or
+/// associated type) must outlive the region `R`. `T` is known to
+/// outlive `RS`. Therefore verify that `R <= RS[i]` for some
+/// `i`. Inference variables may be involved (but this verification
+/// step doesn't influence inference).
#[derive(Debug)]
pub struct Verify<'tcx> {
kind: GenericKind<'tcx>,
Projection(ty::ProjectionTy<'tcx>),
}
-// When we introduce a verification step, we wish to test that a
-// particular region (let's call it `'min`) meets some bound.
-// The bound is described the by the following grammar:
+/// When we introduce a verification step, we wish to test that a
+/// particular region (let's call it `'min`) meets some bound.
+/// The bound is described the by the following grammar:
#[derive(Debug)]
pub enum VerifyBound<'tcx> {
- // B = exists {R} --> some 'r in {R} must outlive 'min
- //
- // Put another way, the subject value is known to outlive all
- // regions in {R}, so if any of those outlives 'min, then the
- // bound is met.
+ /// B = exists {R} --> some 'r in {R} must outlive 'min
+ ///
+ /// Put another way, the subject value is known to outlive all
+ /// regions in {R}, so if any of those outlives 'min, then the
+ /// bound is met.
AnyRegion(Vec<Region<'tcx>>),
- // B = forall {R} --> all 'r in {R} must outlive 'min
- //
- // Put another way, the subject value is known to outlive some
- // region in {R}, so if all of those outlives 'min, then the bound
- // is met.
+ /// B = forall {R} --> all 'r in {R} must outlive 'min
+ ///
+ /// Put another way, the subject value is known to outlive some
+ /// region in {R}, so if all of those outlives 'min, then the bound
+ /// is met.
AllRegions(Vec<Region<'tcx>>),
- // B = exists {B} --> 'min must meet some bound b in {B}
+ /// B = exists {B} --> 'min must meet some bound b in {B}
AnyBound(Vec<VerifyBound<'tcx>>),
- // B = forall {B} --> 'min must meet all bounds b in {B}
+ /// B = forall {B} --> 'min must meet all bounds b in {B}
AllBounds(Vec<VerifyBound<'tcx>>),
}
tcx: TyCtxt<'a, 'gcx, 'tcx>,
var_origins: RefCell<Vec<RegionVariableOrigin>>,
- // Constraints of the form `A <= B` introduced by the region
- // checker. Here at least one of `A` and `B` must be a region
- // variable.
+ /// Constraints of the form `A <= B` introduced by the region
+ /// checker. Here at least one of `A` and `B` must be a region
+ /// variable.
constraints: RefCell<FxHashMap<Constraint<'tcx>, SubregionOrigin<'tcx>>>,
- // A "verify" is something that we need to verify after inference is
- // done, but which does not directly affect inference in any way.
- //
- // An example is a `A <= B` where neither `A` nor `B` are
- // inference variables.
+ /// A "verify" is something that we need to verify after inference is
+ /// done, but which does not directly affect inference in any way.
+ ///
+ /// An example is a `A <= B` where neither `A` nor `B` are
+ /// inference variables.
verifys: RefCell<Vec<Verify<'tcx>>>,
- // A "given" is a relationship that is known to hold. In particular,
- // we often know from closure fn signatures that a particular free
- // region must be a subregion of a region variable:
- //
- // foo.iter().filter(<'a> |x: &'a &'b T| ...)
- //
- // In situations like this, `'b` is in fact a region variable
- // introduced by the call to `iter()`, and `'a` is a bound region
- // on the closure (as indicated by the `<'a>` prefix). If we are
- // naive, we wind up inferring that `'b` must be `'static`,
- // because we require that it be greater than `'a` and we do not
- // know what `'a` is precisely.
- //
- // This hashmap is used to avoid that naive scenario. Basically we
- // record the fact that `'a <= 'b` is implied by the fn signature,
- // and then ignore the constraint when solving equations. This is
- // a bit of a hack but seems to work.
+ /// A "given" is a relationship that is known to hold. In particular,
+ /// we often know from closure fn signatures that a particular free
+ /// region must be a subregion of a region variable:
+ ///
+ /// foo.iter().filter(<'a> |x: &'a &'b T| ...)
+ ///
+ /// In situations like this, `'b` is in fact a region variable
+ /// introduced by the call to `iter()`, and `'a` is a bound region
+ /// on the closure (as indicated by the `<'a>` prefix). If we are
+ /// naive, we wind up inferring that `'b` must be `'static`,
+ /// because we require that it be greater than `'a` and we do not
+ /// know what `'a` is precisely.
+ ///
+ /// This hashmap is used to avoid that naive scenario. Basically we
+ /// record the fact that `'a <= 'b` is implied by the fn signature,
+ /// and then ignore the constraint when solving equations. This is
+ /// a bit of a hack but seems to work.
givens: RefCell<FxHashSet<(Region<'tcx>, ty::RegionVid)>>,
lubs: RefCell<CombineMap<'tcx>>,
skolemization_count: Cell<u32>,
bound_count: Cell<u32>,
- // The undo log records actions that might later be undone.
- //
- // Note: when the undo_log is empty, we are not actively
- // snapshotting. When the `start_snapshot()` method is called, we
- // push an OpenSnapshot entry onto the list to indicate that we
- // are now actively snapshotting. The reason for this is that
- // otherwise we end up adding entries for things like the lower
- // bound on a variable and so forth, which can never be rolled
- // back.
+ /// The undo log records actions that might later be undone.
+ ///
+ /// Note: when the undo_log is empty, we are not actively
+ /// snapshotting. When the `start_snapshot()` method is called, we
+ /// push an OpenSnapshot entry onto the list to indicate that we
+ /// are now actively snapshotting. The reason for this is that
+ /// otherwise we end up adding entries for things like the lower
+ /// bound on a variable and so forth, which can never be rolled
+ /// back.
undo_log: RefCell<Vec<UndoLogEntry<'tcx>>>,
+
unification_table: RefCell<UnificationTable<ty::RegionVid>>,
- // This contains the results of inference. It begins as an empty
- // option and only acquires a value after inference is complete.
+ /// This contains the results of inference. It begins as an empty
+ /// option and only acquires a value after inference is complete.
values: RefCell<Option<Vec<VarValue<'tcx>>>>,
}
continue;
}
}
- },
- Err(FindLintError::Removed) => { continue; }
+ }
+ Err(FindLintError::Removed) => continue,
}
}
};
Some(sess.struct_warn(msg))
},
CheckLintNameResult::NoLint => {
- Some(sess.struct_err(&format!("unknown lint: `{}`", lint_name)))
+ Some(struct_err!(sess, E0602, "unknown lint: `{}`", lint_name))
}
};
m.push_str(&(if n == 1 {
help_name
} else {
- format!("one of {}'s {} elided {}lifetimes", help_name, n,
+ format!("one of {}'s {} {}lifetimes", help_name, n,
if have_bound_regions { "free " } else { "" } )
})[..]);
println!("cargo:rerun-if-changed={}", llvm_config.display());
+ if let Some(cfg_toml) = env::var_os("CFG_LLVM_TOML") {
+ let cfg_path = PathBuf::from(cfg_toml);
+ println!("cargo:rerun-if-changed={}", cfg_path.display());
+ }
+
// Test whether we're cross-compiling LLVM. This is a pretty rare case
// currently where we're producing an LLVM for a different platform than
// what this build script is currently running on.
macro_rules! report_function {
($span:expr, $name:expr) => {
err.note(&format!("{} is a function, perhaps you wish to call it",
- $name));
+ $name));
}
}
let mut candidates = valid_out_of_scope_traits;
candidates.sort();
candidates.dedup();
- let msg = format!("items from traits can only be used if the trait is in scope; the \
- following {traits_are} implemented but not in scope, perhaps add \
- a `use` for {one_of_them}:",
+ err.help("items from traits can only be used if the trait is in scope");
+ let mut msg = format!("the following {traits_are} implemented but not in scope, \
+ perhaps add a `use` for {one_of_them}:",
traits_are = if candidates.len() == 1 {
"trait is"
} else {
"one of them"
});
- err.help(&msg[..]);
-
let limit = if candidates.len() == 5 { 5 } else { 4 };
for (i, trait_did) in candidates.iter().take(limit).enumerate() {
- err.help(&format!("candidate #{}: `use {};`",
- i + 1,
- self.tcx.item_path_str(*trait_did)));
+ msg.push_str(&format!("\ncandidate #{}: `use {};`",
+ i + 1,
+ self.tcx.item_path_str(*trait_did)));
}
if candidates.len() > limit {
- err.note(&format!("and {} others", candidates.len() - limit));
+ msg.push_str(&format!("\nand {} others", candidates.len() - limit));
}
+ err.note(&msg[..]);
+
return;
}
// FIXME #21673 this help message could be tuned to the case
// of a type parameter: suggest adding a trait bound rather
// than implementing.
- let msg = format!("items from traits can only be used if the trait is implemented \
- and in scope; the following {traits_define} an item `{name}`, \
- perhaps you need to implement {one_of_them}:",
- traits_define = if candidates.len() == 1 {
- "trait defines"
- } else {
- "traits define"
- },
- one_of_them = if candidates.len() == 1 {
- "it"
- } else {
- "one of them"
- },
- name = item_name);
-
- err.help(&msg[..]);
+ err.help("items from traits can only be used if the trait is implemented and in scope");
+ let mut msg = format!("the following {traits_define} an item `{name}`, \
+ perhaps you need to implement {one_of_them}:",
+ traits_define = if candidates.len() == 1 {
+ "trait defines"
+ } else {
+ "traits define"
+ },
+ one_of_them = if candidates.len() == 1 {
+ "it"
+ } else {
+ "one of them"
+ },
+ name = item_name);
for (i, trait_info) in candidates.iter().enumerate() {
- err.help(&format!("candidate #{}: `{}`",
- i + 1,
- self.tcx.item_path_str(trait_info.def_id)));
+ msg.push_str(&format!("\ncandidate #{}: `{}`",
+ i + 1,
+ self.tcx.item_path_str(trait_info.def_id)));
}
+ err.note(&msg[..]);
}
}
let mut r = cx.renderinfo.borrow_mut();
r.deref_trait_did = cx.tcx.lang_items.deref_trait();
r.deref_mut_trait_did = cx.tcx.lang_items.deref_mut_trait();
+ r.owned_box_did = cx.tcx.lang_items.owned_box();
}
let mut externs = Vec::new();
stripped_mod: bool,
deref_trait_did: Option<DefId>,
deref_mut_trait_did: Option<DefId>,
+ owned_box_did: Option<DefId>,
// In rare case where a structure is defined in one module but implemented
// in another, if the implementing module is parsed before defining module,
pub external_typarams: FxHashMap<DefId, String>,
pub deref_trait_did: Option<DefId>,
pub deref_mut_trait_did: Option<DefId>,
+ pub owned_box_did: Option<DefId>,
}
/// Helper struct to render all source code to HTML pages
external_typarams,
deref_trait_did,
deref_mut_trait_did,
+ owned_box_did,
} = renderinfo;
let external_paths = external_paths.into_iter()
traits: mem::replace(&mut krate.external_traits, FxHashMap()),
deref_trait_did: deref_trait_did,
deref_mut_trait_did: deref_mut_trait_did,
+ owned_box_did: owned_box_did,
typarams: external_typarams,
};
};
if let Some(self_ty) = self_type_opt {
- let by_mut_ref = match self_ty {
- SelfTy::SelfBorrowed(_lifetime, mutability) => {
- mutability == Mutability::Mutable
- },
+ let (by_mut_ref, by_box) = match self_ty {
+ SelfTy::SelfBorrowed(_, mutability) |
SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
- mutability == Mutability::Mutable
+ (mutability == Mutability::Mutable, false)
+ },
+ SelfTy::SelfExplicit(clean::ResolvedPath { did, .. }) => {
+ (false, Some(did) == cache().owned_box_did)
},
- _ => false,
+ _ => (false, false),
};
- deref_mut_ || !by_mut_ref
+ (deref_mut_ || !by_mut_ref) && !by_box
} else {
false
}
use ffi::OsStr;
use fmt;
+use fs;
use io;
use path::Path;
use str;
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
- pub fn stdin(&mut self, cfg: Stdio) -> &mut Command {
- self.inner.stdin(cfg.0);
+ pub fn stdin<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Command {
+ self.inner.stdin(cfg.into().0);
self
}
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
- pub fn stdout(&mut self, cfg: Stdio) -> &mut Command {
- self.inner.stdout(cfg.0);
+ pub fn stdout<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Command {
+ self.inner.stdout(cfg.into().0);
self
}
/// .expect("ls command failed to start");
/// ```
#[stable(feature = "process", since = "1.0.0")]
- pub fn stderr(&mut self, cfg: Stdio) -> &mut Command {
- self.inner.stderr(cfg.0);
+ pub fn stderr<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Command {
+ self.inner.stderr(cfg.into().0);
self
}
}
}
+#[stable(feature = "stdio_from", since = "1.20.0")]
+impl From<ChildStdin> for Stdio {
+ fn from(child: ChildStdin) -> Stdio {
+ Stdio::from_inner(child.into_inner().into())
+ }
+}
+
+#[stable(feature = "stdio_from", since = "1.20.0")]
+impl From<ChildStdout> for Stdio {
+ fn from(child: ChildStdout) -> Stdio {
+ Stdio::from_inner(child.into_inner().into())
+ }
+}
+
+#[stable(feature = "stdio_from", since = "1.20.0")]
+impl From<ChildStderr> for Stdio {
+ fn from(child: ChildStderr) -> Stdio {
+ Stdio::from_inner(child.into_inner().into())
+ }
+}
+
+#[stable(feature = "stdio_from", since = "1.20.0")]
+impl From<fs::File> for Stdio {
+ fn from(file: fs::File) -> Stdio {
+ Stdio::from_inner(file.into_inner().into())
+ }
+}
+
/// Describes the result of a process after it has terminated.
///
/// This `struct` is used to represent the exit status of a child process.
}
}
+impl From<AnonPipe> for Stdio {
+ fn from(pipe: AnonPipe) -> Stdio {
+ Stdio::Fd(pipe.into_fd())
+ }
+}
+
+impl From<File> for Stdio {
+ fn from(file: File) -> Stdio {
+ Stdio::Fd(file.into_fd())
+ }
+}
+
impl ChildStdio {
fn fd(&self) -> Option<usize> {
match *self {
}
extern {
- static __magenta_job_default: mx_handle_t;
+ pub fn mx_job_default() -> mx_handle_t;
pub fn mx_task_kill(handle: mx_handle_t) -> mx_status_t;
avail: *mut mx_size_t) -> mx_status_t;
}
-pub fn mx_job_default() -> mx_handle_t {
- unsafe { return __magenta_job_default; }
-}
-
// From `enum special_handles` in system/ulib/launchpad/launchpad.c
// HND_LOADER_SVC = 0
// HND_EXEC_VMO = 1
}
}
+impl From<AnonPipe> for Stdio {
+ fn from(pipe: AnonPipe) -> Stdio {
+ Stdio::Fd(pipe.into_fd())
+ }
+}
+
+impl From<File> for Stdio {
+ fn from(file: File) -> Stdio {
+ Stdio::Fd(file.into_fd())
+ }
+}
+
impl ChildStdio {
pub fn fd(&self) -> Option<c_int> {
match *self {
}
}
+impl From<AnonPipe> for Stdio {
+ fn from(pipe: AnonPipe) -> Stdio {
+ Stdio::Handle(pipe.into_handle())
+ }
+}
+
+impl From<File> for Stdio {
+ fn from(file: File) -> Stdio {
+ Stdio::Handle(file.into_handle())
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
// Processes
////////////////////////////////////////////////////////////////////////////////
// Encode the command and arguments in a command line string such
// that the spawned process may recover them using CommandLineToArgvW.
let mut cmd: Vec<u16> = Vec::new();
- append_arg(&mut cmd, prog)?;
+ // Always quote the program name so CreateProcess doesn't interpret args as
+ // part of the name if the binary wasn't found first time.
+ append_arg(&mut cmd, prog, true)?;
for arg in args {
cmd.push(' ' as u16);
- append_arg(&mut cmd, arg)?;
+ append_arg(&mut cmd, arg, false)?;
}
return Ok(cmd);
- fn append_arg(cmd: &mut Vec<u16>, arg: &OsStr) -> io::Result<()> {
+ fn append_arg(cmd: &mut Vec<u16>, arg: &OsStr, force_quotes: bool) -> io::Result<()> {
// If an argument has 0 characters then we need to quote it to ensure
// that it actually gets passed through on the command line or otherwise
// it will be dropped entirely when parsed on the other end.
ensure_no_nuls(arg)?;
let arg_bytes = &arg.as_inner().inner.as_inner();
- let quote = arg_bytes.iter().any(|c| *c == b' ' || *c == b'\t')
+ let quote = force_quotes || arg_bytes.iter().any(|c| *c == b' ' || *c == b'\t')
|| arg_bytes.is_empty();
if quote {
cmd.push('"' as u16);
assert_eq!(
test_wrapper("prog", &["aaa", "bbb", "ccc"]),
- "prog aaa bbb ccc"
+ "\"prog\" aaa bbb ccc"
);
assert_eq!(
);
assert_eq!(
test_wrapper("echo", &["a b c"]),
- "echo \"a b c\""
+ "\"echo\" \"a b c\""
);
assert_eq!(
test_wrapper("echo", &["\" \\\" \\", "\\"]),
- "echo \"\\\" \\\\\\\" \\\\\" \\"
+ "\"echo\" \"\\\" \\\\\\\" \\\\\" \\"
);
assert_eq!(
test_wrapper("\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}", &[]),
- "\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}"
+ "\"\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}\""
);
}
}
self.with_str_from(start, |string| {
if string == "_" {
+ self.sess.span_diagnostic
+ .struct_span_warn(mk_sp(start, self.pos),
+ "underscore literal suffix is not allowed")
+ .warn("this was previously accepted by the compiler but is \
+ being phased out; it will become a hard error in \
+ a future release!")
+ .note("for more information, see issue #42326 \
+ <https://github.com/rust-lang/rust/issues/42326>")
+ .emit();
None
} else {
Some(Symbol::intern(string))
// The interner in thread-local, so `Symbol` shouldn't move between threads.
impl !Send for Symbol { }
+impl !Sync for Symbol { }
impl Symbol {
/// Maps a string to its interned representation.
--- /dev/null
+// Copyright 2017 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.
+
+// compile-flags:-D bogus
+
+// error-pattern:E0602
+// error-pattern:requested on the command line with `-D bogus`
+
+fn main() {}
+++ /dev/null
-// Copyright 2015 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 use reexport::Reexported;
-
-pub struct Foo;
-pub enum Bar { X }
-
-pub mod foo {
- pub trait PubPub {
- fn method(&self) {}
-
- fn method3(&self) {}
- }
-
- impl PubPub for u32 {}
- impl PubPub for i32 {}
-}
-pub mod bar {
- trait PubPriv {
- fn method(&self);
- }
-}
-mod qux {
- pub trait PrivPub {
- fn method(&self);
- }
-}
-mod quz {
- trait PrivPriv {
- fn method(&self);
- }
-}
-
-mod reexport {
- pub trait Reexported {
- fn method(&self);
- }
-}
+++ /dev/null
-// Copyright 2015 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.
-
-trait Foo<A> {
- fn foo(&self, a: A) -> A {
- a
- }
-}
-
-trait NotRelevant<A> {
- fn nr(&self, a: A) -> A {
- a
- }
-}
-
-struct Bar;
-
-impl NotRelevant<usize> for Bar {}
-
-fn main() {
- let f1 = Bar;
-
- f1.foo(1usize);
- //~^ error: method named `foo` found for type `Bar` in the current scope
- //~| help: items from traits can only be used if the trait is implemented and in scope
- //~| help: candidate #1: `Foo`
-}
fn parse_type(iter: Box<Iterator<Item=&str>+'static>) -> &str { iter.next() }
//~^ ERROR missing lifetime specifier [E0106]
-//~^^ HELP 2 elided lifetimes
+//~^^ HELP 2 lifetimes
fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
//~^ ERROR missing lifetime specifier [E0106]
fn f(a: &S, b: i32) -> &i32 {
//~^ ERROR missing lifetime specifier [E0106]
-//~^^ HELP does not say which one of `a`'s 2 elided lifetimes it is borrowed from
+//~^^ HELP does not say which one of `a`'s 2 lifetimes it is borrowed from
panic!();
}
fn g(a: &S, b: bool, c: &i32) -> &i32 {
//~^ ERROR missing lifetime specifier [E0106]
-//~^^ HELP does not say whether it is borrowed from one of `a`'s 2 elided lifetimes or `c`
+//~^^ HELP does not say whether it is borrowed from one of `a`'s 2 lifetimes or `c`
panic!();
}
fn h(a: &bool, b: bool, c: &S, d: &i32) -> &i32 {
//~^ ERROR missing lifetime specifier [E0106]
-//~^^ HELP does not say whether it is borrowed from `a`, one of `c`'s 2 elided lifetimes, or `d`
+//~^^ HELP does not say whether it is borrowed from `a`, one of `c`'s 2 lifetimes, or `d`
panic!();
}
// Lifetime annotation needed because we have two lifetimes: one as a parameter
// and one on the reference.
fn h(_x: &Foo) -> &isize { //~ ERROR missing lifetime specifier
-//~^ HELP the signature does not say which one of `_x`'s 2 elided lifetimes it is borrowed from
+//~^ HELP the signature does not say which one of `_x`'s 2 lifetimes it is borrowed from
panic!()
}
y.zero()
.take() //~ ERROR no method named `take` found for type `Foo` in the current scope
//~^ NOTE the method `take` exists but the following trait bounds were not satisfied
+ //~| NOTE the following traits define an item `take`, perhaps you need to implement one of them
.one(0);
}
+++ /dev/null
-// Copyright 2015 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.
-
-// issue #21405
-// ignore-tidy-linelength
-
-struct Foo;
-
-fn foo<F>(f: F) where F: FnMut(Foo) {}
-
-fn main() {
- foo(|s| s.is_empty());
- //~^ ERROR no method named `is_empty` found
- //~^^ HELP #1: `std::iter::ExactSizeIterator`
- //~^^^ HELP #2: `core::slice::SliceExt`
- //~^^^^ HELP #3: `core::str::StrExt`
- //~^^^^^ HELP items from traits can only be used if the trait is implemented and in scope; the following traits define an item `is_empty`, perhaps you need to implement one of them:
-}
+++ /dev/null
-// Copyright 2015 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.
-
-// aux-build:no_method_suggested_traits.rs
-
-extern crate no_method_suggested_traits;
-
-struct Foo;
-enum Bar { X }
-
-mod foo {
- pub trait Bar {
- fn method(&self) {}
-
- fn method2(&self) {}
- }
-
- impl Bar for u32 {}
-
- impl Bar for char {}
-}
-
-fn main() {
- // test the values themselves, and autoderef.
-
-
- 1u32.method();
- //~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
- //~^^ ERROR no method named
- //~^^^ HELP `use foo::Bar;`
- //~^^^^ HELP `use no_method_suggested_traits::foo::PubPub;`
- std::rc::Rc::new(&mut Box::new(&1u32)).method();
- //~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
- //~^^ ERROR no method named
- //~^^^ HELP `use foo::Bar;`
- //~^^^^ HELP `use no_method_suggested_traits::foo::PubPub;`
-
- 'a'.method();
- //~^ ERROR no method named
- //~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
- //~^^^ HELP `use foo::Bar;`
- std::rc::Rc::new(&mut Box::new(&'a')).method();
- //~^ ERROR no method named
- //~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
- //~^^^ HELP `use foo::Bar;`
-
- 1i32.method();
- //~^ ERROR no method named
- //~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
- //~^^^ HELP `use no_method_suggested_traits::foo::PubPub;`
- std::rc::Rc::new(&mut Box::new(&1i32)).method();
- //~^ ERROR no method named
- //~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
- //~^^^ HELP `use no_method_suggested_traits::foo::PubPub;`
-
- Foo.method();
- //~^ ERROR no method named
- //~^^ HELP following traits define an item `method`, perhaps you need to implement one of them
- //~^^^ HELP `foo::Bar`
- //~^^^^ HELP `no_method_suggested_traits::foo::PubPub`
- //~^^^^^ HELP `no_method_suggested_traits::Reexported`
- //~^^^^^^ HELP `no_method_suggested_traits::bar::PubPriv`
- //~^^^^^^^ HELP `no_method_suggested_traits::qux::PrivPub`
- //~^^^^^^^^ HELP `no_method_suggested_traits::quz::PrivPriv`
- std::rc::Rc::new(&mut Box::new(&Foo)).method();
- //~^ ERROR no method named
- //~^^ HELP following traits define an item `method`, perhaps you need to implement one of them
- //~^^^ HELP `foo::Bar`
- //~^^^^ HELP `no_method_suggested_traits::foo::PubPub`
- //~^^^^^ HELP `no_method_suggested_traits::Reexported`
- //~^^^^^^ HELP `no_method_suggested_traits::bar::PubPriv`
- //~^^^^^^^ HELP `no_method_suggested_traits::qux::PrivPub`
- //~^^^^^^^^ HELP `no_method_suggested_traits::quz::PrivPriv`
-
- 1u64.method2();
- //~^ ERROR no method named
- //~^^ HELP the following trait defines an item `method2`, perhaps you need to implement it
- //~^^^ HELP `foo::Bar`
- std::rc::Rc::new(&mut Box::new(&1u64)).method2();
- //~^ ERROR no method named
- //~^^ HELP the following trait defines an item `method2`, perhaps you need to implement it
- //~^^^ HELP `foo::Bar`
-
- no_method_suggested_traits::Foo.method2();
- //~^ ERROR no method named
- //~^^ HELP following trait defines an item `method2`, perhaps you need to implement it
- //~^^^ HELP `foo::Bar`
- std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2();
- //~^ ERROR no method named
- //~^^ HELP following trait defines an item `method2`, perhaps you need to implement it
- //~^^^ HELP `foo::Bar`
- no_method_suggested_traits::Bar::X.method2();
- //~^ ERROR no method named
- //~^^ HELP following trait defines an item `method2`, perhaps you need to implement it
- //~^^^ HELP `foo::Bar`
- std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2();
- //~^ ERROR no method named
- //~^^ HELP following trait defines an item `method2`, perhaps you need to implement it
- //~^^^ HELP `foo::Bar`
-
- Foo.method3();
- //~^ ERROR no method named
- //~^^ HELP following trait defines an item `method3`, perhaps you need to implement it
- //~^^^ HELP `no_method_suggested_traits::foo::PubPub`
- std::rc::Rc::new(&mut Box::new(&Foo)).method3();
- //~^ ERROR no method named
- //~^^ HELP following trait defines an item `method3`, perhaps you need to implement it
- //~^^^ HELP `no_method_suggested_traits::foo::PubPub`
- Bar::X.method3();
- //~^ ERROR no method named
- //~^^ HELP following trait defines an item `method3`, perhaps you need to implement it
- //~^^^ HELP `no_method_suggested_traits::foo::PubPub`
- std::rc::Rc::new(&mut Box::new(&Bar::X)).method3();
- //~^ ERROR no method named
- //~^^ HELP following trait defines an item `method3`, perhaps you need to implement it
- //~^^^ HELP `no_method_suggested_traits::foo::PubPub`
-
- // should have no help:
- 1_usize.method3(); //~ ERROR no method named
- std::rc::Rc::new(&mut Box::new(&1_usize)).method3(); //~ ERROR no method named
- no_method_suggested_traits::Foo.method3(); //~ ERROR no method named
- std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method3();
- //~^ ERROR no method named
- no_method_suggested_traits::Bar::X.method3(); //~ ERROR no method named
- std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method3();
- //~^ ERROR no method named
-}
--- /dev/null
+// Copyright 2017 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.
+
+fn main() {
+ let _ = "Foo"_;
+ //~^ WARNING underscore literal suffix is not allowed
+ //~| WARNING this was previously accepted
+ //~| NOTE issue #42326
+}
+
+FAIL
+//~^ ERROR
+//~| NOTE
--- /dev/null
+-include ../tools.mk
+
+ifdef IS_WINDOWS
+
+all:
+ $(RUSTC) -o "$(TMPDIR)/hopefullydoesntexist bar.exe" hello.rs
+ $(RUSTC) spawn.rs
+ $(TMPDIR)/spawn.exe
+
+else
+
+all:
+
+endif
--- /dev/null
+// Copyright 2017 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.
+
+fn main() {
+ println!("Hello World!");
+}
--- /dev/null
+// Copyright 2017 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.
+
+use std::io::ErrorKind;
+use std::process::Command;
+
+fn main() {
+ // Make sure it doesn't try to run "hopefullydoesntexist bar.exe".
+ assert_eq!(Command::new("hopefullydoesntexist")
+ .arg("bar")
+ .spawn()
+ .unwrap_err()
+ .kind(),
+ ErrorKind::NotFound);
+}
--- /dev/null
+// Copyright 2017 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.
+
+// ignore-cross-compile
+
+#![feature(rustc_private)]
+
+extern crate rustc_back;
+
+use std::env;
+use std::fs::File;
+use std::io;
+use std::io::{Read, Write};
+use std::process::{Command, Stdio};
+
+use rustc_back::tempdir::TempDir;
+
+fn main() {
+ if env::args().len() > 1 {
+ child().unwrap()
+ } else {
+ parent().unwrap()
+ }
+}
+
+fn parent() -> io::Result<()> {
+ let td = TempDir::new("foo").unwrap();
+ let input = td.path().join("input");
+ let output = td.path().join("output");
+
+ File::create(&input)?.write_all(b"foo\n")?;
+
+ // Set up this chain:
+ // $ me <file | me | me >file
+ // ... to duplicate each line 8 times total.
+
+ let mut child1 = Command::new(env::current_exe()?)
+ .arg("first")
+ .stdin(File::open(&input)?) // tests File::into()
+ .stdout(Stdio::piped())
+ .spawn()?;
+
+ let mut child3 = Command::new(env::current_exe()?)
+ .arg("third")
+ .stdin(Stdio::piped())
+ .stdout(File::create(&output)?) // tests File::into()
+ .spawn()?;
+
+ // Started out of order so we can test both `ChildStdin` and `ChildStdout`.
+ let mut child2 = Command::new(env::current_exe()?)
+ .arg("second")
+ .stdin(child1.stdout.take().unwrap()) // tests ChildStdout::into()
+ .stdout(child3.stdin.take().unwrap()) // tests ChildStdin::into()
+ .spawn()?;
+
+ assert!(child1.wait()?.success());
+ assert!(child2.wait()?.success());
+ assert!(child3.wait()?.success());
+
+ let mut data = String::new();
+ File::open(&output)?.read_to_string(&mut data)?;
+ for line in data.lines() {
+ assert_eq!(line, "foo");
+ }
+ assert_eq!(data.lines().count(), 8);
+ Ok(())
+}
+
+fn child() -> io::Result<()> {
+ // double everything
+ let mut input = vec![];
+ io::stdin().read_to_end(&mut input)?;
+ io::stdout().write_all(&input)?;
+ io::stdout().write_all(&input)?;
+ Ok(())
+}
Command::new(name)
.arg("--child")
.stdin(Stdio::inherit())
- .stdout(unsafe { FromRawFd::from_raw_fd(libc::STDERR_FILENO) })
- .stderr(unsafe { FromRawFd::from_raw_fd(libc::STDOUT_FILENO) })
+ .stdout(unsafe { Stdio::from_raw_fd(libc::STDERR_FILENO) })
+ .stderr(unsafe { Stdio::from_raw_fd(libc::STDOUT_FILENO) })
.spawn()
};
fn evil_lincoln() { let _evil = println!("lincoln"); }
+fn dots() {
+ assert_eq!(String::from(".................................................."),
+ format!("{:?}", .. .. .. .. .. .. .. .. .. .. .. .. ..
+ .. .. .. .. .. .. .. .. .. .. .. ..));
+}
+
+fn you_eight() {
+ assert_eq!(8, {
+ macro_rules! u8 {
+ (u8) => {
+ mod u8 {
+ pub fn u8<'u8>(u8: &'u8 u8) -> &'u8 u8 {
+ "u8";
+ u8
+ }
+ }
+ };
+ }
+
+ u8!(u8);
+ let &u8: &u8 = u8::u8(&8u8);
+ u8
+ });
+}
+
+fn fishy() {
+ assert_eq!(String::from("><>"),
+ String::<>::from::<>("><>").chars::<>().rev::<>().collect::<String>());
+}
+
pub fn main() {
strange();
funny();
canttouchthis();
angrydome();
evil_lincoln();
+ dots();
+ you_eight();
+ fishy();
}
pub fn by_explicit_ref(self: &Foo) {}
pub fn by_mut_ref(&mut self) {}
pub fn by_explicit_mut_ref(self: &mut Foo) {}
+ pub fn by_explicit_box(self: Box<Foo>) {}
+ pub fn by_explicit_self_box(self: Box<Self>) {}
pub fn static_foo() {}
}
// @has - '//*[@id="method.by_mut_ref"]' 'fn by_mut_ref(&mut self)'
// @has - '//*[@id="by_explicit_mut_ref.v"]' 'fn by_explicit_mut_ref(self: &mut Foo)'
// @has - '//*[@id="method.by_explicit_mut_ref"]' 'fn by_explicit_mut_ref(self: &mut Foo)'
+// @!has - '//*[@id="by_explicit_box.v"]' 'fn by_explicit_box(self: Box<Foo>)'
+// @!has - '//*[@id="method.by_explicit_box"]' 'fn by_explicit_box(self: Box<Foo>)'
+// @!has - '//*[@id="by_explicit_self_box.v"]' 'fn by_explicit_self_box(self: Box<Self>)'
+// @!has - '//*[@id="method.by_explicit_self_box"]' 'fn by_explicit_self_box(self: Box<Self>)'
// @!has - '//*[@id="static_foo.v"]' 'fn static_foo()'
// @!has - '//*[@id="method.static_foo"]' 'fn static_foo()'
pub fn by_explicit_ref(self: &Foo) {}
pub fn by_mut_ref(&mut self) {}
pub fn by_explicit_mut_ref(self: &mut Foo) {}
+ pub fn by_explicit_box(self: Box<Foo>) {}
+ pub fn by_explicit_self_box(self: Box<Self>) {}
pub fn static_foo() {}
}
// @!has - '//*[@id="method.by_mut_ref"]' 'fn by_mut_ref(&mut self)'
// @!has - '//*[@id="by_explicit_mut_ref.v"]' 'fn by_explicit_mut_ref(self: &mut Foo)'
// @!has - '//*[@id="method.by_explicit_mut_ref"]' 'fn by_explicit_mut_ref(self: &mut Foo)'
+// @!has - '//*[@id="by_explicit_box.v"]' 'fn by_explicit_box(self: Box<Foo>)'
+// @!has - '//*[@id="method.by_explicit_box"]' 'fn by_explicit_box(self: Box<Foo>)'
+// @!has - '//*[@id="by_explicit_self_box.v"]' 'fn by_explicit_self_box(self: Box<Self>)'
+// @!has - '//*[@id="method.by_explicit_self_box"]' 'fn by_explicit_self_box(self: Box<Self>)'
// @!has - '//*[@id="static_foo.v"]' 'fn static_foo()'
// @!has - '//*[@id="method.static_foo"]' 'fn static_foo()'
--- /dev/null
+// Copyright 2015 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 use reexport::Reexported;
+
+pub struct Foo;
+pub enum Bar { X }
+
+pub mod foo {
+ pub trait PubPub {
+ fn method(&self) {}
+
+ fn method3(&self) {}
+ }
+
+ impl PubPub for u32 {}
+ impl PubPub for i32 {}
+}
+pub mod bar {
+ trait PubPriv {
+ fn method(&self);
+ }
+}
+mod qux {
+ pub trait PrivPub {
+ fn method(&self);
+ }
+}
+mod quz {
+ trait PrivPriv {
+ fn method(&self);
+ }
+}
+
+mod reexport {
+ pub trait Reexported {
+ fn method(&self);
+ }
+}
--- /dev/null
+// Copyright 2015 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.
+
+trait Foo<A> {
+ fn foo(&self, a: A) -> A {
+ a
+ }
+}
+
+trait NotRelevant<A> {
+ fn nr(&self, a: A) -> A {
+ a
+ }
+}
+
+struct Bar;
+
+impl NotRelevant<usize> for Bar {}
+
+fn main() {
+ let f1 = Bar;
+
+ f1.foo(1usize);
+ //~^ error: method named `foo` found for type `Bar` in the current scope
+ //~| help: items from traits can only be used if the trait is implemented and in scope
+ //~| help: candidate #1: `Foo`
+}
--- /dev/null
+error[E0599]: no method named `foo` found for type `Bar` in the current scope
+ --> $DIR/issue-21659-show-relevant-trait-impls-3.rs:30:8
+ |
+30 | f1.foo(1usize);
+ | ^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `foo`, perhaps you need to implement it:
+ candidate #1: `Foo`
+
+error: aborting due to previous error(s)
+
--- /dev/null
+// Copyright 2015 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.
+
+// issue #21405
+// ignore-tidy-linelength
+
+struct Foo;
+
+fn foo<F>(f: F) where F: FnMut(Foo) {}
+
+fn main() {
+ foo(|s| s.is_empty());
+ //~^ ERROR no method named `is_empty` found
+ //~^^ HELP #1: `std::iter::ExactSizeIterator`
+ //~^^^ HELP #2: `core::slice::SliceExt`
+ //~^^^^ HELP #3: `core::str::StrExt`
+ //~^^^^^ HELP items from traits can only be used if the trait is implemented and in scope; the following traits define an item `is_empty`, perhaps you need to implement one of them:
+}
--- /dev/null
+error[E0599]: no method named `is_empty` found for type `Foo` in the current scope
+ --> $DIR/method-suggestion-no-duplication.rs:19:15
+ |
+19 | foo(|s| s.is_empty());
+ | ^^^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following traits define an item `is_empty`, perhaps you need to implement one of them:
+ candidate #1: `std::iter::ExactSizeIterator`
+ candidate #2: `core::slice::SliceExt`
+ candidate #3: `core::str::StrExt`
+
+error: aborting due to previous error(s)
+
--- /dev/null
+// Copyright 2015 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.
+
+// aux-build:no_method_suggested_traits.rs
+extern crate no_method_suggested_traits;
+
+struct Foo;
+enum Bar { X }
+
+mod foo {
+ pub trait Bar {
+ fn method(&self) {}
+
+ fn method2(&self) {}
+ }
+
+ impl Bar for u32 {}
+
+ impl Bar for char {}
+}
+
+fn main() {
+ // test the values themselves, and autoderef.
+
+
+ 1u32.method();
+ //~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
+ //~| ERROR no method named
+ //~| HELP `use foo::Bar;`
+ //~| HELP `use no_method_suggested_traits::foo::PubPub;`
+ std::rc::Rc::new(&mut Box::new(&1u32)).method();
+ //~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
+ //~| ERROR no method named
+ //~| HELP `use foo::Bar;`
+ //~| HELP `use no_method_suggested_traits::foo::PubPub;`
+
+ 'a'.method();
+ //~^ ERROR no method named
+ //~| HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
+ //~| HELP `use foo::Bar;`
+ std::rc::Rc::new(&mut Box::new(&'a')).method();
+ //~^ ERROR no method named
+ //~| HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
+ //~| HELP `use foo::Bar;`
+
+ 1i32.method();
+ //~^ ERROR no method named
+ //~| HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
+ //~| HELP `use no_method_suggested_traits::foo::PubPub;`
+ std::rc::Rc::new(&mut Box::new(&1i32)).method();
+ //~^ ERROR no method named
+ //~| HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
+ //~| HELP `use no_method_suggested_traits::foo::PubPub;`
+
+ Foo.method();
+ //~^ ERROR no method named
+ //~| HELP following traits define an item `method`, perhaps you need to implement one of them
+ //~| HELP `foo::Bar`
+ //~| HELP `no_method_suggested_traits::foo::PubPub`
+ //~| HELP `no_method_suggested_traits::Reexported`
+ //~| HELP `no_method_suggested_traits::bar::PubPriv`
+ //~| HELP `no_method_suggested_traits::qux::PrivPub`
+ //~| HELP `no_method_suggested_traits::quz::PrivPriv`
+ std::rc::Rc::new(&mut Box::new(&Foo)).method();
+ //~^ ERROR no method named
+ //~| HELP following traits define an item `method`, perhaps you need to implement one of them
+ //~| HELP `foo::Bar`
+ //~| HELP `no_method_suggested_traits::foo::PubPub`
+ //~| HELP `no_method_suggested_traits::Reexported`
+ //~| HELP `no_method_suggested_traits::bar::PubPriv`
+ //~| HELP `no_method_suggested_traits::qux::PrivPub`
+ //~| HELP `no_method_suggested_traits::quz::PrivPriv`
+
+ 1u64.method2();
+ //~^ ERROR no method named
+ //~| HELP the following trait defines an item `method2`, perhaps you need to implement it
+ //~| HELP `foo::Bar`
+ std::rc::Rc::new(&mut Box::new(&1u64)).method2();
+ //~^ ERROR no method named
+ //~| HELP the following trait defines an item `method2`, perhaps you need to implement it
+ //~| HELP `foo::Bar`
+
+ no_method_suggested_traits::Foo.method2();
+ //~^ ERROR no method named
+ //~| HELP following trait defines an item `method2`, perhaps you need to implement it
+ //~| HELP `foo::Bar`
+ std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2();
+ //~^ ERROR no method named
+ //~| HELP following trait defines an item `method2`, perhaps you need to implement it
+ //~| HELP `foo::Bar`
+ no_method_suggested_traits::Bar::X.method2();
+ //~^ ERROR no method named
+ //~| HELP following trait defines an item `method2`, perhaps you need to implement it
+ //~| HELP `foo::Bar`
+ std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2();
+ //~^ ERROR no method named
+ //~| HELP following trait defines an item `method2`, perhaps you need to implement it
+ //~| HELP `foo::Bar`
+
+ Foo.method3();
+ //~^ ERROR no method named
+ //~| HELP following trait defines an item `method3`, perhaps you need to implement it
+ //~| HELP `no_method_suggested_traits::foo::PubPub`
+ std::rc::Rc::new(&mut Box::new(&Foo)).method3();
+ //~^ ERROR no method named
+ //~| HELP following trait defines an item `method3`, perhaps you need to implement it
+ //~| HELP `no_method_suggested_traits::foo::PubPub`
+ Bar::X.method3();
+ //~^ ERROR no method named
+ //~| HELP following trait defines an item `method3`, perhaps you need to implement it
+ //~| HELP `no_method_suggested_traits::foo::PubPub`
+ std::rc::Rc::new(&mut Box::new(&Bar::X)).method3();
+ //~^ ERROR no method named
+ //~| HELP following trait defines an item `method3`, perhaps you need to implement it
+ //~| HELP `no_method_suggested_traits::foo::PubPub`
+
+ // should have no help:
+ 1_usize.method3(); //~ ERROR no method named
+ std::rc::Rc::new(&mut Box::new(&1_usize)).method3(); //~ ERROR no method named
+ no_method_suggested_traits::Foo.method3(); //~ ERROR no method named
+ std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method3();
+ //~^ ERROR no method named
+ no_method_suggested_traits::Bar::X.method3(); //~ ERROR no method named
+ std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method3();
+ //~^ ERROR no method named
+}
--- /dev/null
+error[E0599]: no method named `method` found for type `u32` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:33:10
+ |
+33 | 1u32.method();
+ | ^^^^^^
+ |
+ = help: items from traits can only be used if the trait is in scope
+ = note: the following traits are implemented but not in scope, perhaps add a `use` for one of them:
+ candidate #1: `use foo::Bar;`
+ candidate #2: `use no_method_suggested_traits::foo::PubPub;`
+
+error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::boxed::Box<&u32>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:38:44
+ |
+38 | std::rc::Rc::new(&mut Box::new(&1u32)).method();
+ | ^^^^^^
+ |
+ = help: items from traits can only be used if the trait is in scope
+ = note: the following traits are implemented but not in scope, perhaps add a `use` for one of them:
+ candidate #1: `use foo::Bar;`
+ candidate #2: `use no_method_suggested_traits::foo::PubPub;`
+
+error[E0599]: no method named `method` found for type `char` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:44:9
+ |
+44 | 'a'.method();
+ | ^^^^^^
+ |
+ = help: items from traits can only be used if the trait is in scope
+ = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
+ candidate #1: `use foo::Bar;`
+
+error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::boxed::Box<&char>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:48:43
+ |
+48 | std::rc::Rc::new(&mut Box::new(&'a')).method();
+ | ^^^^^^
+ |
+ = help: items from traits can only be used if the trait is in scope
+ = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
+ candidate #1: `use foo::Bar;`
+
+error[E0599]: no method named `method` found for type `i32` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:53:10
+ |
+53 | 1i32.method();
+ | ^^^^^^
+ |
+ = help: items from traits can only be used if the trait is in scope
+ = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
+ candidate #1: `use no_method_suggested_traits::foo::PubPub;`
+
+error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::boxed::Box<&i32>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:57:44
+ |
+57 | std::rc::Rc::new(&mut Box::new(&1i32)).method();
+ | ^^^^^^
+ |
+ = help: items from traits can only be used if the trait is in scope
+ = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
+ candidate #1: `use no_method_suggested_traits::foo::PubPub;`
+
+error[E0599]: no method named `method` found for type `Foo` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:62:9
+ |
+62 | Foo.method();
+ | ^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following traits define an item `method`, perhaps you need to implement one of them:
+ candidate #1: `foo::Bar`
+ candidate #2: `no_method_suggested_traits::foo::PubPub`
+ candidate #3: `no_method_suggested_traits::bar::PubPriv`
+ candidate #4: `no_method_suggested_traits::qux::PrivPub`
+ candidate #5: `no_method_suggested_traits::quz::PrivPriv`
+ candidate #6: `no_method_suggested_traits::Reexported`
+
+error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::boxed::Box<&Foo>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:71:43
+ |
+71 | std::rc::Rc::new(&mut Box::new(&Foo)).method();
+ | ^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following traits define an item `method`, perhaps you need to implement one of them:
+ candidate #1: `foo::Bar`
+ candidate #2: `no_method_suggested_traits::foo::PubPub`
+ candidate #3: `no_method_suggested_traits::bar::PubPriv`
+ candidate #4: `no_method_suggested_traits::qux::PrivPub`
+ candidate #5: `no_method_suggested_traits::quz::PrivPriv`
+ candidate #6: `no_method_suggested_traits::Reexported`
+
+error[E0599]: no method named `method2` found for type `u64` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:81:10
+ |
+81 | 1u64.method2();
+ | ^^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `method2`, perhaps you need to implement it:
+ candidate #1: `foo::Bar`
+
+error[E0599]: no method named `method2` found for type `std::rc::Rc<&mut std::boxed::Box<&u64>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:85:44
+ |
+85 | std::rc::Rc::new(&mut Box::new(&1u64)).method2();
+ | ^^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `method2`, perhaps you need to implement it:
+ candidate #1: `foo::Bar`
+
+error[E0599]: no method named `method2` found for type `no_method_suggested_traits::Foo` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:90:37
+ |
+90 | no_method_suggested_traits::Foo.method2();
+ | ^^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `method2`, perhaps you need to implement it:
+ candidate #1: `foo::Bar`
+
+error[E0599]: no method named `method2` found for type `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:94:71
+ |
+94 | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2();
+ | ^^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `method2`, perhaps you need to implement it:
+ candidate #1: `foo::Bar`
+
+error[E0599]: no method named `method2` found for type `no_method_suggested_traits::Bar` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:98:40
+ |
+98 | no_method_suggested_traits::Bar::X.method2();
+ | ^^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `method2`, perhaps you need to implement it:
+ candidate #1: `foo::Bar`
+
+error[E0599]: no method named `method2` found for type `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:102:74
+ |
+102 | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2();
+ | ^^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `method2`, perhaps you need to implement it:
+ candidate #1: `foo::Bar`
+
+error[E0599]: no method named `method3` found for type `Foo` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:107:9
+ |
+107 | Foo.method3();
+ | ^^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `method3`, perhaps you need to implement it:
+ candidate #1: `no_method_suggested_traits::foo::PubPub`
+
+error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::boxed::Box<&Foo>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:111:43
+ |
+111 | std::rc::Rc::new(&mut Box::new(&Foo)).method3();
+ | ^^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `method3`, perhaps you need to implement it:
+ candidate #1: `no_method_suggested_traits::foo::PubPub`
+
+error[E0599]: no method named `method3` found for type `Bar` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:115:12
+ |
+115 | Bar::X.method3();
+ | ^^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `method3`, perhaps you need to implement it:
+ candidate #1: `no_method_suggested_traits::foo::PubPub`
+
+error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::boxed::Box<&Bar>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:119:46
+ |
+119 | std::rc::Rc::new(&mut Box::new(&Bar::X)).method3();
+ | ^^^^^^^
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `method3`, perhaps you need to implement it:
+ candidate #1: `no_method_suggested_traits::foo::PubPub`
+
+error[E0599]: no method named `method3` found for type `usize` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:125:13
+ |
+125 | 1_usize.method3(); //~ ERROR no method named
+ | ^^^^^^^
+
+error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::boxed::Box<&usize>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:126:47
+ |
+126 | std::rc::Rc::new(&mut Box::new(&1_usize)).method3(); //~ ERROR no method named
+ | ^^^^^^^
+
+error[E0599]: no method named `method3` found for type `no_method_suggested_traits::Foo` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:127:37
+ |
+127 | no_method_suggested_traits::Foo.method3(); //~ ERROR no method named
+ | ^^^^^^^
+
+error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:128:71
+ |
+128 | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method3();
+ | ^^^^^^^
+
+error[E0599]: no method named `method3` found for type `no_method_suggested_traits::Bar` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:130:40
+ |
+130 | no_method_suggested_traits::Bar::X.method3(); //~ ERROR no method named
+ | ^^^^^^^
+
+error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>` in the current scope
+ --> $DIR/no-method-suggested-traits.rs:131:74
+ |
+131 | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method3();
+ | ^^^^^^^
+
+error: aborting due to previous error(s)
+
29 | fn f9(usize) -> usize; //~ NOTE candidate
| ^^^^^^^^^^^^^^^^^^^^^^
= help: to disambiguate the method call, write `UnusedTrait::f9(u, 342)` instead
- = help: items from traits can only be used if the trait is implemented and in scope; the following traits define an item `f9`, perhaps you need to implement one of them:
- = help: candidate #1: `CtxtFn`
- = help: candidate #2: `OtherTrait`
- = help: candidate #3: `UnusedTrait`
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following traits define an item `f9`, perhaps you need to implement one of them:
+ candidate #1: `CtxtFn`
+ candidate #2: `OtherTrait`
+ candidate #3: `UnusedTrait`
error[E0599]: no method named `fff` found for type `Myisize` in the current scope
--> $DIR/issue-7575.rs:74:30
59 | | }
| |_____^
= help: to disambiguate the method call, write `ManyImplTrait::is_str(t)` instead
- = help: items from traits can only be used if the trait is implemented and in scope; the following trait defines an item `is_str`, perhaps you need to implement it:
- = help: candidate #1: `ManyImplTrait`
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `is_str`, perhaps you need to implement it:
+ candidate #1: `ManyImplTrait`
error: aborting due to previous error(s)