mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Auto merge of #35908 - jonathandturner:rollup, r=jonathandturner
Rollup of 20 pull requests - Successful merges: #35360, #35526, #35809, #35817, #35820, #35824, #35835, #35841, #35842, #35858, #35860, #35861, #35864, #35878, #35879, #35881, #35882, #35889, #35891, #35901 - Failed merges: #35395
This commit is contained in:
commit
d0da7f6af9
@ -230,7 +230,7 @@ To find documentation-related issues, sort by the [A-docs label][adocs].
|
||||
In many cases, you don't need a full `make doc`. You can use `rustdoc` directly
|
||||
to check small fixes. For example, `rustdoc src/doc/reference.md` will render
|
||||
reference to `doc/reference.html`. The CSS might be messed up, but you can
|
||||
verify that HTML is right.
|
||||
verify that the HTML is right.
|
||||
|
||||
## Issue Triage
|
||||
|
||||
|
@ -47,6 +47,34 @@ As you can see, the `trait` block looks very similar to the `impl` block,
|
||||
but we don’t define a body, only a type signature. When we `impl` a trait,
|
||||
we use `impl Trait for Item`, rather than only `impl Item`.
|
||||
|
||||
`Self` may be used in a type annotation to refer to an instance of the type
|
||||
implementing this trait passed as a parameter. `Self`, `&Self` or `&mut Self`
|
||||
may be used depending on the level of ownership required.
|
||||
|
||||
```rust
|
||||
struct Circle {
|
||||
x: f64,
|
||||
y: f64,
|
||||
radius: f64,
|
||||
}
|
||||
|
||||
trait HasArea {
|
||||
fn area(&self) -> f64;
|
||||
|
||||
fn is_larger(&self, &Self) -> bool;
|
||||
}
|
||||
|
||||
impl HasArea for Circle {
|
||||
fn area(&self) -> f64 {
|
||||
std::f64::consts::PI * (self.radius * self.radius)
|
||||
}
|
||||
|
||||
fn is_larger(&self, other: &Self) -> bool {
|
||||
self.area() > other.area()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Trait bounds on generic functions
|
||||
|
||||
Traits are useful because they allow a type to make certain promises about its
|
||||
|
@ -6,6 +6,7 @@ These are some links to repos with configs which ease the use of rust.
|
||||
|
||||
* [rust.vim](https://github.com/rust-lang/rust.vim)
|
||||
* [emacs rust-mode](https://github.com/rust-lang/rust-mode)
|
||||
* [sublime-rust](https://github.com/rust-lang/sublime-rust)
|
||||
* [gedit-config](https://github.com/rust-lang/gedit-config)
|
||||
* [kate-config](https://github.com/rust-lang/kate-config)
|
||||
* [nano-config](https://github.com/rust-lang/nano-config)
|
||||
|
@ -263,6 +263,23 @@ impl<T> Rc<T> {
|
||||
}
|
||||
|
||||
/// Checks if `Rc::try_unwrap` would return `Ok`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(rc_would_unwrap)]
|
||||
///
|
||||
/// use std::rc::Rc;
|
||||
///
|
||||
/// let x = Rc::new(3);
|
||||
/// assert!(Rc::would_unwrap(&x));
|
||||
/// assert_eq!(Rc::try_unwrap(x), Ok(3));
|
||||
///
|
||||
/// let x = Rc::new(4);
|
||||
/// let _y = x.clone();
|
||||
/// assert!(!Rc::would_unwrap(&x));
|
||||
/// assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4)));
|
||||
/// ```
|
||||
#[unstable(feature = "rc_would_unwrap",
|
||||
reason = "just added for niche usecase",
|
||||
issue = "28356")]
|
||||
|
@ -132,7 +132,7 @@ use boxed::Box;
|
||||
/// [`OsString`]: ../../std/ffi/struct.OsString.html
|
||||
///
|
||||
/// Indexing is intended to be a constant-time operation, but UTF-8 encoding
|
||||
/// does not allow us to do this. Furtheremore, it's not clear what sort of
|
||||
/// does not allow us to do this. Furthermore, it's not clear what sort of
|
||||
/// thing the index should return: a byte, a codepoint, or a grapheme cluster.
|
||||
/// The [`as_bytes()`] and [`chars()`] methods return iterators over the first
|
||||
/// two, respectively.
|
||||
|
@ -299,26 +299,63 @@ sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// A trivial implementation of `Mul`. When `Foo * Foo` happens, it ends up
|
||||
/// calling `mul`, and therefore, `main` prints `Multiplying!`.
|
||||
/// Implementing a `Mul`tipliable rational number struct:
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Mul;
|
||||
///
|
||||
/// struct Foo;
|
||||
/// // The uniqueness of rational numbers in lowest terms is a consequence of
|
||||
/// // the fundamental theorem of arithmetic.
|
||||
/// #[derive(Eq)]
|
||||
/// #[derive(PartialEq, Debug)]
|
||||
/// struct Rational {
|
||||
/// nominator: usize,
|
||||
/// denominator: usize,
|
||||
/// }
|
||||
///
|
||||
/// impl Mul for Foo {
|
||||
/// type Output = Foo;
|
||||
/// impl Rational {
|
||||
/// fn new(nominator: usize, denominator: usize) -> Self {
|
||||
/// if denominator == 0 {
|
||||
/// panic!("Zero is an invalid denominator!");
|
||||
/// }
|
||||
///
|
||||
/// fn mul(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Multiplying!");
|
||||
/// self
|
||||
/// // Reduce to lowest terms by dividing by the greatest common
|
||||
/// // divisor.
|
||||
/// let gcd = gcd(nominator, denominator);
|
||||
/// Rational {
|
||||
/// nominator: nominator / gcd,
|
||||
/// denominator: denominator / gcd,
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo * Foo;
|
||||
/// impl Mul for Rational {
|
||||
/// // The multiplication of rational numbers is a closed operation.
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn mul(self, rhs: Self) -> Self {
|
||||
/// let nominator = self.nominator * rhs.nominator;
|
||||
/// let denominator = self.denominator * rhs.denominator;
|
||||
/// Rational::new(nominator, denominator)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// // Euclid's two-thousand-year-old algorithm for finding the greatest common
|
||||
/// // divisor.
|
||||
/// fn gcd(x: usize, y: usize) -> usize {
|
||||
/// let mut x = x;
|
||||
/// let mut y = y;
|
||||
/// while y != 0 {
|
||||
/// let t = y;
|
||||
/// y = x % y;
|
||||
/// x = t;
|
||||
/// }
|
||||
/// x
|
||||
/// }
|
||||
///
|
||||
/// assert_eq!(Rational::new(1, 2), Rational::new(2, 4));
|
||||
/// assert_eq!(Rational::new(2, 3) * Rational::new(3, 4),
|
||||
/// Rational::new(1, 2));
|
||||
/// ```
|
||||
///
|
||||
/// Note that `RHS = Self` by default, but this is not mandatory. Here is an
|
||||
@ -486,26 +523,34 @@ div_impl_float! { f32 f64 }
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// A trivial implementation of `Rem`. When `Foo % Foo` happens, it ends up
|
||||
/// calling `rem`, and therefore, `main` prints `Remainder-ing!`.
|
||||
/// This example implements `Rem` on a `SplitSlice` object. After `Rem` is
|
||||
/// implemented, one can use the `%` operator to find out what the remaining
|
||||
/// elements of the slice would be after splitting it into equal slices of a
|
||||
/// given length.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Rem;
|
||||
///
|
||||
/// struct Foo;
|
||||
/// #[derive(PartialEq, Debug)]
|
||||
/// struct SplitSlice<'a, T: 'a> {
|
||||
/// slice: &'a [T],
|
||||
/// }
|
||||
///
|
||||
/// impl Rem for Foo {
|
||||
/// type Output = Foo;
|
||||
/// impl<'a, T> Rem<usize> for SplitSlice<'a, T> {
|
||||
/// type Output = SplitSlice<'a, T>;
|
||||
///
|
||||
/// fn rem(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Remainder-ing!");
|
||||
/// self
|
||||
/// fn rem(self, modulus: usize) -> Self {
|
||||
/// let len = self.slice.len();
|
||||
/// let rem = len % modulus;
|
||||
/// let start = len - rem;
|
||||
/// SplitSlice {slice: &self.slice[start..]}
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo % Foo;
|
||||
/// }
|
||||
/// // If we were to divide &[0, 1, 2, 3, 4, 5, 6, 7] into slices of size 3,
|
||||
/// // the remainder would be &[6, 7]
|
||||
/// assert_eq!(SplitSlice { slice: &[0, 1, 2, 3, 4, 5, 6, 7] } % 3,
|
||||
/// SplitSlice { slice: &[6, 7] });
|
||||
/// ```
|
||||
#[lang = "rem"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -694,26 +739,41 @@ not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// A trivial implementation of `BitAnd`. When `Foo & Foo` happens, it ends up
|
||||
/// calling `bitand`, and therefore, `main` prints `Bitwise And-ing!`.
|
||||
/// In this example, the `BitAnd` trait is implemented for a `BooleanVector`
|
||||
/// struct.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::BitAnd;
|
||||
///
|
||||
/// struct Foo;
|
||||
/// #[derive(Debug)]
|
||||
/// struct BooleanVector {
|
||||
/// value: Vec<bool>,
|
||||
/// };
|
||||
///
|
||||
/// impl BitAnd for Foo {
|
||||
/// type Output = Foo;
|
||||
/// impl BitAnd for BooleanVector {
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn bitand(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Bitwise And-ing!");
|
||||
/// self
|
||||
/// fn bitand(self, rhs: Self) -> Self {
|
||||
/// BooleanVector {
|
||||
/// value: self.value
|
||||
/// .iter()
|
||||
/// .zip(rhs.value.iter())
|
||||
/// .map(|(x, y)| *x && *y)
|
||||
/// .collect(),
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo & Foo;
|
||||
/// impl PartialEq for BooleanVector {
|
||||
/// fn eq(&self, other: &Self) -> bool {
|
||||
/// self.value == other.value
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// let bv1 = BooleanVector { value: vec![true, true, false, false] };
|
||||
/// let bv2 = BooleanVector { value: vec![true, false, true, false] };
|
||||
/// let expected = BooleanVector { value: vec![true, false, false, false] };
|
||||
/// assert_eq!(bv1 & bv2, expected);
|
||||
/// ```
|
||||
#[lang = "bitand"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -1490,28 +1550,44 @@ shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// A trivial implementation of `Index`. When `Foo[Bar]` happens, it ends up
|
||||
/// calling `index`, and therefore, `main` prints `Indexing!`.
|
||||
/// This example implements `Index` on a read-only `NucleotideCount` container,
|
||||
/// enabling individual counts to be retrieved with index syntax.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Index;
|
||||
///
|
||||
/// #[derive(Copy, Clone)]
|
||||
/// struct Foo;
|
||||
/// struct Bar;
|
||||
/// enum Nucleotide {
|
||||
/// A,
|
||||
/// C,
|
||||
/// G,
|
||||
/// T,
|
||||
/// }
|
||||
///
|
||||
/// impl Index<Bar> for Foo {
|
||||
/// type Output = Foo;
|
||||
/// struct NucleotideCount {
|
||||
/// a: usize,
|
||||
/// c: usize,
|
||||
/// g: usize,
|
||||
/// t: usize,
|
||||
/// }
|
||||
///
|
||||
/// fn index<'a>(&'a self, _index: Bar) -> &'a Foo {
|
||||
/// println!("Indexing!");
|
||||
/// self
|
||||
/// impl Index<Nucleotide> for NucleotideCount {
|
||||
/// type Output = usize;
|
||||
///
|
||||
/// fn index(&self, nucleotide: Nucleotide) -> &usize {
|
||||
/// match nucleotide {
|
||||
/// Nucleotide::A => &self.a,
|
||||
/// Nucleotide::C => &self.c,
|
||||
/// Nucleotide::G => &self.g,
|
||||
/// Nucleotide::T => &self.t,
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo[Bar];
|
||||
/// }
|
||||
/// let nucleotide_count = NucleotideCount {a: 14, c: 9, g: 10, t: 12};
|
||||
/// assert_eq!(nucleotide_count[Nucleotide::A], 14);
|
||||
/// assert_eq!(nucleotide_count[Nucleotide::C], 9);
|
||||
/// assert_eq!(nucleotide_count[Nucleotide::G], 10);
|
||||
/// assert_eq!(nucleotide_count[Nucleotide::T], 12);
|
||||
/// ```
|
||||
#[lang = "index"]
|
||||
#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
|
||||
|
@ -128,7 +128,9 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
|
||||
/// let x = 12;
|
||||
/// let y = &x as *const i32;
|
||||
///
|
||||
/// unsafe { println!("{}", std::ptr::read(y)); }
|
||||
/// unsafe {
|
||||
/// assert_eq!(std::ptr::read(y), 12);
|
||||
/// }
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -178,7 +180,7 @@ pub unsafe fn read_and_drop<T>(dest: *mut T) -> T {
|
||||
///
|
||||
/// unsafe {
|
||||
/// std::ptr::write(y, z);
|
||||
/// println!("{}", std::ptr::read(y));
|
||||
/// assert_eq!(std::ptr::read(y), 12);
|
||||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -220,7 +222,9 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
|
||||
/// let x = 12;
|
||||
/// let y = &x as *const i32;
|
||||
///
|
||||
/// unsafe { println!("{}", std::ptr::read_volatile(y)); }
|
||||
/// unsafe {
|
||||
/// assert_eq!(std::ptr::read_volatile(y), 12);
|
||||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "volatile", since = "1.9.0")]
|
||||
@ -266,7 +270,7 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
|
||||
///
|
||||
/// unsafe {
|
||||
/// std::ptr::write_volatile(y, z);
|
||||
/// println!("{}", std::ptr::read_volatile(y));
|
||||
/// assert_eq!(std::ptr::read_volatile(y), 12);
|
||||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
|
@ -23,9 +23,8 @@ use syntax::ast::NodeId;
|
||||
pub enum AccessLevel {
|
||||
// Exported items + items participating in various kinds of public interfaces,
|
||||
// but not directly nameable. For example, if function `fn f() -> T {...}` is
|
||||
// public, then type `T` is exported. Its values can be obtained by other crates
|
||||
// even if the type itseld is not nameable.
|
||||
// FIXME: Mostly unimplemented. Only `type` aliases export items currently.
|
||||
// public, then type `T` is reachable. Its values can be obtained by other crates
|
||||
// even if the type itself is not nameable.
|
||||
Reachable,
|
||||
// Public items + items accessible to other crates with help of `pub use` reexports
|
||||
Exported,
|
||||
|
@ -647,10 +647,13 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
struct_span_err!(self.bccx, span, E0503,
|
||||
"cannot use `{}` because it was mutably borrowed",
|
||||
&self.bccx.loan_path_to_string(copy_path))
|
||||
.span_note(loan_span,
|
||||
.span_label(loan_span,
|
||||
&format!("borrow of `{}` occurs here",
|
||||
&self.bccx.loan_path_to_string(&loan_path))
|
||||
)
|
||||
.span_label(span,
|
||||
&format!("use of borrowed `{}`",
|
||||
&self.bccx.loan_path_to_string(&loan_path)))
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
@ -914,9 +914,11 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
}
|
||||
mc::AliasableStatic |
|
||||
mc::AliasableStaticMut => {
|
||||
struct_span_err!(
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess, span, E0388,
|
||||
"{} in a static location", prefix)
|
||||
"{} in a static location", prefix);
|
||||
err.span_label(span, &format!("cannot write data in a static definition"));
|
||||
err
|
||||
}
|
||||
mc::AliasableBorrowed => {
|
||||
struct_span_err!(
|
||||
|
@ -14,7 +14,7 @@ register_long_diagnostics! {
|
||||
E0454: r##"
|
||||
A link name was given with an empty name. Erroneous code example:
|
||||
|
||||
```
|
||||
```compile_fail,E0454
|
||||
#[link(name = "")] extern {} // error: #[link(name = "")] given with empty name
|
||||
```
|
||||
|
||||
@ -32,7 +32,7 @@ as frameworks are specific to that operating system.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail"
|
||||
```compile_fail,E0455
|
||||
#[link(name = "FooCoreServices", kind = "framework")] extern {}
|
||||
// OS used to compile is Linux for example
|
||||
```
|
||||
@ -50,7 +50,7 @@ See more: https://doc.rust-lang.org/book/conditional-compilation.html
|
||||
E0458: r##"
|
||||
An unknown "kind" was specified for a link attribute. Erroneous code example:
|
||||
|
||||
```
|
||||
```compile_fail,E0458
|
||||
#[link(kind = "wonderful_unicorn")] extern {}
|
||||
// error: unknown kind: `wonderful_unicorn`
|
||||
```
|
||||
@ -64,7 +64,7 @@ Please specify a valid "kind" value, from one of the following:
|
||||
E0459: r##"
|
||||
A link was used without a name parameter. Erroneous code example:
|
||||
|
||||
```
|
||||
```compile_fail,E0459
|
||||
#[link(kind = "dylib")] extern {}
|
||||
// error: #[link(...)] specified without `name = "foo"`
|
||||
```
|
||||
@ -80,7 +80,7 @@ you want. Example:
|
||||
E0463: r##"
|
||||
A plugin/crate was declared but cannot be found. Erroneous code example:
|
||||
|
||||
```
|
||||
```compile_fail,E0463
|
||||
#![feature(plugin)]
|
||||
#![plugin(cookie_monster)] // error: can't find crate for `cookie_monster`
|
||||
extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`
|
||||
|
@ -251,20 +251,24 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
|
||||
err
|
||||
}
|
||||
ResolutionError::TypeNotMemberOfTrait(type_, trait_) => {
|
||||
struct_span_err!(resolver.session,
|
||||
let mut err = struct_span_err!(resolver.session,
|
||||
span,
|
||||
E0437,
|
||||
"type `{}` is not a member of trait `{}`",
|
||||
type_,
|
||||
trait_)
|
||||
trait_);
|
||||
err.span_label(span, &format!("not a member of trait `Foo`"));
|
||||
err
|
||||
}
|
||||
ResolutionError::ConstNotMemberOfTrait(const_, trait_) => {
|
||||
struct_span_err!(resolver.session,
|
||||
let mut err = struct_span_err!(resolver.session,
|
||||
span,
|
||||
E0438,
|
||||
"const `{}` is not a member of trait `{}`",
|
||||
const_,
|
||||
trait_)
|
||||
trait_);
|
||||
err.span_label(span, &format!("not a member of trait `Foo`"));
|
||||
err
|
||||
}
|
||||
ResolutionError::VariableNotBoundInPattern(variable_name, from, to) => {
|
||||
struct_span_err!(resolver.session,
|
||||
@ -336,19 +340,23 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
|
||||
err
|
||||
}
|
||||
ResolutionError::StructVariantUsedAsFunction(path_name) => {
|
||||
struct_span_err!(resolver.session,
|
||||
let mut err = struct_span_err!(resolver.session,
|
||||
span,
|
||||
E0423,
|
||||
"`{}` is the name of a struct or struct variant, but this expression \
|
||||
uses it like a function name",
|
||||
path_name)
|
||||
path_name);
|
||||
err.span_label(span, &format!("struct called like a function"));
|
||||
err
|
||||
}
|
||||
ResolutionError::SelfNotAvailableInStaticMethod => {
|
||||
struct_span_err!(resolver.session,
|
||||
let mut err = struct_span_err!(resolver.session,
|
||||
span,
|
||||
E0424,
|
||||
"`self` is not available in a static method. Maybe a `self` \
|
||||
argument is missing?")
|
||||
"`self` is not available in a static method");
|
||||
err.span_label(span, &format!("not available in static method"));
|
||||
err.note(&format!("maybe a `self` argument is missing?"));
|
||||
err
|
||||
}
|
||||
ResolutionError::UnresolvedName { path, message: msg, context, is_static_method,
|
||||
is_field, def } => {
|
||||
@ -390,11 +398,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
|
||||
err
|
||||
}
|
||||
ResolutionError::UndeclaredLabel(name) => {
|
||||
struct_span_err!(resolver.session,
|
||||
span,
|
||||
E0426,
|
||||
"use of undeclared label `{}`",
|
||||
name)
|
||||
let mut err = struct_span_err!(resolver.session,
|
||||
span,
|
||||
E0426,
|
||||
"use of undeclared label `{}`",
|
||||
name);
|
||||
err.span_label(span, &format!("undeclared label `{}`",&name));
|
||||
err
|
||||
}
|
||||
ResolutionError::SelfImportsOnlyAllowedWithin => {
|
||||
struct_span_err!(resolver.session,
|
||||
@ -418,10 +428,14 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
|
||||
}
|
||||
ResolutionError::UnresolvedImport(name) => {
|
||||
let msg = match name {
|
||||
Some((n, p)) => format!("unresolved import `{}`{}", n, p),
|
||||
Some((n, _)) => format!("unresolved import `{}`", n),
|
||||
None => "unresolved import".to_owned(),
|
||||
};
|
||||
struct_span_err!(resolver.session, span, E0432, "{}", msg)
|
||||
let mut err = struct_span_err!(resolver.session, span, E0432, "{}", msg);
|
||||
if let Some((_, p)) = name {
|
||||
err.span_label(span, &p);
|
||||
}
|
||||
err
|
||||
}
|
||||
ResolutionError::FailedToResolve(msg) => {
|
||||
let mut err = struct_span_err!(resolver.session, span, E0433,
|
||||
@ -438,10 +452,12 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
|
||||
closure form instead")
|
||||
}
|
||||
ResolutionError::AttemptToUseNonConstantValueInConstant => {
|
||||
struct_span_err!(resolver.session,
|
||||
let mut err = struct_span_err!(resolver.session,
|
||||
span,
|
||||
E0435,
|
||||
"attempt to use a non-constant value in a constant")
|
||||
"attempt to use a non-constant value in a constant");
|
||||
err.span_label(span, &format!("non-constant used with constant"));
|
||||
err
|
||||
}
|
||||
ResolutionError::BindingShadowsSomethingUnacceptable(what_binding, name, binding) => {
|
||||
let shadows_what = PathResolution::new(binding.def().unwrap()).kind_name();
|
||||
|
@ -423,7 +423,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
|
||||
if let Failed(err) = self.finalize_import(import) {
|
||||
errors = true;
|
||||
let (span, help) = match err {
|
||||
Some((span, msg)) => (span, format!(". {}", msg)),
|
||||
Some((span, msg)) => (span, msg),
|
||||
None => (import.span, String::new()),
|
||||
};
|
||||
|
||||
@ -596,9 +596,9 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
|
||||
};
|
||||
let module_str = module_to_string(module);
|
||||
let msg = if &module_str == "???" {
|
||||
format!("There is no `{}` in the crate root{}", name, lev_suggestion)
|
||||
format!("no `{}` in the root{}", name, lev_suggestion)
|
||||
} else {
|
||||
format!("There is no `{}` in `{}`{}", name, module_str, lev_suggestion)
|
||||
format!("no `{}` in `{}`{}", name, module_str, lev_suggestion)
|
||||
};
|
||||
Failed(Some((directive.span, msg)))
|
||||
} else {
|
||||
|
@ -347,9 +347,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
if let ty::TyTrait(..) = mt.ty.sty {
|
||||
// This is "x = SomeTrait" being reduced from
|
||||
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
|
||||
span_err!(self.tcx.sess, span, E0033,
|
||||
"type `{}` cannot be dereferenced",
|
||||
self.ty_to_string(expected));
|
||||
let type_str = self.ty_to_string(expected);
|
||||
struct_span_err!(self.tcx.sess, span, E0033,
|
||||
"type `{}` cannot be dereferenced", type_str)
|
||||
.span_label(span, &format!("type `{}` cannot be dereferenced", type_str))
|
||||
.emit();
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +161,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
|
||||
}
|
||||
CastError::CastToBool => {
|
||||
struct_span_err!(fcx.tcx.sess, self.span, E0054, "cannot cast as `bool`")
|
||||
.span_label(self.span, &format!("unsupported cast"))
|
||||
.help("compare with zero instead")
|
||||
.emit();
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ impl RWLock {
|
||||
// We roughly maintain the deadlocking behavior by panicking to ensure
|
||||
// that this lock acquisition does not succeed.
|
||||
//
|
||||
// We also check whether there this lock is already write locked. This
|
||||
// We also check whether this lock is already write locked. This
|
||||
// is only possible if it was write locked by the current thread and
|
||||
// the implementation allows recursive locking. The POSIX standard
|
||||
// doesn't require recursivly locking a rwlock to deadlock, but we can't
|
||||
// doesn't require recursively locking a rwlock to deadlock, but we can't
|
||||
// allow that because it could lead to aliasing issues.
|
||||
if r == libc::EAGAIN {
|
||||
panic!("rwlock maximum reader count exceeded");
|
||||
|
@ -20,6 +20,7 @@ static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
|
||||
//~| ERROR E0017
|
||||
//~| NOTE statics require immutable values
|
||||
//~| ERROR E0388
|
||||
//~| NOTE cannot write data in a static definition
|
||||
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
|
||||
//~| NOTE statics require immutable values
|
||||
//~| ERROR E0017
|
||||
|
@ -13,7 +13,13 @@ trait SomeTrait {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let trait_obj: &SomeTrait = SomeTrait; //~ ERROR E0425
|
||||
//~^ ERROR E0038
|
||||
let &invalid = trait_obj; //~ ERROR E0033
|
||||
let trait_obj: &SomeTrait = SomeTrait;
|
||||
//~^ ERROR E0425
|
||||
//~| ERROR E0038
|
||||
//~| method `foo` has no receiver
|
||||
//~| NOTE the trait `SomeTrait` cannot be made into an object
|
||||
|
||||
let &invalid = trait_obj;
|
||||
//~^ ERROR E0033
|
||||
//~| NOTE type `&SomeTrait` cannot be dereferenced
|
||||
}
|
||||
|
@ -12,4 +12,5 @@ fn main () {
|
||||
struct Foo { a: bool };
|
||||
|
||||
let f = Foo(); //~ ERROR E0423
|
||||
//~^ struct called like a function
|
||||
}
|
||||
|
@ -14,7 +14,10 @@ impl Foo {
|
||||
fn bar(self) {}
|
||||
|
||||
fn foo() {
|
||||
self.bar(); //~ ERROR E0424
|
||||
self.bar();
|
||||
//~^ ERROR `self` is not available in a static method [E0424]
|
||||
//~| NOTE not available in static method
|
||||
//~| NOTE maybe a `self` argument is missing?
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
fn main () {
|
||||
loop {
|
||||
break 'a; //~ ERROR E0426
|
||||
break 'a;
|
||||
//~^ ERROR E0426
|
||||
//~| NOTE undeclared label `'a`
|
||||
}
|
||||
}
|
||||
|
@ -11,4 +11,5 @@
|
||||
fn main () {
|
||||
let foo = 42u32;
|
||||
const FOO : u32 = foo; //~ ERROR E0435
|
||||
//~| NOTE non-constant used with constant
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ trait Foo {}
|
||||
|
||||
impl Foo for i32 {
|
||||
type Bar = bool; //~ ERROR E0437
|
||||
//~| NOTE not a member of trait `Foo`
|
||||
}
|
||||
|
||||
fn main () {
|
||||
|
@ -14,6 +14,7 @@ trait Foo {}
|
||||
|
||||
impl Foo for i32 {
|
||||
const BAR: bool = true; //~ ERROR E0438
|
||||
//~| NOTE not a member of trait `Foo`
|
||||
}
|
||||
|
||||
fn main () {
|
||||
|
21
src/test/compile-fail/E0441.rs
Normal file
21
src/test/compile-fail/E0441.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(repr_simd)]
|
||||
#![feature(platform_intrinsics)]
|
||||
|
||||
#[repr(simd)]
|
||||
struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
|
||||
|
||||
extern "platform-intrinsic" {
|
||||
fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8; //~ ERROR E0441
|
||||
}
|
||||
|
||||
fn main() {}
|
29
src/test/compile-fail/E0442.rs
Normal file
29
src/test/compile-fail/E0442.rs
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(repr_simd)]
|
||||
#![feature(platform_intrinsics)]
|
||||
|
||||
#[repr(simd)]
|
||||
struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
|
||||
i8, i8, i8, i8, i8, i8, i8, i8);
|
||||
#[repr(simd)]
|
||||
struct i32x4(i32, i32, i32, i32);
|
||||
#[repr(simd)]
|
||||
struct i64x2(i64, i64);
|
||||
|
||||
extern "platform-intrinsic" {
|
||||
fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
|
||||
//~^ ERROR E0442
|
||||
//~| ERROR E0442
|
||||
//~| ERROR E0442
|
||||
}
|
||||
|
||||
fn main() {}
|
23
src/test/compile-fail/E0443.rs
Normal file
23
src/test/compile-fail/E0443.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(repr_simd)]
|
||||
#![feature(platform_intrinsics)]
|
||||
|
||||
#[repr(simd)]
|
||||
struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
|
||||
#[repr(simd)]
|
||||
struct i64x8(i64, i64, i64, i64, i64, i64, i64, i64);
|
||||
|
||||
extern "platform-intrinsic" {
|
||||
fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; //~ ERROR E0443
|
||||
}
|
||||
|
||||
fn main() {}
|
21
src/test/compile-fail/E0444.rs
Normal file
21
src/test/compile-fail/E0444.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(repr_simd)]
|
||||
#![feature(platform_intrinsics)]
|
||||
|
||||
#[repr(simd)]
|
||||
struct f64x2(f64, f64);
|
||||
|
||||
extern "platform-intrinsic" {
|
||||
fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444
|
||||
}
|
||||
|
||||
fn main() {}
|
19
src/test/compile-fail/E0445.rs
Normal file
19
src/test/compile-fail/E0445.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2016 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 {
|
||||
fn dummy(&self) { }
|
||||
}
|
||||
|
||||
pub trait Bar : Foo {} //~ ERROR E0445
|
||||
pub struct Bar2<T: Foo>(pub T); //~ ERROR E0445
|
||||
pub fn foo<T: Foo> (t: T) {} //~ ERROR E0445
|
||||
|
||||
fn main() {}
|
19
src/test/compile-fail/E0446.rs
Normal file
19
src/test/compile-fail/E0446.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
mod Foo {
|
||||
struct Bar(u32);
|
||||
|
||||
pub fn bar() -> Bar { //~ ERROR E0446
|
||||
Bar(0)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
24
src/test/compile-fail/E0449.rs
Normal file
24
src/test/compile-fail/E0449.rs
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2016 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 Bar;
|
||||
|
||||
trait Foo {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
pub impl Bar {} //~ ERROR E0449
|
||||
|
||||
pub impl Foo for Bar { //~ ERROR E0449
|
||||
pub fn foo() {} //~ ERROR E0449
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
17
src/test/compile-fail/E0450.rs
Normal file
17
src/test/compile-fail/E0450.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
mod Bar {
|
||||
pub struct Foo(isize);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let f = Bar::Foo(0); //~ ERROR E0450
|
||||
}
|
20
src/test/compile-fail/E0451.rs
Normal file
20
src/test/compile-fail/E0451.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
mod Bar {
|
||||
pub struct Foo {
|
||||
pub a: isize,
|
||||
b: isize,
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
|
||||
}
|
14
src/test/compile-fail/E0452.rs
Normal file
14
src/test/compile-fail/E0452.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
#![allow(foo = "")] //~ ERROR E0452
|
||||
|
||||
fn main() {
|
||||
}
|
15
src/test/compile-fail/E0453.rs
Normal file
15
src/test/compile-fail/E0453.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
#![forbid(non_snake_case)]
|
||||
|
||||
#[allow(non_snake_case)] //~ ERROR E0453
|
||||
fn main() {
|
||||
}
|
14
src/test/compile-fail/E0454.rs
Normal file
14
src/test/compile-fail/E0454.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
#[link(name = "")] extern {} //~ ERROR E0454
|
||||
|
||||
fn main() {
|
||||
}
|
15
src/test/compile-fail/E0458.rs
Normal file
15
src/test/compile-fail/E0458.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
#[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458
|
||||
//~^ ERROR E0459
|
||||
|
||||
fn main() {
|
||||
}
|
14
src/test/compile-fail/E0459.rs
Normal file
14
src/test/compile-fail/E0459.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
#[link(kind = "dylib")] extern {} //~ ERROR E0459
|
||||
|
||||
fn main() {
|
||||
}
|
16
src/test/compile-fail/E0463.rs
Normal file
16
src/test/compile-fail/E0463.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(plugin)]
|
||||
#![plugin(cookie_monster)] //~ ERROR E0463
|
||||
extern crate cake_is_a_lie;
|
||||
|
||||
fn main() {
|
||||
}
|
@ -71,6 +71,7 @@ fn copy_after_mut_borrow() {
|
||||
let _x = &mut a.x;
|
||||
//~^ NOTE borrow of `a.x` occurs here
|
||||
let _y = a.y; //~ ERROR cannot use
|
||||
//~^ NOTE use of borrowed `a.x`
|
||||
}
|
||||
|
||||
fn move_after_mut_borrow() {
|
||||
@ -141,6 +142,7 @@ fn copy_after_mut_borrow_nested() {
|
||||
let _x = &mut a.x.x;
|
||||
//~^ NOTE borrow of `a.x.x` occurs here
|
||||
let _y = a.y; //~ ERROR cannot use
|
||||
//~^ NOTE use of borrowed `a.x.x`
|
||||
}
|
||||
|
||||
fn move_after_mut_borrow_nested() {
|
||||
|
@ -59,10 +59,12 @@ fn main()
|
||||
//~^ ERROR casting
|
||||
//~^^ HELP through a usize first
|
||||
let _ = 3_i32 as bool;
|
||||
//~^ ERROR cannot cast as `bool`
|
||||
//~^ ERROR cannot cast as `bool` [E0054]
|
||||
//~| unsupported cast
|
||||
//~| HELP compare with zero
|
||||
let _ = E::A as bool;
|
||||
//~^ ERROR cannot cast as `bool`
|
||||
//~^ ERROR cannot cast as `bool` [E0054]
|
||||
//~| unsupported cast
|
||||
//~| HELP compare with zero
|
||||
let _ = 0x61u32 as char; //~ ERROR only `u8` can be cast
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use spam::{ham, eggs};
|
||||
//~^ ERROR unresolved import `spam::eggs`. There is no `eggs` in `spam`
|
||||
use spam::{ham, eggs}; //~ ERROR unresolved import `spam::eggs` [E0432]
|
||||
//~^ no `eggs` in `spam`
|
||||
|
||||
mod spam {
|
||||
pub fn ham() { }
|
||||
|
@ -9,13 +9,14 @@
|
||||
// except according to those terms.
|
||||
|
||||
use zed::bar;
|
||||
use zed::baz;
|
||||
//~^ ERROR unresolved import `zed::baz`. There is no `baz` in `zed`
|
||||
use zed::baz; //~ ERROR unresolved import `zed::baz` [E0432]
|
||||
//~^ no `baz` in `zed`. Did you mean to use `bar`?
|
||||
|
||||
|
||||
mod zed {
|
||||
pub fn bar() { println!("bar"); }
|
||||
use foo; //~ ERROR unresolved import
|
||||
use foo; //~ ERROR unresolved import `foo` [E0432]
|
||||
//~^ no `foo` in the root
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -8,8 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use baz::zed::bar;
|
||||
//~^ ERROR unresolved import `baz::zed::bar`. Could not find `zed` in `baz`
|
||||
use baz::zed::bar; //~ ERROR unresolved import `baz::zed::bar` [E0432]
|
||||
//~^ Could not find `zed` in `baz`
|
||||
|
||||
mod baz {}
|
||||
mod zed {
|
||||
|
@ -15,8 +15,8 @@ extern crate issue_12612_1 as foo;
|
||||
use foo::bar;
|
||||
|
||||
mod test {
|
||||
use bar::foo;
|
||||
//~^ ERROR unresolved import `bar::foo`. Maybe a missing `extern crate bar`?
|
||||
use bar::foo; //~ ERROR unresolved import `bar::foo` [E0432]
|
||||
//~^ Maybe a missing `extern crate bar`?
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -9,8 +9,8 @@
|
||||
// except according to those terms.
|
||||
|
||||
use a::f;
|
||||
use b::f;
|
||||
//~^ ERROR: unresolved import `b::f`. There is no `f` in `b`
|
||||
use b::f; //~ ERROR: unresolved import `b::f` [E0432]
|
||||
//~^ no `f` in `b`
|
||||
|
||||
mod a { pub fn f() {} }
|
||||
mod b { }
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
// Testing that we don't fail abnormally after hitting the errors
|
||||
|
||||
use unresolved::*; //~ ERROR unresolved import `unresolved::*`. Maybe a missing `extern crate unres
|
||||
use unresolved::*; //~ ERROR unresolved import `unresolved::*` [E0432]
|
||||
//~^ Maybe a missing `extern crate unresolved`?
|
||||
|
||||
fn main() {}
|
||||
|
@ -13,5 +13,7 @@ enum Foo {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let f = Foo::Variant(42); //~ ERROR uses it like a function
|
||||
let f = Foo::Variant(42);
|
||||
//~^ ERROR uses it like a function
|
||||
//~| struct called like a function
|
||||
}
|
||||
|
@ -13,5 +13,7 @@ enum Homura {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let homura = Homura::Madoka; //~ ERROR uses it like a function
|
||||
let homura = Homura::Madoka;
|
||||
//~^ ERROR uses it like a function
|
||||
//~| struct called like a function
|
||||
}
|
||||
|
@ -59,7 +59,9 @@ impl cat {
|
||||
impl cat {
|
||||
fn meow() {
|
||||
if self.whiskers > 3 {
|
||||
//~^ ERROR: `self` is not available in a static method. Maybe a `self` argument is missing?
|
||||
//~^ ERROR `self` is not available in a static method [E0424]
|
||||
//~| NOTE not available in static method
|
||||
//~| NOTE maybe a `self` argument is missing?
|
||||
println!("MEOW");
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ macro_rules! width(
|
||||
($this:expr) => {
|
||||
$this.width.unwrap()
|
||||
//~^ ERROR cannot use `self.width` because it was mutably borrowed
|
||||
//~| NOTE use of borrowed `*self`
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -8,7 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use m::f as x; //~ ERROR unresolved import `m::f`. There is no `f` in `m`
|
||||
use m::f as x; //~ ERROR unresolved import `m::f` [E0432]
|
||||
//~^ no `f` in `m`
|
||||
|
||||
mod m {}
|
||||
|
||||
|
@ -9,8 +9,12 @@
|
||||
// except according to those terms.
|
||||
|
||||
type Alias = ();
|
||||
use Alias::*; //~ ERROR Not a module
|
||||
use std::io::Result::*; //~ ERROR Not a module
|
||||
use Alias::*;
|
||||
//~^ ERROR unresolved import `Alias::*` [E0432]
|
||||
//~| Not a module `Alias`
|
||||
use std::io::Result::*;
|
||||
//~^ ERROR unresolved import `std::io::Result::*` [E0432]
|
||||
//~| Not a module `Result`
|
||||
|
||||
trait T {}
|
||||
use T::*; //~ ERROR items in traits are not importable
|
||||
|
@ -8,9 +8,11 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use bar::Foo; //~ ERROR There is no `Foo` in `bar` [E0432]
|
||||
use bar::Foo; //~ ERROR unresolved import `bar::Foo` [E0432]
|
||||
//~^ no `Foo` in `bar`
|
||||
mod bar {
|
||||
use Foo; //~ ERROR There is no `Foo` in the crate root [E0432]
|
||||
use Foo; //~ ERROR unresolved import `Foo` [E0432]
|
||||
//~^ no `Foo` in the root
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -14,7 +14,8 @@ impl K for isize {} //~ ERROR: `K` is not a trait
|
||||
//~| NOTE: not a trait
|
||||
//~| NOTE: aliases cannot be used for traits
|
||||
|
||||
use ImportError; //~ ERROR unresolved
|
||||
use ImportError; //~ ERROR unresolved import `ImportError` [E0432]
|
||||
//~^ no `ImportError` in the root
|
||||
impl ImportError for () {} // check that this is not an additional error (c.f. #35142)
|
||||
|
||||
fn main() {}
|
||||
|
@ -8,14 +8,17 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use self::*; //~ ERROR: unresolved import `self::*`. Cannot glob-import a module into itself.
|
||||
use self::*; //~ ERROR: unresolved import `self::*` [E0432]
|
||||
//~^ Cannot glob-import a module into itself.
|
||||
|
||||
mod foo {
|
||||
use foo::*; //~ ERROR: unresolved import `foo::*`. Cannot glob-import a module into itself.
|
||||
use foo::*; //~ ERROR: unresolved import `foo::*` [E0432]
|
||||
//~^ Cannot glob-import a module into itself.
|
||||
|
||||
mod bar {
|
||||
use super::bar::*;
|
||||
//~^ ERROR: unresolved import `super::bar::*`. Cannot glob-import a module into itself.
|
||||
//~^ ERROR: unresolved import `super::bar::*` [E0432]
|
||||
//~| Cannot glob-import a module into itself.
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,12 +25,14 @@ pub fn foo() {}
|
||||
|
||||
fn test1() {
|
||||
use bar::foo;
|
||||
//~^ ERROR unresolved import `bar::foo`. There is no `foo` in `bar`
|
||||
//~^ ERROR unresolved import `bar::foo` [E0432]
|
||||
//~| no `foo` in `bar`
|
||||
}
|
||||
|
||||
fn test2() {
|
||||
use bar::glob::foo;
|
||||
//~^ ERROR unresolved import `bar::glob::foo`. There is no `foo` in `bar::glob`
|
||||
//~^ ERROR unresolved import `bar::glob::foo` [E0432]
|
||||
//~| no `foo` in `bar::glob`
|
||||
}
|
||||
|
||||
#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 }
|
||||
|
@ -26,7 +26,8 @@ pub fn foo() {}
|
||||
|
||||
fn test1() {
|
||||
use bar::gpriv;
|
||||
//~^ ERROR unresolved import `bar::gpriv`. There is no `gpriv` in `bar`
|
||||
//~^ ERROR unresolved import `bar::gpriv` [E0432]
|
||||
//~| no `gpriv` in `bar`
|
||||
|
||||
// This should pass because the compiler will insert a fake name binding
|
||||
// for `gpriv`
|
||||
|
@ -12,11 +12,20 @@
|
||||
fn broken() {
|
||||
let mut x = 3;
|
||||
let mut _y = vec!(&mut x);
|
||||
//~^ NOTE borrow of `x` occurs here
|
||||
//~| NOTE borrow of `x` occurs here
|
||||
//~| NOTE borrow of `x` occurs here
|
||||
while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed
|
||||
//~^ NOTE use of borrowed `x`
|
||||
let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
|
||||
//~^ NOTE use of borrowed `x`
|
||||
_y.push(&mut z); //~ ERROR `z` does not live long enough
|
||||
//~^ NOTE does not live long enough
|
||||
x += 1; //~ ERROR cannot assign
|
||||
//~^ NOTE assignment to borrowed `x` occurs here
|
||||
}
|
||||
//~^ NOTE borrowed value only valid until here
|
||||
}
|
||||
//~^ NOTE borrowed value must be valid until here
|
||||
|
||||
fn main() { }
|
||||
|
@ -11,16 +11,20 @@
|
||||
mod a {
|
||||
extern crate collections;
|
||||
use collections::HashMap;
|
||||
//~^ ERROR unresolved import `collections::HashMap`. Did you mean `self::collections`?
|
||||
//~^ ERROR unresolved import `collections::HashMap` [E0432]
|
||||
//~| Did you mean `self::collections`?
|
||||
mod b {
|
||||
use collections::HashMap;
|
||||
//~^ ERROR unresolved import `collections::HashMap`. Did you mean `a::collections`?
|
||||
//~^ ERROR unresolved import `collections::HashMap` [E0432]
|
||||
//~| Did you mean `a::collections`?
|
||||
mod c {
|
||||
use collections::HashMap;
|
||||
//~^ ERROR unresolved import `collections::HashMap`. Did you mean `a::collections`?
|
||||
//~^ ERROR unresolved import `collections::HashMap` [E0432]
|
||||
//~| Did you mean `a::collections`?
|
||||
mod d {
|
||||
use collections::HashMap;
|
||||
//~^ ERROR unresolved import `collections::HashMap`. Did you mean `a::collections`?
|
||||
//~^ ERROR unresolved import `collections::HashMap` [E0432]
|
||||
//~| Did you mean `a::collections`?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use super::f; //~ ERROR unresolved import `super::f`. There are too many initial `super`s.
|
||||
use super::f; //~ ERROR unresolved import `super::f` [E0432]
|
||||
//~^ There are too many initial `super`s.
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
@ -10,13 +10,17 @@
|
||||
|
||||
// ignore-tidy-linelength
|
||||
|
||||
use foo::bar; //~ ERROR unresolved import `foo::bar`. Maybe a missing `extern crate foo`?
|
||||
use foo::bar; //~ ERROR unresolved import `foo::bar` [E0432]
|
||||
//~^ Maybe a missing `extern crate foo`?
|
||||
|
||||
use bar::Baz as x; //~ ERROR unresolved import `bar::Baz`. There is no `Baz` in `bar`. Did you mean to use `Bar`?
|
||||
use bar::Baz as x; //~ ERROR unresolved import `bar::Baz` [E0432]
|
||||
//~^ no `Baz` in `bar`. Did you mean to use `Bar`?
|
||||
|
||||
use food::baz; //~ ERROR unresolved import `food::baz`. There is no `baz` in `food`. Did you mean to use `bag`?
|
||||
use food::baz; //~ ERROR unresolved import `food::baz`
|
||||
//~^ no `baz` in `food`. Did you mean to use `bag`?
|
||||
|
||||
use food::{beens as Foo}; //~ ERROR unresolved import `food::beens`. There is no `beens` in `food`. Did you mean to use `beans`?
|
||||
use food::{beens as Foo}; //~ ERROR unresolved import `food::beens` [E0432]
|
||||
//~^ no `beens` in `food`. Did you mean to use `beans`?
|
||||
|
||||
mod bar {
|
||||
pub struct Bar;
|
||||
|
@ -18,10 +18,12 @@ use Trait::C;
|
||||
//~^ ERROR `C` is not directly importable
|
||||
|
||||
use Foo::new;
|
||||
//~^ ERROR unresolved import `Foo::new`. Not a module `Foo`
|
||||
//~^ ERROR unresolved import `Foo::new` [E0432]
|
||||
//~| Not a module `Foo`
|
||||
|
||||
use Foo::C2;
|
||||
//~^ ERROR unresolved import `Foo::C2`. Not a module `Foo`
|
||||
//~^ ERROR unresolved import `Foo::C2` [E0432]
|
||||
//~| Not a module `Foo`
|
||||
|
||||
pub trait Trait {
|
||||
fn foo();
|
||||
|
@ -14,9 +14,14 @@
|
||||
mod a {
|
||||
mod b {
|
||||
use self as A; //~ ERROR `self` imports are only allowed within a { } list
|
||||
//~^ ERROR unresolved import `self`. There is no `self` in the crate root
|
||||
use super as B; //~ ERROR unresolved import `super`. There is no `super` in the crate root
|
||||
use super::{self as C}; //~ERROR unresolved import `super`. There is no `super` in the crate
|
||||
//~^ ERROR unresolved import `self` [E0432]
|
||||
//~| no `self` in the root
|
||||
use super as B;
|
||||
//~^ ERROR unresolved import `super` [E0432]
|
||||
//~| no `super` in the root
|
||||
use super::{self as C};
|
||||
//~^ ERROR unresolved import `super` [E0432]
|
||||
//~| no `super` in the root
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,10 +10,12 @@
|
||||
|
||||
mod foo {
|
||||
use self::{self};
|
||||
//~^ ERROR unresolved import `self`. There is no `self` in the crate root
|
||||
//~^ ERROR unresolved import `self` [E0432]
|
||||
//~| no `self` in the root
|
||||
|
||||
use super::{self};
|
||||
//~^ ERROR unresolved import `super`. There is no `super` in the crate root
|
||||
//~^ ERROR unresolved import `super` [E0432]
|
||||
//~| no `super` in the root
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
Loading…
Reference in New Issue
Block a user