1
Fork 0

Auto merge of #49051 - kennytm:rollup, r=kennytm

Rollup of 17 pull requests

- Successful merges: #48706, #48875, #48892, #48922, #48957, #48959, #48961, #48965, #49007, #49024, #49042, #49050, #48853, #48990, #49037, #49049, #48972
- Failed merges:
This commit is contained in:
bors 2018-03-16 00:09:14 +00:00
commit 36b6687318
120 changed files with 637 additions and 462 deletions

43
src/Cargo.lock generated
View file

@ -198,7 +198,7 @@ dependencies = [
"hex 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"home 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ignore 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"jobserver 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
@ -944,11 +944,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "jobserver"
version = "0.1.9"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1349,19 +1350,18 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parking_lot_core"
version = "0.2.9"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1469,16 +1469,6 @@ dependencies = [
"nibble_vec 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand"
version = "0.3.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand"
version = "0.4.2"
@ -1692,7 +1682,7 @@ dependencies = [
"flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fmt_macros 0.0.0",
"graphviz 0.0.0",
"jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"jobserver 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proc_macro 0.0.0",
@ -1723,7 +1713,7 @@ dependencies = [
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1824,7 +1814,7 @@ name = "rustc_back"
version = "0.0.0"
dependencies = [
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serialize 0.0.0",
"syntax 0.0.0",
]
@ -1867,7 +1857,7 @@ dependencies = [
"ena 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
"serialize 0.0.0",
"stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1923,7 +1913,7 @@ version = "0.0.0"
dependencies = [
"graphviz 0.0.0",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"serialize 0.0.0",
@ -2102,7 +2092,7 @@ dependencies = [
"cc 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"jobserver 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2948,7 +2938,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d3f2be4da1690a039e9ae5fd575f706a63ad5a2120f161b1d653c9da3930dd21"
"checksum itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b07332223953b5051bceb67e8c4700aa65291535568e1f12408c43c4a42c0394"
"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c"
"checksum jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "565f6106bd87b394398f813bea4e5ecad6d6b0f6aa077592d088f882a506481d"
"checksum jobserver 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2abd9fd3242accb0e2e30986f2cf30cda3e19eec5cc6d584b218ce2b1c0e3c"
"checksum json 0.11.12 (registry+https://github.com/rust-lang/crates.io-index)" = "39ebf0fac977ee3a4a3242b6446004ff64514889e3e2730bbd4f764a67a2e483"
"checksum jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf83704f4e79979a424d1082dd2c1e52683058056c9280efa19ac5f6bc9033c"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
@ -2990,7 +2980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum os_pipe 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "998bfbb3042e715190fe2a41abfa047d7e8cb81374d2977d7f100eacd8619cb1"
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
"checksum parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3e7f7c9857874e54afeb950eebeae662b1e51a2493666d2ea4c0a5d91dcf0412"
"checksum parking_lot_core 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6bf05dc61189828dfd7a59fd6e66d538e88d6b30390da1124a291e09fd3098b3"
"checksum parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "538ef00b7317875071d5e00f603f24d16f0b474c1a5fc0ccb8b454ca72eafa79"
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
"checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8"
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
@ -3003,7 +2993,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eca14c727ad12702eb4b6bfb5a232287dcf8385cb8ca83a3eeaf6519c44c408"
"checksum racer 2.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "034f1c4528581c40a60e96875467c03315868084e08ff4ceb46a00f7be3b16b4"
"checksum radix_trie 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "211c49b6a9995cac0fd1dd9ca60b42cf3a51e151a12eb954b3a9e75513426ee8"
"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1"
"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5"
"checksum rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "485541959c8ecc49865526fe6c4de9653dd6e60d829d6edf0be228167b60372d"
"checksum rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d24ad214285a7729b174ed6d3bcfcb80177807f959d95fafd5bfc5c4f201ac8"

View file

@ -175,9 +175,6 @@ fn main() {
if let Ok(s) = env::var("RUSTC_CODEGEN_UNITS") {
cmd.arg("-C").arg(format!("codegen-units={}", s));
}
if env::var("RUSTC_THINLTO").is_ok() {
cmd.arg("-Ccodegen-units=16").arg("-Zthinlto");
}
// Emit save-analysis info.
if env::var("RUSTC_SAVE_ANALYSIS") == Ok("api".to_string()) {

View file

@ -778,17 +778,6 @@ impl<'a> Builder<'a> {
if cmd != "bench" {
cargo.arg("--release");
}
if self.config.rust_codegen_units.is_none() &&
self.build.is_rust_llvm(compiler.host) &&
self.config.rust_thinlto {
cargo.env("RUSTC_THINLTO", "1");
} else if self.config.rust_codegen_units.is_none() {
// Generally, if ThinLTO has been disabled for some reason, we
// want to set the codegen units to 1. However, we shouldn't do
// this if the option was specifically set by the user.
cargo.env("RUSTC_CODEGEN_UNITS", "1");
}
}
if self.config.locked_deps {

View file

@ -86,7 +86,6 @@ pub struct Config {
// rust codegen options
pub rust_optimize: bool,
pub rust_codegen_units: Option<u32>,
pub rust_thinlto: bool,
pub rust_debug_assertions: bool,
pub rust_debuginfo: bool,
pub rust_debuginfo_lines: bool,
@ -270,7 +269,6 @@ impl Default for StringOrBool {
struct Rust {
optimize: Option<bool>,
codegen_units: Option<u32>,
thinlto: Option<bool>,
debug_assertions: Option<bool>,
debuginfo: Option<bool>,
debuginfo_lines: Option<bool>,
@ -429,7 +427,6 @@ impl Config {
// Store off these values as options because if they're not provided
// we'll infer default values for them later
let mut thinlto = None;
let mut llvm_assertions = None;
let mut debuginfo_lines = None;
let mut debuginfo_only_std = None;
@ -473,7 +470,6 @@ impl Config {
optimize = rust.optimize;
ignore_git = rust.ignore_git;
debug_jemalloc = rust.debug_jemalloc;
thinlto = rust.thinlto;
set(&mut config.rust_optimize_tests, rust.optimize_tests);
set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
set(&mut config.codegen_tests, rust.codegen_tests);
@ -561,7 +557,6 @@ impl Config {
"stable" | "beta" | "nightly" => true,
_ => false,
};
config.rust_thinlto = thinlto.unwrap_or(true);
config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default);
config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default);

View file

@ -71,7 +71,6 @@ o("full-tools", None, "enable all tools")
# Optimization and debugging options. These may be overridden by the release
# channel, etc.
o("optimize", "rust.optimize", "build optimized rust code")
o("thinlto", "rust.thinlto", "build Rust with ThinLTO enabled")
o("optimize-llvm", "llvm.optimize", "build optimized LLVM")
o("llvm-assertions", "llvm.assertions", "build LLVM with assertions")
o("debug-assertions", "rust.debug-assertions", "build with debugging assertions")

View file

@ -46,7 +46,6 @@ export RUST_RELEASE_CHANNEL=nightly
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"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-thinlto"
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"

View file

@ -35,6 +35,22 @@ let x = 5;
There's some subtlety though! Read on for more details.
## Passing or failing a doctest
Like regular unit tests, regular doctests are considered to "pass"
if they compile and run without panicking.
So if you want to demonstrate that some computation gives a certain result,
the `assert!` family of macros works the same as other Rust code:
```rust
let foo = "foo";
assert_eq!(foo, "foo");
```
This way, if the computation ever returns something different,
the code panics and the doctest fails.
## Pre-processing examples
In the example above, you'll note something strange: there's no `main`

View file

@ -9,11 +9,8 @@
// except according to those terms.
use std::borrow::Cow;
#[cfg(not(target_arch = "asmjs"))]
use std::collections::CollectionAllocErr::*;
#[cfg(not(target_arch = "asmjs"))]
use std::mem::size_of;
#[cfg(not(target_arch = "asmjs"))]
use std::{usize, isize};
pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
@ -535,7 +532,6 @@ fn test_reserve_exact() {
assert!(s.capacity() >= 33)
}
#[cfg(not(target_arch = "asmjs"))]
#[test]
fn test_try_reserve() {
@ -613,7 +609,6 @@ fn test_try_reserve() {
}
#[cfg(not(target_arch = "asmjs"))]
#[test]
fn test_try_reserve_exact() {

View file

@ -10,11 +10,8 @@
use std::borrow::Cow;
use std::mem::size_of;
use std::{usize, panic};
#[cfg(not(target_arch = "asmjs"))]
use std::isize;
use std::{usize, isize, panic};
use std::vec::{Drain, IntoIter};
#[cfg(not(target_arch = "asmjs"))]
use std::collections::CollectionAllocErr::*;
struct DropCounter<'a> {
@ -994,7 +991,6 @@ fn test_reserve_exact() {
assert!(v.capacity() >= 33)
}
#[cfg(not(target_arch = "asmjs"))]
#[test]
fn test_try_reserve() {
@ -1097,7 +1093,6 @@ fn test_try_reserve() {
}
#[cfg(not(target_arch = "asmjs"))]
#[test]
fn test_try_reserve_exact() {

View file

@ -11,13 +11,9 @@
use std::collections::VecDeque;
use std::fmt::Debug;
use std::collections::vec_deque::{Drain};
#[cfg(not(target_arch = "asmjs"))]
use std::collections::CollectionAllocErr::*;
#[cfg(not(target_arch = "asmjs"))]
use std::mem::size_of;
use std::isize;
#[cfg(not(target_arch = "asmjs"))]
use std::usize;
use std::{usize, isize};
use self::Taggy::*;
use self::Taggypar::*;
@ -1053,7 +1049,6 @@ fn test_reserve_exact_2() {
assert!(v.capacity() >= 48)
}
#[cfg(not(target_arch = "asmjs"))]
#[test]
fn test_try_reserve() {
@ -1155,7 +1150,6 @@ fn test_try_reserve() {
}
#[cfg(not(target_arch = "asmjs"))]
#[test]
fn test_try_reserve_exact() {

View file

@ -2605,7 +2605,7 @@ impl<I, U> DoubleEndedIterator for Flatten<I>
}
}
#[stable(feature = "fused", since = "1.26.0")]
#[unstable(feature = "iterator_flatten", issue = "48213")]
impl<I, U> FusedIterator for Flatten<I>
where I: FusedIterator, U: Iterator,
I::Item: IntoIterator<IntoIter = U, Item = U::Item> {}

View file

@ -55,7 +55,9 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
}
}
pub fn find_entry_point(session: &Session, hir_map: &hir_map::Map) {
pub fn find_entry_point(session: &Session,
hir_map: &hir_map::Map,
crate_name: &str) {
let any_exe = session.crate_types.borrow().iter().any(|ty| {
*ty == config::CrateTypeExecutable
});
@ -81,7 +83,7 @@ pub fn find_entry_point(session: &Session, hir_map: &hir_map::Map) {
hir_map.krate().visit_all_item_likes(&mut ctxt);
configure_main(&mut ctxt);
configure_main(&mut ctxt, crate_name);
}
// Beware, this is duplicated in libsyntax/entry.rs, make sure to keep
@ -150,7 +152,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
}
}
fn configure_main(this: &mut EntryContext) {
fn configure_main(this: &mut EntryContext, crate_name: &str) {
if this.start_fn.is_some() {
*this.session.entry_fn.borrow_mut() = this.start_fn;
this.session.entry_type.set(Some(config::EntryStart));
@ -162,7 +164,8 @@ fn configure_main(this: &mut EntryContext) {
this.session.entry_type.set(Some(config::EntryMain));
} else {
// No main function
let mut err = struct_err!(this.session, E0601, "main function not found");
let mut err = struct_err!(this.session, E0601,
"`main` function not found in crate `{}`", crate_name);
if !this.non_main_fns.is_empty() {
// There were some functions named 'main' though. Try to give the user a hint.
err.note("the main function must be defined at the crate level \
@ -175,6 +178,9 @@ fn configure_main(this: &mut EntryContext) {
err.emit();
this.session.abort_if_errors();
} else {
if let Some(ref filename) = this.session.local_crate_source_file {
err.note(&format!("consider adding a `main` function to `{}`", filename.display()));
}
if this.session.teach(&err.get_code().unwrap()) {
err.note("If you don't know the basics of Rust, you can go look to the Rust Book \
to get started: https://doc.rust-lang.org/book/");

View file

@ -12,7 +12,7 @@ crate-type = ["dylib"]
syntax = { path = "../libsyntax" }
serialize = { path = "../libserialize" }
log = "0.4"
rand = "0.3"
rand = "0.4"
[features]
jemalloc = []

View file

@ -15,7 +15,9 @@ pub fn target() -> Result<Target, String> {
let mut args = LinkArgs::new();
args.insert(LinkerFlavor::Em,
vec!["-s".to_string(),
"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()]);
"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string(),
"-s".to_string(),
"ABORTING_MALLOC=0".to_string()]);
let opts = TargetOptions {
dynamic_linking: false,

View file

@ -979,7 +979,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(trans: &TransCrate,
time(sess,
"looking for entry point",
|| middle::entry::find_entry_point(sess, &hir_map));
|| middle::entry::find_entry_point(sess, &hir_map, name));
sess.plugin_registrar_fn.set(time(sess, "looking for plugin registrar", || {
plugin::build::find_plugin_registrar(sess.diagnostic(), &hir_map)

View file

@ -11,7 +11,7 @@ crate-type = ["dylib"]
[dependencies]
graphviz = { path = "../libgraphviz" }
log = "0.4"
rand = "0.3"
rand = "0.4"
rustc = { path = "../librustc" }
rustc_data_structures = { path = "../librustc_data_structures" }
serialize = { path = "../libserialize" }

View file

@ -41,7 +41,7 @@ use rustc::ty;
use rustc::hir::{Freevar, FreevarMap, TraitCandidate, TraitMap, GlobMap};
use rustc::util::nodemap::{NodeMap, NodeSet, FxHashMap, FxHashSet, DefIdMap};
use syntax::codemap::{dummy_spanned, respan, CodeMap};
use syntax::codemap::{dummy_spanned, respan, BytePos, CodeMap};
use syntax::ext::hygiene::{Mark, MarkKind, SyntaxContext};
use syntax::ast::{self, Name, NodeId, Ident, SpannedIdent, FloatTy, IntTy, UintTy};
use syntax::ext::base::SyntaxExtension;
@ -179,11 +179,12 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
E0401,
"can't use type parameters from outer function");
err.span_label(span, "use of type variable from outer function");
let cm = resolver.session.codemap();
match outer_def {
Def::SelfTy(_, maybe_impl_defid) => {
if let Some(impl_span) = maybe_impl_defid.map_or(None,
|def_id| resolver.definitions.opt_span(def_id)) {
let cm = resolver.session.codemap();
err.span_label(reduce_impl_span_to_impl_keyword(cm, impl_span),
"`Self` type implicitely declared here, on the `impl`");
}
@ -206,12 +207,13 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
// Try to retrieve the span of the function signature and generate a new message with
// a local type parameter
let sugg_msg = "try using a local type parameter instead";
if let Some((sugg_span, new_snippet)) = generate_local_type_param_snippet(
resolver.session.codemap(), span) {
if let Some((sugg_span, new_snippet)) = generate_local_type_param_snippet(cm, span) {
// Suggest the modification to the user
err.span_suggestion(sugg_span,
sugg_msg,
new_snippet);
} else if let Some(sp) = generate_fn_name_span(cm, span) {
err.span_label(sp, "try adding a local type parameter in this method instead");
} else {
err.help("try using a local type parameter instead");
}
@ -407,6 +409,15 @@ fn reduce_impl_span_to_impl_keyword(cm: &CodeMap, impl_span: Span) -> Span {
impl_span
}
fn generate_fn_name_span(cm: &CodeMap, span: Span) -> Option<Span> {
let prev_span = cm.span_extend_to_prev_str(span, "fn", true);
cm.span_to_snippet(prev_span).map(|snippet| {
let len = snippet.find(|c: char| !c.is_alphanumeric() && c != '_')
.expect("no label after fn");
prev_span.with_hi(BytePos(prev_span.lo().0 + len as u32))
}).ok()
}
/// Take the span of a type parameter in a function signature and try to generate a span for the
/// function name (with generics) and a new snippet for this span with the pointed type parameter as
/// a new local type parameter.
@ -428,17 +439,12 @@ fn reduce_impl_span_to_impl_keyword(cm: &CodeMap, impl_span: Span) -> Span {
fn generate_local_type_param_snippet(cm: &CodeMap, span: Span) -> Option<(Span, String)> {
// Try to extend the span to the previous "fn" keyword to retrieve the function
// signature
let sugg_span = cm.span_extend_to_prev_str(span, "fn");
let sugg_span = cm.span_extend_to_prev_str(span, "fn", false);
if sugg_span != span {
if let Ok(snippet) = cm.span_to_snippet(sugg_span) {
use syntax::codemap::BytePos;
// Consume the function name
let mut offset = 0;
for c in snippet.chars().take_while(|c| c.is_ascii_alphanumeric() ||
*c == '_') {
offset += c.len_utf8();
}
let mut offset = snippet.find(|c: char| !c.is_alphanumeric() && c != '_')
.expect("no label after fn");
// Consume the generics part of the function signature
let mut bracket_counter = 0;

View file

@ -30,6 +30,7 @@ use cabi_sparc64;
use cabi_nvptx;
use cabi_nvptx64;
use cabi_hexagon;
use cabi_wasm32;
use mir::place::PlaceRef;
use mir::operand::OperandValue;
use type_::Type;
@ -948,7 +949,13 @@ impl<'a, 'tcx> FnType<'tcx> {
"powerpc64" => cabi_powerpc64::compute_abi_info(cx, self),
"s390x" => cabi_s390x::compute_abi_info(cx, self),
"asmjs" => cabi_asmjs::compute_abi_info(cx, self),
"wasm32" => cabi_asmjs::compute_abi_info(cx, self),
"wasm32" => {
if cx.sess().opts.target_triple.contains("emscripten") {
cabi_asmjs::compute_abi_info(cx, self)
} else {
cabi_wasm32::compute_abi_info(cx, self)
}
}
"msp430" => cabi_msp430::compute_abi_info(self),
"sparc" => cabi_sparc::compute_abi_info(cx, self),
"sparc64" => cabi_sparc64::compute_abi_info(cx, self),

View file

@ -28,18 +28,6 @@ fn extend_integer_width_mips(arg: &mut ArgType, bits: u64) {
arg.extend_integer_width_to(bits);
}
fn bits_to_int_reg(bits: u64) -> Reg {
if bits <= 8 {
Reg::i8()
} else if bits <= 16 {
Reg::i16()
} else if bits <= 32 {
Reg::i32()
} else {
Reg::i64()
}
}
fn float_reg<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, ret: &ArgType<'tcx>, i: usize) -> Option<Reg> {
match ret.layout.field(cx, i).abi {
layout::Abi::Scalar(ref scalar) => match scalar.value {
@ -82,7 +70,7 @@ fn classify_ret_ty<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>)
// Cast to a uniform int structure
ret.cast_to(Uniform {
unit: bits_to_int_reg(bits),
unit: Reg::i64(),
total: size
});
} else {

View file

@ -0,0 +1,31 @@
// 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.
use abi::{FnType, ArgType};
use context::CodegenCx;
fn classify_ret_ty<'a, 'tcx>(_cx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
ret.extend_integer_width_to(32);
}
fn classify_arg_ty(arg: &mut ArgType) {
arg.extend_integer_width_to(32);
}
pub fn compute_abi_info<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
if !fty.ret.is_ignore() {
classify_ret_ty(cx, &mut fty.ret);
}
for arg in &mut fty.args {
if arg.is_ignore() { continue; }
classify_arg_ty(arg);
}
}

View file

@ -123,6 +123,7 @@ mod cabi_sparc64;
mod cabi_x86;
mod cabi_x86_64;
mod cabi_x86_win64;
mod cabi_wasm32;
mod callee;
mod common;
mod consts;

View file

@ -92,6 +92,7 @@ const X86_WHITELIST: &'static [&'static str] = &["aes", "avx", "avx2", "avx512bw
"bmi1", "bmi2", "fma", "fxsr",
"lzcnt", "mmx", "pclmulqdq",
"popcnt", "rdrand", "rdseed",
"sha",
"sse", "sse2", "sse3", "sse4.1",
"sse4.2", "sse4a", "ssse3",
"tbm", "xsave", "xsavec",

View file

@ -525,7 +525,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
} else {
fcx.tcx.sess.diagnostic().mut_span_err(
span, &format!("invalid `self` type: {:?}", self_arg_ty))
.note(&format!("type must be `{:?}` or a type that dereferences to it`", self_ty))
.note(&format!("type must be `{:?}` or a type that dereferences to it", self_ty))
.help("consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`")
.code(DiagnosticId::Error("E0307".into()))
.emit();

View file

@ -52,10 +52,10 @@ fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_def_id: DefId) {
let did = Some(trait_def_id);
let li = tcx.lang_items();
let span = tcx.sess.codemap().def_span(tcx.span_of_impl(impl_def_id).unwrap());
// Disallow *all* explicit impls of `Sized` and `Unsize` for now.
if did == li.sized_trait() {
let span = tcx.span_of_impl(impl_def_id).unwrap();
struct_span_err!(tcx.sess,
span,
E0322,
@ -66,11 +66,12 @@ fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_d
}
if did == li.unsize_trait() {
let span = tcx.span_of_impl(impl_def_id).unwrap();
span_err!(tcx.sess,
struct_span_err!(tcx.sess,
span,
E0328,
"explicit impls for the `Unsize` trait are not permitted");
"explicit impls for the `Unsize` trait are not permitted")
.span_label(span, "impl of `Unsize` not allowed")
.emit();
return;
}
@ -88,14 +89,14 @@ fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_d
} else {
return; // everything OK
};
let mut err = struct_span_err!(tcx.sess,
tcx.span_of_impl(impl_def_id).unwrap(),
struct_span_err!(tcx.sess,
span,
E0183,
"manual implementations of `{}` are experimental",
trait_name);
help!(&mut err,
"add `#![feature(unboxed_closures)]` to the crate attributes to enable");
err.emit();
trait_name)
.span_label(span, format!("manual implementations of `{}` are experimental", trait_name))
.help("add `#![feature(unboxed_closures)]` to the crate attributes to enable")
.emit();
}
pub fn provide(providers: &mut Providers) {
@ -168,13 +169,17 @@ fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeI
traits::supertrait_def_ids(tcx,
data.principal().unwrap().def_id());
if supertrait_def_ids.any(|d| d == trait_def_id) {
span_err!(tcx.sess,
tcx.span_of_impl(impl_def_id).unwrap(),
let sp = tcx.sess.codemap().def_span(tcx.span_of_impl(impl_def_id).unwrap());
struct_span_err!(tcx.sess,
sp,
E0371,
"the object type `{}` automatically \
implements the trait `{}`",
"the object type `{}` automatically implements the trait `{}`",
trait_ref.self_ty(),
tcx.item_path_str(trait_def_id));
tcx.item_path_str(trait_def_id))
.span_label(sp, format!("`{}` automatically implements trait `{}`",
trait_ref.self_ty(),
tcx.item_path_str(trait_def_id)))
.emit();
}
}
}

View file

@ -40,29 +40,36 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
self.tcx.hir.node_to_string(item.id));
let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap();
let trait_def_id = trait_ref.def_id;
let cm = self.tcx.sess.codemap();
let sp = cm.def_span(item.span);
match traits::orphan_check(self.tcx, def_id) {
Ok(()) => {}
Err(traits::OrphanCheckErr::NoLocalInputType) => {
struct_span_err!(self.tcx.sess,
item.span,
sp,
E0117,
"only traits defined in the current crate can be \
implemented for arbitrary types")
.span_label(item.span, "impl doesn't use types inside crate")
.note(&format!("the impl does not reference any types defined in \
this crate"))
.span_label(sp, "impl doesn't use types inside crate")
.note("the impl does not reference any types defined in this crate")
.note("define and implement a trait or new type instead")
.emit();
return;
}
Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => {
span_err!(self.tcx.sess,
item.span,
struct_span_err!(self.tcx.sess,
sp,
E0210,
"type parameter `{}` must be used as the type parameter for \
some local type (e.g. `MyStruct<T>`); only traits defined in \
the current crate can be implemented for a type parameter",
param_ty);
"type parameter `{}` must be used as the type parameter \
for some local type (e.g. `MyStruct<{}>`)",
param_ty,
param_ty)
.span_label(sp,
format!("type parameter `{}` must be used as the type \
parameter for some local type", param_ty))
.note("only traits defined in the current crate can be implemented \
for a type parameter")
.emit();
return;
}
}
@ -121,22 +128,29 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
if self_def_id.is_local() {
None
} else {
Some(format!("cross-crate traits with a default impl, like `{}`, \
Some((
format!("cross-crate traits with a default impl, like `{}`, \
can only be implemented for a struct/enum type \
defined in the current crate",
self.tcx.item_path_str(trait_def_id)))
self.tcx.item_path_str(trait_def_id)),
"can't implement cross-crate trait for type in another crate"
))
}
}
_ => {
Some(format!("cross-crate traits with a default impl, like `{}`, can \
Some((format!("cross-crate traits with a default impl, like `{}`, can \
only be implemented for a struct/enum type, not `{}`",
self.tcx.item_path_str(trait_def_id),
self_ty))
self_ty),
"can't implement cross-crate trait with a default impl for \
non-struct/enum type"))
}
};
if let Some(msg) = msg {
span_err!(self.tcx.sess, item.span, E0321, "{}", msg);
if let Some((msg, label)) = msg {
struct_span_err!(self.tcx.sess, sp, E0321, "{}", msg)
.span_label(sp, label)
.emit();
return;
}
}

View file

@ -1,172 +1,3 @@
# The walking tour of rustdoc
For more information about how `librustdoc` works, see the [rustc guide].
Rustdoc is implemented entirely within the crate `librustdoc`. After partially compiling a crate to
get its AST (technically the HIR map) from rustc, librustdoc performs two major steps past that to
render a set of documentation:
* "Clean" the AST into a form that's more suited to creating documentation (and slightly more
resistant to churn in the compiler).
* Use this cleaned AST to render a crate's documentation, one page at a time.
Naturally, there's more than just this, and those descriptions simplify out lots of details, but
that's the high-level overview.
(Side note: this is a library crate! The `rustdoc` binary is crated using the project in
`src/tools/rustdoc`. Note that literally all that does is call the `main()` that's in this crate's
`lib.rs`, though.)
## Cheat sheet
* Use `x.py build --stage 1 src/libstd src/tools/rustdoc` to make a useable rustdoc you can run on
other projects.
* Add `src/libtest` to be able to use `rustdoc --test`.
* If you've used `rustup toolchain link local /path/to/build/$TARGET/stage1` previously, then
after the previous build command, `cargo +local doc` will Just Work.
* Use `x.py doc --stage 1 src/libstd` to use this rustdoc to generate the standard library docs.
* The completed docs will be available in `build/$TARGET/doc/std`, though the bundle is meant to
be used as though you would copy out the `doc` folder to a web server, since that's where the
CSS/JS and landing page are.
* Most of the HTML printing code is in `html/format.rs` and `html/render.rs`. It's in a bunch of
`fmt::Display` implementations and supplementary functions.
* The types that got `Display` impls above are defined in `clean/mod.rs`, right next to the custom
`Clean` trait used to process them out of the rustc HIR.
* The bits specific to using rustdoc as a test harness are in `test.rs`.
* The Markdown renderer is loaded up in `html/markdown.rs`, including functions for extracting
doctests from a given block of Markdown.
* The tests on rustdoc *output* are located in `src/test/rustdoc`, where they're handled by the test
runner of rustbuild and the supplementary script `src/etc/htmldocck.py`.
* Tests on search index generation are located in `src/test/rustdoc-js`, as a series of JavaScript
files that encode queries on the standard library search index and expected results.
## From crate to clean
In `core.rs` are two central items: the `DocContext` struct, and the `run_core` function. The latter
is where rustdoc calls out to rustc to compile a crate to the point where rustdoc can take over. The
former is a state container used when crawling through a crate to gather its documentation.
The main process of crate crawling is done in `clean/mod.rs` through several implementations of the
`Clean` trait defined within. This is a conversion trait, which defines one method:
```rust
pub trait Clean<T> {
fn clean(&self, cx: &DocContext) -> T;
}
```
`clean/mod.rs` also defines the types for the "cleaned" AST used later on to render documentation
pages. Each usually accompanies an implementation of `Clean` that takes some AST or HIR type from
rustc and converts it into the appropriate "cleaned" type. "Big" items like modules or associated
items may have some extra processing in its `Clean` implementation, but for the most part these
impls are straightforward conversions. The "entry point" to this module is the `impl Clean<Crate>
for visit_ast::RustdocVisitor`, which is called by `run_core` above.
You see, I actually lied a little earlier: There's another AST transformation that happens before
the events in `clean/mod.rs`. In `visit_ast.rs` is the type `RustdocVisitor`, which *actually*
crawls a `hir::Crate` to get the first intermediate representation, defined in `doctree.rs`. This
pass is mainly to get a few intermediate wrappers around the HIR types and to process visibility
and inlining. This is where `#[doc(inline)]`, `#[doc(no_inline)]`, and `#[doc(hidden)]` are
processed, as well as the logic for whether a `pub use` should get the full page or a "Reexport"
line in the module page.
The other major thing that happens in `clean/mod.rs` is the collection of doc comments and
`#[doc=""]` attributes into a separate field of the Attributes struct, present on anything that gets
hand-written documentation. This makes it easier to collect this documentation later in the process.
The primary output of this process is a clean::Crate with a tree of Items which describe the
publicly-documentable items in the target crate.
### Hot potato
Before moving on to the next major step, a few important "passes" occur over the documentation.
These do things like combine the separate "attributes" into a single string and strip leading
whitespace to make the document easier on the markdown parser, or drop items that are not public or
deliberately hidden with `#[doc(hidden)]`. These are all implemented in the `passes/` directory, one
file per pass. By default, all of these passes are run on a crate, but the ones regarding dropping
private/hidden items can be bypassed by passing `--document-private-items` to rustdoc.
(Strictly speaking, you can fine-tune the passes run and even add your own, but [we're trying to
deprecate that][44136]. If you need finer-grain control over these passes, please let us know!)
[44136]: https://github.com/rust-lang/rust/issues/44136
## From clean to crate
This is where the "second phase" in rustdoc begins. This phase primarily lives in the `html/`
folder, and it all starts with `run()` in `html/render.rs`. This code is responsible for setting up
the `Context`, `SharedContext`, and `Cache` which are used during rendering, copying out the static
files which live in every rendered set of documentation (things like the fonts, CSS, and JavaScript
that live in `html/static/`), creating the search index, and printing out the source code rendering,
before beginning the process of rendering all the documentation for the crate.
Several functions implemented directly on `Context` take the `clean::Crate` and set up some state
between rendering items or recursing on a module's child items. From here the "page rendering"
begins, via an enormous `write!()` call in `html/layout.rs`. The parts that actually generate HTML
from the items and documentation occurs within a series of `std::fmt::Display` implementations and
functions that pass around a `&mut std::fmt::Formatter`. The top-level implementation that writes
out the page body is the `impl<'a> fmt::Display for Item<'a>` in `html/render.rs`, which switches
out to one of several `item_*` functions based on the kind of `Item` being rendered.
Depending on what kind of rendering code you're looking for, you'll probably find it either in
`html/render.rs` for major items like "what sections should I print for a struct page" or
`html/format.rs` for smaller component pieces like "how should I print a where clause as part of
some other item".
Whenever rustdoc comes across an item that should print hand-written documentation alongside, it
calls out to `html/markdown.rs` which interfaces with the Markdown parser. This is exposed as a
series of types that wrap a string of Markdown, and implement `fmt::Display` to emit HTML text. It
takes special care to enable certain features like footnotes and tables and add syntax highlighting
to Rust code blocks (via `html/highlight.rs`) before running the Markdown parser. There's also a
function in here (`find_testable_code`) that specifically scans for Rust code blocks so the
test-runner code can find all the doctests in the crate.
### From soup to nuts
(alternate title: ["An unbroken thread that stretches from those first `Cell`s to us"][video])
[video]: https://www.youtube.com/watch?v=hOLAGYmUQV0
It's important to note that the AST cleaning can ask the compiler for information (crucially,
`DocContext` contains a `TyCtxt`), but page rendering cannot. The `clean::Crate` created within
`run_core` is passed outside the compiler context before being handed to `html::render::run`. This
means that a lot of the "supplementary data" that isn't immediately available inside an item's
definition, like which trait is the `Deref` trait used by the language, needs to be collected during
cleaning, stored in the `DocContext`, and passed along to the `SharedContext` during HTML rendering.
This manifests as a bunch of shared state, context variables, and `RefCell`s.
Also of note is that some items that come from "asking the compiler" don't go directly into the
`DocContext` - for example, when loading items from a foreign crate, rustdoc will ask about trait
implementations and generate new `Item`s for the impls based on that information. This goes directly
into the returned `Crate` rather than roundabout through the `DocContext`. This way, these
implementations can be collected alongside the others, right before rendering the HTML.
## Other tricks up its sleeve
All this describes the process for generating HTML documentation from a Rust crate, but there are
couple other major modes that rustdoc runs in. It can also be run on a standalone Markdown file, or
it can run doctests on Rust code or standalone Markdown files. For the former, it shortcuts straight
to `html/markdown.rs`, optionally including a mode which inserts a Table of Contents to the output
HTML.
For the latter, rustdoc runs a similar partial-compilation to get relevant documentation in
`test.rs`, but instead of going through the full clean and render process, it runs a much simpler
crate walk to grab *just* the hand-written documentation. Combined with the aforementioned
"`find_testable_code`" in `html/markdown.rs`, it builds up a collection of tests to run before
handing them off to the libtest test runner. One notable location in `test.rs` is the function
`make_test`, which is where hand-written doctests get transformed into something that can be
executed.
## Dotting i's and crossing t's
So that's rustdoc's code in a nutshell, but there's more things in the repo that deal with it. Since
we have the full `compiletest` suite at hand, there's a set of tests in `src/test/rustdoc` that make
sure the final HTML is what we expect in various situations. These tests also use a supplementary
script, `src/etc/htmldocck.py`, that allows it to look through the final HTML using XPath notation
to get a precise look at the output. The full description of all the commands available to rustdoc
tests is in `htmldocck.py`.
In addition, there are separate tests for the search index and rustdoc's ability to query it. The
files in `src/test/rustdoc-js` each contain a different search query and the expected results,
broken out by search tab. These files are processed by a script in `src/tools/rustdoc-js` and the
Node.js runtime. These tests don't have as thorough of a writeup, but a broad example that features
results in all tabs can be found in `basic.js`. The basic idea is that you match a given `QUERY`
with a set of `EXPECTED` results, complete with the full item path of each item.
[rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/rustdoc.html

View file

@ -2755,11 +2755,8 @@ mod test_map {
use cell::RefCell;
use rand::{thread_rng, Rng};
use panic;
#[cfg(not(target_arch = "asmjs"))]
use realstd::collections::CollectionAllocErr::*;
#[cfg(not(target_arch = "asmjs"))]
use realstd::mem::size_of;
#[cfg(not(target_arch = "asmjs"))]
use realstd::usize;
#[test]
@ -3696,7 +3693,6 @@ mod test_map {
assert_eq!(hm.len(), 0);
}
#[cfg(not(target_arch = "asmjs"))]
#[test]
fn test_try_reserve() {

View file

@ -372,6 +372,25 @@ impl FromStr for SocketAddr {
/// [`IpAddr`], [`Ipv4Addr`], [`Ipv6Addr`], [`SocketAddr`], [`SocketAddrV4`], and
/// [`SocketAddrV6`].
///
/// # Potential causes
///
/// `AddrParseError` may be thrown because the provided string does not parse as the given type,
/// often because it includes information only handled by a different address type.
///
/// ```should_panic
/// use std::net::IpAddr;
/// let _foo: IpAddr = "127.0.0.1:8080".parse().expect("Cannot handle the socket port");
/// ```
///
/// [`IpAddr`] doesn't handle the port. Use [`SocketAddr`] instead.
///
/// ```
/// use std::net::SocketAddr;
///
/// // No problem, the `panic!` message has disappeared.
/// let _foo: SocketAddr = "127.0.0.1:8080".parse().expect("unreachable panic");
/// ```
///
/// [`FromStr`]: ../../std/str/trait.FromStr.html
/// [`IpAddr`]: ../../std/net/enum.IpAddr.html
/// [`Ipv4Addr`]: ../../std/net/struct.Ipv4Addr.html

View file

@ -622,15 +622,23 @@ impl CodeMap {
sp
}
/// Extend the given `Span` to just after the previous occurrence of `pat`. Return the same span
/// if no character could be found or if an error occurred while retrieving the code snippet.
pub fn span_extend_to_prev_str(&self, sp: Span, pat: &str) -> Span {
/// Extend the given `Span` to just after the previous occurrence of `pat` when surrounded by
/// whitespace. Return the same span if no character could be found or if an error occurred
/// while retrieving the code snippet.
pub fn span_extend_to_prev_str(&self, sp: Span, pat: &str, accept_newlines: bool) -> Span {
// assure that the pattern is delimited, to avoid the following
// fn my_fn()
// ^^^^ returned span without the check
// ---------- correct span
for ws in &[" ", "\t", "\n"] {
let pat = pat.to_owned() + ws;
if let Ok(prev_source) = self.span_to_prev_source(sp) {
let prev_source = prev_source.rsplit(pat).nth(0).unwrap_or("").trim_left();
if !prev_source.is_empty() && !prev_source.contains('\n') {
let prev_source = prev_source.rsplit(&pat).nth(0).unwrap_or("").trim_left();
if !prev_source.is_empty() && (!prev_source.contains('\n') || accept_newlines) {
return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32));
}
}
}
sp
}

View file

@ -484,13 +484,15 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
match *ext {
MultiModifier(ref mac) => {
let meta = attr.parse_meta(self.cx.parse_sess).ok()?;
let meta = attr.parse_meta(self.cx.parse_sess)
.map_err(|mut e| { e.emit(); }).ok()?;
let item = mac.expand(self.cx, attr.span, &meta, item);
Some(kind.expect_from_annotatables(item))
}
MultiDecorator(ref mac) => {
let mut items = Vec::new();
let meta = attr.parse_meta(self.cx.parse_sess).ok()?;
let meta = attr.parse_meta(self.cx.parse_sess)
.expect("derive meta should already have been parsed");
mac.expand(self.cx, attr.span, &meta, &item, &mut |item| items.push(item));
items.push(item);
Some(kind.expect_from_annotatables(items))

View file

@ -449,6 +449,9 @@ declare_features! (
// Parentheses in patterns
(active, pattern_parentheses, "1.26.0", None, None),
// `use path as _;` and `extern crate c as _;`
(active, underscore_imports, "1.26.0", Some(48216), None),
);
declare_features! (
@ -1434,9 +1437,24 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}
}
fn visit_use_tree(&mut self, use_tree: &'a ast::UseTree, id: NodeId, _nested: bool) {
if let ast::UseTreeKind::Simple(ident) = use_tree.kind {
if ident.name == "_" {
gate_feature_post!(&self, underscore_imports, use_tree.span,
"renaming imports with `_` is unstable");
}
}
visit::walk_use_tree(self, use_tree, id);
}
fn visit_item(&mut self, i: &'a ast::Item) {
match i.node {
ast::ItemKind::ExternCrate(_) => {
if i.ident.name == "_" {
gate_feature_post!(&self, underscore_imports, i.span,
"renaming extern crates with `_` is unstable");
}
if let Some(attr) = attr::find_by_name(&i.attrs[..], "macro_reexport") {
gate_feature_post!(&self, macro_reexport, attr.span,
"macros re-exports are experimental \

View file

@ -7065,7 +7065,11 @@ impl<'a> Parser<'a> {
fn parse_rename(&mut self) -> PResult<'a, Option<Ident>> {
if self.eat_keyword(keywords::As) {
if self.eat(&token::Underscore) {
Ok(Some(Ident::with_empty_ctxt(Symbol::gensym("_"))))
} else {
self.parse_ident().map(Some)
}
} else {
Ok(None)
}

View file

@ -17,6 +17,7 @@
// ignore-asmjs
// ignore-hexagon
// ignore-mips
// ignore-mips64
// ignore-powerpc
// ignore-s390x
// ignore-sparc

View file

@ -21,9 +21,7 @@
// ignore-bpfeb
// ignore-hexagon
// ignore-mips
// ignore-mipsel
// ignore-mips64
// ignore-mips64el
// ignore-msp430
// ignore-powerpc
// ignore-r600

View file

@ -17,9 +17,7 @@
// ignore-bpfeb
// ignore-hexagon
// ignore-mips
// ignore-mipsel
// ignore-mips64
// ignore-mips64el
// ignore-msp430
// ignore-powerpc
// ignore-r600

View file

@ -17,9 +17,7 @@
// ignore-bpfeb
// ignore-hexagon
// ignore-mips
// ignore-mipsel
// ignore-mips64
// ignore-mips64el
// ignore-msp430
// ignore-powerpc
// ignore-r600

View file

@ -17,9 +17,7 @@
// ignore-bpfeb
// ignore-hexagon
// ignore-mips
// ignore-mipsel
// ignore-mips64
// ignore-mips64el
// ignore-msp430
// ignore-powerpc
// ignore-r600

View file

@ -12,6 +12,7 @@
// ignore-aarch64
// ignore-asmjs
// ignore-mips64
// ignore-s390x
// ignore-wasm
// ignore-x86

View file

@ -0,0 +1,49 @@
// 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: -C no-prepopulate-passes
// only-mips64
// See repr-transparent.rs
#![crate_type="lib"]
#![feature(repr_transparent)]
#[repr(C)]
pub struct Big([u32; 16]);
#[repr(transparent)]
pub struct BigW(Big);
// CHECK: define void @test_Big(%Big* [[BIG_RET_ATTRS:.*]], [8 x i64]
#[no_mangle]
pub extern fn test_Big(_: Big) -> Big { loop {} }
// CHECK: define void @test_BigW(%BigW* [[BIG_RET_ATTRS]], [8 x i64]
#[no_mangle]
pub extern fn test_BigW(_: BigW) -> BigW { loop {} }
#[repr(C)]
pub union BigU {
foo: [u32; 16],
}
#[repr(transparent)]
pub struct BigUw(BigU);
// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS:.*]], [8 x i64]
#[no_mangle]
pub extern fn test_BigU(_: BigU) -> BigU { loop {} }
// CHECK: define void @test_BigUw(%BigUw* [[BIGU_RET_ATTRS]], [8 x i64]
#[no_mangle]
pub extern fn test_BigUw(_: BigUw) -> BigUw { loop {} }

View file

@ -10,8 +10,9 @@
// ignore-arm
// ignore-aarch64
// ignore-mips
// ignore-mips64
// ignore-powerpc
// ignore-aarch64
// ignore-wasm
// ignore-emscripten
// ignore-windows

View file

@ -11,6 +11,8 @@
// ignore-arm
// ignore-aarch64
// ignore-emscripten
// ignore-mips
// ignore-mips64
// compile-flags: -O
#![feature(repr_simd)]

View file

@ -37,6 +37,9 @@ pub fn plugin_registrar(reg: &mut Registry) {
reg.register_syntax_extension(
Symbol::intern("into_multi_foo"),
MultiModifier(Box::new(expand_into_foo_multi)));
reg.register_syntax_extension(
Symbol::intern("noop_attribute"),
MultiModifier(Box::new(expand_noop_attribute)));
reg.register_syntax_extension(
Symbol::intern("duplicate"),
MultiDecorator(Box::new(expand_duplicate)));
@ -93,6 +96,13 @@ fn expand_into_foo_multi(cx: &mut ExtCtxt,
}
}
fn expand_noop_attribute(_cx: &mut ExtCtxt,
_sp: Span,
_attr: &MetaItem,
it: Annotatable) -> Annotatable {
it
}
// Create a duplicate of the annotatable, based on the MetaItem
fn expand_duplicate(cx: &mut ExtCtxt,
_sp: Span,

View file

@ -0,0 +1,29 @@
// Copyright 2013-2014 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.
// This is a regression test against an ICE that used to occur
// on malformed attributes for a custom MultiModifier.
// aux-build:macro_crate_test.rs
// ignore-stage1
#![feature(plugin)]
#![plugin(macro_crate_test)]
#[noop_attribute"x"] //~ ERROR expected one of
fn night() { }
#[noop_attribute("hi"), rank = 2] //~ ERROR unexpected token
fn knight() { }
#[noop_attribute("/user", data= = "<user")] //~ ERROR literal or identifier
fn nite() { }
fn main() {}

View file

@ -15,6 +15,8 @@
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
// ignore-mips
// ignore-mips64
#![feature(asm, rustc_attrs)]

View file

@ -12,6 +12,8 @@
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
// ignore-mips
// ignore-mips64
#![feature(asm)]

View file

@ -15,6 +15,8 @@
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
// ignore-mips
// ignore-mips64
#![feature(asm, rustc_attrs)]

View file

@ -12,6 +12,8 @@
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
// ignore-mips
// ignore-mips64
#![feature(asm)]

View file

@ -12,6 +12,8 @@
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
// ignore-mips
// ignore-mips64
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir

View file

@ -21,7 +21,9 @@
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"))]
target_arch = "aarch64",
target_arch = "mips",
target_arch = "mips64"))]
mod test_cases {
fn is_move() {
let y: &mut isize;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//
// error-pattern: main function not found
// error-pattern: `main` function not found
// compile-flags: --cfg foo
// main is conditionally compiled, but the conditional compilation

View file

@ -8,6 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern:main function not found
// error-pattern: `main` function not found
#![cfg(bar)]

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: main function not found
// error-pattern: `main` function not found
// Since we're not compiling a test runner this function should be elided
// and the build will fail because main doesn't exist

View file

@ -8,5 +8,5 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern:main function not found
// error-pattern: `main` function not found
fn mian() { }

View file

@ -10,6 +10,8 @@
// ignore-arm
// ignore-aarch64
// ignore-mips
// ignore-mips64
// ignore-wasm
// ignore-cloudabi no processes
// ignore-emscripten no processes

View file

@ -10,6 +10,8 @@
// ignore-arm
// ignore-aarch64
// ignore-mips
// ignore-mips64
// ignore-wasm
// ignore-cloudabi no processes
// ignore-emscripten no processes

View file

@ -2,7 +2,7 @@ error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`,
--> $DIR/empty_span.rs:17:5
|
LL | unsafe impl Send for &'static Foo { } //~ ERROR cross-crate traits with a default impl
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type
error: aborting due to previous error

View file

@ -32,7 +32,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/coherence-impls-copy.rs:33:1
|
LL | impl Copy for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
@ -41,7 +41,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/coherence-impls-copy.rs:40:1
|
LL | impl Copy for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
@ -50,7 +50,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/coherence-impls-copy.rs:44:1
|
LL | impl Copy for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead

View file

@ -8,11 +8,13 @@ LL | impl<R> External for (Q, R) {} //~ ERROR must be used
- impl<'a, 'b, 'c, T, U, V, W> complex_impl_support::External for (T, complex_impl_support::M<'a, 'b, 'c, std::boxed::Box<U>, V, W>)
where <U as std::ops::FnOnce<(T,)>>::Output == V, <V as std::iter::Iterator>::Item == T, 'b : 'a, T : 'a, U: std::ops::FnOnce<(T,)>, U : 'static, V: std::iter::Iterator, V: std::clone::Clone, W: std::ops::Add, <W as std::ops::Add>::Output: std::marker::Copy;
error[E0210]: type parameter `R` must be used as the type parameter for some local type (e.g. `MyStruct<T>`); only traits defined in the current crate can be implemented for a type parameter
error[E0210]: type parameter `R` must be used as the type parameter for some local type (e.g. `MyStruct<R>`)
--> $DIR/complex-impl.rs:19:1
|
LL | impl<R> External for (Q, R) {} //~ ERROR must be used
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `R` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter
error: aborting due to 2 previous errors

View file

@ -8,11 +8,13 @@ LL | impl<Foo> Deref for Foo { } //~ ERROR must be used
- impl<'a, T> std::ops::Deref for &'a T
where T: ?Sized;
error[E0210]: type parameter `Foo` must be used as the type parameter for some local type (e.g. `MyStruct<T>`); only traits defined in the current crate can be implemented for a type parameter
error[E0210]: type parameter `Foo` must be used as the type parameter for some local type (e.g. `MyStruct<Foo>`)
--> $DIR/issue-28981.rs:15:1
|
LL | impl<Foo> Deref for Foo { } //~ ERROR must be used
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^ type parameter `Foo` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter
error: aborting due to 2 previous errors

View file

@ -8,7 +8,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/E0117.rs:11:1
|
LL | impl Drop for u32 {} //~ ERROR E0117
| ^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead

View file

@ -14,7 +14,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
--> $DIR/E0206.rs:13:1
|
LL | impl Copy for Foo { }
| ^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
| ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead

View file

@ -0,0 +1,20 @@
// 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.
#![feature(unsize)]
use std::marker::Unsize;
pub struct MyType;
impl<T> Unsize<T> for MyType {}
//~^ ERROR explicit impls for the `Unsize` trait are not permitted [E0328]
fn main() {}

View file

@ -0,0 +1,9 @@
error[E0328]: explicit impls for the `Unsize` trait are not permitted
--> $DIR/E0328.rs:17:1
|
LL | impl<T> Unsize<T> for MyType {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of `Unsize` not allowed
error: aborting due to previous error
For more information about this error, try `rustc --explain E0328`.

View file

@ -11,14 +11,14 @@
trait Baz<T> {}
fn foo<T>(x: T) {
fn bar<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
}
fn baz<U,
V: Baz<U>,
W: Fn()>
(y: T) { //~ ERROR E0401
}
bar(x);
bfnr(x);
}

View file

@ -1,12 +1,12 @@
error[E0401]: can't use type parameters from outer function
--> $DIR/E0401.rs:14:38
--> $DIR/E0401.rs:14:39
|
LL | fn foo<T>(x: T) {
| - type variable from outer function
LL | fn bar<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
| -------------------------- ^ use of type variable from outer function
LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
| --------------------------- ^ use of type variable from outer function
| |
| help: try using a local type parameter instead: `bar<U, V: Baz<U>, W: Fn(), T>`
| help: try using a local type parameter instead: `bfnr<U, V: Baz<U>, W: Fn(), T>`
error[E0401]: can't use type parameters from outer function
--> $DIR/E0401.rs:19:16
@ -14,10 +14,11 @@ error[E0401]: can't use type parameters from outer function
LL | fn foo<T>(x: T) {
| - type variable from outer function
...
LL | fn baz<U,
| --- try adding a local type parameter in this method instead
...
LL | (y: T) { //~ ERROR E0401
| ^ use of type variable from outer function
|
= help: try using a local type parameter instead
error[E0401]: can't use type parameters from outer function
--> $DIR/E0401.rs:32:25

View file

@ -15,3 +15,5 @@ fn cookie() -> ! {
//~^^ ERROR definition of an unknown language item: `cookie` [E0522]
loop {}
}
fn main() {}

View file

@ -1,12 +1,9 @@
error[E0601]: main function not found
error[E0522]: definition of an unknown language item: `cookie`
--> $DIR/E0522.rs:13:1
|
LL | #[lang = "cookie"]
| ^^^^^^^^^^^^^^^^^^ definition of unknown language item `cookie`
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors occurred: E0522, E0601.
For more information about an error, try `rustc --explain E0522`.
For more information about this error, try `rustc --explain E0522`.

View file

@ -0,0 +1,11 @@
// 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.
// Test for main function not found.

View file

@ -0,0 +1,7 @@
error[E0601]: `main` function not found in crate `E0601`
|
= note: consider adding a `main` function to `$DIR/E0601.rs`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0601`.

View file

@ -30,3 +30,5 @@ fn test3_2() {
enum A { //~ ERROR 128-bit type is unstable
A(u64)
}
fn main() {}

View file

@ -30,8 +30,6 @@ LL | let x: u128 = 0; //~ ERROR 128-bit type is unstable
|
= help: add #![feature(i128_type)] to the crate attributes to enable
error[E0601]: main function not found
error[E0658]: repr with 128-bit type is unstable (see issue #35118)
--> $DIR/feature-gate-i128_type2.rs:30:1
|
@ -42,7 +40,6 @@ LL | | }
|
= help: add #![feature(repr128)] to the crate attributes to enable
error: aborting due to 6 previous errors
error: aborting due to 5 previous errors
Some errors occurred: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.
For more information about this error, try `rustc --explain E0658`.

View file

@ -0,0 +1,14 @@
// 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.
extern crate std as _; //~ ERROR renaming extern crates with `_` is unstable
use std::vec as _; //~ ERROR renaming imports with `_` is unstable
fn main() {}

View file

@ -0,0 +1,19 @@
error[E0658]: renaming extern crates with `_` is unstable (see issue #48216)
--> $DIR/feature-gate-underscore-imports.rs:11:1
|
LL | extern crate std as _; //~ ERROR renaming extern crates with `_` is unstable
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(underscore_imports)] to the crate attributes to enable
error[E0658]: renaming imports with `_` is unstable (see issue #48216)
--> $DIR/feature-gate-underscore-imports.rs:12:5
|
LL | use std::vec as _; //~ ERROR renaming imports with `_` is unstable
| ^^^^^^^^^^^^^
|
= help: add #![feature(underscore_imports)] to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: main function not found
// error-pattern: `main` function not found
// At time of authorship, a crate-level #![bench] with no `--test`
// will cause compilation to error unconditionally with "main function

View file

@ -1,4 +1,6 @@
error[E0601]: main function not found
error[E0601]: `main` function not found in crate `issue_43106_gating_of_bench`
|
= note: consider adding a `main` function to `$DIR/issue-43106-gating-of-bench.rs`
error: aborting due to previous error

View file

@ -35,3 +35,5 @@ mod inline {
#[inline = "2100"] impl S { }
//~^ ERROR attribute should be applied to function
}
fn main() {}

View file

@ -1,5 +1,3 @@
error[E0601]: main function not found
error[E0518]: attribute should be applied to function
--> $DIR/issue-43106-gating-of-inline.rs:21:1
|
@ -39,7 +37,6 @@ error[E0518]: attribute should be applied to function
LL | #[inline = "2100"] impl S { }
| ^^^^^^^^^^^^^^^^^^ ---------- not a function
error: aborting due to 6 previous errors
error: aborting due to 5 previous errors
Some errors occurred: E0518, E0601.
For more information about an error, try `rustc --explain E0518`.
For more information about this error, try `rustc --explain E0518`.

View file

@ -13,5 +13,9 @@
// `#![macro_escape]` is incompatible with crate-level `#![macro_use]`
// already present in issue-43106-gating-of-builtin-attrs.
// must-compile-successfully
#![macro_escape]
//~^ WARN macro_escape is a deprecated synonym for macro_use
fn main() {}

View file

@ -1,13 +1,8 @@
warning: macro_escape is a deprecated synonym for macro_use
--> $DIR/issue-43106-gating-of-macro_escape.rs:16:1
--> $DIR/issue-43106-gating-of-macro_escape.rs:18:1
|
LL | #![macro_escape]
| ^^^^^^^^^^^^^^^^
|
= help: consider an outer attribute, #[macro_use] mod ...
error[E0601]: main function not found
error: aborting due to previous error
For more information about this error, try `rustc --explain E0601`.

View file

@ -40,3 +40,5 @@ mod proc_macro_derive2 {
#[proc_macro_derive = "2500"] impl S { }
//~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
}
fn main() {}

View file

@ -34,8 +34,5 @@ error: the `#[proc_macro_derive]` attribute may only be used on bare functions
LL | #[proc_macro_derive = "2500"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0601]: main function not found
error: aborting due to 6 previous errors
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0601`.

View file

@ -36,3 +36,4 @@ mod rustc_deprecated {
//~^ ERROR stability attributes may not be used outside of the standard library
}
fn main() {}

View file

@ -1,5 +1,3 @@
error[E0601]: main function not found
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:17:1
|
@ -42,6 +40,5 @@ error: stability attributes may not be used outside of the standard library
LL | #[rustc_deprecated = "1500"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 8 previous errors
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0601`.

View file

@ -35,3 +35,5 @@ mod stable {
#[stable = "1300"] impl S { }
//~^ ERROR stability attributes may not be used outside of the standard library
}
fn main() {}

View file

@ -1,5 +1,3 @@
error[E0601]: main function not found
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:17:1
|
@ -42,6 +40,5 @@ error: stability attributes may not be used outside of the standard library
LL | #[stable = "1300"] impl S { }
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 8 previous errors
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0601`.

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: main function not found
// error-pattern: `main` function not found
// At time of authorship, crate-level #[test] attribute with no
// `--test` signals unconditional error complaining of missing main

View file

@ -1,4 +1,6 @@
error[E0601]: main function not found
error[E0601]: `main` function not found in crate `issue_43106_gating_of_test`
|
= note: consider adding a `main` function to `$DIR/issue-43106-gating-of-test.rs`
error: aborting due to previous error

View file

@ -35,3 +35,5 @@ mod unstable {
#[unstable = "1200"] impl S { }
//~^ ERROR stability attributes may not be used outside of the standard library
}
fn main() {}

View file

@ -1,5 +1,3 @@
error[E0601]: main function not found
error: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:17:1
|
@ -42,6 +40,5 @@ error: stability attributes may not be used outside of the standard library
LL | #[unstable = "1200"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to 8 previous errors
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0601`.

View file

@ -12,3 +12,5 @@
const A: u8 = { yield 3u8; 3u8};
//~^ ERROR yield statement outside
fn main() {}

View file

@ -1,12 +1,9 @@
error[E0601]: main function not found
error[E0627]: yield statement outside of generator literal
--> $DIR/yield-in-const.rs:13:17
|
LL | const A: u8 = { yield 3u8; 3u8};
| ^^^^^^^^^
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors occurred: E0601, E0627.
For more information about an error, try `rustc --explain E0601`.
For more information about this error, try `rustc --explain E0627`.

View file

@ -12,3 +12,5 @@
static B: u8 = { yield 3u8; 3u8};
//~^ ERROR yield statement outside
fn main() {}

View file

@ -1,12 +1,9 @@
error[E0601]: main function not found
error[E0627]: yield statement outside of generator literal
--> $DIR/yield-in-static.rs:13:18
|
LL | static B: u8 = { yield 3u8; 3u8};
| ^^^^^^^^^
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors occurred: E0601, E0627.
For more information about an error, try `rustc --explain E0601`.
For more information about this error, try `rustc --explain E0627`.

View file

@ -36,3 +36,5 @@ fn g() {
mod baz { pub use two_macros::m; }
}
}
fn main() {}

View file

@ -36,9 +36,6 @@ LL | | }
| |_^
= note: macro-expanded items do not shadow when used in a macro invocation path
error[E0601]: main function not found
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
Some errors occurred: E0601, E0659.
For more information about an error, try `rustc --explain E0601`.
For more information about this error, try `rustc --explain E0659`.

View file

@ -49,3 +49,5 @@ mod m4 {
use two_macros::m;
m!(); //~ ERROR ambiguous
}
fn main() {}

View file

@ -51,9 +51,6 @@ LL | use two_macros::m;
| ^^^^^^^^^^^^^
= note: macro-expanded macro imports do not shadow
error[E0601]: main function not found
error: aborting due to 3 previous errors
error: aborting due to 4 previous errors
Some errors occurred: E0601, E0659.
For more information about an error, try `rustc --explain E0601`.
For more information about this error, try `rustc --explain E0659`.

View file

@ -20,3 +20,5 @@ impl Deref for Struct {
}
}
//~^^^^ ERROR cannot infer an appropriate lifetime for lifetime parameter
fn main() {}

View file

@ -1,5 +1,3 @@
error[E0601]: main function not found
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in generic type due to conflicting requirements
--> $DIR/mismatched_trait_impl-2.rs:18:5
|
@ -18,7 +16,6 @@ LL | | }
expected fn(&Struct) -> &Trait + 'static
found fn(&Struct) -> &Trait
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors occurred: E0495, E0601.
For more information about an error, try `rustc --explain E0495`.
For more information about this error, try `rustc --explain E0495`.

View file

@ -14,3 +14,5 @@ trait T {
}
//~^^ ERROR function is expected to take a single 0-tuple as argument
}
fn main() {}

Some files were not shown because too many files have changed in this diff Show more