mirror of
https://git.proxmox.com/git/rustc
synced 2025-11-03 19:30:33 +00:00
New upstream version 1.30.0+dfsg1
This commit is contained in:
parent
b7449926af
commit
4462d4a060
192
RELEASES.md
192
RELEASES.md
@ -1,3 +1,144 @@
|
||||
Version 1.30.0 (2018-10-25)
|
||||
==========================
|
||||
|
||||
Language
|
||||
--------
|
||||
- [Procedural macros are now available.][52081] These kinds of macros allow for
|
||||
more powerful code generation. There is a [new chapter available][proc-macros]
|
||||
in the Rust Programming Language book that goes further in depth.
|
||||
- [You can now use keywords as identifiers using the raw identifiers
|
||||
syntax (`r#`),][53236] e.g. `let r#for = true;`
|
||||
- [Using anonymous parameters in traits is now deprecated with a warning and
|
||||
will be a hard error in the 2018 edition.][53272]
|
||||
- [You can now use `crate` in paths.][54404] This allows you to refer to the
|
||||
crate root in the path, e.g. `use crate::foo;` refers to `foo` in `src/lib.rs`.
|
||||
- [Using a external crate no longer requires being prefixed with `::`.][54404]
|
||||
Previously, using a external crate in a module without a use statement
|
||||
required `let json = ::serde_json::from_str(foo);` but can now be written
|
||||
as `let json = serde_json::from_str(foo);`.
|
||||
- [You can now apply the `#[used]` attribute to static items to prevent the
|
||||
compiler from optimising them away, even if they appear to be unused,][51363]
|
||||
e.g. `#[used] static FOO: u32 = 1;`
|
||||
- [You can now import and reexport macros from other crates with the `use`
|
||||
syntax.][50911] Macros exported with `#[macro_export]` are now placed into
|
||||
the root module of the crate. If your macro relies on calling other local
|
||||
macros, it is recommended to export with the
|
||||
`#[macro_export(local_inner_macros)]` attribute so users won't have to import
|
||||
those macros.
|
||||
- [You can now catch visibility keywords (e.g. `pub`, `pub(crate)`) in macros
|
||||
using the `vis` specifier.][53370]
|
||||
- [Non-macro attributes now allow all forms of literals, not just
|
||||
strings.][53044] Previously, you would write `#[attr("true")]`, and you can now
|
||||
write `#[attr(true)]`.
|
||||
- [You can now specify a function to handle a panic in the Rust runtime with the
|
||||
`#[panic_handler]` attribute.][51366]
|
||||
|
||||
Compiler
|
||||
--------
|
||||
- [Added the `riscv32imc-unknown-none-elf` target.][53822]
|
||||
- [Added the `aarch64-unknown-netbsd` target][53165]
|
||||
|
||||
Libraries
|
||||
---------
|
||||
- [`ManuallyDrop` now allows the inner type to be unsized.][53033]
|
||||
|
||||
Stabilized APIs
|
||||
---------------
|
||||
- [`Ipv4Addr::BROADCAST`]
|
||||
- [`Ipv4Addr::LOCALHOST`]
|
||||
- [`Ipv4Addr::UNSPECIFIED`]
|
||||
- [`Ipv6Addr::LOCALHOST`]
|
||||
- [`Ipv6Addr::UNSPECIFIED`]
|
||||
- [`Iterator::find_map`]
|
||||
|
||||
The following methods are replacement methods for `trim_left`, `trim_right`,
|
||||
`trim_left_matches`, and `trim_right_matches`, which will be deprecated
|
||||
in 1.33.0:
|
||||
- [`str::trim_end_matches`]
|
||||
- [`str::trim_end`]
|
||||
- [`str::trim_start_matches`]
|
||||
- [`str::trim_start`]
|
||||
|
||||
Cargo
|
||||
----
|
||||
- [`cargo run` doesn't require specifying a package in workspaces.][cargo/5877]
|
||||
- [`cargo doc` now supports `--message-format=json`.][cargo/5878] This is
|
||||
equivalent to calling `rustdoc --error-format=json`.
|
||||
- [You can specify which edition to create a project in cargo
|
||||
with `cargo new --edition`.][cargo/5984] Currently only `2015` is a
|
||||
valid option.
|
||||
- [Cargo will now provide a progress bar for builds.][cargo/5995]
|
||||
|
||||
Misc
|
||||
----
|
||||
- [`rustdoc` allows you to specify what edition to treat your code as with the
|
||||
`--edition` option.][54057]
|
||||
- [`rustdoc` now has the `--color` (specify whether to output color) and
|
||||
`--error-format` (specify error format, e.g. `json`) options.][53003]
|
||||
- [We now distribute a `rust-gdbgui` script that invokes `gdbgui` with Rust
|
||||
debug symbols.][53774]
|
||||
- [Attributes from Rust tools such as `rustfmt` or `clippy` are now
|
||||
available,][53459] e.g. `#[rustfmt::skip]` will skip formatting the next item.
|
||||
|
||||
[50911]: https://github.com/rust-lang/rust/pull/50911/
|
||||
[51363]: https://github.com/rust-lang/rust/pull/51363/
|
||||
[51366]: https://github.com/rust-lang/rust/pull/51366/
|
||||
[52081]: https://github.com/rust-lang/rust/pull/52081/
|
||||
[53003]: https://github.com/rust-lang/rust/pull/53003/
|
||||
[53033]: https://github.com/rust-lang/rust/pull/53033/
|
||||
[53044]: https://github.com/rust-lang/rust/pull/53044/
|
||||
[53165]: https://github.com/rust-lang/rust/pull/53165/
|
||||
[53213]: https://github.com/rust-lang/rust/pull/53213/
|
||||
[53236]: https://github.com/rust-lang/rust/pull/53236/
|
||||
[53272]: https://github.com/rust-lang/rust/pull/53272/
|
||||
[53370]: https://github.com/rust-lang/rust/pull/53370/
|
||||
[53459]: https://github.com/rust-lang/rust/pull/53459/
|
||||
[53774]: https://github.com/rust-lang/rust/pull/53774/
|
||||
[53822]: https://github.com/rust-lang/rust/pull/53822/
|
||||
[54057]: https://github.com/rust-lang/rust/pull/54057/
|
||||
[54146]: https://github.com/rust-lang/rust/pull/54146/
|
||||
[54404]: https://github.com/rust-lang/rust/pull/54404/
|
||||
[cargo/5877]: https://github.com/rust-lang/cargo/pull/5877/
|
||||
[cargo/5878]: https://github.com/rust-lang/cargo/pull/5878/
|
||||
[cargo/5984]: https://github.com/rust-lang/cargo/pull/5984/
|
||||
[cargo/5995]: https://github.com/rust-lang/cargo/pull/5995/
|
||||
[proc-macros]: https://doc.rust-lang.org/book/2018-edition/ch19-06-macros.html
|
||||
|
||||
[`Ipv4Addr::BROADCAST`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv4Addr.html#associatedconstant.BROADCAST
|
||||
[`Ipv4Addr::LOCALHOST`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv4Addr.html#associatedconstant.LOCALHOST
|
||||
[`Ipv4Addr::UNSPECIFIED`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv4Addr.html#associatedconstant.UNSPECIFIED
|
||||
[`Ipv6Addr::LOCALHOST`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv6Addr.html#associatedconstant.LOCALHOST
|
||||
[`Ipv6Addr::UNSPECIFIED`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv6Addr.html#associatedconstant.UNSPECIFIED
|
||||
[`Iterator::find_map`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.find_map
|
||||
[`str::trim_end_matches`]: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim_end_matches
|
||||
[`str::trim_end`]: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim_end
|
||||
[`str::trim_start_matches`]: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim_start_matches
|
||||
[`str::trim_start`]: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim_start
|
||||
|
||||
|
||||
Version 1.29.2 (2018-10-11)
|
||||
===========================
|
||||
|
||||
- [Workaround for an aliasing-related LLVM bug, which caused miscompilation.][54639]
|
||||
- The `rls-preview` component on the windows-gnu targets has been restored.
|
||||
|
||||
[54639]: https://github.com/rust-lang/rust/pull/54639
|
||||
|
||||
|
||||
Version 1.29.1 (2018-09-25)
|
||||
===========================
|
||||
|
||||
Security Notes
|
||||
--------------
|
||||
|
||||
- The standard library's `str::repeat` function contained an out of bounds write
|
||||
caused by an integer overflow. This has been fixed by deterministically
|
||||
panicking when an overflow happens.
|
||||
|
||||
Thank you to Scott McMurray for responsibily disclosing this vulnerability to
|
||||
us.
|
||||
|
||||
|
||||
Version 1.29.0 (2018-09-13)
|
||||
==========================
|
||||
|
||||
@ -9,7 +150,7 @@ Compiler
|
||||
|
||||
Libraries
|
||||
---------
|
||||
- [`Once::call_once` now no longer requires `Once` to be `'static`.][52239]
|
||||
- [`Once::call_once` no longer requires `Once` to be `'static`.][52239]
|
||||
- [`BuildHasherDefault` now implements `PartialEq` and `Eq`.][52402]
|
||||
- [`Box<CStr>`, `Box<OsStr>`, and `Box<Path>` now implement `Clone`.][51912]
|
||||
- [Implemented `PartialEq<&str>` for `OsString` and `PartialEq<OsString>`
|
||||
@ -25,10 +166,10 @@ Stabilized APIs
|
||||
|
||||
Cargo
|
||||
-----
|
||||
- [Cargo can silently fix some bad lockfiles ][cargo/5831] You can use
|
||||
`--locked` to disable this behaviour.
|
||||
- [Cargo can silently fix some bad lockfiles.][cargo/5831] You can use
|
||||
`--locked` to disable this behavior.
|
||||
- [`cargo-install` will now allow you to cross compile an install
|
||||
using `--target`][cargo/5614]
|
||||
using `--target`.][cargo/5614]
|
||||
- [Added the `cargo-fix` subcommand to automatically move project code from
|
||||
2015 edition to 2018.][cargo/5723]
|
||||
- [`cargo doc` can now optionally document private types using the
|
||||
@ -40,19 +181,22 @@ Misc
|
||||
the specified level to that level.][52354] For example `--cap-lints warn`
|
||||
will demote `deny` and `forbid` lints to `warn`.
|
||||
- [`rustc` and `rustdoc` will now have the exit code of `1` if compilation
|
||||
fails, and `101` if there is a panic.][52197]
|
||||
fails and `101` if there is a panic.][52197]
|
||||
- [A preview of clippy has been made available through rustup.][51122]
|
||||
You can install the preview with `rustup component add clippy-preview`
|
||||
You can install the preview with `rustup component add clippy-preview`.
|
||||
|
||||
Compatibility Notes
|
||||
-------------------
|
||||
- [`str::{slice_unchecked, slice_unchecked_mut}` are now deprecated.][51807]
|
||||
Use `str::get_unchecked(begin..end)` instead.
|
||||
- [`std::env::home_dir` is now deprecated for its unintuitive behaviour.][51656]
|
||||
- [`std::env::home_dir` is now deprecated for its unintuitive behavior.][51656]
|
||||
Consider using the `home_dir` function from
|
||||
https://crates.io/crates/dirs instead.
|
||||
- [`rustc` will no longer silently ignore invalid data in target spec.][52330]
|
||||
- [`cfg` attributes and `--cfg` command line flags are now more
|
||||
strictly validated.][53893]
|
||||
|
||||
[53893]: https://github.com/rust-lang/rust/pull/53893/
|
||||
[52861]: https://github.com/rust-lang/rust/pull/52861/
|
||||
[52656]: https://github.com/rust-lang/rust/pull/52656/
|
||||
[52239]: https://github.com/rust-lang/rust/pull/52239/
|
||||
@ -285,7 +429,7 @@ Language
|
||||
be used as an identifier.
|
||||
- [The dyn syntax is now available.][49968] This syntax is equivalent to the
|
||||
bare `Trait` syntax, and should make it clearer when being used in tandem with
|
||||
`impl Trait`. Since it is equivalent to the following syntax:
|
||||
`impl Trait` because it is equivalent to the following syntax:
|
||||
`&Trait == &dyn Trait`, `&mut Trait == &mut dyn Trait`, and
|
||||
`Box<Trait> == Box<dyn Trait>`.
|
||||
- [Attributes on generic parameters such as types and lifetimes are
|
||||
@ -348,10 +492,10 @@ Cargo
|
||||
a different directory than `target` for placing compilation artifacts.
|
||||
- [Cargo will be adding automatic target inference for binaries, benchmarks,
|
||||
examples, and tests in the Rust 2018 edition.][cargo/5335] If your project specifies
|
||||
specific targets e.g. using `[[bin]]` and have other binaries in locations
|
||||
specific targets, e.g. using `[[bin]]`, and have other binaries in locations
|
||||
where cargo would infer a binary, Cargo will produce a warning. You can
|
||||
disable this feature ahead of time by setting any of the following `autobins`,
|
||||
`autobenches`, `autoexamples`, `autotests` to false.
|
||||
disable this feature ahead of time by setting any of the following to false:
|
||||
`autobins`, `autobenches`, `autoexamples`, `autotests`.
|
||||
- [Cargo will now cache compiler information.][cargo/5359] This can be disabled by
|
||||
setting `CARGO_CACHE_RUSTC_INFO=0` in your environment.
|
||||
|
||||
@ -367,8 +511,8 @@ Compatibility Notes
|
||||
work.][49896] e.g. `::core::prelude::v1::StrExt::is_empty("")` will not
|
||||
compile, `"".is_empty()` will still compile.
|
||||
- [`Debug` output on `atomic::{AtomicBool, AtomicIsize, AtomicPtr, AtomicUsize}`
|
||||
will only print the inner type.][48553] e.g.
|
||||
`print!("{:?}", AtomicBool::new(true))` will print `true`
|
||||
will only print the inner type.][48553] E.g.
|
||||
`print!("{:?}", AtomicBool::new(true))` will print `true`,
|
||||
not `AtomicBool(true)`.
|
||||
- [The maximum number for `repr(align(N))` is now 2²⁹.][50378] Previously you
|
||||
could enter higher numbers but they were not supported by LLVM. Up to 512MB
|
||||
@ -431,7 +575,7 @@ Version 1.26.2 (2018-06-05)
|
||||
Compatibility Notes
|
||||
-------------------
|
||||
|
||||
- [The borrow checker was fixed to avoid unsoundness when using match ergonomics][51117]
|
||||
- [The borrow checker was fixed to avoid unsoundness when using match ergonomics.][51117]
|
||||
|
||||
[51117]: https://github.com/rust-lang/rust/issues/51117
|
||||
|
||||
@ -442,18 +586,18 @@ Version 1.26.1 (2018-05-29)
|
||||
Tools
|
||||
-----
|
||||
|
||||
- [RLS now works on Windows][50646]
|
||||
- [Rustfmt stopped badly formatting text in some cases][rustfmt/2695]
|
||||
- [RLS now works on Windows.][50646]
|
||||
- [Rustfmt stopped badly formatting text in some cases.][rustfmt/2695]
|
||||
|
||||
|
||||
Compatibility Notes
|
||||
--------
|
||||
|
||||
- [`fn main() -> impl Trait` no longer works for non-Termination
|
||||
trait][50656]
|
||||
trait.][50656]
|
||||
This reverts an accidental stabilization.
|
||||
- [`NaN > NaN` no longer returns true in const-fn contexts][50812]
|
||||
- [Prohibit using turbofish for `impl Trait` in method arguments][50950]
|
||||
- [`NaN > NaN` no longer returns true in const-fn contexts.][50812]
|
||||
- [Prohibit using turbofish for `impl Trait` in method arguments.][50950]
|
||||
|
||||
[50646]: https://github.com/rust-lang/rust/issues/50646
|
||||
[50656]: https://github.com/rust-lang/rust/pull/50656
|
||||
@ -469,18 +613,18 @@ Language
|
||||
- [Closures now implement `Copy` and/or `Clone` if all captured variables
|
||||
implement either or both traits.][49299]
|
||||
- [The inclusive range syntax e.g. `for x in 0..=10` is now stable.][47813]
|
||||
- [The `'_` lifetime is now stable. The underscore lifetime can be used anywhere where a
|
||||
- [The `'_` lifetime is now stable. The underscore lifetime can be used anywhere a
|
||||
lifetime can be elided.][49458]
|
||||
- [`impl Trait` is now stable allowing you to have abstract types in returns
|
||||
or in function parameters.][49255] e.g. `fn foo() -> impl Iterator<Item=u8>` or
|
||||
or in function parameters.][49255] E.g. `fn foo() -> impl Iterator<Item=u8>` or
|
||||
`fn open(path: impl AsRef<Path>)`.
|
||||
- [Pattern matching will now automatically apply dereferences.][49394]
|
||||
- [128-bit integers in the form of `u128` and `i128` are now stable.][49101]
|
||||
- [`main` can now return `Result<(), E: Debug>`][49162] in addition to `()`.
|
||||
- [A lot of operations are now available in a const context.][46882] E.g. You
|
||||
can now index into constant arrays, reference and dereference into constants,
|
||||
and use Tuple struct constructors.
|
||||
- [Fixed entry slice patterns are now stable.][48516] e.g.
|
||||
and use tuple struct constructors.
|
||||
- [Fixed entry slice patterns are now stable.][48516] E.g.
|
||||
```rust
|
||||
let points = [1, 2, 3, 4];
|
||||
match points {
|
||||
@ -905,7 +1049,7 @@ Language
|
||||
Compiler
|
||||
--------
|
||||
- [Enabled `TrapUnreachable` in LLVM which should mitigate the impact of
|
||||
undefined behaviour.][45920]
|
||||
undefined behavior.][45920]
|
||||
- [rustc now suggests renaming import if names clash.][45660]
|
||||
- [Display errors/warnings correctly when there are zero-width or
|
||||
wide characters.][45711]
|
||||
|
||||
@ -1 +1 @@
|
||||
0ebb250883d63faae833070c11287fc6e7305517
|
||||
da5f414c2c0bfe5198934493f04c676e2b23ff2e
|
||||
@ -51,7 +51,7 @@ fi
|
||||
#
|
||||
# FIXME: need a scheme for changing this `nightly` value to `beta` and `stable`
|
||||
# either automatically or manually.
|
||||
export RUST_RELEASE_CHANNEL=beta
|
||||
export RUST_RELEASE_CHANNEL=stable
|
||||
if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then
|
||||
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"
|
||||
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"
|
||||
|
||||
@ -345,17 +345,3 @@ $ rustdoc src/lib.rs --sysroot /path/to/sysroot
|
||||
|
||||
Similar to `rustc --sysroot`, this lets you change the sysroot `rustdoc` uses
|
||||
when compiling your code.
|
||||
|
||||
### `--edition`: control the edition of docs and doctests
|
||||
|
||||
Using this flag looks like this:
|
||||
|
||||
```bash
|
||||
$ rustdoc src/lib.rs --edition 2018
|
||||
$ rustdoc --test src/lib.rs --edition 2018
|
||||
```
|
||||
|
||||
This flag allows rustdoc to treat your rust code as the given edition. It will compile doctests with
|
||||
the given edition as well. As with `rustc`, the default edition that `rustdoc` will use is `2015`
|
||||
(the first edition).
|
||||
|
||||
|
||||
@ -346,6 +346,19 @@ details.
|
||||
|
||||
[issue-display-warnings]: https://github.com/rust-lang/rust/issues/41574
|
||||
|
||||
### `--edition`: control the edition of docs and doctests
|
||||
|
||||
Using this flag looks like this:
|
||||
|
||||
```bash
|
||||
$ rustdoc src/lib.rs -Z unstable-options --edition 2018
|
||||
$ rustdoc --test src/lib.rs -Z unstable-options --edition 2018
|
||||
```
|
||||
|
||||
This flag allows rustdoc to treat your rust code as the given edition. It will compile doctests with
|
||||
the given edition as well. As with `rustc`, the default edition that `rustdoc` will use is `2015`
|
||||
(the first edition).
|
||||
|
||||
### `--extern-html-root-url`: control how rustdoc links to non-local crates
|
||||
|
||||
Using this flag looks like this:
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
# `infer_outlives_requirements`
|
||||
|
||||
The tracking issue for this feature is: [#44493]
|
||||
|
||||
[#44493]: https://github.com/rust-lang/rust/issues/44493
|
||||
|
||||
------------------------
|
||||
The `infer_outlives_requirements` feature indicates that certain
|
||||
outlives requirements can be inferred by the compiler rather than
|
||||
stating them explicitly.
|
||||
|
||||
For example, currently generic struct definitions that contain
|
||||
references, require where-clauses of the form T: 'a. By using
|
||||
this feature the outlives predicates will be inferred, although
|
||||
they may still be written explicitly.
|
||||
|
||||
```rust,ignore (pseudo-Rust)
|
||||
struct Foo<'a, T>
|
||||
where T: 'a // <-- currently required
|
||||
{
|
||||
bar: &'a T,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Examples:
|
||||
|
||||
|
||||
```rust,ignore (pseudo-Rust)
|
||||
#![feature(infer_outlives_requirements)]
|
||||
|
||||
// Implicitly infer T: 'a
|
||||
struct Foo<'a, T> {
|
||||
bar: &'a T,
|
||||
}
|
||||
```
|
||||
|
||||
```rust,ignore (pseudo-Rust)
|
||||
#![feature(infer_outlives_requirements)]
|
||||
|
||||
// Implicitly infer `U: 'b`
|
||||
struct Foo<'b, U> {
|
||||
bar: Bar<'b, U>
|
||||
}
|
||||
|
||||
struct Bar<'a, T> where T: 'a {
|
||||
x: &'a (),
|
||||
y: T,
|
||||
}
|
||||
```
|
||||
|
||||
```rust,ignore (pseudo-Rust)
|
||||
#![feature(infer_outlives_requirements)]
|
||||
|
||||
// Implicitly infer `b': 'a`
|
||||
struct Foo<'a, 'b, T> {
|
||||
x: &'a &'b T
|
||||
}
|
||||
```
|
||||
|
||||
```rust,ignore (pseudo-Rust)
|
||||
#![feature(infer_outlives_requirements)]
|
||||
|
||||
// Implicitly infer `<T as std::iter::Iterator>::Item : 'a`
|
||||
struct Foo<'a, T: Iterator> {
|
||||
bar: &'a T::Item
|
||||
```
|
||||
@ -19,7 +19,6 @@
|
||||
|
||||
use core::cmp::Ordering;
|
||||
use core::fmt;
|
||||
use core::isize;
|
||||
use core::iter::{repeat, FromIterator, FusedIterator};
|
||||
use core::mem;
|
||||
use core::ops::Bound::{Excluded, Included, Unbounded};
|
||||
@ -203,33 +202,6 @@ impl<T> VecDeque<T> {
|
||||
len);
|
||||
}
|
||||
|
||||
/// Copies all values from `src` to the back of `self`, wrapping around if needed.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The capacity must be sufficient to hold self.len() + src.len() elements.
|
||||
/// If so, this function never panics.
|
||||
#[inline]
|
||||
unsafe fn copy_slice(&mut self, src: &[T]) {
|
||||
/// This is guaranteed by `RawVec`.
|
||||
debug_assert!(self.capacity() <= isize::MAX as usize);
|
||||
|
||||
let expected_new_len = self.len() + src.len();
|
||||
debug_assert!(self.capacity() >= expected_new_len);
|
||||
|
||||
let dst_high_ptr = self.ptr().add(self.head);
|
||||
let dst_high_len = self.cap() - self.head;
|
||||
|
||||
let split = cmp::min(src.len(), dst_high_len);
|
||||
let (src_high, src_low) = src.split_at(split);
|
||||
|
||||
ptr::copy_nonoverlapping(src_high.as_ptr(), dst_high_ptr, src_high.len());
|
||||
ptr::copy_nonoverlapping(src_low.as_ptr(), self.ptr(), src_low.len());
|
||||
|
||||
self.head = self.wrap_add(self.head, src.len());
|
||||
debug_assert!(self.len() == expected_new_len);
|
||||
}
|
||||
|
||||
/// Copies a potentially wrapping block of memory len long from src to dest.
|
||||
/// (abs(dst - src) + len) must be no larger than cap() (There must be at
|
||||
/// most one continuous overlapping region between src and dest).
|
||||
@ -1052,7 +1024,7 @@ impl<T> VecDeque<T> {
|
||||
iter: Iter {
|
||||
tail: drain_tail,
|
||||
head: drain_head,
|
||||
ring: unsafe { self.buffer_as_slice() },
|
||||
ring: unsafe { self.buffer_as_mut_slice() },
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -1862,22 +1834,8 @@ impl<T> VecDeque<T> {
|
||||
#[inline]
|
||||
#[stable(feature = "append", since = "1.4.0")]
|
||||
pub fn append(&mut self, other: &mut Self) {
|
||||
unsafe {
|
||||
// Guarantees there is space in `self` for `other`.
|
||||
self.reserve(other.len());
|
||||
|
||||
{
|
||||
let (src_high, src_low) = other.as_slices();
|
||||
|
||||
// This is only safe because copy_slice never panics when capacity is sufficient.
|
||||
self.copy_slice(src_low);
|
||||
self.copy_slice(src_high);
|
||||
}
|
||||
|
||||
// Some values now exist in both `other` and `self` but are made inaccessible
|
||||
// in`other`.
|
||||
other.tail = other.head;
|
||||
}
|
||||
// naive impl
|
||||
self.extend(other.drain(..));
|
||||
}
|
||||
|
||||
/// Retains only the elements specified by the predicate.
|
||||
@ -2635,8 +2593,8 @@ impl<T> From<VecDeque<T>> for Vec<T> {
|
||||
let mut right_offset = 0;
|
||||
for i in left_edge..right_edge {
|
||||
right_offset = (i - left_edge) % (cap - right_edge);
|
||||
let src = right_edge + right_offset;
|
||||
ptr::swap(buf.add(i), buf.add(src));
|
||||
let src: isize = (right_edge + right_offset) as isize;
|
||||
ptr::swap(buf.add(i), buf.offset(src));
|
||||
}
|
||||
let n_ops = right_edge - left_edge;
|
||||
left_edge += n_ops;
|
||||
|
||||
@ -77,6 +77,7 @@
|
||||
#![cfg_attr(not(test), feature(fn_traits))]
|
||||
#![cfg_attr(not(test), feature(generator_trait))]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![cfg_attr(test, feature(test))]
|
||||
|
||||
#![feature(allocator_api)]
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#![feature(libc)]
|
||||
#![feature(linkage)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(staged_api)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![cfg_attr(dummy_jemalloc, allow(dead_code, unused_extern_crates))]
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#![feature(allocator_api)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(staged_api)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))]
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(dropck_eyepatch)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(raw_vec_internals)]
|
||||
#![cfg_attr(test, feature(test))]
|
||||
|
||||
|
||||
@ -92,6 +92,7 @@
|
||||
#![feature(link_llvm_intrinsics)]
|
||||
#![feature(never_type)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
#![feature(no_core)]
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
test(attr(deny(warnings))))]
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
|
||||
pub use self::Piece::*;
|
||||
pub use self::Position::*;
|
||||
|
||||
@ -289,6 +289,7 @@
|
||||
test(attr(allow(unused_variables), deny(warnings))))]
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(str_escape)]
|
||||
|
||||
use self::LabelText::*;
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(libc)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(panic_runtime)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#![feature(lang_items)]
|
||||
#![feature(libc)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(panic_unwind)]
|
||||
#![feature(raw)]
|
||||
#![feature(staged_api)]
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(rustc_private)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(lang_items)]
|
||||
|
||||
@ -16,4 +16,5 @@
|
||||
issue = "0")]
|
||||
#![allow(unused_features)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(staged_api)]
|
||||
|
||||
@ -1232,54 +1232,41 @@ let x: i32 = "I am not a number!";
|
||||
"##,
|
||||
|
||||
E0309: r##"
|
||||
The type definition contains some field whose type
|
||||
requires an outlives annotation. Outlives annotations
|
||||
(e.g., `T: 'a`) are used to guarantee that all the data in T is valid
|
||||
for at least the lifetime `'a`. This scenario most commonly
|
||||
arises when the type contains an associated type reference
|
||||
like `<T as SomeTrait<'a>>::Output`, as shown in this example:
|
||||
Types in type definitions have lifetimes associated with them that represent
|
||||
how long the data stored within them is guaranteed to be live. This lifetime
|
||||
must be as long as the data needs to be alive, and missing the constraint that
|
||||
denotes this will cause this error.
|
||||
|
||||
```compile_fail,E0309
|
||||
// This won't compile because the applicable impl of
|
||||
// `SomeTrait` (below) requires that `T: 'a`, but the struct does
|
||||
// not have a matching where-clause.
|
||||
// This won't compile because T is not constrained, meaning the data
|
||||
// stored in it is not guaranteed to last as long as the reference
|
||||
struct Foo<'a, T> {
|
||||
foo: <T as SomeTrait<'a>>::Output,
|
||||
}
|
||||
|
||||
trait SomeTrait<'a> {
|
||||
type Output;
|
||||
}
|
||||
|
||||
impl<'a, T> SomeTrait<'a> for T
|
||||
where
|
||||
T: 'a,
|
||||
{
|
||||
type Output = u32;
|
||||
foo: &'a T
|
||||
}
|
||||
```
|
||||
|
||||
Here, the where clause `T: 'a` that appears on the impl is not known to be
|
||||
satisfied on the struct. To make this example compile, you have to add
|
||||
a where-clause like `T: 'a` to the struct definition:
|
||||
This will compile, because it has the constraint on the type parameter:
|
||||
|
||||
```
|
||||
struct Foo<'a, T>
|
||||
where
|
||||
T: 'a,
|
||||
{
|
||||
foo: <T as SomeTrait<'a>>::Output
|
||||
struct Foo<'a, T: 'a> {
|
||||
foo: &'a T
|
||||
}
|
||||
```
|
||||
|
||||
To see why this is important, consider the case where `T` is itself a reference
|
||||
(e.g., `T = &str`). If we don't include the restriction that `T: 'a`, the
|
||||
following code would be perfectly legal:
|
||||
|
||||
```compile_fail,E0309
|
||||
struct Foo<'a, T> {
|
||||
foo: &'a T
|
||||
}
|
||||
|
||||
trait SomeTrait<'a> {
|
||||
type Output;
|
||||
}
|
||||
|
||||
impl<'a, T> SomeTrait<'a> for T
|
||||
where
|
||||
T: 'a,
|
||||
{
|
||||
type Output = u32;
|
||||
fn main() {
|
||||
let v = "42".to_string();
|
||||
let f = Foo{foo: &v};
|
||||
drop(v);
|
||||
println!("{}", f.foo); // but we've already dropped v!
|
||||
}
|
||||
```
|
||||
"##,
|
||||
@ -1478,31 +1465,30 @@ A reference has a longer lifetime than the data it references.
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0491
|
||||
trait SomeTrait<'a> {
|
||||
type Output;
|
||||
// struct containing a reference requires a lifetime parameter,
|
||||
// because the data the reference points to must outlive the struct (see E0106)
|
||||
struct Struct<'a> {
|
||||
ref_i32: &'a i32,
|
||||
}
|
||||
|
||||
impl<'a, T> SomeTrait<'a> for T {
|
||||
type Output = &'a T; // compile error E0491
|
||||
// However, a nested struct like this, the signature itself does not tell
|
||||
// whether 'a outlives 'b or the other way around.
|
||||
// So it could be possible that 'b of reference outlives 'a of the data.
|
||||
struct Nested<'a, 'b> {
|
||||
ref_struct: &'b Struct<'a>, // compile error E0491
|
||||
}
|
||||
```
|
||||
|
||||
Here, the problem is that a reference type like `&'a T` is only valid
|
||||
if all the data in T outlives the lifetime `'a`. But this impl as written
|
||||
is applicable to any lifetime `'a` and any type `T` -- we have no guarantee
|
||||
that `T` outlives `'a`. To fix this, you can add a where clause like
|
||||
`where T: 'a`.
|
||||
To fix this issue, you can specify a bound to the lifetime like below:
|
||||
|
||||
```
|
||||
trait SomeTrait<'a> {
|
||||
type Output;
|
||||
struct Struct<'a> {
|
||||
ref_i32: &'a i32,
|
||||
}
|
||||
|
||||
impl<'a, T> SomeTrait<'a> for T
|
||||
where
|
||||
T: 'a,
|
||||
{
|
||||
type Output = &'a T; // compile error E0491
|
||||
// 'a: 'b means 'a outlives 'b
|
||||
struct Nested<'a: 'b, 'b> {
|
||||
ref_struct: &'b Struct<'a>,
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
@ -287,6 +287,31 @@ impl DefPath {
|
||||
s
|
||||
}
|
||||
|
||||
/// Return filename friendly string of the DefPah with the
|
||||
/// crate-prefix.
|
||||
pub fn to_string_friendly<F>(&self, crate_imported_name: F) -> String
|
||||
where F: FnOnce(CrateNum) -> Symbol
|
||||
{
|
||||
let crate_name_str = crate_imported_name(self.krate).as_str();
|
||||
let mut s = String::with_capacity(crate_name_str.len() + self.data.len() * 16);
|
||||
|
||||
write!(s, "::{}", crate_name_str).unwrap();
|
||||
|
||||
for component in &self.data {
|
||||
if component.disambiguator == 0 {
|
||||
write!(s, "::{}", component.data.as_interned_str()).unwrap();
|
||||
} else {
|
||||
write!(s,
|
||||
"{}[{}]",
|
||||
component.data.as_interned_str(),
|
||||
component.disambiguator)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
/// Return filename friendly string of the DefPah without
|
||||
/// the crate-prefix. This method is useful if you don't have
|
||||
/// a TyCtxt available.
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![feature(extern_types)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(non_exhaustive)]
|
||||
#![feature(proc_macro_internals)]
|
||||
#![feature(quote)]
|
||||
|
||||
@ -299,7 +299,7 @@ impl<'a> LintLevelsBuilder<'a> {
|
||||
"change it to",
|
||||
new_lint_name.to_string(),
|
||||
Applicability::MachineApplicable,
|
||||
).emit();
|
||||
).cancel();
|
||||
|
||||
let src = LintSource::Node(Symbol::intern(&new_lint_name), li.span);
|
||||
for id in ids {
|
||||
|
||||
@ -395,7 +395,13 @@ fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
krate: &hir::Crate)
|
||||
-> Vec<ast::NodeId>
|
||||
{
|
||||
let worklist = access_levels.map.iter().map(|(&id, _)| id).chain(
|
||||
let worklist = access_levels.map.iter().filter_map(|(&id, level)| {
|
||||
if level >= &privacy::AccessLevel::Reachable {
|
||||
Some(id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}).chain(
|
||||
// Seed entry point
|
||||
tcx.sess.entry_fn.borrow().map(|(id, _, _)| id)
|
||||
).collect::<Vec<_>>();
|
||||
|
||||
@ -646,7 +646,6 @@ impl Options {
|
||||
match self.debugging_opts.share_generics {
|
||||
Some(setting) => setting,
|
||||
None => {
|
||||
self.incremental.is_some() ||
|
||||
match self.optimize {
|
||||
OptLevel::No |
|
||||
OptLevel::Less |
|
||||
|
||||
@ -927,8 +927,8 @@ pub struct GlobalCtxt<'tcx> {
|
||||
freevars: FxHashMap<DefId, Lrc<Vec<hir::Freevar>>>,
|
||||
|
||||
maybe_unused_trait_imports: FxHashSet<DefId>,
|
||||
|
||||
maybe_unused_extern_crates: Vec<(DefId, Span)>,
|
||||
pub extern_prelude: FxHashSet<ast::Name>,
|
||||
|
||||
// Internal cache for metadata decoding. No need to track deps on this.
|
||||
pub rcache: Lock<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>,
|
||||
@ -1245,6 +1245,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
.into_iter()
|
||||
.map(|(id, sp)| (hir.local_def_id(id), sp))
|
||||
.collect(),
|
||||
extern_prelude: resolutions.extern_prelude,
|
||||
hir,
|
||||
def_path_hash_to_def_id,
|
||||
queries: query::Queries::new(
|
||||
|
||||
@ -36,7 +36,7 @@ use ty::subst::{Subst, Substs};
|
||||
use ty::util::{IntTypeExt, Discr};
|
||||
use ty::walk::TypeWalker;
|
||||
use util::captures::Captures;
|
||||
use util::nodemap::{NodeSet, DefIdMap, FxHashMap};
|
||||
use util::nodemap::{NodeSet, DefIdMap, FxHashMap, FxHashSet};
|
||||
use arena::SyncDroplessArena;
|
||||
use session::DataTypeKind;
|
||||
|
||||
@ -139,6 +139,7 @@ pub struct Resolutions {
|
||||
pub maybe_unused_trait_imports: NodeSet,
|
||||
pub maybe_unused_extern_crates: Vec<(NodeId, Span)>,
|
||||
pub export_map: ExportMap,
|
||||
pub extern_prelude: FxHashSet<Name>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
|
||||
@ -606,6 +606,7 @@ impl<'a, 'tcx, 'x> SpecializedDecoder<interpret::AllocId> for CacheDecoder<'a, '
|
||||
alloc_decoding_session.decode_alloc_id(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'x> SpecializedDecoder<Span> for CacheDecoder<'a, 'tcx, 'x> {
|
||||
fn specialized_decode(&mut self) -> Result<Span, Self::Error> {
|
||||
let tag: u8 = Decodable::decode(self)?;
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(try_from)]
|
||||
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
|
||||
#[allow(unused_extern_crates)]
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#![sanitizer_runtime]
|
||||
#![feature(alloc_system)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(sanitizer_runtime)]
|
||||
#![feature(staged_api)]
|
||||
#![no_std]
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(quote)]
|
||||
|
||||
#![recursion_limit="256"]
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#![allow(unused_attributes)]
|
||||
#![feature(libc)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(quote)]
|
||||
#![feature(range_contains)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
@ -10,11 +10,9 @@
|
||||
|
||||
use abi::{FnType, FnTypeExt};
|
||||
use common::*;
|
||||
use llvm;
|
||||
use rustc::hir;
|
||||
use rustc::ty::{self, Ty, TypeFoldable};
|
||||
use rustc::ty::layout::{self, Align, LayoutOf, Size, TyLayout};
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
use rustc_target::abi::FloatTy;
|
||||
use rustc_mir::monomorphize::item::DefPathBasedNames;
|
||||
use type_::Type;
|
||||
@ -433,12 +431,19 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
||||
PointerKind::Shared
|
||||
},
|
||||
hir::MutMutable => {
|
||||
// Only emit noalias annotations for LLVM >= 6 or in panic=abort
|
||||
// mode, as prior versions had many bugs in conjunction with
|
||||
// unwinding. See also issue #31681.
|
||||
// Previously we would only emit noalias annotations for LLVM >= 6 or in
|
||||
// panic=abort mode. That was deemed right, as prior versions had many bugs
|
||||
// in conjunction with unwinding, but later versions didn’t seem to have
|
||||
// said issues. See issue #31681.
|
||||
//
|
||||
// Alas, later on we encountered a case where noalias would generate wrong
|
||||
// code altogether even with recent versions of LLVM in *safe* code with no
|
||||
// unwinding involved. See #54462.
|
||||
//
|
||||
// For now, do not enable mutable_noalias by default at all, while the
|
||||
// issue is being figured out.
|
||||
let mutable_noalias = cx.tcx.sess.opts.debugging_opts.mutable_noalias
|
||||
.unwrap_or(unsafe { llvm::LLVMRustVersionMajor() >= 6 }
|
||||
|| cx.tcx.sess.panic_strategy() == PanicStrategy::Abort);
|
||||
.unwrap_or(false);
|
||||
if mutable_noalias {
|
||||
PointerKind::UniqueBorrowed
|
||||
} else {
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#![feature(box_syntax)]
|
||||
#![feature(custom_attribute)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![allow(unused_attributes)]
|
||||
#![feature(quote)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#![allow(unused_extern_crates)]
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
|
||||
extern crate bitflags;
|
||||
extern crate log;
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#![feature(optin_builtin_traits)]
|
||||
#![cfg_attr(stage0, feature(macro_vis_matcher))]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(allow_internal_unstable)]
|
||||
#![feature(vec_resize_with)]
|
||||
|
||||
|
||||
@ -790,6 +790,7 @@ where
|
||||
trait_map: resolver.trait_map,
|
||||
maybe_unused_trait_imports: resolver.maybe_unused_trait_imports,
|
||||
maybe_unused_extern_crates: resolver.maybe_unused_extern_crates,
|
||||
extern_prelude: resolver.extern_prelude,
|
||||
},
|
||||
|
||||
analysis: ty::CrateAnalysis {
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#![feature(box_syntax)]
|
||||
#![cfg_attr(unix, feature(libc))]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(option_replace)]
|
||||
#![feature(quote)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#![feature(range_contains)]
|
||||
#![cfg_attr(unix, feature(libc))]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
extern crate atty;
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(specialization)]
|
||||
|
||||
#![recursion_limit="256"]
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#![feature(box_syntax)]
|
||||
#![cfg_attr(stage0, feature(macro_vis_matcher))]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(quote)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
@ -312,7 +313,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
|
||||
},
|
||||
FutureIncompatibleInfo {
|
||||
id: LintId::of(ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE),
|
||||
reference: "issue TBD",
|
||||
reference: "issue #53130 <https://github.com/rust-lang/rust/issues/53130>",
|
||||
edition: Some(Edition::Edition2018),
|
||||
},
|
||||
FutureIncompatibleInfo {
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(static_nobundle)]
|
||||
|
||||
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#![sanitizer_runtime]
|
||||
#![feature(alloc_system)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(sanitizer_runtime)]
|
||||
#![feature(staged_api)]
|
||||
#![no_std]
|
||||
|
||||
@ -256,6 +256,7 @@ impl<'a> CrateLoader<'a> {
|
||||
|
||||
let cmeta = cstore::CrateMetadata {
|
||||
name: crate_root.name,
|
||||
imported_name: ident,
|
||||
extern_crate: Lock::new(None),
|
||||
def_path_table: Lrc::new(def_path_table),
|
||||
trait_impls,
|
||||
|
||||
@ -53,8 +53,13 @@ pub struct ImportedSourceFile {
|
||||
}
|
||||
|
||||
pub struct CrateMetadata {
|
||||
/// Original name of the crate.
|
||||
pub name: Symbol,
|
||||
|
||||
/// Name of the crate as imported. I.e. if imported with
|
||||
/// `extern crate foo as bar;` this will be `bar`.
|
||||
pub imported_name: Symbol,
|
||||
|
||||
/// Information about the extern crate that caused this crate to
|
||||
/// be loaded. If this is `None`, then the crate was injected
|
||||
/// (e.g., by the allocator)
|
||||
|
||||
@ -441,8 +441,7 @@ impl cstore::CStore {
|
||||
let data = self.get_crate_data(id.krate);
|
||||
if let Some(ref proc_macros) = data.proc_macros {
|
||||
return LoadedMacro::ProcMacro(proc_macros[id.index.to_proc_macro_index()].1.clone());
|
||||
} else if data.name == "proc_macro" &&
|
||||
self.get_crate_data(id.krate).item_name(id.index) == "quote" {
|
||||
} else if data.name == "proc_macro" && data.item_name(id.index) == "quote" {
|
||||
use syntax::ext::base::SyntaxExtension;
|
||||
use syntax_ext::proc_macro_impl::BangProcMacro;
|
||||
|
||||
@ -454,8 +453,9 @@ impl cstore::CStore {
|
||||
return LoadedMacro::ProcMacro(Lrc::new(ext));
|
||||
}
|
||||
|
||||
let (name, def) = data.get_macro(id.index);
|
||||
let source_name = FileName::Macros(name.to_string());
|
||||
let def = data.get_macro(id.index);
|
||||
let macro_full_name = data.def_path(id.index).to_string_friendly(|_| data.imported_name);
|
||||
let source_name = FileName::Macros(macro_full_name);
|
||||
|
||||
let source_file = sess.parse_sess.source_map().new_source_file(source_name, def.body);
|
||||
let local_span = Span::new(source_file.start_pos, source_file.end_pos, NO_EXPANSION);
|
||||
|
||||
@ -1101,10 +1101,10 @@ impl<'a, 'tcx> CrateMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_macro(&self, id: DefIndex) -> (InternedString, MacroDef) {
|
||||
pub fn get_macro(&self, id: DefIndex) -> MacroDef {
|
||||
let entry = self.entry(id);
|
||||
match entry.kind {
|
||||
EntryKind::MacroDef(macro_def) => (self.item_name(id), macro_def.decode(self)),
|
||||
EntryKind::MacroDef(macro_def) => macro_def.decode(self),
|
||||
_ => bug!(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#![feature(libc)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(proc_macro_internals)]
|
||||
#![feature(proc_macro_quote)]
|
||||
#![feature(quote)]
|
||||
|
||||
@ -17,7 +17,7 @@ use rustc::hir::{self, def_id::DefId};
|
||||
use rustc::mir::interpret::ConstEvalErr;
|
||||
use rustc::mir;
|
||||
use rustc::ty::{self, TyCtxt, Instance, query::TyCtxtAt};
|
||||
use rustc::ty::layout::{LayoutOf, TyLayout};
|
||||
use rustc::ty::layout::{self, LayoutOf, TyLayout};
|
||||
use rustc::ty::subst::Subst;
|
||||
use rustc_data_structures::indexed_vec::IndexVec;
|
||||
|
||||
@ -90,8 +90,18 @@ pub fn eval_promoted<'a, 'mir, 'tcx>(
|
||||
pub fn op_to_const<'tcx>(
|
||||
ecx: &EvalContext<'_, '_, 'tcx, CompileTimeEvaluator>,
|
||||
op: OpTy<'tcx>,
|
||||
normalize: bool,
|
||||
may_normalize: bool,
|
||||
) -> EvalResult<'tcx, &'tcx ty::Const<'tcx>> {
|
||||
// We do not normalize just any data. Only scalar layout and fat pointers.
|
||||
let normalize = may_normalize
|
||||
&& match op.layout.abi {
|
||||
layout::Abi::Scalar(..) => true,
|
||||
layout::Abi::ScalarPair(..) => {
|
||||
// Must be a fat pointer
|
||||
op.layout.ty.builtin_deref(true).is_some()
|
||||
},
|
||||
_ => false,
|
||||
};
|
||||
let normalized_op = if normalize {
|
||||
ecx.try_read_value(op)?
|
||||
} else {
|
||||
|
||||
@ -15,6 +15,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
|
||||
*/
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(impl_header_lifetime_elision)]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#![sanitizer_runtime]
|
||||
#![feature(alloc_system)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(sanitizer_runtime)]
|
||||
#![feature(staged_api)]
|
||||
#![no_std]
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
#[macro_use]
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#![allow(nonstandard_style)]
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
|
||||
pub struct Intrinsic {
|
||||
pub inputs: &'static [&'static Type],
|
||||
|
||||
@ -65,6 +65,7 @@
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
#[macro_use] extern crate syntax;
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
#![recursion_limit="256"]
|
||||
@ -1380,13 +1381,7 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn predicates(&mut self) -> &mut Self {
|
||||
// NB: We use `explicit_predicates_of` and not `predicates_of`
|
||||
// because we don't want to report privacy errors due to where
|
||||
// clauses that the compiler inferred. We only want to
|
||||
// consider the ones that the user wrote. This is important
|
||||
// for the inferred outlives rules; see
|
||||
// `src/test/ui/rfc-2093-infer-outlives/privacy.rs`.
|
||||
let predicates = self.tcx.explicit_predicates_of(self.item_def_id);
|
||||
let predicates = self.tcx.predicates_of(self.item_def_id);
|
||||
for predicate in &predicates.predicates {
|
||||
predicate.visit_with(self);
|
||||
match predicate {
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(slice_sort_by_cached_key)]
|
||||
|
||||
@ -71,11 +72,10 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan};
|
||||
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::cmp;
|
||||
use std::{cmp, fmt, iter, ptr};
|
||||
use std::collections::BTreeSet;
|
||||
use std::fmt;
|
||||
use std::iter;
|
||||
use std::mem::replace;
|
||||
use rustc_data_structures::ptr_key::PtrKey;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
||||
use resolve_imports::{ImportDirective, ImportDirectiveSubclass, NameResolution, ImportResolver};
|
||||
@ -1113,6 +1113,17 @@ impl<'a> ModuleData<'a> {
|
||||
fn nearest_item_scope(&'a self) -> Module<'a> {
|
||||
if self.is_trait() { self.parent.unwrap() } else { self }
|
||||
}
|
||||
|
||||
fn is_ancestor_of(&self, mut other: &Self) -> bool {
|
||||
while !ptr::eq(self, other) {
|
||||
if let Some(parent) = other.parent {
|
||||
other = parent;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> fmt::Debug for ModuleData<'a> {
|
||||
@ -1350,7 +1361,7 @@ pub struct Resolver<'a, 'b: 'a> {
|
||||
graph_root: Module<'a>,
|
||||
|
||||
prelude: Option<Module<'a>>,
|
||||
extern_prelude: FxHashSet<Name>,
|
||||
pub extern_prelude: FxHashSet<Name>,
|
||||
|
||||
/// n.b. This is used only for better diagnostics, not name resolution itself.
|
||||
has_self: FxHashSet<DefId>,
|
||||
@ -1408,6 +1419,7 @@ pub struct Resolver<'a, 'b: 'a> {
|
||||
block_map: NodeMap<Module<'a>>,
|
||||
module_map: FxHashMap<DefId, Module<'a>>,
|
||||
extern_module_map: FxHashMap<(DefId, bool /* MacrosOnly? */), Module<'a>>,
|
||||
binding_parent_modules: FxHashMap<PtrKey<'a, NameBinding<'a>>, Module<'a>>,
|
||||
|
||||
pub make_glob_map: bool,
|
||||
/// Maps imports to the names of items actually imported (this actually maps
|
||||
@ -1666,13 +1678,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
||||
let mut extern_prelude: FxHashSet<Name> =
|
||||
session.opts.externs.iter().map(|kv| Symbol::intern(kv.0)).collect();
|
||||
|
||||
// HACK(eddyb) this ignore the `no_{core,std}` attributes.
|
||||
// FIXME(eddyb) warn (elsewhere) if core/std is used with `no_{core,std}`.
|
||||
// if !attr::contains_name(&krate.attrs, "no_core") {
|
||||
// if !attr::contains_name(&krate.attrs, "no_std") {
|
||||
extern_prelude.insert(Symbol::intern("core"));
|
||||
extern_prelude.insert(Symbol::intern("std"));
|
||||
extern_prelude.insert(Symbol::intern("meta"));
|
||||
if !attr::contains_name(&krate.attrs, "no_core") {
|
||||
extern_prelude.insert(Symbol::intern("core"));
|
||||
if !attr::contains_name(&krate.attrs, "no_std") {
|
||||
extern_prelude.insert(Symbol::intern("std"));
|
||||
if session.rust_2018() {
|
||||
extern_prelude.insert(Symbol::intern("meta"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut invocations = FxHashMap();
|
||||
invocations.insert(Mark::root(),
|
||||
@ -1722,6 +1736,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
||||
module_map,
|
||||
block_map: NodeMap(),
|
||||
extern_module_map: FxHashMap(),
|
||||
binding_parent_modules: FxHashMap(),
|
||||
|
||||
make_glob_map: make_glob_map == MakeGlobMap::Yes,
|
||||
glob_map: NodeMap(),
|
||||
@ -1962,9 +1977,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
||||
}
|
||||
|
||||
if !module.no_implicit_prelude {
|
||||
// `record_used` means that we don't try to load crates during speculative resolution
|
||||
if record_used && ns == TypeNS && self.extern_prelude.contains(&ident.name) {
|
||||
let crate_id = self.crate_loader.process_path_extern(ident.name, ident.span);
|
||||
if ns == TypeNS && self.extern_prelude.contains(&ident.name) {
|
||||
let crate_id = if record_used {
|
||||
self.crate_loader.process_path_extern(ident.name, ident.span)
|
||||
} else if let Some(crate_id) =
|
||||
self.crate_loader.maybe_process_path_extern(ident.name, ident.span) {
|
||||
crate_id
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX });
|
||||
self.populate_module_if_necessary(&crate_root);
|
||||
|
||||
@ -4540,6 +4561,31 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
||||
vis.is_accessible_from(module.normal_ancestor_id, self)
|
||||
}
|
||||
|
||||
fn set_binding_parent_module(&mut self, binding: &'a NameBinding<'a>, module: Module<'a>) {
|
||||
if let Some(old_module) = self.binding_parent_modules.insert(PtrKey(binding), module) {
|
||||
if !ptr::eq(module, old_module) {
|
||||
span_bug!(binding.span, "parent module is reset for binding");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn disambiguate_legacy_vs_modern(
|
||||
&self,
|
||||
legacy: &'a NameBinding<'a>,
|
||||
modern: &'a NameBinding<'a>,
|
||||
) -> bool {
|
||||
// Some non-controversial subset of ambiguities "modern macro name" vs "macro_rules"
|
||||
// is disambiguated to mitigate regressions from macro modularization.
|
||||
// Scoping for `macro_rules` behaves like scoping for `let` at module level, in general.
|
||||
match (self.binding_parent_modules.get(&PtrKey(legacy)),
|
||||
self.binding_parent_modules.get(&PtrKey(modern))) {
|
||||
(Some(legacy), Some(modern)) =>
|
||||
legacy.normal_ancestor_id == modern.normal_ancestor_id &&
|
||||
modern.is_ancestor_of(legacy),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn report_ambiguity_error(&self, ident: Ident, b1: &NameBinding, b2: &NameBinding) {
|
||||
let participle = |is_import: bool| if is_import { "imported" } else { "defined" };
|
||||
let msg1 =
|
||||
|
||||
@ -575,6 +575,13 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
||||
// 5. Standard library prelude (de-facto closed, controlled).
|
||||
// 6. Language prelude (closed, controlled).
|
||||
// (Macro NS)
|
||||
// 0. Derive helpers (open, not controlled). All ambiguities with other names
|
||||
// are currently reported as errors. They should be higher in priority than preludes
|
||||
// and probably even names in modules according to the "general principles" above. They
|
||||
// also should be subject to restricted shadowing because are effectively produced by
|
||||
// derives (you need to resolve the derive first to add helpers into scope), but they
|
||||
// should be available before the derive is expanded for compatibility.
|
||||
// It's mess in general, so we are being conservative for now.
|
||||
// 1. Names in modules (both normal `mod`ules and blocks), loop through hygienic parents
|
||||
// (open, not controlled).
|
||||
// 2. `macro_use` prelude (open, the open part is from macro expansions, not controlled).
|
||||
@ -583,13 +590,6 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
||||
// 2b. Standard library prelude is currently implemented as `macro-use` (closed, controlled)
|
||||
// 3. Language prelude: builtin macros (closed, controlled, except for legacy plugins).
|
||||
// 4. Language prelude: builtin attributes (closed, controlled).
|
||||
// N (unordered). Derive helpers (open, not controlled). All ambiguities with other names
|
||||
// are currently reported as errors. They should be higher in priority than preludes
|
||||
// and maybe even names in modules according to the "general principles" above. They
|
||||
// also should be subject to restricted shadowing because are effectively produced by
|
||||
// derives (you need to resolve the derive first to add helpers into scope), but they
|
||||
// should be available before the derive is expanded for compatibility.
|
||||
// It's mess in general, so we are being conservative for now.
|
||||
|
||||
assert!(ns == TypeNS || ns == MacroNS);
|
||||
assert!(force || !record_used); // `record_used` implies `force`
|
||||
@ -621,7 +621,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
||||
}
|
||||
|
||||
// Go through all the scopes and try to resolve the name.
|
||||
let mut where_to_resolve = WhereToResolve::Module(parent_scope.module);
|
||||
let mut where_to_resolve = WhereToResolve::DeriveHelpers;
|
||||
let mut use_prelude = !parent_scope.module.no_implicit_prelude;
|
||||
loop {
|
||||
let result = match where_to_resolve {
|
||||
@ -751,8 +751,8 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
||||
}
|
||||
WhereToResolve::MacroUsePrelude => WhereToResolve::BuiltinMacros,
|
||||
WhereToResolve::BuiltinMacros => WhereToResolve::BuiltinAttrs,
|
||||
WhereToResolve::BuiltinAttrs => WhereToResolve::DeriveHelpers,
|
||||
WhereToResolve::DeriveHelpers => break, // nowhere else to search
|
||||
WhereToResolve::BuiltinAttrs => break, // nowhere else to search
|
||||
WhereToResolve::DeriveHelpers => WhereToResolve::Module(parent_scope.module),
|
||||
WhereToResolve::ExternPrelude => WhereToResolve::ToolPrelude,
|
||||
WhereToResolve::ToolPrelude => WhereToResolve::StdLibPrelude,
|
||||
WhereToResolve::StdLibPrelude => WhereToResolve::BuiltinTypes,
|
||||
@ -956,11 +956,13 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
||||
},
|
||||
(Some(legacy_binding), Ok((binding, FromPrelude(from_prelude))))
|
||||
if legacy_binding.def() != binding.def_ignoring_ambiguity() &&
|
||||
(!from_prelude ||
|
||||
(!from_prelude &&
|
||||
!self.disambiguate_legacy_vs_modern(legacy_binding, binding) ||
|
||||
legacy_binding.may_appear_after(parent_scope.expansion, binding)) => {
|
||||
self.report_ambiguity_error(ident, legacy_binding, binding);
|
||||
},
|
||||
// OK, non-macro-expanded legacy wins over prelude even if defs are different
|
||||
// Also, non-macro-expanded legacy wins over modern from the same module
|
||||
// Also, legacy and modern can co-exist if their defs are same
|
||||
(Some(legacy_binding), Ok(_)) |
|
||||
// OK, unambiguous resolution
|
||||
@ -1096,6 +1098,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
||||
let def = Def::Macro(def_id, MacroKind::Bang);
|
||||
let vis = ty::Visibility::Invisible; // Doesn't matter for legacy bindings
|
||||
let binding = (def, vis, item.span, expansion).to_name_binding(self.arenas);
|
||||
self.set_binding_parent_module(binding, self.current_module);
|
||||
let legacy_binding = self.arenas.alloc_legacy_binding(LegacyBinding {
|
||||
parent_legacy_scope: *current_legacy_scope, binding, ident
|
||||
});
|
||||
|
||||
@ -478,6 +478,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
|
||||
binding: &'a NameBinding<'a>)
|
||||
-> Result<(), &'a NameBinding<'a>> {
|
||||
self.check_reserved_macro_name(ident, ns);
|
||||
self.set_binding_parent_module(binding, module);
|
||||
self.update_resolution(module, ident, ns, |this, resolution| {
|
||||
if let Some(old_binding) = resolution.binding {
|
||||
if binding.is_glob_import() {
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![feature(custom_attribute)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
#![recursion_limit="256"]
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#![cfg_attr(stage0, feature(const_fn))]
|
||||
#![cfg_attr(not(stage0), feature(min_const_fn))]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
#[macro_use]
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#![cfg_attr(stage0, feature(extern_prelude))]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
|
||||
#![recursion_limit="256"]
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#![sanitizer_runtime]
|
||||
#![feature(alloc_system)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(sanitizer_runtime)]
|
||||
#![feature(staged_api)]
|
||||
#![no_std]
|
||||
|
||||
@ -130,15 +130,13 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
|
||||
});
|
||||
|
||||
for extern_crate in &crates_to_lint {
|
||||
assert!(extern_crate.def_id.is_local());
|
||||
let id = tcx.hir.as_local_node_id(extern_crate.def_id).unwrap();
|
||||
let item = tcx.hir.expect_item(id);
|
||||
|
||||
// If the crate is fully unused, we suggest removing it altogether.
|
||||
// We do this in any edition.
|
||||
if extern_crate.warn_if_unused {
|
||||
if let Some(&span) = unused_extern_crates.get(&extern_crate.def_id) {
|
||||
assert_eq!(extern_crate.def_id.krate, LOCAL_CRATE);
|
||||
let hir_id = tcx.hir.definitions().def_index_to_hir_id(extern_crate.def_id.index);
|
||||
let id = tcx.hir.hir_to_node_id(hir_id);
|
||||
let msg = "unused extern crate";
|
||||
tcx.struct_span_lint_node(lint, id, span, msg)
|
||||
.span_suggestion_short_with_applicability(
|
||||
@ -157,6 +155,13 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the extern crate isn't in the extern prelude,
|
||||
// there is no way it can be written as an `use`.
|
||||
let orig_name = extern_crate.orig_name.unwrap_or(item.name);
|
||||
if !tcx.extern_prelude.contains(&orig_name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the extern crate has any attributes, they may have funky
|
||||
// semantics we can't faithfully represent using `use` (most
|
||||
// notably `#[macro_use]`). Ignore it.
|
||||
@ -165,9 +170,6 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
|
||||
}
|
||||
|
||||
// Otherwise, we can convert it into a `use` of some kind.
|
||||
let hir_id = tcx.hir.definitions().def_index_to_hir_id(extern_crate.def_id.index);
|
||||
let id = tcx.hir.hir_to_node_id(hir_id);
|
||||
let item = tcx.hir.expect_item(id);
|
||||
let msg = "`extern crate` is not idiomatic in the new edition";
|
||||
let help = format!(
|
||||
"convert it to a `{}`",
|
||||
|
||||
@ -1578,10 +1578,14 @@ fn predicates_defined_on<'a, 'tcx>(
|
||||
def_id: DefId,
|
||||
) -> ty::GenericPredicates<'tcx> {
|
||||
let explicit = tcx.explicit_predicates_of(def_id);
|
||||
let predicates = [
|
||||
&explicit.predicates[..],
|
||||
&tcx.inferred_outlives_of(def_id)[..],
|
||||
].concat();
|
||||
let predicates = if tcx.sess.features_untracked().infer_outlives_requirements {
|
||||
[
|
||||
&explicit.predicates[..],
|
||||
&tcx.inferred_outlives_of(def_id)[..],
|
||||
].concat()
|
||||
} else {
|
||||
explicit.predicates
|
||||
};
|
||||
|
||||
ty::GenericPredicates {
|
||||
parent: explicit.parent,
|
||||
|
||||
@ -76,6 +76,7 @@ This API is completely unstable and subject to change.
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(quote)]
|
||||
#![feature(refcell_replace_swap)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
@ -66,8 +66,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
|
||||
|
||||
debug!("InferVisitor::visit_item(item={:?})", item_did);
|
||||
|
||||
let node_id = self
|
||||
.tcx
|
||||
let node_id = self.tcx
|
||||
.hir
|
||||
.as_local_node_id(item_did)
|
||||
.expect("expected local def-id");
|
||||
@ -109,8 +108,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
|
||||
// Therefore mark `predicates_added` as true and which will ensure
|
||||
// we walk the crates again and re-calculate predicates for all
|
||||
// items.
|
||||
let item_predicates_len: usize = self
|
||||
.global_inferred_outlives
|
||||
let item_predicates_len: usize = self.global_inferred_outlives
|
||||
.get(&item_did)
|
||||
.map(|p| p.len())
|
||||
.unwrap_or(0);
|
||||
|
||||
@ -457,6 +457,7 @@ pub fn run_core(search_paths: SearchPaths,
|
||||
trait_map: resolver.trait_map.clone(),
|
||||
maybe_unused_trait_imports: resolver.maybe_unused_trait_imports.clone(),
|
||||
maybe_unused_extern_crates: resolver.maybe_unused_extern_crates.clone(),
|
||||
extern_prelude: resolver.extern_prelude.clone(),
|
||||
};
|
||||
let analysis = ty::CrateAnalysis {
|
||||
access_levels: Lrc::new(AccessLevels::default()),
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#![feature(box_patterns)]
|
||||
#![feature(box_syntax)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(set_stdio)]
|
||||
#![feature(slice_sort_by_cached_key)]
|
||||
#![feature(test)]
|
||||
@ -285,7 +286,7 @@ fn opts() -> Vec<RustcOptGroup> {
|
||||
\"light-suffix.css\"",
|
||||
"PATH")
|
||||
}),
|
||||
stable("edition", |o| {
|
||||
unstable("edition", |o| {
|
||||
o.optopt("", "edition",
|
||||
"edition to use when compiling rust code (default: 2015)",
|
||||
"EDITION")
|
||||
|
||||
@ -220,7 +220,6 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
|
||||
output_types: outputs,
|
||||
externs,
|
||||
cg: config::CodegenOptions {
|
||||
prefer_dynamic: true,
|
||||
linker,
|
||||
..cg
|
||||
},
|
||||
|
||||
@ -25,6 +25,7 @@ Core encoding and decoding interfaces.
|
||||
#![feature(specialization)]
|
||||
#![feature(never_type)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![cfg_attr(test, feature(test))]
|
||||
|
||||
pub use self::serialize::{Decoder, Encoder, Decodable, Encodable};
|
||||
|
||||
@ -274,6 +274,7 @@
|
||||
#![feature(needs_panic_runtime)]
|
||||
#![feature(never_type)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![feature(on_unimplemented)]
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
@ -89,6 +89,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||
parser.expect(&token::Comma)?;
|
||||
let lo = parser.span.lo();
|
||||
let (path, tokens) = parser.parse_meta_item_unrestricted()?;
|
||||
parser.eat(&token::Comma); // Optional trailing comma
|
||||
parser.expect(&token::CloseDelim(token::Paren))?;
|
||||
Ok((cfg, path, tokens, parser.prev_span.with_lo(lo)))
|
||||
}) {
|
||||
|
||||
@ -37,7 +37,7 @@ use visit::{self, FnKind, Visitor};
|
||||
use parse::ParseSess;
|
||||
use symbol::{keywords, Symbol};
|
||||
|
||||
use std::{env};
|
||||
use std::{env, path};
|
||||
|
||||
macro_rules! set {
|
||||
// The const_fn feature also enables the min_const_fn feature, because `min_const_fn` allows
|
||||
@ -403,9 +403,15 @@ declare_features! (
|
||||
// `extern` in paths
|
||||
(active, extern_in_paths, "1.23.0", Some(44660), None),
|
||||
|
||||
// `foo.rs` as an alternative to `foo/mod.rs`
|
||||
(active, non_modrs_mods, "1.24.0", Some(44660), Some(Edition::Edition2018)),
|
||||
|
||||
// Use `?` as the Kleene "at most one" operator
|
||||
(active, macro_at_most_once_rep, "1.25.0", Some(48075), None),
|
||||
|
||||
// Infer outlives requirements; RFC 2093
|
||||
(active, infer_outlives_requirements, "1.26.0", Some(44493), None),
|
||||
|
||||
// Infer static outlives requirements; RFC 2093
|
||||
(active, infer_static_outlives_requirements, "1.26.0", Some(44493), None),
|
||||
|
||||
@ -648,8 +654,6 @@ declare_features! (
|
||||
(accepted, repr_transparent, "1.28.0", Some(43036), None),
|
||||
// Defining procedural macros in `proc-macro` crates
|
||||
(accepted, proc_macro, "1.29.0", Some(38356), None),
|
||||
// `foo.rs` as an alternative to `foo/mod.rs`
|
||||
(accepted, non_modrs_mods, "1.30.0", Some(44660), None),
|
||||
// Allows use of the :vis macro fragment specifier
|
||||
(accepted, macro_vis_matcher, "1.30.0", Some(41022), None),
|
||||
// Allows importing and reexporting macros with `use`,
|
||||
@ -663,8 +667,6 @@ declare_features! (
|
||||
(accepted, proc_macro_path_invoc, "1.30.0", Some(38356), None),
|
||||
// Allows all literals in attribute lists and values of key-value pairs.
|
||||
(accepted, attr_literals, "1.30.0", Some(34981), None),
|
||||
// Infer outlives requirements; RFC 2093
|
||||
(accepted, infer_outlives_requirements, "1.30.0", Some(44493), None),
|
||||
(accepted, panic_handler, "1.30.0", Some(44489), None),
|
||||
// Used to preserve symbols (see llvm.used)
|
||||
(accepted, used, "1.30.0", Some(40289), None),
|
||||
@ -1126,6 +1128,12 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
|
||||
"never will be stable",
|
||||
cfg_fn!(rustc_attrs))),
|
||||
|
||||
// RFC #2093
|
||||
("infer_outlives_requirements", Normal, Gated(Stability::Unstable,
|
||||
"infer_outlives_requirements",
|
||||
"infer outlives requirements is an experimental feature",
|
||||
cfg_fn!(infer_outlives_requirements))),
|
||||
|
||||
// RFC #2093
|
||||
("infer_static_outlives_requirements", Normal, Gated(Stability::Unstable,
|
||||
"infer_static_outlives_requirements",
|
||||
@ -1493,6 +1501,31 @@ impl<'a> PostExpansionVisitor<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PostExpansionVisitor<'a> {
|
||||
fn whole_crate_feature_gates(&mut self, _krate: &ast::Crate) {
|
||||
for &(ident, span) in &*self.context.parse_sess.non_modrs_mods.borrow() {
|
||||
if !span.allows_unstable() {
|
||||
let cx = &self.context;
|
||||
let level = GateStrength::Hard;
|
||||
let has_feature = cx.features.non_modrs_mods;
|
||||
let name = "non_modrs_mods";
|
||||
debug!("gate_feature(feature = {:?}, span = {:?}); has? {}",
|
||||
name, span, has_feature);
|
||||
|
||||
if !has_feature && !span.allows_unstable() {
|
||||
leveled_feature_err(
|
||||
cx.parse_sess, name, span, GateIssue::Language,
|
||||
"mod statements in non-mod.rs files are unstable", level
|
||||
)
|
||||
.help(&format!("on stable builds, rename this file to {}{}mod.rs",
|
||||
ident, path::MAIN_SEPARATOR))
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
fn visit_attribute(&mut self, attr: &ast::Attribute) {
|
||||
if !attr.span.allows_unstable() {
|
||||
@ -2059,6 +2092,7 @@ pub fn check_crate(krate: &ast::Crate,
|
||||
};
|
||||
|
||||
let visitor = &mut PostExpansionVisitor { context: &ctx };
|
||||
visitor.whole_crate_feature_gates(krate);
|
||||
visit::walk_crate(visitor, krate);
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(slice_sort_by_cached_key)]
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#![feature(proc_macro_internals)]
|
||||
#![feature(decl_macro)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(str_escape)]
|
||||
#![feature(quote)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
@ -65,7 +65,7 @@ impl Edition {
|
||||
pub fn is_stable(&self) -> bool {
|
||||
match *self {
|
||||
Edition::Edition2015 => true,
|
||||
Edition::Edition2018 => true,
|
||||
Edition::Edition2018 => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(custom_attribute)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(non_exhaustive)]
|
||||
#![feature(optin_builtin_traits)]
|
||||
#![feature(specialization)]
|
||||
@ -87,7 +88,7 @@ scoped_thread_local!(pub static GLOBALS: Globals);
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, RustcDecodable, RustcEncodable)]
|
||||
pub enum FileName {
|
||||
Real(PathBuf),
|
||||
/// e.g. "std" macros
|
||||
/// A macro. This includes the full name of the macro, so that there are no clashes.
|
||||
Macros(String),
|
||||
/// call to `quote!`
|
||||
QuoteExpansion,
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
// Handle rustfmt skips
|
||||
#![feature(custom_attribute)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
use std::io::prelude::*;
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#![feature(fnbox)]
|
||||
#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(set_stdio)]
|
||||
#![feature(panic_unwind)]
|
||||
#![feature(staged_api)]
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#![feature(cfg_target_vendor)]
|
||||
#![feature(link_cfg)]
|
||||
#![cfg_attr(not(stage0), feature(nll))]
|
||||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
|
||||
#![feature(staged_api)]
|
||||
#![feature(unwind_attributes)]
|
||||
#![feature(static_nobundle)]
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
# source tarball for a stable release you'll likely see `1.x.0` for rustc and
|
||||
# `0.x.0` for Cargo where they were released on `date`.
|
||||
|
||||
date: 2018-09-13
|
||||
rustc: 1.29.0
|
||||
date: 2018-10-12
|
||||
rustc: 1.29.2
|
||||
cargo: 0.30.0
|
||||
|
||||
# When making a stable release the process currently looks like:
|
||||
|
||||
@ -53,13 +53,13 @@ pub fn named_borrow<'r>(_: &'r i32) {
|
||||
pub fn unsafe_borrow(_: &UnsafeInner) {
|
||||
}
|
||||
|
||||
// CHECK: @mutable_unsafe_borrow(i16* noalias dereferenceable(2) %arg0)
|
||||
// CHECK: @mutable_unsafe_borrow(i16* dereferenceable(2) %arg0)
|
||||
// ... unless this is a mutable borrow, those never alias
|
||||
#[no_mangle]
|
||||
pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {
|
||||
}
|
||||
|
||||
// CHECK: @mutable_borrow(i32* noalias dereferenceable(4) %arg0)
|
||||
// CHECK: @mutable_borrow(i32* dereferenceable(4) %arg0)
|
||||
// FIXME #25759 This should also have `nocapture`
|
||||
#[no_mangle]
|
||||
pub fn mutable_borrow(_: &mut i32) {
|
||||
@ -102,7 +102,7 @@ pub fn helper(_: usize) {
|
||||
pub fn slice(_: &[u8]) {
|
||||
}
|
||||
|
||||
// CHECK: @mutable_slice([0 x i8]* noalias nonnull %arg0.0, [[USIZE]] %arg0.1)
|
||||
// CHECK: @mutable_slice([0 x i8]* nonnull %arg0.0, [[USIZE]] %arg0.1)
|
||||
// FIXME #25759 This should also have `nocapture`
|
||||
#[no_mangle]
|
||||
pub fn mutable_slice(_: &mut [u8]) {
|
||||
|
||||
@ -11,13 +11,11 @@
|
||||
// aux-build:derive-b.rs
|
||||
// ignore-stage1
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate derive_b;
|
||||
|
||||
#[B] //~ ERROR `B` is a derive mode
|
||||
#[C]
|
||||
#[B]
|
||||
#[C] //~ ERROR attribute `C` is currently unknown to the compiler
|
||||
#[B(D)]
|
||||
#[B(E = "foo")]
|
||||
#[B(arbitrary tokens)]
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
// Regression test that `infer_outlives_predicates` can be
|
||||
// used with incremental without an ICE.
|
||||
|
||||
#![feature(infer_outlives_requirements)]
|
||||
|
||||
struct Foo<'a, T> {
|
||||
x: &'a T
|
||||
}
|
||||
|
||||
@ -183,6 +183,7 @@ fn main() {
|
||||
async_closure,
|
||||
async_fn,
|
||||
async_fn_with_internal_borrow,
|
||||
Foo::async_method,
|
||||
|x| {
|
||||
async move {
|
||||
unsafe { await!(unsafe_async_fn(x)) }
|
||||
|
||||
8
src/test/run-pass/impl-trait/existential-minimal.stderr
Normal file
8
src/test/run-pass/impl-trait/existential-minimal.stderr
Normal file
@ -0,0 +1,8 @@
|
||||
warning: function is never used: `foo`
|
||||
--> $DIR/existential-minimal.rs:15:1
|
||||
|
|
||||
LL | fn foo() -> impl std::fmt::Debug { "cake" }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[warn(dead_code)] on by default
|
||||
|
||||
14
src/test/run-pass/impl-trait/issue-42479.stderr
Normal file
14
src/test/run-pass/impl-trait/issue-42479.stderr
Normal file
@ -0,0 +1,14 @@
|
||||
warning: struct is never constructed: `Foo`
|
||||
--> $DIR/issue-42479.rs:15:1
|
||||
|
|
||||
LL | struct Foo {
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: #[warn(dead_code)] on by default
|
||||
|
||||
warning: method is never used: `inside`
|
||||
--> $DIR/issue-42479.rs:20:5
|
||||
|
|
||||
LL | fn inside(&self) -> impl Iterator<Item = &i32> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
32
src/test/run-pass/impl-trait/issue-49376.stderr
Normal file
32
src/test/run-pass/impl-trait/issue-49376.stderr
Normal file
@ -0,0 +1,32 @@
|
||||
warning: function is never used: `gen`
|
||||
--> $DIR/issue-49376.rs:18:1
|
||||
|
|
||||
LL | fn gen() -> impl PartialOrd + PartialEq + Debug { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[warn(dead_code)] on by default
|
||||
|
||||
warning: struct is never constructed: `Bar`
|
||||
--> $DIR/issue-49376.rs:20:1
|
||||
|
|
||||
LL | struct Bar {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
warning: function is never used: `foo`
|
||||
--> $DIR/issue-49376.rs:24:1
|
||||
|
|
||||
LL | fn foo() -> impl Foo {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: function is never used: `test_impl_ops`
|
||||
--> $DIR/issue-49376.rs:28:1
|
||||
|
|
||||
LL | fn test_impl_ops() -> impl Add + Sub + Mul + Div { 1 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: function is never used: `test_impl_assign_ops`
|
||||
--> $DIR/issue-49376.rs:29:1
|
||||
|
|
||||
LL | fn test_impl_assign_ops() -> impl AddAssign + SubAssign + MulAssign + DivAssign { 1 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
33
src/test/run-pass/issue-54462-mutable-noalias-correctness.rs
Normal file
33
src/test/run-pass/issue-54462-mutable-noalias-correctness.rs
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright 2018 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: -Ccodegen-units=1 -O
|
||||
|
||||
fn linidx(row: usize, col: usize) -> usize {
|
||||
row * 1 + col * 3
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0];
|
||||
|
||||
for i in 0..2 {
|
||||
for j in i+1..3 {
|
||||
if mat[linidx(j, 3)] > mat[linidx(i, 3)] {
|
||||
for k in 0..4 {
|
||||
let (x, rest) = mat.split_at_mut(linidx(i, k) + 1);
|
||||
let a = x.last_mut().unwrap();
|
||||
let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap();
|
||||
::std::mem::swap(a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert_eq!([9.0, 5.0, 1.0, 10.0, 6.0, 2.0, 11.0, 7.0, 3.0, 12.0, 8.0, 4.0], mat);
|
||||
}
|
||||
54
src/test/run-pass/issue-54467.rs
Normal file
54
src/test/run-pass/issue-54467.rs
Normal file
@ -0,0 +1,54 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub trait Stream {
|
||||
type Item;
|
||||
type Error;
|
||||
}
|
||||
|
||||
pub trait ParseError<I> {
|
||||
type Output;
|
||||
}
|
||||
|
||||
impl ParseError<char> for u32 {
|
||||
type Output = ();
|
||||
}
|
||||
|
||||
impl Stream for () {
|
||||
type Item = char;
|
||||
type Error = u32;
|
||||
}
|
||||
|
||||
pub struct Lex<'a, I>
|
||||
where I: Stream,
|
||||
I::Error: ParseError<char>,
|
||||
<<I as Stream>::Error as ParseError<char>>::Output: 'a
|
||||
{
|
||||
x: &'a <I::Error as ParseError<char>>::Output
|
||||
}
|
||||
|
||||
pub struct Reserved<'a, I> where
|
||||
I: Stream<Item=char> + 'a,
|
||||
I::Error: ParseError<I::Item>,
|
||||
// <<I as Stream>::Error as ParseError<char>>::Output: 'a // comment this to compile
|
||||
|
||||
{
|
||||
x: Lex<'a, I>
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let r: Reserved<()> = Reserved {
|
||||
x: Lex {
|
||||
x: &()
|
||||
}
|
||||
};
|
||||
|
||||
let _v = r.x.x;
|
||||
}
|
||||
8
src/test/run-pass/issues/issue-49556.stderr
Normal file
8
src/test/run-pass/issues/issue-49556.stderr
Normal file
@ -0,0 +1,8 @@
|
||||
warning: function is never used: `iter`
|
||||
--> $DIR/issue-49556.rs:12:1
|
||||
|
|
||||
LL | fn iter<'a>(data: &'a [usize]) -> impl Iterator<Item = usize> + 'a {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[warn(dead_code)] on by default
|
||||
|
||||
8
src/test/run-pass/traits/conservative_impl_trait.stderr
Normal file
8
src/test/run-pass/traits/conservative_impl_trait.stderr
Normal file
@ -0,0 +1,8 @@
|
||||
warning: function is never used: `batches`
|
||||
--> $DIR/conservative_impl_trait.rs:14:1
|
||||
|
|
||||
LL | fn batches(n: &u32) -> impl Iterator<Item=&u32> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[warn(dead_code)] on by default
|
||||
|
||||
@ -12,7 +12,7 @@ error[E0425]: cannot find value `no` in this scope
|
||||
3 | no
|
||||
| ^^ not found in this scope
|
||||
|
||||
thread '$DIR/failed-doctest-output.rs - OtherStruct (line 26)' panicked at 'couldn't compile the test', librustdoc/test.rs:333:13
|
||||
thread '$DIR/failed-doctest-output.rs - OtherStruct (line 26)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13
|
||||
note: Run with `RUST_BACKTRACE=1` for a backtrace.
|
||||
|
||||
---- $DIR/failed-doctest-output.rs - SomeStruct (line 20) stdout ----
|
||||
@ -21,7 +21,7 @@ thread '$DIR/failed-doctest-output.rs - SomeStruct (line 20)' panicked at 'test
|
||||
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1
|
||||
note: Run with `RUST_BACKTRACE=1` for a backtrace.
|
||||
|
||||
', librustdoc/test.rs:368:17
|
||||
', librustdoc/test.rs:367:17
|
||||
|
||||
|
||||
failures:
|
||||
|
||||
@ -25,3 +25,13 @@ pub fn derive_foo(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_bar(input: TokenStream) -> TokenStream {
|
||||
panic!("lolnope");
|
||||
}
|
||||
|
||||
#[proc_macro_derive(WithHelper, attributes(helper))]
|
||||
pub fn with_helper(input: TokenStream) -> TokenStream {
|
||||
TokenStream::new()
|
||||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn helper(_: TokenStream, input: TokenStream) -> TokenStream {
|
||||
input
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
// aux-build:plugin.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_use(WithHelper)]
|
||||
extern crate plugin;
|
||||
|
||||
use plugin::helper;
|
||||
|
||||
#[derive(WithHelper)]
|
||||
#[helper] //~ ERROR `helper` is ambiguous
|
||||
struct S;
|
||||
|
||||
fn main() {}
|
||||
@ -0,0 +1,20 @@
|
||||
error[E0659]: `helper` is ambiguous
|
||||
--> $DIR/helper-attr-blocked-by-import-ambig.rs:10:3
|
||||
|
|
||||
LL | #[helper] //~ ERROR `helper` is ambiguous
|
||||
| ^^^^^^ ambiguous name
|
||||
|
|
||||
note: `helper` could refer to the name defined here
|
||||
--> $DIR/helper-attr-blocked-by-import-ambig.rs:9:10
|
||||
|
|
||||
LL | #[derive(WithHelper)]
|
||||
| ^^^^^^^^^^
|
||||
note: `helper` could also refer to the name imported here
|
||||
--> $DIR/helper-attr-blocked-by-import-ambig.rs:7:5
|
||||
|
|
||||
LL | use plugin::helper;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
@ -0,0 +1,29 @@
|
||||
// compile-pass
|
||||
// aux-build:plugin.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_use(WithHelper)]
|
||||
extern crate plugin;
|
||||
|
||||
use self::one::*;
|
||||
use self::two::*;
|
||||
|
||||
mod helper {}
|
||||
|
||||
mod one {
|
||||
use helper;
|
||||
|
||||
#[derive(WithHelper)]
|
||||
#[helper]
|
||||
struct One;
|
||||
}
|
||||
|
||||
mod two {
|
||||
use helper;
|
||||
|
||||
#[derive(WithHelper)]
|
||||
#[helper]
|
||||
struct Two;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@ -1,40 +0,0 @@
|
||||
// Copyright 2018 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:lint_tool_test.rs
|
||||
// ignore-stage1
|
||||
// compile-flags: --cfg foo
|
||||
#![feature(plugin)]
|
||||
#![feature(tool_lints)]
|
||||
#![plugin(lint_tool_test)]
|
||||
#![allow(dead_code)]
|
||||
#![cfg_attr(foo, warn(test_lint))]
|
||||
//~^ WARNING lint name `test_lint` is deprecated and may not have an effect in the future
|
||||
//~^^ WARNING lint name `test_lint` is deprecated and may not have an effect in the future
|
||||
#![deny(clippy_group)]
|
||||
//~^ WARNING lint name `clippy_group` is deprecated and may not have an effect in the future
|
||||
|
||||
fn lintme() { } //~ ERROR item is named 'lintme'
|
||||
|
||||
#[allow(clippy::group)]
|
||||
fn lintmetoo() {}
|
||||
|
||||
#[allow(clippy::test_lint)]
|
||||
pub fn main() {
|
||||
fn lintme() { }
|
||||
fn lintmetoo() { } //~ ERROR item is named 'lintmetoo'
|
||||
}
|
||||
|
||||
#[allow(test_group)]
|
||||
//~^ WARNING lint name `test_group` is deprecated and may not have an effect in the future
|
||||
#[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist`
|
||||
fn hello() {
|
||||
fn lintmetoo() { }
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
warning: lint name `test_lint` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore
|
||||
--> $DIR/lint_tool_test.rs:18:23
|
||||
|
|
||||
LL | #![cfg_attr(foo, warn(test_lint))]
|
||||
| ^^^^^^^^^ help: change it to: `clippy::test_lint`
|
||||
|
|
||||
= note: #[warn(renamed_and_removed_lints)] on by default
|
||||
|
||||
warning: lint name `clippy_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore
|
||||
--> $DIR/lint_tool_test.rs:21:9
|
||||
|
|
||||
LL | #![deny(clippy_group)]
|
||||
| ^^^^^^^^^^^^ help: change it to: `clippy::group`
|
||||
|
||||
warning: lint name `test_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore
|
||||
--> $DIR/lint_tool_test.rs:35:9
|
||||
|
|
||||
LL | #[allow(test_group)]
|
||||
| ^^^^^^^^^^ help: change it to: `clippy::test_group`
|
||||
|
||||
warning: unknown lint: `this_lint_does_not_exist`
|
||||
--> $DIR/lint_tool_test.rs:37:8
|
||||
|
|
||||
LL | #[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[warn(unknown_lints)] on by default
|
||||
|
||||
warning: lint name `test_lint` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore
|
||||
--> $DIR/lint_tool_test.rs:18:23
|
||||
|
|
||||
LL | #![cfg_attr(foo, warn(test_lint))]
|
||||
| ^^^^^^^^^ help: change it to: `clippy::test_lint`
|
||||
|
||||
error: item is named 'lintme'
|
||||
--> $DIR/lint_tool_test.rs:24:1
|
||||
|
|
||||
LL | fn lintme() { } //~ ERROR item is named 'lintme'
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/lint_tool_test.rs:21:9
|
||||
|
|
||||
LL | #![deny(clippy_group)]
|
||||
| ^^^^^^^^^^^^
|
||||
= note: #[deny(clippy::test_lint)] implied by #[deny(clippy::group)]
|
||||
|
||||
error: item is named 'lintmetoo'
|
||||
--> $DIR/lint_tool_test.rs:32:5
|
||||
|
|
||||
LL | fn lintmetoo() { } //~ ERROR item is named 'lintmetoo'
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/lint_tool_test.rs:21:9
|
||||
|
|
||||
LL | #![deny(clippy_group)]
|
||||
| ^^^^^^^^^^^^
|
||||
= note: #[deny(clippy::test_group)] implied by #[deny(clippy::group)]
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
@ -4,17 +4,16 @@ error[E0659]: `my_attr` is ambiguous
|
||||
LL | #[my_attr] //~ ERROR `my_attr` is ambiguous
|
||||
| ^^^^^^^ ambiguous name
|
||||
|
|
||||
note: `my_attr` could refer to the name imported here
|
||||
--> $DIR/derive-helper-shadowing.rs:4:5
|
||||
|
|
||||
LL | use derive_helper_shadowing::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: `my_attr` could also refer to the name defined here
|
||||
note: `my_attr` could refer to the name defined here
|
||||
--> $DIR/derive-helper-shadowing.rs:7:10
|
||||
|
|
||||
LL | #[derive(MyTrait)]
|
||||
| ^^^^^^^
|
||||
= note: consider adding an explicit import of `my_attr` to disambiguate
|
||||
note: `my_attr` could also refer to the name imported here
|
||||
--> $DIR/derive-helper-shadowing.rs:4:5
|
||||
|
|
||||
LL | use derive_helper_shadowing::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user