diff --git a/config.toml.example b/config.toml.example index 9ca0f563d0af1..1d60d8c949441 100644 --- a/config.toml.example +++ b/config.toml.example @@ -312,11 +312,6 @@ # bootstrap) #codegen-backends = ["llvm"] -# Flag indicating whether `libstd` calls an imported function to hande basic IO -# when targetting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown` -# target, as without this option the test output will not be captured. -#wasm-syscall = false - # ============================================================================= # Options for specific targets # diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 780513dd94394..79058984b1352 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -377,11 +377,6 @@ impl<'a> Builder<'a> { self.ensure(Libdir { compiler, target }) } - pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf { - self.sysroot_libdir(compiler, compiler.host) - .with_file_name("codegen-backends") - } - /// Returns the compiler's libdir where it stores the dynamic libraries that /// it itself links against. /// @@ -474,18 +469,6 @@ impl<'a> Builder<'a> { stage = compiler.stage; } - let mut extra_args = env::var(&format!("RUSTFLAGS_STAGE_{}", stage)).unwrap_or_default(); - if stage != 0 { - let s = env::var("RUSTFLAGS_STAGE_NOT_0").unwrap_or_default(); - extra_args.push_str(" "); - extra_args.push_str(&s); - } - - if !extra_args.is_empty() { - cargo.env("RUSTFLAGS", - format!("{} {}", env::var("RUSTFLAGS").unwrap_or_default(), extra_args)); - } - // Customize the compiler we're running. Specify the compiler to cargo // as our shim and then pass it some various options used to configure // how the actual compiler itself is called. diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 1d5e11c5d6d41..fa289bbd76a8b 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -724,7 +724,8 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder, // // Here we're looking for the output dylib of the `CodegenBackend` step and // we're copying that into the `codegen-backends` folder. - let dst = builder.sysroot_codegen_backends(target_compiler); + let libdir = builder.sysroot_libdir(target_compiler, target); + let dst = libdir.join("codegen-backends"); t!(fs::create_dir_all(&dst)); for backend in builder.config.rust_codegen_backends.iter() { diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 0da04bebac513..dbeb27cbfb7d3 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -107,7 +107,6 @@ pub struct Config { pub debug_jemalloc: bool, pub use_jemalloc: bool, pub backtrace: bool, // support for RUST_BACKTRACE - pub wasm_syscall: bool, // misc pub low_priority: bool, @@ -283,7 +282,6 @@ struct Rust { test_miri: Option, save_toolstates: Option, codegen_backends: Option>, - wasm_syscall: Option, } /// TOML representation of how each build target is configured. @@ -465,7 +463,6 @@ impl Config { set(&mut config.rust_dist_src, rust.dist_src); set(&mut config.quiet_tests, rust.quiet_tests); set(&mut config.test_miri, rust.test_miri); - set(&mut config.wasm_syscall, rust.wasm_syscall); config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false); config.rustc_default_linker = rust.default_linker.clone(); config.musl_root = rust.musl_root.clone().map(PathBuf::from); diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index dbb7d19e43285..4127239dc49b8 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -435,9 +435,11 @@ impl Step for Rustc { } // Copy over the codegen backends - let backends_src = builder.sysroot_codegen_backends(compiler); - let backends_rel = backends_src.strip_prefix(&src).unwrap(); - let backends_dst = image.join(&backends_rel); + let backends_src = builder.sysroot_libdir(compiler, host) + .join("codegen-backends"); + let backends_dst = image.join("lib/rustlib") + .join(&*host) + .join("lib/codegen-backends"); t!(fs::create_dir_all(&backends_dst)); cp_r(&backends_src, &backends_dst); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index f2a7ce30c8ac7..aae0a4f056f08 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -423,9 +423,6 @@ impl Build { if self.config.profiler { features.push_str(" profiler"); } - if self.config.wasm_syscall { - features.push_str(" wasm_syscall"); - } features } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 5fdc6e0092064..a316b0f7ef91b 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1286,14 +1286,6 @@ impl Step for Crate { cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), build.config.nodejs.as_ref().expect("nodejs not configured")); } else if target.starts_with("wasm32") { - // Warn about running tests without the `wasm_syscall` feature enabled. - // The javascript shim implements the syscall interface so that test - // output can be correctly reported. - if !build.config.wasm_syscall { - println!("Libstd was built without `wasm_syscall` feature enabled: \ - test output may not be visible."); - } - // On the wasm32-unknown-unknown target we're using LTO which is // incompatible with `-C prefer-dynamic`, so disable that here cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); diff --git a/src/doc/unstable-book/src/language-features/generators.md b/src/doc/unstable-book/src/language-features/generators.md index e8e2132dca254..7a559a7bec866 100644 --- a/src/doc/unstable-book/src/language-features/generators.md +++ b/src/doc/unstable-book/src/language-features/generators.md @@ -139,11 +139,11 @@ closure-like semantics. Namely: types and such. * Traits like `Send` and `Sync` are automatically implemented for a `Generator` - depending on the captured variables of the environment. Unlike closures, + depending on the captured variables of the environment. Unlike closures though generators also depend on variables live across suspension points. This means that although the ambient environment may be `Send` or `Sync`, the generator itself may not be due to internal variables live across `yield` points being - not-`Send` or not-`Sync`. Note that generators, like closures, do + not-`Send` or not-`Sync`. Note, though, that generators, like closures, do not implement traits like `Copy` or `Clone` automatically. * Whenever a generator is dropped it will drop all captured environment @@ -155,7 +155,7 @@ lifted at a future date, the design is ongoing! ### Generators as state machines -In the compiler, generators are currently compiled as state machines. Each +In the compiler generators are currently compiled as state machines. Each `yield` expression will correspond to a different state that stores all live variables over that suspension point. Resumption of a generator will dispatch on the current state and then execute internally until a `yield` is reached, at diff --git a/src/etc/wasm32-shim.js b/src/etc/wasm32-shim.js index 69647f37eecc6..d55083e0f8e03 100644 --- a/src/etc/wasm32-shim.js +++ b/src/etc/wasm32-shim.js @@ -28,74 +28,12 @@ let m = new WebAssembly.Module(buffer); let memory = null; -function viewstruct(data, fields) { - return new Uint32Array(memory.buffer).subarray(data/4, data/4 + fields); -} - function copystr(a, b) { - let view = new Uint8Array(memory.buffer).subarray(a, a + b); - return String.fromCharCode.apply(null, view); -} - -function syscall_write([fd, ptr, len]) { - let s = copystr(ptr, len); - switch (fd) { - case 1: process.stdout.write(s); break; - case 2: process.stderr.write(s); break; + if (memory === null) { + return null } -} - -function syscall_exit([code]) { - process.exit(code); -} - -function syscall_args(params) { - let [ptr, len] = params; - - // Calculate total required buffer size - let totalLen = -1; - for (let i = 2; i < process.argv.length; ++i) { - totalLen += Buffer.byteLength(process.argv[i]) + 1; - } - if (totalLen < 0) { totalLen = 0; } - params[2] = totalLen; - - // If buffer is large enough, copy data - if (len >= totalLen) { - let view = new Uint8Array(memory.buffer); - for (let i = 2; i < process.argv.length; ++i) { - let value = process.argv[i]; - Buffer.from(value).copy(view, ptr); - ptr += Buffer.byteLength(process.argv[i]) + 1; - } - } -} - -function syscall_getenv(params) { - let [keyPtr, keyLen, valuePtr, valueLen] = params; - - let key = copystr(keyPtr, keyLen); - let value = process.env[key]; - - if (value == null) { - params[4] = 0xFFFFFFFF; - } else { - let view = new Uint8Array(memory.buffer); - let totalLen = Buffer.byteLength(value); - params[4] = totalLen; - if (valueLen >= totalLen) { - Buffer.from(value).copy(view, valuePtr); - } - } -} - -function syscall_time(params) { - let t = Date.now(); - let secs = Math.floor(t / 1000); - let millis = t % 1000; - params[1] = Math.floor(secs / 0x100000000); - params[2] = secs % 0x100000000; - params[3] = Math.floor(millis * 1000000); + let view = new Uint8Array(memory.buffer).slice(a, a + b); + return String.fromCharCode.apply(null, view); } let imports = {}; @@ -110,25 +48,68 @@ imports.env = { log10: Math.log10, log10f: Math.log10, - rust_wasm_syscall: function(index, data) { - switch (index) { - case 1: syscall_write(viewstruct(data, 3)); return true; - case 2: syscall_exit(viewstruct(data, 1)); return true; - case 3: syscall_args(viewstruct(data, 3)); return true; - case 4: syscall_getenv(viewstruct(data, 5)); return true; - case 6: syscall_time(viewstruct(data, 4)); return true; - default: - console.log("Unsupported syscall: " + index); - return false; + // These are called in src/libstd/sys/wasm/stdio.rs and are used when + // debugging is enabled. + rust_wasm_write_stdout: function(a, b) { + let s = copystr(a, b); + if (s !== null) { + process.stdout.write(s); } - } + }, + rust_wasm_write_stderr: function(a, b) { + let s = copystr(a, b); + if (s !== null) { + process.stderr.write(s); + } + }, + + // These are called in src/libstd/sys/wasm/args.rs and are used when + // debugging is enabled. + rust_wasm_args_count: function() { + if (memory === null) + return 0; + return process.argv.length - 2; + }, + rust_wasm_args_arg_size: function(i) { + return Buffer.byteLength(process.argv[i + 2]); + }, + rust_wasm_args_arg_fill: function(idx, ptr) { + let arg = process.argv[idx + 2]; + let view = new Uint8Array(memory.buffer); + Buffer.from(arg).copy(view, ptr); + }, + + // These are called in src/libstd/sys/wasm/os.rs and are used when + // debugging is enabled. + rust_wasm_getenv_len: function(a, b) { + let key = copystr(a, b); + if (key === null) { + return -1; + } + if (!(key in process.env)) { + return -1; + } + return Buffer.byteLength(process.env[key]); + }, + rust_wasm_getenv_data: function(a, b, ptr) { + let key = copystr(a, b); + let value = process.env[key]; + let view = new Uint8Array(memory.buffer); + Buffer.from(value).copy(view, ptr); + }, }; -let instance = new WebAssembly.Instance(m, imports); -memory = instance.exports.memory; -try { - instance.exports.main(); -} catch (e) { - console.error(e); - process.exit(101); +let module_imports = WebAssembly.Module.imports(m); + +for (var i = 0; i < module_imports.length; i++) { + let imp = module_imports[i]; + if (imp.module != 'env') { + continue + } + if (imp.name == 'memory' && imp.kind == 'memory') { + memory = new WebAssembly.Memory({initial: 20}); + imports.env.memory = memory; + } } + +let instance = new WebAssembly.Instance(m, imports); diff --git a/src/liballoc/btree/map.rs b/src/liballoc/btree/map.rs index b320bed54320a..b114dc640fbaf 100644 --- a/src/liballoc/btree/map.rs +++ b/src/liballoc/btree/map.rs @@ -1748,11 +1748,6 @@ impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap { type Output = V; - /// Returns a reference to the value corresponding to the supplied key. - /// - /// # Panics - /// - /// Panics if the key is not present in the `BTreeMap`. #[inline] fn index(&self, key: &Q) -> &V { self.get(key).expect("no entry found for key") diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 6c8a1c3062b00..65aacb23bd768 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -1586,7 +1586,6 @@ impl Display for ! { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for bool { - #[inline] fn fmt(&self, f: &mut Formatter) -> Result { Display::fmt(self, f) } @@ -1749,7 +1748,6 @@ impl Debug for [T] { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for () { - #[inline] fn fmt(&self, f: &mut Formatter) -> Result { f.pad("()") } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 2992e7cf8db34..ee989854a3772 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -157,7 +157,6 @@ macro_rules! debug { ($T:ident) => { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for $T { - #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(self, f) } diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 7314fac282b66..06c29b47bf921 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -307,7 +307,6 @@ use fmt; use iter_private::TrustedRandomAccess; use ops::Try; use usize; -use intrinsics; #[stable(feature = "rust1", since = "1.0.0")] pub use self::iterator::Iterator; @@ -695,49 +694,6 @@ impl Iterator for StepBy where I: Iterator { (f(inner_hint.0), inner_hint.1.map(f)) } } - - #[inline] - fn nth(&mut self, mut n: usize) -> Option { - if self.first_take { - self.first_take = false; - let first = self.iter.next(); - if n == 0 { - return first; - } - n -= 1; - } - // n and self.step are indices, we need to add 1 to get the amount of elements - // When calling `.nth`, we need to subtract 1 again to convert back to an index - // step + 1 can't overflow because `.step_by` sets `self.step` to `step - 1` - let mut step = self.step + 1; - // n + 1 could overflow - // thus, if n is usize::MAX, instead of adding one, we call .nth(step) - if n == usize::MAX { - self.iter.nth(step - 1); - } else { - n += 1; - } - - // overflow handling - loop { - let mul = n.checked_mul(step); - if unsafe { intrinsics::likely(mul.is_some()) } { - return self.iter.nth(mul.unwrap() - 1); - } - let div_n = usize::MAX / n; - let div_step = usize::MAX / step; - let nth_n = div_n * n; - let nth_step = div_step * step; - let nth = if nth_n > nth_step { - step -= div_n; - nth_n - } else { - n -= div_step; - nth_step - }; - self.iter.nth(nth - 1); - } - } } // StepBy can only make the iterator shorter, so the len will still fit. diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 2e1f925c49a36..d5190b65863cb 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -168,7 +168,6 @@ pub mod slice; pub mod str; pub mod hash; pub mod fmt; -pub mod time; // note: does not need to be public mod char_private; diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index e52e119ff59b9..8997cf9c6bff9 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -161,68 +161,6 @@ fn test_iterator_step_by() { assert_eq!(it.next(), None); } -#[test] -fn test_iterator_step_by_nth() { - let mut it = (0..16).step_by(5); - assert_eq!(it.nth(0), Some(0)); - assert_eq!(it.nth(0), Some(5)); - assert_eq!(it.nth(0), Some(10)); - assert_eq!(it.nth(0), Some(15)); - assert_eq!(it.nth(0), None); - - let it = (0..18).step_by(5); - assert_eq!(it.clone().nth(0), Some(0)); - assert_eq!(it.clone().nth(1), Some(5)); - assert_eq!(it.clone().nth(2), Some(10)); - assert_eq!(it.clone().nth(3), Some(15)); - assert_eq!(it.clone().nth(4), None); - assert_eq!(it.clone().nth(42), None); -} - -#[test] -fn test_iterator_step_by_nth_overflow() { - #[cfg(target_pointer_width = "8")] - type Bigger = u16; - #[cfg(target_pointer_width = "16")] - type Bigger = u32; - #[cfg(target_pointer_width = "32")] - type Bigger = u64; - #[cfg(target_pointer_width = "64")] - type Bigger = u128; - - #[derive(Clone)] - struct Test(Bigger); - impl<'a> Iterator for &'a mut Test { - type Item = i32; - fn next(&mut self) -> Option { Some(21) } - fn nth(&mut self, n: usize) -> Option { - self.0 += n as Bigger + 1; - Some(42) - } - } - - let mut it = Test(0); - let root = usize::MAX >> (::std::mem::size_of::() * 8 / 2); - let n = root + 20; - (&mut it).step_by(n).nth(n); - assert_eq!(it.0, n as Bigger * n as Bigger); - - // large step - let mut it = Test(0); - (&mut it).step_by(usize::MAX).nth(5); - assert_eq!(it.0, (usize::MAX as Bigger) * 5); - - // n + 1 overflows - let mut it = Test(0); - (&mut it).step_by(2).nth(usize::MAX); - assert_eq!(it.0, (usize::MAX as Bigger) * 2); - - // n + 1 overflows - let mut it = Test(0); - (&mut it).step_by(1).nth(usize::MAX); - assert_eq!(it.0, (usize::MAX as Bigger) * 1); -} - #[test] #[should_panic] fn test_iterator_step_by_zero() { diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index 5f768ef4399e8..c3bd6a2bc187d 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -27,12 +27,10 @@ #![feature(libc)] #![feature(panic_runtime)] #![feature(staged_api)] -#![feature(rustc_attrs)] // Rust's "try" function, but if we're aborting on panics we just call the // function as there's nothing else we need to do here. #[no_mangle] -#[rustc_std_internal_symbol] pub unsafe extern fn __rust_maybe_catch_panic(f: fn(*mut u8), data: *mut u8, _data_ptr: *mut usize, @@ -52,7 +50,6 @@ pub unsafe extern fn __rust_maybe_catch_panic(f: fn(*mut u8), // will kill us with an illegal instruction, which will do a good enough job for // now hopefully. #[no_mangle] -#[rustc_std_internal_symbol] pub unsafe extern fn __rust_start_panic(_data: usize, _vtable: usize) -> u32 { abort(); diff --git a/src/librustc/README.md b/src/librustc/README.md index 722456a76ce59..ddf71a06d607c 100644 --- a/src/librustc/README.md +++ b/src/librustc/README.md @@ -176,7 +176,6 @@ pointers for understanding them better. - `'gcx` -- the lifetime of the global arena (see `librustc/ty`). - generics -- the set of generic type parameters defined on a type or item - ICE -- internal compiler error. When the compiler crashes. -- ICH -- incremental compilation hash. - infcx -- the inference context (see `librustc/infer`) - MIR -- the **Mid-level IR** that is created after type-checking for use by borrowck and trans. Defined in the `src/librustc/mir/` module, but much of the code that manipulates it is diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 4034055d04155..1de9091b5df7d 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -639,9 +639,6 @@ define_dep_nodes!( <'tcx> [] TargetFeaturesEnabled(DefId), [] InstanceDefSizeEstimate { instance_def: InstanceDef<'tcx> }, - - [] GetSymbolExportLevel(DefId), - ); trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug { diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 03fc40b2e39fc..b10e742595720 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -175,6 +175,25 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { ty::ReEarlyBound(_) | ty::ReFree(_) => { let scope = region.free_region_binding_scope(self); + let prefix = match *region { + ty::ReEarlyBound(ref br) => { + format!("the lifetime {} as defined on", br.name) + } + ty::ReFree(ref fr) => { + match fr.bound_region { + ty::BrAnon(idx) => { + format!("the anonymous lifetime #{} defined on", idx + 1) + } + ty::BrFresh(_) => "an anonymous lifetime defined on".to_owned(), + _ => { + format!("the lifetime {} as defined on", + fr.bound_region) + } + } + } + _ => bug!() + }; + let node = self.hir.as_local_node_id(scope) .unwrap_or(DUMMY_NODE_ID); let unknown; @@ -199,26 +218,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { &unknown } }; - let (prefix, span) = match *region { - ty::ReEarlyBound(ref br) => { - (format!("the lifetime {} as defined on", br.name), - self.sess.codemap().def_span(self.hir.span(node))) - } - ty::ReFree(ref fr) => { - match fr.bound_region { - ty::BrAnon(idx) => { - (format!("the anonymous lifetime #{} defined on", idx + 1), - self.hir.span(node)) - } - ty::BrFresh(_) => ("an anonymous lifetime defined on".to_owned(), - self.hir.span(node)), - _ => (format!("the lifetime {} as defined on", fr.bound_region), - self.sess.codemap().def_span(self.hir.span(node))), - } - } - _ => bug!() - }; - let (msg, opt_span) = explain_span(self, tag, span); + let (msg, opt_span) = explain_span(self, tag, self.hir.span(node)); (format!("{} {}", prefix, msg), opt_span) } @@ -807,7 +807,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } }; - let span = cause.span(&self.tcx); + let span = cause.span; diag.span_label(span, terr.to_string()); if let Some((sp, msg)) = secondary_span { @@ -842,7 +842,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { "did you mean `{}(/* fields */)`?", self.tcx.item_path_str(def_id) ); - diag.span_label(span, message); + diag.span_label(cause.span, message); } } } @@ -870,7 +870,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { trace, terr); - let span = trace.cause.span(&self.tcx); + let span = trace.cause.span; let failure_code = trace.cause.as_failure_code(terr); let mut diag = match failure_code { FailureCode::Error0317(failure_str) => { @@ -1076,31 +1076,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { sup_region, "..."); - match (&sup_origin, &sub_origin) { - (&infer::Subtype(ref sup_trace), &infer::Subtype(ref sub_trace)) => { - if let (Some((sup_expected, sup_found)), - Some((sub_expected, sub_found))) = (self.values_str(&sup_trace.values), - self.values_str(&sub_trace.values)) { - if sub_expected == sup_expected && sub_found == sup_found { - self.tcx.note_and_explain_region( - region_scope_tree, - &mut err, - "...but the lifetime must also be valid for ", - sub_region, - "...", - ); - err.note(&format!("...so that the {}:\nexpected {}\n found {}", - sup_trace.cause.as_requirement_str(), - sup_expected.content(), - sup_found.content())); - err.emit(); - return; - } - } - } - _ => {} - } - self.note_region_origin(&mut err, &sup_origin); self.tcx.note_and_explain_region(region_scope_tree, &mut err, diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs index 02ec9fe74c1fe..e46613b3e4da0 100644 --- a/src/librustc/infer/error_reporting/note.rs +++ b/src/librustc/infer/error_reporting/note.rs @@ -23,10 +23,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if let Some((expected, found)) = self.values_str(&trace.values) { let expected = expected.content(); let found = found.content(); - err.note(&format!("...so that the {}:\nexpected {}\n found {}", - trace.cause.as_requirement_str(), - expected, - found)); + // FIXME: do we want a "the" here? + err.span_note(trace.cause.span, + &format!("...so that {} (expected {}, found {})", + trace.cause.as_requirement_str(), + expected, + found)); } else { // FIXME: this really should be handled at some earlier stage. Our // handling of region checking when type errors are present is diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index db6863d6dadc2..d727dfb0c4b2d 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -66,7 +66,6 @@ #![feature(specialization)] #![feature(unboxed_closures)] #![feature(underscore_lifetimes)] -#![feature(universal_impl_trait)] #![feature(trace_macros)] #![feature(catch_expr)] #![feature(test)] diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 9543d01597d04..b9546143a054b 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1288,8 +1288,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED], "in dep-info output, omit targets for tracking dependencies of the dep-info files \ themselves"), - approximate_suggestions: bool = (false, parse_bool, [UNTRACKED], - "include machine-applicability of suggestions in JSON output"), unpretty: Option = (None, parse_unpretty, [UNTRACKED], "Present the input source, unstable (and less-pretty) variants; valid types are any of the types for `--pretty`, as well as: diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index f4a00a43d8d92..2765239d5e649 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -904,27 +904,22 @@ pub fn build_session_with_codemap(sopts: config::Options, let emitter: Box = match (sopts.error_format, emitter_dest) { (config::ErrorOutputType::HumanReadable(color_config), None) => { - Box::new(EmitterWriter::stderr(color_config, - Some(codemap.clone()), - false, - sopts.debugging_opts.teach)) + Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), false)) } (config::ErrorOutputType::HumanReadable(_), Some(dst)) => { - Box::new(EmitterWriter::new(dst, Some(codemap.clone()), false, false)) + Box::new(EmitterWriter::new(dst, Some(codemap.clone()), false)) } (config::ErrorOutputType::Json(pretty), None) => { - Box::new(JsonEmitter::stderr(Some(registry), codemap.clone(), - pretty, sopts.debugging_opts.approximate_suggestions)) + Box::new(JsonEmitter::stderr(Some(registry), codemap.clone(), pretty)) } (config::ErrorOutputType::Json(pretty), Some(dst)) => { - Box::new(JsonEmitter::new(dst, Some(registry), codemap.clone(), - pretty, sopts.debugging_opts.approximate_suggestions)) + Box::new(JsonEmitter::new(dst, Some(registry), codemap.clone(), pretty)) } (config::ErrorOutputType::Short(color_config), None) => { - Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), true, false)) + Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), true)) } (config::ErrorOutputType::Short(_), Some(dst)) => { - Box::new(EmitterWriter::new(dst, Some(codemap.clone()), true, false)) + Box::new(EmitterWriter::new(dst, Some(codemap.clone()), true)) } }; @@ -1100,11 +1095,11 @@ pub enum IncrCompSession { pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { let emitter: Box = match output { config::ErrorOutputType::HumanReadable(color_config) => { - Box::new(EmitterWriter::stderr(color_config, None, false, false)) + Box::new(EmitterWriter::stderr(color_config, None, false)) } config::ErrorOutputType::Json(pretty) => Box::new(JsonEmitter::basic(pretty)), config::ErrorOutputType::Short(color_config) => { - Box::new(EmitterWriter::stderr(color_config, None, true, false)) + Box::new(EmitterWriter::stderr(color_config, None, true)) } }; let handler = errors::Handler::with_emitter(true, false, emitter); @@ -1115,11 +1110,11 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { pub fn early_warn(output: config::ErrorOutputType, msg: &str) { let emitter: Box = match output { config::ErrorOutputType::HumanReadable(color_config) => { - Box::new(EmitterWriter::stderr(color_config, None, false, false)) + Box::new(EmitterWriter::stderr(color_config, None, false)) } config::ErrorOutputType::Json(pretty) => Box::new(JsonEmitter::basic(pretty)), config::ErrorOutputType::Short(color_config) => { - Box::new(EmitterWriter::stderr(color_config, None, true, false)) + Box::new(EmitterWriter::stderr(color_config, None, true)) } }; let handler = errors::Handler::with_emitter(true, false, emitter); diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 9de18612d816c..ae68e3fe8d01f 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -19,7 +19,7 @@ use ty::{self, Ty, TyCtxt}; use ty::fold::TypeFoldable; use ty::subst::Subst; -use infer::{InferOk}; +use infer::{InferCtxt, InferOk}; /// Whether we do the orphan check relative to this crate or /// to some remote crate. @@ -40,20 +40,13 @@ pub struct OverlapResult<'tcx> { pub intercrate_ambiguity_causes: Vec, } -/// If there are types that satisfy both impls, invokes `on_overlap` -/// with a suitably-freshened `ImplHeader` with those types -/// substituted. Otherwise, invokes `no_overlap`. -pub fn overlapping_impls<'gcx, F1, F2, R>( - tcx: TyCtxt<'_, 'gcx, 'gcx>, - impl1_def_id: DefId, - impl2_def_id: DefId, - intercrate_mode: IntercrateMode, - on_overlap: F1, - no_overlap: F2, -) -> R -where - F1: FnOnce(OverlapResult<'_>) -> R, - F2: FnOnce() -> R, +/// If there are types that satisfy both impls, returns a suitably-freshened +/// `ImplHeader` with those types substituted +pub fn overlapping_impls<'cx, 'gcx, 'tcx>(infcx: &InferCtxt<'cx, 'gcx, 'tcx>, + impl1_def_id: DefId, + impl2_def_id: DefId, + intercrate_mode: IntercrateMode) + -> Option> { debug!("impl_can_satisfy(\ impl1_def_id={:?}, \ @@ -63,23 +56,8 @@ where impl2_def_id, intercrate_mode); - let overlaps = tcx.infer_ctxt().enter(|infcx| { - let selcx = &mut SelectionContext::intercrate(&infcx, intercrate_mode); - overlap(selcx, impl1_def_id, impl2_def_id).is_some() - }); - - if !overlaps { - return no_overlap(); - } - - // In the case where we detect an error, run the check again, but - // this time tracking intercrate ambuiguity causes for better - // diagnostics. (These take time and can lead to false errors.) - tcx.infer_ctxt().enter(|infcx| { - let selcx = &mut SelectionContext::intercrate(&infcx, intercrate_mode); - selcx.enable_tracking_intercrate_ambiguity_causes(); - on_overlap(overlap(selcx, impl1_def_id, impl2_def_id).unwrap()) - }) + let selcx = &mut SelectionContext::intercrate(infcx, intercrate_mode); + overlap(selcx, impl1_def_id, impl2_def_id) } fn with_fresh_ty_vars<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, @@ -157,10 +135,10 @@ fn overlap<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, return None } - let impl_header = selcx.infcx().resolve_type_vars_if_possible(&a_impl_header); - let intercrate_ambiguity_causes = selcx.take_intercrate_ambiguity_causes(); - debug!("overlap: intercrate_ambiguity_causes={:#?}", intercrate_ambiguity_causes); - Some(OverlapResult { impl_header, intercrate_ambiguity_causes }) + Some(OverlapResult { + impl_header: selcx.infcx().resolve_type_vars_if_possible(&a_impl_header), + intercrate_ambiguity_causes: selcx.intercrate_ambiguity_causes().to_vec(), + }) } pub fn trait_ref_is_knowable<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index d65becb912a3c..42200a3a44728 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -831,11 +831,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { span, node: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _), .. - }) | - hir::map::NodeTraitItem(&hir::TraitItem { - span, - node: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _), - .. }) => { (self.tcx.sess.codemap().def_span(span), decl.inputs.iter() .map(|arg| match arg.clone().into_inner().node { diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 0616dda228e68..fd47e09aad7f9 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -100,19 +100,6 @@ pub struct ObligationCause<'tcx> { pub code: ObligationCauseCode<'tcx> } -impl<'tcx> ObligationCause<'tcx> { - pub fn span<'a, 'gcx>(&self, tcx: &TyCtxt<'a, 'gcx, 'tcx>) -> Span { - match self.code { - ObligationCauseCode::CompareImplMethodObligation { .. } | - ObligationCauseCode::MainFunctionType | - ObligationCauseCode::StartFunctionType => { - tcx.sess.codemap().def_span(self.span) - } - _ => self.span, - } - } -} - #[derive(Clone, Debug, PartialEq, Eq)] pub enum ObligationCauseCode<'tcx> { /// Not well classified or should be obvious from span. diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 4ed25646d436d..55cbc890e1e91 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -92,10 +92,10 @@ pub struct SelectionContext<'cx, 'gcx: 'cx+'tcx, 'tcx: 'cx> { inferred_obligations: SnapshotVec>, - intercrate_ambiguity_causes: Option>, + intercrate_ambiguity_causes: Vec, } -#[derive(Clone, Debug)] +#[derive(Clone)] pub enum IntercrateAmbiguityCause { DownstreamCrate { trait_desc: String, @@ -423,7 +423,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { freshener: infcx.freshener(), intercrate: None, inferred_obligations: SnapshotVec::new(), - intercrate_ambiguity_causes: None, + intercrate_ambiguity_causes: Vec::new(), } } @@ -435,30 +435,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { freshener: infcx.freshener(), intercrate: Some(mode), inferred_obligations: SnapshotVec::new(), - intercrate_ambiguity_causes: None, + intercrate_ambiguity_causes: Vec::new(), } } - /// Enables tracking of intercrate ambiguity causes. These are - /// used in coherence to give improved diagnostics. We don't do - /// this until we detect a coherence error because it can lead to - /// false overflow results (#47139) and because it costs - /// computation time. - pub fn enable_tracking_intercrate_ambiguity_causes(&mut self) { - assert!(self.intercrate.is_some()); - assert!(self.intercrate_ambiguity_causes.is_none()); - self.intercrate_ambiguity_causes = Some(vec![]); - debug!("selcx: enable_tracking_intercrate_ambiguity_causes"); - } - - /// Gets the intercrate ambiguity causes collected since tracking - /// was enabled and disables tracking at the same time. If - /// tracking is not enabled, just returns an empty vector. - pub fn take_intercrate_ambiguity_causes(&mut self) -> Vec { - assert!(self.intercrate.is_some()); - self.intercrate_ambiguity_causes.take().unwrap_or(vec![]) - } - pub fn infcx(&self) -> &'cx InferCtxt<'cx, 'gcx, 'tcx> { self.infcx } @@ -471,6 +451,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { self.infcx } + pub fn intercrate_ambiguity_causes(&self) -> &[IntercrateAmbiguityCause] { + &self.intercrate_ambiguity_causes + } + /// Wraps the inference context's in_snapshot s.t. snapshot handling is only from the selection /// context's self. fn in_snapshot(&mut self, f: F) -> R @@ -844,23 +828,19 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { debug!("evaluate_stack({:?}) --> unbound argument, intercrate --> ambiguous", stack.fresh_trait_ref); // Heuristics: show the diagnostics when there are no candidates in crate. - if self.intercrate_ambiguity_causes.is_some() { - debug!("evaluate_stack: intercrate_ambiguity_causes is some"); - if let Ok(candidate_set) = self.assemble_candidates(stack) { - if !candidate_set.ambiguous && candidate_set.vec.is_empty() { - let trait_ref = stack.obligation.predicate.skip_binder().trait_ref; - let self_ty = trait_ref.self_ty(); - let cause = IntercrateAmbiguityCause::DownstreamCrate { - trait_desc: trait_ref.to_string(), - self_desc: if self_ty.has_concrete_skeleton() { - Some(self_ty.to_string()) - } else { - None - }, - }; - debug!("evaluate_stack: pushing cause = {:?}", cause); - self.intercrate_ambiguity_causes.as_mut().unwrap().push(cause); - } + if let Ok(candidate_set) = self.assemble_candidates(stack) { + if !candidate_set.ambiguous && candidate_set.vec.is_empty() { + let trait_ref = stack.obligation.predicate.skip_binder().trait_ref; + let self_ty = trait_ref.self_ty(); + let cause = IntercrateAmbiguityCause::DownstreamCrate { + trait_desc: trait_ref.to_string(), + self_desc: if self_ty.has_concrete_skeleton() { + Some(self_ty.to_string()) + } else { + None + }, + }; + self.intercrate_ambiguity_causes.push(cause); } } return EvaluatedToAmbig; @@ -1112,29 +1092,25 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { None => {} Some(conflict) => { debug!("coherence stage: not knowable"); - if self.intercrate_ambiguity_causes.is_some() { - debug!("evaluate_stack: intercrate_ambiguity_causes is some"); - // Heuristics: show the diagnostics when there are no candidates in crate. - let candidate_set = self.assemble_candidates(stack)?; - if !candidate_set.ambiguous && candidate_set.vec.iter().all(|c| { - !self.evaluate_candidate(stack, &c).may_apply() - }) { - let trait_ref = stack.obligation.predicate.skip_binder().trait_ref; - let self_ty = trait_ref.self_ty(); - let trait_desc = trait_ref.to_string(); - let self_desc = if self_ty.has_concrete_skeleton() { - Some(self_ty.to_string()) - } else { - None - }; - let cause = if let Conflict::Upstream = conflict { - IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_desc, self_desc } - } else { - IntercrateAmbiguityCause::DownstreamCrate { trait_desc, self_desc } - }; - debug!("evaluate_stack: pushing cause = {:?}", cause); - self.intercrate_ambiguity_causes.as_mut().unwrap().push(cause); - } + // Heuristics: show the diagnostics when there are no candidates in crate. + let candidate_set = self.assemble_candidates(stack)?; + if !candidate_set.ambiguous && candidate_set.vec.iter().all(|c| { + !self.evaluate_candidate(stack, &c).may_apply() + }) { + let trait_ref = stack.obligation.predicate.skip_binder().trait_ref; + let self_ty = trait_ref.self_ty(); + let trait_desc = trait_ref.to_string(); + let self_desc = if self_ty.has_concrete_skeleton() { + Some(self_ty.to_string()) + } else { + None + }; + let cause = if let Conflict::Upstream = conflict { + IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_desc, self_desc } + } else { + IntercrateAmbiguityCause::DownstreamCrate { trait_desc, self_desc } + }; + self.intercrate_ambiguity_causes.push(cause); } return Ok(None); } diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index a10169e13e60a..834389e5d009c 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -133,12 +133,12 @@ impl<'a, 'gcx, 'tcx> Children { }; let tcx = tcx.global_tcx(); - let (le, ge) = traits::overlapping_impls( - tcx, - possible_sibling, - impl_def_id, - traits::IntercrateMode::Issue43355, - |overlap| { + let (le, ge) = tcx.infer_ctxt().enter(|infcx| { + let overlap = traits::overlapping_impls(&infcx, + possible_sibling, + impl_def_id, + traits::IntercrateMode::Issue43355); + if let Some(overlap) = overlap { if tcx.impls_are_allowed_to_overlap(impl_def_id, possible_sibling) { return Ok((false, false)); } @@ -151,9 +151,10 @@ impl<'a, 'gcx, 'tcx> Children { } else { Ok((le, ge)) } - }, - || Ok((false, false)), - )?; + } else { + Ok((false, false)) + } + })?; if le && !ge { debug!("descending as child of TraitRef {:?}", @@ -170,14 +171,16 @@ impl<'a, 'gcx, 'tcx> Children { return Ok(Inserted::Replaced(possible_sibling)); } else { if !tcx.impls_are_allowed_to_overlap(impl_def_id, possible_sibling) { - traits::overlapping_impls( - tcx, - possible_sibling, - impl_def_id, - traits::IntercrateMode::Fixed, - |overlap| last_lint = Some(overlap_error(overlap)), - || (), - ); + tcx.infer_ctxt().enter(|infcx| { + if let Some(overlap) = traits::overlapping_impls( + &infcx, + possible_sibling, + impl_def_id, + traits::IntercrateMode::Fixed) + { + last_lint = Some(overlap_error(overlap)); + } + }); } // no overlap (error bailed already via ?) diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/maps/mod.rs index 85fca68187fe6..6c79f6a62fa0b 100644 --- a/src/librustc/ty/maps/mod.rs +++ b/src/librustc/ty/maps/mod.rs @@ -343,7 +343,6 @@ define_maps! { <'tcx> -> (Arc, Arc>>>), [] fn export_name: ExportName(DefId) -> Option, [] fn contains_extern_indicator: ContainsExternIndicator(DefId) -> bool, - [] fn symbol_export_level: GetSymbolExportLevel(DefId) -> SymbolExportLevel, [] fn is_translated_function: IsTranslatedFunction(DefId) -> bool, [] fn codegen_unit: CodegenUnit(InternedString) -> Arc>, [] fn compile_codegen_unit: CompileCodegenUnit(InternedString) -> Stats, diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index 0ab6ee1a54a9b..c9eebc3d2a0a7 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -921,8 +921,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::TargetFeaturesWhitelist => { force!(target_features_whitelist, LOCAL_CRATE); } DepKind::TargetFeaturesEnabled => { force!(target_features_enabled, def_id!()); } - - DepKind::GetSymbolExportLevel => { force!(symbol_export_level, def_id!()); } } true diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 2872c59157d6b..3c8a676dcc200 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -468,10 +468,6 @@ pub struct TargetOptions { /// The codegen backend to use for this target, typically "llvm" pub codegen_backend: String, - - /// The default visibility for symbols in this target should be "hidden" - /// rather than "default" - pub default_hidden_visibility: bool, } impl Default for TargetOptions { @@ -542,7 +538,6 @@ impl Default for TargetOptions { no_builtins: false, i128_lowering: false, codegen_backend: "llvm".to_string(), - default_hidden_visibility: false, } } } @@ -790,7 +785,6 @@ impl Target { key!(singlethread, bool); key!(no_builtins, bool); key!(codegen_backend); - key!(default_hidden_visibility, bool); if let Some(array) = obj.find("abi-blacklist").and_then(Json::as_array) { for name in array.iter().filter_map(|abi| abi.as_string()) { @@ -988,7 +982,6 @@ impl ToJson for Target { target_option_val!(singlethread); target_option_val!(no_builtins); target_option_val!(codegen_backend); - target_option_val!(default_hidden_visibility); if default.abi_blacklist != self.options.abi_blacklist { d.insert("abi-blacklist".to_string(), self.options.abi_blacklist.iter() diff --git a/src/librustc_back/target/msp430_none_elf.rs b/src/librustc_back/target/msp430_none_elf.rs index 966df897f01f1..509a7cf5e0323 100644 --- a/src/librustc_back/target/msp430_none_elf.rs +++ b/src/librustc_back/target/msp430_none_elf.rs @@ -53,12 +53,6 @@ pub fn target() -> TargetResult { // don't want to invoke that many gcc instances. default_codegen_units: Some(1), - // Since MSP430 doesn't meaningfully support faulting on illegal - // instructions, LLVM generates a call to abort() function instead - // of a trap instruction. Such calls are 4 bytes long, and that is - // too much overhead for such small target. - trap_unreachable: false, - .. Default::default( ) } }) diff --git a/src/librustc_back/target/wasm32_unknown_unknown.rs b/src/librustc_back/target/wasm32_unknown_unknown.rs index 242860e5c6e92..7e1011ab8af96 100644 --- a/src/librustc_back/target/wasm32_unknown_unknown.rs +++ b/src/librustc_back/target/wasm32_unknown_unknown.rs @@ -83,9 +83,6 @@ pub fn target() -> Result { // performing LTO with compiler-builtins. no_builtins: true, - // no dynamic linking, no need for default visibility! - default_hidden_visibility: true, - .. Default::default() }; Ok(Target { diff --git a/src/librustc_borrowck/borrowck/unused.rs b/src/librustc_borrowck/borrowck/unused.rs index 7bcd8a185453b..ddee122d0a6bd 100644 --- a/src/librustc_borrowck/borrowck/unused.rs +++ b/src/librustc_borrowck/borrowck/unused.rs @@ -77,7 +77,7 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> { continue } - let mut_span = tcx.sess.codemap().span_until_non_whitespace(ids[0].2); + let mut_span = tcx.sess.codemap().span_until_char(ids[0].2, ' '); // Ok, every name wasn't used mutably, so issue a warning that this // didn't need to be mutable. diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index ae53ed0e1140d..fd171b8992470 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -127,16 +127,13 @@ impl<'a, 'tcx> Visitor<'tcx> for MatchVisitor<'a, 'tcx> { } } - impl<'a, 'tcx> PatternContext<'a, 'tcx> { fn report_inlining_errors(&self, pat_span: Span) { for error in &self.errors { match *error { PatternError::StaticInPattern(span) => { - self.span_e0158(span, "statics cannot be referenced in patterns") - } - PatternError::AssociatedConstInPattern(span) => { - self.span_e0158(span, "associated consts cannot be referenced in patterns") + span_err!(self.tcx.sess, span, E0158, + "statics cannot be referenced in patterns"); } PatternError::ConstEval(ref err) => { err.report(self.tcx, pat_span, "pattern"); @@ -144,10 +141,6 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } } } - - fn span_e0158(&self, span: Span, text: &str) { - span_err!(self.tcx.sess, span, E0158, "{}", text) - } } impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { diff --git a/src/librustc_const_eval/pattern.rs b/src/librustc_const_eval/pattern.rs index e0b3929e32a8d..3577feaf90c1a 100644 --- a/src/librustc_const_eval/pattern.rs +++ b/src/librustc_const_eval/pattern.rs @@ -27,7 +27,6 @@ use syntax_pos::Span; #[derive(Clone, Debug)] pub enum PatternError<'tcx> { - AssociatedConstInPattern(Span), StaticInPattern(Span), ConstEval(ConstEvalErr<'tcx>), } @@ -636,10 +635,6 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { -> Pattern<'tcx> { let ty = self.tables.node_id_to_type(id); let def = self.tables.qpath_def(qpath, id); - let is_associated_const = match def { - Def::AssociatedConst(_) => true, - _ => false, - }; let kind = match def { Def::Const(def_id) | Def::AssociatedConst(def_id) => { let substs = self.tables.node_substs(id); @@ -661,11 +656,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { return pat; } None => { - self.errors.push(if is_associated_const { - PatternError::AssociatedConstInPattern(span) - } else { - PatternError::StaticInPattern(span) - }); + self.errors.push(PatternError::StaticInPattern(span)); PatternKind::Wild } } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 05dcaf731352a..6118ee94c84cf 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -167,8 +167,7 @@ pub fn run(run_compiler: F) -> isize let emitter = errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None, - true, - false); + true); let handler = errors::Handler::with_emitter(true, false, Box::new(emitter)); handler.emit(&MultiSpan::new(), "aborting due to previous error(s)", @@ -290,7 +289,7 @@ fn get_trans_sysroot(backend_name: &str) -> fn() -> Box { let sysroot = sysroot_candidates.iter() .map(|sysroot| { let libdir = filesearch::relative_target_lib_path(&sysroot, &target); - sysroot.join(libdir).with_file_name("codegen-backends") + sysroot.join(&libdir).join("codegen-backends") }) .filter(|f| { info!("codegen backend candidate: {}", f.display()); @@ -457,13 +456,10 @@ pub fn run_compiler<'a>(args: &[String], None); let (odir, ofile) = make_output(&matches); - let (input, input_file_path, input_err) = match make_input(&matches.free) { - Some((input, input_file_path, input_err)) => { - let (input, input_file_path) = callbacks.some_input(input, input_file_path); - (input, input_file_path, input_err) - }, + let (input, input_file_path) = match make_input(&matches.free) { + Some((input, input_file_path)) => callbacks.some_input(input, input_file_path), None => match callbacks.no_input(&matches, &sopts, &cfg, &odir, &ofile, &descriptions) { - Some((input, input_file_path)) => (input, input_file_path, None), + Some((input, input_file_path)) => (input, input_file_path), None => return (Ok(()), None), }, }; @@ -474,13 +470,6 @@ pub fn run_compiler<'a>(args: &[String], sopts, input_file_path.clone(), descriptions, codemap, emitter_dest, ); - if let Some(err) = input_err { - // Immediately stop compilation if there was an issue reading - // the input (for example if the input stream is not UTF-8). - sess.err(&format!("{}", err)); - return (Err(CompileIncomplete::Stopped), Some(sess)); - } - let trans = get_trans(&sess); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); @@ -523,22 +512,17 @@ fn make_output(matches: &getopts::Matches) -> (Option, Option) } // Extract input (string or file and optional path) from matches. -fn make_input(free_matches: &[String]) -> Option<(Input, Option, Option)> { +fn make_input(free_matches: &[String]) -> Option<(Input, Option)> { if free_matches.len() == 1 { let ifile = &free_matches[0]; if ifile == "-" { let mut src = String::new(); - let err = if io::stdin().read_to_string(&mut src).is_err() { - Some(io::Error::new(io::ErrorKind::InvalidData, - "couldn't read from stdin, as it did not contain valid UTF-8")) - } else { - None - }; + io::stdin().read_to_string(&mut src).unwrap(); Some((Input::Str { name: FileName::Anon, input: src }, - None, err)) + None)) } else { Some((Input::File(PathBuf::from(ifile)), - Some(PathBuf::from(ifile)), None)) + Some(PathBuf::from(ifile)))) } } else { None @@ -1450,7 +1434,6 @@ pub fn monitor(f: F) { let emitter = Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None, - false, false)); let handler = errors::Handler::with_emitter(true, false, emitter); diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 40e4efb397d30..2e654fe9929a6 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -222,7 +222,6 @@ impl Diagnostic { }], msg: msg.to_owned(), show_code_when_inline: false, - approximate: false, }); self } @@ -253,7 +252,6 @@ impl Diagnostic { }], msg: msg.to_owned(), show_code_when_inline: true, - approximate: false, }); self } @@ -269,41 +267,6 @@ impl Diagnostic { }).collect(), msg: msg.to_owned(), show_code_when_inline: true, - approximate: false, - }); - self - } - - /// This is a suggestion that may contain mistakes or fillers and should - /// be read and understood by a human. - pub fn span_approximate_suggestion(&mut self, sp: Span, msg: &str, - suggestion: String) -> &mut Self { - self.suggestions.push(CodeSuggestion { - substitutions: vec![Substitution { - parts: vec![SubstitutionPart { - snippet: suggestion, - span: sp, - }], - }], - msg: msg.to_owned(), - show_code_when_inline: true, - approximate: true, - }); - self - } - - pub fn span_approximate_suggestions(&mut self, sp: Span, msg: &str, - suggestions: Vec) -> &mut Self { - self.suggestions.push(CodeSuggestion { - substitutions: suggestions.into_iter().map(|snippet| Substitution { - parts: vec![SubstitutionPart { - snippet, - span: sp, - }], - }).collect(), - msg: msg.to_owned(), - show_code_when_inline: true, - approximate: true, }); self } diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 2536fc648c70a..61674ada6fa63 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -186,16 +186,6 @@ impl<'a> DiagnosticBuilder<'a> { msg: &str, suggestions: Vec) -> &mut Self); - forward!(pub fn span_approximate_suggestion(&mut self, - sp: Span, - msg: &str, - suggestion: String) - -> &mut Self); - forward!(pub fn span_approximate_suggestions(&mut self, - sp: Span, - msg: &str, - suggestions: Vec) - -> &mut Self); forward!(pub fn set_span>(&mut self, sp: S) -> &mut Self); forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self); diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index a49284eb55a46..8a4fd24a29b89 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -106,7 +106,6 @@ pub struct EmitterWriter { dst: Destination, cm: Option>, short_message: bool, - teach: bool, } struct FileWithAnnotatedLines { @@ -118,37 +117,32 @@ struct FileWithAnnotatedLines { impl EmitterWriter { pub fn stderr(color_config: ColorConfig, code_map: Option>, - short_message: bool, - teach: bool) + short_message: bool) -> EmitterWriter { if color_config.use_color() { let dst = Destination::from_stderr(); EmitterWriter { dst, cm: code_map, - short_message, - teach, + short_message: short_message, } } else { EmitterWriter { dst: Raw(Box::new(io::stderr())), cm: code_map, - short_message, - teach, + short_message: short_message, } } } pub fn new(dst: Box, code_map: Option>, - short_message: bool, - teach: bool) + short_message: bool) -> EmitterWriter { EmitterWriter { dst: Raw(dst), cm: code_map, - short_message, - teach, + short_message: short_message, } } @@ -290,10 +284,6 @@ impl EmitterWriter { line: &Line, width_offset: usize, code_offset: usize) -> Vec<(usize, Style)> { - if line.line_index == 0 { - return Vec::new(); - } - let source_string = match file.get_line(line.line_index - 1) { Some(s) => s, None => return Vec::new(), @@ -561,14 +551,7 @@ impl EmitterWriter { code_offset + annotation.start_col, style); } - _ if self.teach => { - buffer.set_style_range(line_offset, - code_offset + annotation.start_col, - code_offset + annotation.end_col, - style, - annotation.is_primary); - } - _ => {} + _ => (), } } @@ -1031,21 +1014,8 @@ impl EmitterWriter { // Then, the secondary file indicator buffer.prepend(buffer_msg_line_offset + 1, "::: ", Style::LineNumber); - let loc = if let Some(first_line) = annotated_file.lines.first() { - let col = if let Some(first_annotation) = first_line.annotations.first() { - format!(":{}", first_annotation.start_col + 1) - } else { - "".to_string() - }; - format!("{}:{}{}", - annotated_file.file.name, - cm.doctest_offset_line(first_line.line_index), - col) - } else { - annotated_file.file.name.to_string() - }; buffer.append(buffer_msg_line_offset + 1, - &loc, + &annotated_file.file.name.to_string(), Style::LineAndColumn); for _ in 0..max_line_num_len { buffer.prepend(buffer_msg_line_offset + 1, " ", Style::NoStyle); diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 236698ed2d45d..3d50c95d3f4f9 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -83,12 +83,6 @@ pub struct CodeSuggestion { pub substitutions: Vec, pub msg: String, pub show_code_when_inline: bool, - /// Whether or not the suggestion is approximate - /// - /// Sometimes we may show suggestions with placeholders, - /// which are useful for users but not useful for - /// tools like rustfix - pub approximate: bool, } #[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] @@ -303,7 +297,7 @@ impl Handler { cm: Option>, flags: HandlerFlags) -> Handler { - let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false)); + let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false)); Handler::with_emitter_and_flags(emitter, flags) } diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index 6035f33c822ce..c2f4701999ea9 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -27,8 +27,7 @@ pub struct FileInfo { /// The "primary file", if any, gets a `-->` marker instead of /// `>>>`, and has a line-number/column printed and not just a - /// filename (other files are not guaranteed to have line numbers - /// or columns). It appears first in the listing. It is known to + /// filename. It appears first in the listing. It is known to /// contain at least one primary span, though primary spans (which /// are designated with `^^^`) may also occur in other files. primary_span: Option, diff --git a/src/librustc_errors/styled_buffer.rs b/src/librustc_errors/styled_buffer.rs index 2c736ec22c3b3..2c33f80520360 100644 --- a/src/librustc_errors/styled_buffer.rs +++ b/src/librustc_errors/styled_buffer.rs @@ -144,25 +144,4 @@ impl StyledBuffer { pub fn num_lines(&self) -> usize { self.text.len() } - - pub fn set_style_range(&mut self, - line: usize, - col_start: usize, - col_end: usize, - style: Style, - overwrite: bool) { - for col in col_start..col_end { - self.set_style(line, col, style, overwrite); - } - } - - pub fn set_style(&mut self, line: usize, col: usize, style: Style, overwrite: bool) { - if let Some(ref mut line) = self.styles.get_mut(line) { - if let Some(s) = line.get_mut(col) { - if *s == Style::NoStyle || *s == Style::Quotation || overwrite { - *s = style; - } - } - } - } } diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index e9471cdb4f949..806d787c84522 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -107,7 +107,6 @@ use rustc::dep_graph::WorkProductId; use rustc::hir::def_id::DefId; use rustc::hir::map::DefPathData; use rustc::mir::mono::{Linkage, Visibility}; -use rustc::middle::exported_symbols::SymbolExportLevel; use rustc::ty::{self, TyCtxt, InstanceDef}; use rustc::ty::item_path::characteristic_def_id_of_type; use rustc::util::nodemap::{FxHashMap, FxHashSet}; @@ -323,16 +322,7 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, .or_insert_with(make_codegen_unit); let mut can_be_internalized = true; - let default_visibility = |id: DefId| { - if tcx.sess.target.target.options.default_hidden_visibility && - tcx.symbol_export_level(id) != SymbolExportLevel::C - { - Visibility::Hidden - } else { - Visibility::Default - } - }; - let (linkage, mut visibility) = match trans_item.explicit_linkage(tcx) { + let (linkage, visibility) = match trans_item.explicit_linkage(tcx) { Some(explicit_linkage) => (explicit_linkage, Visibility::Default), None => { match trans_item { @@ -362,8 +352,7 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, Visibility::Hidden } else if def_id.is_local() { if tcx.is_exported_symbol(def_id) { - can_be_internalized = false; - default_visibility(def_id) + Visibility::Default } else { Visibility::Hidden } @@ -386,8 +375,7 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, MonoItem::GlobalAsm(node_id) => { let def_id = tcx.hir.local_def_id(node_id); let visibility = if tcx.is_exported_symbol(def_id) { - can_be_internalized = false; - default_visibility(def_id) + Visibility::Default } else { Visibility::Hidden }; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 2da4bfedd3a17..ecf3c9e42d58f 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3998,20 +3998,14 @@ impl<'a> Resolver<'a> { if let (Ok(snippet), false) = (cm.span_to_snippet(binding.span), binding.is_renamed_extern_crate()) { - let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() { - format!("Other{}", name) - } else { - format!("other_{}", name) - }; - err.span_suggestion(binding.span, rename_msg, if snippet.ends_with(';') { - format!("{} as {};", + format!("{} as Other{};", &snippet[..snippet.len()-1], - suggested_name) + name) } else { - format!("{} as {}", snippet, suggested_name) + format!("{} as Other{}", snippet, name) }); } else { err.span_label(binding.span, rename_msg); diff --git a/src/librustc_trans/allocator.rs b/src/librustc_trans/allocator.rs index e1c145b122d76..fd5aa1364d381 100644 --- a/src/librustc_trans/allocator.rs +++ b/src/librustc_trans/allocator.rs @@ -86,10 +86,6 @@ pub(crate) unsafe fn trans(tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind) name.as_ptr(), ty); - if tcx.sess.target.target.options.default_hidden_visibility { - llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden); - } - let callee = CString::new(kind.fn_name(method.name)).unwrap(); let callee = llvm::LLVMRustGetOrInsertFunction(llmod, callee.as_ptr(), diff --git a/src/librustc_trans/asm.rs b/src/librustc_trans/asm.rs index 751f8148a2a90..c7be0c4e67d71 100644 --- a/src/librustc_trans/asm.rs +++ b/src/librustc_trans/asm.rs @@ -59,9 +59,8 @@ pub fn trans_inline_asm<'a, 'tcx>( // Default per-arch clobbers // Basically what clang does let arch_clobbers = match &bx.sess().target.target.arch[..] { - "x86" | "x86_64" => vec!["~{dirflag}", "~{fpsr}", "~{flags}"], - "mips" | "mips64" => vec!["~{$1}"], - _ => Vec::new() + "x86" | "x86_64" => vec!["~{dirflag}", "~{fpsr}", "~{flags}"], + _ => Vec::new() }; let all_constraints = diff --git a/src/librustc_trans/back/symbol_export.rs b/src/librustc_trans/back/symbol_export.rs index 989ef8a953746..15ff59c7df998 100644 --- a/src/librustc_trans/back/symbol_export.rs +++ b/src/librustc_trans/back/symbol_export.rs @@ -133,8 +133,6 @@ pub fn provide(providers: &mut Providers) { Arc::new(local_crate) }; - - providers.symbol_export_level = export_level; } pub fn provide_extern(providers: &mut Providers) { @@ -205,7 +203,6 @@ pub fn provide_extern(providers: &mut Providers) { Arc::new(crate_exports) }; - providers.symbol_export_level = export_level; } fn export_level(tcx: TyCtxt, sym_def_id: DefId) -> SymbolExportLevel { diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 206c73b017459..8afa63a5e9735 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -824,7 +824,9 @@ fn binaryen_assemble(cgcx: &CodegenContext, if cgcx.debuginfo != config::NoDebugInfo { options.debuginfo(true); } - + if cgcx.crate_types.contains(&config::CrateTypeExecutable) { + options.start("main"); + } options.stack(1024 * 1024); options.import_memory(cgcx.wasm_import_memory); let assembled = input.and_then(|input| { @@ -1450,7 +1452,7 @@ fn start_executing_work(tcx: TyCtxt, target_pointer_width: tcx.sess.target.target.target_pointer_width.clone(), binaryen_linker: tcx.sess.linker_flavor() == LinkerFlavor::Binaryen, debuginfo: tcx.sess.opts.debuginfo, - wasm_import_memory, + wasm_import_memory: wasm_import_memory, assembler_cmd, }; diff --git a/src/librustc_trans/llvm_util.rs b/src/librustc_trans/llvm_util.rs index 843231d376f6c..15988008de2fc 100644 --- a/src/librustc_trans/llvm_util.rs +++ b/src/librustc_trans/llvm_util.rs @@ -79,16 +79,16 @@ unsafe fn configure_llvm(sess: &Session) { // detection code will walk past the end of the feature array, // leading to crashes. -const ARM_WHITELIST: &'static [&'static str] = &["neon\0", "v7\0", "vfp2\0", "vfp3\0", "vfp4\0"]; +const ARM_WHITELIST: &'static [&'static str] = &["neon\0", "vfp2\0", "vfp3\0", "vfp4\0"]; -const AARCH64_WHITELIST: &'static [&'static str] = &["neon\0", "v7\0"]; +const AARCH64_WHITELIST: &'static [&'static str] = &["neon\0"]; const X86_WHITELIST: &'static [&'static str] = &["avx\0", "avx2\0", "bmi\0", "bmi2\0", "sse\0", "sse2\0", "sse3\0", "sse4.1\0", "sse4.2\0", "ssse3\0", "tbm\0", "lzcnt\0", "popcnt\0", "sse4a\0", "rdrnd\0", "rdseed\0", "fma\0", "xsave\0", "xsaveopt\0", "xsavec\0", - "xsaves\0", "aes\0", + "xsaves\0", "avx512bw\0", "avx512cd\0", "avx512dq\0", "avx512er\0", "avx512f\0", "avx512ifma\0", diff --git a/src/librustc_trans/type_of.rs b/src/librustc_trans/type_of.rs index af957500f7002..b1533cfad19f5 100644 --- a/src/librustc_trans/type_of.rs +++ b/src/librustc_trans/type_of.rs @@ -57,9 +57,7 @@ fn uncached_llvm_type<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, ty::TyClosure(..) | ty::TyGenerator(..) | ty::TyAdt(..) | - // FIXME(eddyb) producing readable type names for trait objects can result - // in problematically distinct types due to HRTB and subtyping (see #47638). - // ty::TyDynamic(..) | + ty::TyDynamic(..) | ty::TyForeign(..) | ty::TyStr => { let mut name = String::with_capacity(32); diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 4c10f28eb8e5d..570eecfc267de 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -40,8 +40,6 @@ pub fn compare_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, debug!("compare_impl_method(impl_trait_ref={:?})", impl_trait_ref); - let impl_m_span = tcx.sess.codemap().def_span(impl_m_span); - if let Err(ErrorReported) = compare_self_type(tcx, impl_m, impl_m_span, @@ -188,7 +186,6 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, check_region_bounds_on_impl_method(tcx, impl_m_span, impl_m, - trait_m, &trait_m_generics, &impl_m_generics, trait_to_skol_substs)?; @@ -313,7 +310,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; let mut diag = struct_span_err!(tcx.sess, - cause.span(&tcx), + cause.span, E0053, "method `{}` has an incompatible type for trait", trait_m.name); @@ -349,12 +346,10 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span, impl_m: &ty::AssociatedItem, - trait_m: &ty::AssociatedItem, trait_generics: &ty::Generics, impl_generics: &ty::Generics, trait_to_skol_substs: &Substs<'tcx>) -> Result<(), ErrorReported> { - let span = tcx.sess.codemap().def_span(span); let trait_params = &trait_generics.regions[..]; let impl_params = &impl_generics.regions[..]; @@ -376,18 +371,14 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // are zero. Since I don't quite know how to phrase things at // the moment, give a kind of vague error message. if trait_params.len() != impl_params.len() { - let mut err = struct_span_err!(tcx.sess, - span, - E0195, - "lifetime parameters or bounds on method `{}` do not match \ - the trait declaration", - impl_m.name); - err.span_label(span, "lifetimes do not match method in trait"); - if let Some(sp) = tcx.hir.span_if_local(trait_m.def_id) { - err.span_label(tcx.sess.codemap().def_span(sp), - "lifetimes in impl do not match this method in trait"); - } - err.emit(); + struct_span_err!(tcx.sess, + span, + E0195, + "lifetime parameters or bounds on method `{}` do not match the \ + trait declaration", + impl_m.name) + .span_label(span, "lifetimes do not match trait") + .emit(); return Err(ErrorReported); } @@ -433,9 +424,9 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a }).map(|(ref impl_arg, ref trait_arg)| { (impl_arg.span, Some(trait_arg.span)) }) - .unwrap_or_else(|| (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id))) + .unwrap_or_else(|| (cause.span, tcx.hir.span_if_local(trait_m.def_id))) } else { - (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)) + (cause.span, tcx.hir.span_if_local(trait_m.def_id)) } } TypeError::Sorts(ExpectedFound { .. }) => { @@ -468,14 +459,14 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a { (impl_m_output.span(), Some(trait_m_output.span())) } else { - (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)) + (cause.span, tcx.hir.span_if_local(trait_m.def_id)) } }) } else { - (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)) + (cause.span, tcx.hir.span_if_local(trait_m.def_id)) } } - _ => (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)), + _ => (cause.span, tcx.hir.span_if_local(trait_m.def_id)), } } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 483dd345286d4..9a3dba440eae1 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -5033,9 +5033,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // If not, error. if alternative.is_ty_var() || alternative.references_error() { if !self.is_tainted_by_errors() { - type_error_struct!(self.tcx.sess, sp, ty, E0619, - "the type of this value must be known in this context") - .emit(); + self.need_type_info((**self).body_id, sp, ty); } self.demand_suptype(sp, self.tcx.types.err, ty); ty = self.tcx.types.err; diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index 88a2dc817ae63..07d5f813cbbce 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -82,37 +82,29 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> { for (i, &impl1_def_id) in impls.iter().enumerate() { for &impl2_def_id in &impls[(i + 1)..] { - let used_to_be_allowed = traits::overlapping_impls( - self.tcx, - impl1_def_id, - impl2_def_id, - IntercrateMode::Issue43355, - |overlap| { + let used_to_be_allowed = self.tcx.infer_ctxt().enter(|infcx| { + if let Some(overlap) = + traits::overlapping_impls(&infcx, impl1_def_id, impl2_def_id, + IntercrateMode::Issue43355) + { self.check_for_common_items_in_impls( - impl1_def_id, - impl2_def_id, - overlap, - false, - ); + impl1_def_id, impl2_def_id, overlap, false); false - }, - || true, - ); + } else { + true + } + }); if used_to_be_allowed { - traits::overlapping_impls( - self.tcx, - impl1_def_id, - impl2_def_id, - IntercrateMode::Fixed, - |overlap| self.check_for_common_items_in_impls( - impl1_def_id, - impl2_def_id, - overlap, - true, - ), - || (), - ); + self.tcx.infer_ctxt().enter(|infcx| { + if let Some(overlap) = + traits::overlapping_impls(&infcx, impl1_def_id, impl2_def_id, + IntercrateMode::Fixed) + { + self.check_for_common_items_in_impls( + impl1_def_id, impl2_def_id, overlap, true); + } + }); } } } diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index ac7f54250d32b..0465a6a0f11bd 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4368,6 +4368,7 @@ i_am_a_function(); "##, E0619: r##" +#### Note: this error code is no longer emitted by the compiler. The type-checker needed to know the type of an expression, but that type had not yet been inferred. diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 82ced00644da8..dce0c4b001a0d 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -872,7 +872,7 @@ pub fn render(w: &mut fmt::Formatter, let link_out = format!("{content}", link = link_buf, title = title.map_or(String::new(), - |t| format!(" title=\"{}\"", Escape(&t))), + |t| format!(" title=\"{}\"", t)), content = content.unwrap_or(String::new())); unsafe { hoedown_buffer_put(ob, link_out.as_ptr(), link_out.len()); } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 087d88419bc84..d61b80c9aa03e 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -238,7 +238,6 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, )); let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()), Some(codemap.clone()), - false, false); let old = io::set_panic(Some(box Sink(data.clone()))); let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout())); diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index c1fe4a89d6ac0..3430ecabcbeae 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -48,4 +48,3 @@ jemalloc = ["alloc_jemalloc"] force_alloc_system = [] panic-unwind = ["panic_unwind"] profiler = ["profiler_builtins"] -wasm_syscall = [] diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 82a687ae5e493..b01420f36a0c3 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1384,14 +1384,9 @@ impl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap { type Output = V; - /// Returns a reference to the value corresponding to the supplied key. - /// - /// # Panics - /// - /// Panics if the key is not present in the `HashMap`. #[inline] - fn index(&self, key: &Q) -> &V { - self.get(key).expect("no entry found for key") + fn index(&self, index: &Q) -> &V { + self.get(index).expect("no entry found for key") } } diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs index bdd675e6e2b85..f0b41f30251e0 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -292,8 +292,8 @@ impl Error { /// # if cfg!(target_os = "linux") { /// use std::io; /// - /// let error = io::Error::from_raw_os_error(22); - /// assert_eq!(error.kind(), io::ErrorKind::InvalidInput); + /// let error = io::Error::from_raw_os_error(98); + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); /// # } /// ``` /// @@ -303,8 +303,8 @@ impl Error { /// # if cfg!(windows) { /// use std::io; /// - /// let error = io::Error::from_raw_os_error(10022); - /// assert_eq!(error.kind(), io::ErrorKind::InvalidInput); + /// let error = io::Error::from_raw_os_error(10048); + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); /// # } /// ``` #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 9b2f815b71383..5c66ac6ddded8 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1843,10 +1843,4 @@ mod tests { } assert!(events > 0); } - - #[test] - fn test_command_implements_send() { - fn take_send_type(_: T) {} - take_send_type(Command::new("")) - } } diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 7e057401fab70..c53bcdbf8e36f 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -45,7 +45,7 @@ pub struct Command { // other keys. program: CString, args: Vec, - argv: Argv, + argv: Vec<*const c_char>, env: CommandEnv, cwd: Option, @@ -58,12 +58,6 @@ pub struct Command { stderr: Option, } -// Create a new type for argv, so that we can make it `Send` -struct Argv(Vec<*const c_char>); - -// It is safe to make Argv Send, because it contains pointers to memory owned by `Command.args` -unsafe impl Send for Argv {} - // passed back to std::process with the pipes connected to the child, if any // were requested pub struct StdioPipes { @@ -98,7 +92,7 @@ impl Command { let mut saw_nul = false; let program = os2c(program, &mut saw_nul); Command { - argv: Argv(vec![program.as_ptr(), ptr::null()]), + argv: vec![program.as_ptr(), ptr::null()], program, args: Vec::new(), env: Default::default(), @@ -117,8 +111,8 @@ impl Command { // Overwrite the trailing NULL pointer in `argv` and then add a new null // pointer. let arg = os2c(arg, &mut self.saw_nul); - self.argv.0[self.args.len() + 1] = arg.as_ptr(); - self.argv.0.push(ptr::null()); + self.argv[self.args.len() + 1] = arg.as_ptr(); + self.argv.push(ptr::null()); // Also make sure we keep track of the owned value to schedule a // destructor for this memory. @@ -139,7 +133,7 @@ impl Command { self.saw_nul } pub fn get_argv(&self) -> &Vec<*const c_char> { - &self.argv.0 + &self.argv } #[allow(dead_code)] diff --git a/src/libstd/sys/wasm/args.rs b/src/libstd/sys/wasm/args.rs index b3c6b671e8099..d2a4a7b19d548 100644 --- a/src/libstd/sys/wasm/args.rs +++ b/src/libstd/sys/wasm/args.rs @@ -10,8 +10,8 @@ use ffi::OsString; use marker::PhantomData; +use mem; use vec; -use sys::ArgsSysCall; pub unsafe fn init(_argc: isize, _argv: *const *const u8) { // On wasm these should always be null, so there's nothing for us to do here @@ -21,10 +21,38 @@ pub unsafe fn cleanup() { } pub fn args() -> Args { - let v = ArgsSysCall::perform(); - Args { - iter: v.into_iter(), - _dont_send_or_sync_me: PhantomData, + // When the runtime debugging is enabled we'll link to some extra runtime + // functions to actually implement this. These are for now just implemented + // in a node.js script but they're off by default as they're sort of weird + // in a web-wasm world. + if !super::DEBUG { + return Args { + iter: Vec::new().into_iter(), + _dont_send_or_sync_me: PhantomData, + } + } + + // You'll find the definitions of these in `src/etc/wasm32-shim.js`. These + // are just meant for debugging and should not be relied on. + extern { + fn rust_wasm_args_count() -> usize; + fn rust_wasm_args_arg_size(a: usize) -> usize; + fn rust_wasm_args_arg_fill(a: usize, ptr: *mut u8); + } + + unsafe { + let cnt = rust_wasm_args_count(); + let mut v = Vec::with_capacity(cnt); + for i in 0..cnt { + let n = rust_wasm_args_arg_size(i); + let mut data = vec![0; n]; + rust_wasm_args_arg_fill(i, data.as_mut_ptr()); + v.push(mem::transmute::, OsString>(data)); + } + Args { + iter: v.into_iter(), + _dont_send_or_sync_me: PhantomData, + } } } diff --git a/src/libstd/sys/wasm/mod.rs b/src/libstd/sys/wasm/mod.rs index c02e5e809c8bb..ba3d6a2813a45 100644 --- a/src/libstd/sys/wasm/mod.rs +++ b/src/libstd/sys/wasm/mod.rs @@ -26,11 +26,17 @@ use io; use os::raw::c_char; -use ptr; -use sys::os_str::Buf; -use sys_common::{AsInner, FromInner}; -use ffi::{OsString, OsStr}; -use time::Duration; + +// Right now the wasm backend doesn't even have the ability to print to the +// console by default. Wasm can't import anything from JS! (you have to +// explicitly provide it). +// +// Sometimes that's a real bummer, though, so this flag can be set to `true` to +// enable calling various shims defined in `src/etc/wasm32-shim.js` which should +// help receive debug output and see what's going on. In general this flag +// currently controls "will we call out to our own defined shims in node.js", +// and this flag should always be `false` for release builds. +const DEBUG: bool = false; pub mod args; #[cfg(feature = "backtrace")] @@ -86,7 +92,7 @@ pub unsafe fn strlen(mut s: *const c_char) -> usize { } pub unsafe fn abort_internal() -> ! { - ExitSysCall::perform(1) + ::intrinsics::abort(); } // We don't have randomness yet, but I totally used a random number generator to @@ -97,218 +103,3 @@ pub unsafe fn abort_internal() -> ! { pub fn hashmap_random_keys() -> (u64, u64) { (1, 2) } - -// Implement a minimal set of system calls to enable basic IO -pub enum SysCallIndex { - Read = 0, - Write = 1, - Exit = 2, - Args = 3, - GetEnv = 4, - SetEnv = 5, - Time = 6, -} - -#[repr(C)] -pub struct ReadSysCall { - fd: usize, - ptr: *mut u8, - len: usize, - result: usize, -} - -impl ReadSysCall { - pub fn perform(fd: usize, buffer: &mut [u8]) -> usize { - let mut call_record = ReadSysCall { - fd, - len: buffer.len(), - ptr: buffer.as_mut_ptr(), - result: 0 - }; - if unsafe { syscall(SysCallIndex::Read, &mut call_record) } { - call_record.result - } else { - 0 - } - } -} - -#[repr(C)] -pub struct WriteSysCall { - fd: usize, - ptr: *const u8, - len: usize, -} - -impl WriteSysCall { - pub fn perform(fd: usize, buffer: &[u8]) { - let mut call_record = WriteSysCall { - fd, - len: buffer.len(), - ptr: buffer.as_ptr() - }; - unsafe { syscall(SysCallIndex::Write, &mut call_record); } - } -} - -#[repr(C)] -pub struct ExitSysCall { - code: usize, -} - -impl ExitSysCall { - pub fn perform(code: usize) -> ! { - let mut call_record = ExitSysCall { - code - }; - unsafe { - syscall(SysCallIndex::Exit, &mut call_record); - ::intrinsics::abort(); - } - } -} - -fn receive_buffer Result>(estimate: usize, mut f: F) - -> Result, E> -{ - let mut buffer = vec![0; estimate]; - loop { - let result = f(&mut buffer)?; - if result <= buffer.len() { - buffer.truncate(result); - break; - } - buffer.resize(result, 0); - } - Ok(buffer) -} - -#[repr(C)] -pub struct ArgsSysCall { - ptr: *mut u8, - len: usize, - result: usize -} - -impl ArgsSysCall { - pub fn perform() -> Vec { - receive_buffer(1024, |buffer| -> Result { - let mut call_record = ArgsSysCall { - len: buffer.len(), - ptr: buffer.as_mut_ptr(), - result: 0 - }; - if unsafe { syscall(SysCallIndex::Args, &mut call_record) } { - Ok(call_record.result) - } else { - Ok(0) - } - }) - .unwrap() - .split(|b| *b == 0) - .map(|s| FromInner::from_inner(Buf { inner: s.to_owned() })) - .collect() - } -} - -#[repr(C)] -pub struct GetEnvSysCall { - key_ptr: *const u8, - key_len: usize, - value_ptr: *mut u8, - value_len: usize, - result: usize -} - -impl GetEnvSysCall { - pub fn perform(key: &OsStr) -> Option { - let key_buf = &AsInner::as_inner(key).inner; - receive_buffer(64, |buffer| { - let mut call_record = GetEnvSysCall { - key_len: key_buf.len(), - key_ptr: key_buf.as_ptr(), - value_len: buffer.len(), - value_ptr: buffer.as_mut_ptr(), - result: !0usize - }; - if unsafe { syscall(SysCallIndex::GetEnv, &mut call_record) } { - if call_record.result == !0usize { - Err(()) - } else { - Ok(call_record.result) - } - } else { - Err(()) - } - }).ok().map(|s| { - FromInner::from_inner(Buf { inner: s }) - }) - } -} - -#[repr(C)] -pub struct SetEnvSysCall { - key_ptr: *const u8, - key_len: usize, - value_ptr: *const u8, - value_len: usize -} - -impl SetEnvSysCall { - pub fn perform(key: &OsStr, value: Option<&OsStr>) { - let key_buf = &AsInner::as_inner(key).inner; - let value_buf = value.map(|v| &AsInner::as_inner(v).inner); - let mut call_record = SetEnvSysCall { - key_len: key_buf.len(), - key_ptr: key_buf.as_ptr(), - value_len: value_buf.map(|v| v.len()).unwrap_or(!0usize), - value_ptr: value_buf.map(|v| v.as_ptr()).unwrap_or(ptr::null()) - }; - unsafe { syscall(SysCallIndex::SetEnv, &mut call_record); } - } -} - -pub enum TimeClock { - Monotonic = 0, - System = 1, -} - -#[repr(C)] -pub struct TimeSysCall { - clock: usize, - secs_hi: usize, - secs_lo: usize, - nanos: usize -} - -impl TimeSysCall { - pub fn perform(clock: TimeClock) -> Duration { - let mut call_record = TimeSysCall { - clock: clock as usize, - secs_hi: 0, - secs_lo: 0, - nanos: 0 - }; - if unsafe { syscall(SysCallIndex::Time, &mut call_record) } { - Duration::new( - ((call_record.secs_hi as u64) << 32) | (call_record.secs_lo as u64), - call_record.nanos as u32 - ) - } else { - panic!("Time system call is not implemented by WebAssembly host"); - } - } -} - -unsafe fn syscall(index: SysCallIndex, data: &mut T) -> bool { - #[cfg(feature = "wasm_syscall")] - extern { - #[no_mangle] - fn rust_wasm_syscall(index: usize, data: *mut Void) -> usize; - } - - #[cfg(not(feature = "wasm_syscall"))] - unsafe fn rust_wasm_syscall(_index: usize, _data: *mut Void) -> usize { 0 } - - rust_wasm_syscall(index as usize, data as *mut T as *mut Void) != 0 -} diff --git a/src/libstd/sys/wasm/os.rs b/src/libstd/sys/wasm/os.rs index 23ca1754719be..c98030f7ebf53 100644 --- a/src/libstd/sys/wasm/os.rs +++ b/src/libstd/sys/wasm/os.rs @@ -8,13 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use core::intrinsics; + use error::Error as StdError; use ffi::{OsString, OsStr}; use fmt; use io; +use mem; use path::{self, PathBuf}; use str; -use sys::{unsupported, Void, ExitSysCall, GetEnvSysCall, SetEnvSysCall}; +use sys::{unsupported, Void}; pub fn errno() -> i32 { 0 @@ -84,15 +87,36 @@ pub fn env() -> Env { } pub fn getenv(k: &OsStr) -> io::Result> { - Ok(GetEnvSysCall::perform(k)) + // If we're debugging the runtime then we actually probe node.js to ask for + // the value of environment variables to help provide inputs to programs. + // The `extern` shims here are defined in `src/etc/wasm32-shim.js` and are + // intended for debugging only, you should not rely on them. + if !super::DEBUG { + return Ok(None) + } + + extern { + fn rust_wasm_getenv_len(k: *const u8, kl: usize) -> isize; + fn rust_wasm_getenv_data(k: *const u8, kl: usize, v: *mut u8); + } + unsafe { + let k: &[u8] = mem::transmute(k); + let n = rust_wasm_getenv_len(k.as_ptr(), k.len()); + if n == -1 { + return Ok(None) + } + let mut data = vec![0; n as usize]; + rust_wasm_getenv_data(k.as_ptr(), k.len(), data.as_mut_ptr()); + Ok(Some(mem::transmute(data))) + } } -pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> { - Ok(SetEnvSysCall::perform(k, Some(v))) +pub fn setenv(_k: &OsStr, _v: &OsStr) -> io::Result<()> { + unsupported() } -pub fn unsetenv(k: &OsStr) -> io::Result<()> { - Ok(SetEnvSysCall::perform(k, None)) +pub fn unsetenv(_n: &OsStr) -> io::Result<()> { + unsupported() } pub fn temp_dir() -> PathBuf { @@ -104,7 +128,7 @@ pub fn home_dir() -> Option { } pub fn exit(_code: i32) -> ! { - ExitSysCall::perform(_code as isize as usize) + unsafe { intrinsics::abort() } } pub fn getpid() -> u32 { diff --git a/src/libstd/sys/wasm/stdio.rs b/src/libstd/sys/wasm/stdio.rs index beb19c0ed2c1f..0f75f24025183 100644 --- a/src/libstd/sys/wasm/stdio.rs +++ b/src/libstd/sys/wasm/stdio.rs @@ -9,19 +9,19 @@ // except according to those terms. use io; -use sys::{ReadSysCall, WriteSysCall}; +use sys::{Void, unsupported}; -pub struct Stdin; +pub struct Stdin(Void); pub struct Stdout; pub struct Stderr; impl Stdin { pub fn new() -> io::Result { - Ok(Stdin) + unsupported() } - pub fn read(&self, data: &mut [u8]) -> io::Result { - Ok(ReadSysCall::perform(0, data)) + pub fn read(&self, _data: &mut [u8]) -> io::Result { + match self.0 {} } } @@ -31,7 +31,19 @@ impl Stdout { } pub fn write(&self, data: &[u8]) -> io::Result { - WriteSysCall::perform(1, data); + // If runtime debugging is enabled at compile time we'll invoke some + // runtime functions that are defined in our src/etc/wasm32-shim.js + // debugging script. Note that this ffi function call is intended + // *purely* for debugging only and should not be relied upon. + if !super::DEBUG { + return unsupported() + } + extern { + fn rust_wasm_write_stdout(data: *const u8, len: usize); + } + unsafe { + rust_wasm_write_stdout(data.as_ptr(), data.len()) + } Ok(data.len()) } @@ -46,7 +58,16 @@ impl Stderr { } pub fn write(&self, data: &[u8]) -> io::Result { - WriteSysCall::perform(2, data); + // See comments in stdout for what's going on here. + if !super::DEBUG { + return unsupported() + } + extern { + fn rust_wasm_write_stderr(data: *const u8, len: usize); + } + unsafe { + rust_wasm_write_stderr(data.as_ptr(), data.len()) + } Ok(data.len()) } diff --git a/src/libstd/sys/wasm/time.rs b/src/libstd/sys/wasm/time.rs index e52435e63398f..c269def98f6ff 100644 --- a/src/libstd/sys/wasm/time.rs +++ b/src/libstd/sys/wasm/time.rs @@ -8,50 +8,56 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use fmt; use time::Duration; -use sys::{TimeSysCall, TimeClock}; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] -pub struct Instant(Duration); +pub struct Instant; -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] -pub struct SystemTime(Duration); +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct SystemTime; -pub const UNIX_EPOCH: SystemTime = SystemTime(Duration::from_secs(0)); +pub const UNIX_EPOCH: SystemTime = SystemTime; impl Instant { pub fn now() -> Instant { - Instant(TimeSysCall::perform(TimeClock::Monotonic)) + panic!("not supported on web assembly"); } - pub fn sub_instant(&self, other: &Instant) -> Duration { - self.0 - other.0 + pub fn sub_instant(&self, _other: &Instant) -> Duration { + panic!("can't sub yet"); } - pub fn add_duration(&self, other: &Duration) -> Instant { - Instant(self.0 + *other) + pub fn add_duration(&self, _other: &Duration) -> Instant { + panic!("can't add yet"); } - pub fn sub_duration(&self, other: &Duration) -> Instant { - Instant(self.0 - *other) + pub fn sub_duration(&self, _other: &Duration) -> Instant { + panic!("can't sub yet"); } } impl SystemTime { pub fn now() -> SystemTime { - SystemTime(TimeSysCall::perform(TimeClock::System)) + panic!("not supported on web assembly"); } - pub fn sub_time(&self, other: &SystemTime) + pub fn sub_time(&self, _other: &SystemTime) -> Result { - self.0.checked_sub(other.0).ok_or_else(|| other.0 - self.0) + panic!() + } + + pub fn add_duration(&self, _other: &Duration) -> SystemTime { + panic!() } - pub fn add_duration(&self, other: &Duration) -> SystemTime { - SystemTime(self.0 + *other) + pub fn sub_duration(&self, _other: &Duration) -> SystemTime { + panic!() } +} - pub fn sub_duration(&self, other: &Duration) -> SystemTime { - SystemTime(self.0 - *other) +impl fmt::Debug for SystemTime { + fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + panic!() } } diff --git a/src/libcore/time.rs b/src/libstd/time/duration.rs similarity index 98% rename from src/libcore/time.rs rename to src/libstd/time/duration.rs index 1a0208d2f25b2..ee444830be450 100644 --- a/src/libcore/time.rs +++ b/src/libstd/time/duration.rs @@ -7,19 +7,6 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -#![stable(feature = "duration_core", since = "1.24.0")] - -//! Temporal quantification. -//! -//! Example: -//! -//! ``` -//! use std::time::Duration; -//! -//! let five_seconds = Duration::new(5, 0); -//! // both declarations are equivalent -//! assert_eq!(Duration::new(5, 0), Duration::from_secs(5)); -//! ``` use iter::Sum; use ops::{Add, Sub, Mul, Div, AddAssign, SubAssign, MulAssign, DivAssign}; @@ -58,7 +45,7 @@ const MICROS_PER_SEC: u64 = 1_000_000; /// /// let ten_millis = Duration::from_millis(10); /// ``` -#[stable(feature = "duration_core", since = "1.24.0")] +#[stable(feature = "duration", since = "1.3.0")] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, Default)] pub struct Duration { secs: u64, diff --git a/src/libstd/time.rs b/src/libstd/time/mod.rs similarity index 99% rename from src/libstd/time.rs rename to src/libstd/time/mod.rs index 12f2a9bb85f83..6ce3b3e8a0031 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time/mod.rs @@ -29,7 +29,9 @@ use sys::time; use sys_common::FromInner; #[stable(feature = "time", since = "1.3.0")] -pub use core::time::Duration; +pub use self::duration::Duration; + +mod duration; /// A measurement of a monotonically nondecreasing clock. /// Opaque and useful only with `Duration`. diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 3601b9ba8a8c1..a6a7f9e20b3a9 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -593,30 +593,8 @@ impl CodeMap { } } - /// Given a `Span`, get a new `Span` covering the first token and all its trailing whitespace or - /// the original `Span`. - /// - /// If `sp` points to `"let mut x"`, then a span pointing at `"let "` will be returned. - pub fn span_until_non_whitespace(&self, sp: Span) -> Span { - if let Ok(snippet) = self.span_to_snippet(sp) { - let mut offset = 0; - // get the bytes width of all the non-whitespace characters - for c in snippet.chars().take_while(|c| !c.is_whitespace()) { - offset += c.len_utf8(); - } - // get the bytes width of all the whitespace characters after that - for c in snippet[offset..].chars().take_while(|c| c.is_whitespace()) { - offset += c.len_utf8(); - } - if offset > 1 { - return sp.with_hi(BytePos(sp.lo().0 + offset as u32)); - } - } - sp - } - - /// Given a `Span`, try to get a shorter span ending just after the first occurrence of `char` - /// `c`. + /// Given a `Span`, try to get a shorter span ending just after the first + /// occurrence of `char` `c`. pub fn span_through_char(&self, sp: Span, c: char) -> Span { if let Ok(snippet) = self.span_to_snippet(sp) { if let Some(offset) = snippet.find(c) { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 1a9849ca5307d..3e3c1618fffb2 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -90,8 +90,8 @@ use codemap::Spanned; use errors::FatalError; use ext::tt::quoted::{self, TokenTree}; use parse::{Directory, ParseSess}; -use parse::parser::{Parser, PathStyle}; -use parse::token::{self, DocComment, Nonterminal, Token}; +use parse::parser::{PathStyle, Parser}; +use parse::token::{self, DocComment, Token, Nonterminal}; use print::pprust; use symbol::keywords; use tokenstream::TokenStream; @@ -100,12 +100,11 @@ use util::small_vector::SmallVector; use std::mem; use std::rc::Rc; use std::collections::HashMap; -use std::collections::hash_map::Entry::{Occupied, Vacant}; +use std::collections::hash_map::Entry::{Vacant, Occupied}; -// To avoid costly uniqueness checks, we require that `MatchSeq` always has a nonempty body. +// To avoid costly uniqueness checks, we require that `MatchSeq` always has +// a nonempty body. -/// Either a sequence of token trees or a single one. This is used as the representation of the -/// sequence of tokens that make up a matcher. #[derive(Clone)] enum TokenTreeOrTokenTreeVec { Tt(TokenTree), @@ -113,8 +112,6 @@ enum TokenTreeOrTokenTreeVec { } impl TokenTreeOrTokenTreeVec { - /// Returns the number of constituent top-level token trees of `self` (top-level in that it - /// will not recursively descend into subtrees). fn len(&self) -> usize { match *self { TtSeq(ref v) => v.len(), @@ -122,7 +119,6 @@ impl TokenTreeOrTokenTreeVec { } } - /// The the `index`-th token tree of `self`. fn get_tt(&self, index: usize) -> TokenTree { match *self { TtSeq(ref v) => v[index].clone(), @@ -131,96 +127,36 @@ impl TokenTreeOrTokenTreeVec { } } -/// An unzipping of `TokenTree`s... see the `stack` field of `MatcherPos`. -/// -/// This is used by `inner_parse_loop` to keep track of delimited submatchers that we have -/// descended into. +/// an unzipping of `TokenTree`s #[derive(Clone)] struct MatcherTtFrame { - /// The "parent" matcher that we are descending into. elts: TokenTreeOrTokenTreeVec, - /// The position of the "dot" in `elts` at the time we descended. idx: usize, } -/// Represents a single "position" (aka "matcher position", aka "item"), as described in the module -/// documentation. #[derive(Clone)] struct MatcherPos { - /// The token or sequence of tokens that make up the matcher + stack: Vec, top_elts: TokenTreeOrTokenTreeVec, - /// The position of the "dot" in this matcher + sep: Option, idx: usize, - /// The beginning position in the source that the beginning of this matcher corresponds to. In - /// other words, the token in the source at `sp_lo` is matched against the first token of the - /// matcher. - sp_lo: BytePos, - - /// For each named metavar in the matcher, we keep track of token trees matched against the - /// metavar by the black box parser. In particular, there may be more than one match per - /// metavar if we are in a repetition (each repetition matches each of the variables). - /// Moreover, matchers and repetitions can be nested; the `matches` field is shared (hence the - /// `Rc`) among all "nested" matchers. `match_lo`, `match_cur`, and `match_hi` keep track of - /// the current position of the `self` matcher position in the shared `matches` list. - /// - /// Also, note that while we are descending into a sequence, matchers are given their own - /// `matches` vector. Only once we reach the end of a full repetition of the sequence do we add - /// all bound matches from the submatcher into the shared top-level `matches` vector. If `sep` - /// and `up` are `Some`, then `matches` is _not_ the shared top-level list. Instead, if one - /// wants the shared `matches`, one should use `up.matches`. + up: Option>, matches: Vec>>, - /// The position in `matches` corresponding to the first metavar in this matcher's sequence of - /// token trees. In other words, the first metavar in the first token of `top_elts` corresponds - /// to `matches[match_lo]`. match_lo: usize, - /// The position in `matches` corresponding to the metavar we are currently trying to match - /// against the source token stream. `match_lo <= match_cur <= match_hi`. match_cur: usize, - /// Similar to `match_lo` except `match_hi` is the position in `matches` of the _last_ metavar - /// in this matcher. match_hi: usize, - - // Specifically used if we are matching a repetition. If we aren't both should be `None`. - /// The separator if we are in a repetition - sep: Option, - /// The "parent" matcher position if we are in a repetition. That is, the matcher position just - /// before we enter the sequence. - up: Option>, - - // Specifically used to "unzip" token trees. By "unzip", we mean to unwrap the delimiters from - // a delimited token tree (e.g. something wrapped in `(` `)`) or to get the contents of a doc - // comment... - /// When matching against matchers with nested delimited submatchers (e.g. `pat ( pat ( .. ) - /// pat ) pat`), we need to keep track of the matchers we are descending into. This stack does - /// that where the bottom of the stack is the outermost matcher. - // Also, throughout the comments, this "descent" is often referred to as "unzipping"... - stack: Vec, + sp_lo: BytePos, } impl MatcherPos { - /// Add `m` as a named match for the `idx`-th metavar. fn push_match(&mut self, idx: usize, m: NamedMatch) { let matches = Rc::make_mut(&mut self.matches[idx]); matches.push(m); } } -/// Represents the possible results of an attempted parse. -pub enum ParseResult { - /// Parsed successfully. - Success(T), - /// Arm failed to match. If the second parameter is `token::Eof`, it indicates an unexpected - /// end of macro invocation. Otherwise, it indicates that no rules expected the given token. - Failure(syntax_pos::Span, Token), - /// Fatal error (malformed macro?). Abort compilation. - Error(syntax_pos::Span, String), -} - -/// A `ParseResult` where the `Success` variant contains a mapping of `Ident`s to `NamedMatch`es. -/// This represents the mapping of metavars to the token trees they bind to. pub type NamedParseResult = ParseResult>>; -/// Count how many metavars are named in the given matcher `ms`. pub fn count_names(ms: &[TokenTree]) -> usize { ms.iter().fold(0, |count, elt| { count + match *elt { @@ -233,38 +169,20 @@ pub fn count_names(ms: &[TokenTree]) -> usize { }) } -/// Initialize `len` empty shared `Vec`s to be used to store matches of metavars. -fn create_matches(len: usize) -> Vec>> { - (0..len).into_iter().map(|_| Rc::new(Vec::new())).collect() -} - -/// Generate the top-level matcher position in which the "dot" is before the first token of the -/// matcher `ms` and we are going to start matching at position `lo` in the source. fn initial_matcher_pos(ms: Vec, lo: BytePos) -> Box { let match_idx_hi = count_names(&ms[..]); let matches = create_matches(match_idx_hi); Box::new(MatcherPos { - // Start with the top level matcher given to us - top_elts: TtSeq(ms), // "elts" is an abbr. for "elements" - // The "dot" is before the first token of the matcher + stack: vec![], + top_elts: TtSeq(ms), + sep: None, idx: 0, - // We start matching with byte `lo` in the source code - sp_lo: lo, - - // Initialize `matches` to a bunch of empty `Vec`s -- one for each metavar in `top_elts`. - // `match_lo` for `top_elts` is 0 and `match_hi` is `matches.len()`. `match_cur` is 0 since - // we haven't actually matched anything yet. + up: None, matches, match_lo: 0, match_cur: 0, match_hi: match_idx_hi, - - // Haven't descended into any delimiters, so empty stack - stack: vec![], - - // Haven't descended into any sequences, so both of these are `None`. - sep: None, - up: None, + sp_lo: lo }) } @@ -284,36 +202,29 @@ fn initial_matcher_pos(ms: Vec, lo: BytePos) -> Box { /// token tree. The depth of the `NamedMatch` structure will therefore depend /// only on the nesting depth of `ast::TTSeq`s in the originating /// token tree it was derived from. + #[derive(Debug, Clone)] pub enum NamedMatch { MatchedSeq(Rc>, syntax_pos::Span), - MatchedNonterminal(Rc), + MatchedNonterminal(Rc) } -/// Takes a sequence of token trees `ms` representing a matcher which successfully matched input -/// and an iterator of items that matched input and produces a `NamedParseResult`. -fn nameize>( - sess: &ParseSess, - ms: &[TokenTree], - mut res: I, -) -> NamedParseResult { - // Recursively descend into each type of matcher (e.g. sequences, delimited, metavars) and make - // sure that each metavar has _exactly one_ binding. If a metavar does not have exactly one - // binding, then there is an error. If it does, then we insert the binding into the - // `NamedParseResult`. - fn n_rec>( - sess: &ParseSess, - m: &TokenTree, - res: &mut I, - ret_val: &mut HashMap>, - ) -> Result<(), (syntax_pos::Span, String)> { +fn nameize>(sess: &ParseSess, ms: &[TokenTree], mut res: I) + -> NamedParseResult { + fn n_rec>(sess: &ParseSess, m: &TokenTree, res: &mut I, + ret_val: &mut HashMap>) + -> Result<(), (syntax_pos::Span, String)> { match *m { - TokenTree::Sequence(_, ref seq) => for next_m in &seq.tts { - n_rec(sess, next_m, res.by_ref(), ret_val)? - }, - TokenTree::Delimited(_, ref delim) => for next_m in &delim.tts { - n_rec(sess, next_m, res.by_ref(), ret_val)?; - }, + TokenTree::Sequence(_, ref seq) => { + for next_m in &seq.tts { + n_rec(sess, next_m, res.by_ref(), ret_val)? + } + } + TokenTree::Delimited(_, ref delim) => { + for next_m in &delim.tts { + n_rec(sess, next_m, res.by_ref(), ret_val)?; + } + } TokenTree::MetaVarDecl(span, _, id) if id.name == keywords::Invalid.name() => { if sess.missing_fragment_specifiers.borrow_mut().remove(&span) { return Err((span, "missing fragment specifier".to_string())); @@ -339,7 +250,7 @@ fn nameize>( let mut ret_val = HashMap::new(); for m in ms { match n_rec(sess, m, res.by_ref(), &mut ret_val) { - Ok(_) => {} + Ok(_) => {}, Err((sp, msg)) => return Error(sp, msg), } } @@ -347,20 +258,25 @@ fn nameize>( Success(ret_val) } -/// Generate an appropriate parsing failure message. For EOF, this is "unexpected end...". For -/// other tokens, this is "unexpected token...". +pub enum ParseResult { + Success(T), + /// Arm failed to match. If the second parameter is `token::Eof`, it + /// indicates an unexpected end of macro invocation. Otherwise, it + /// indicates that no rules expected the given token. + Failure(syntax_pos::Span, Token), + /// Fatal error (malformed macro?). Abort compilation. + Error(syntax_pos::Span, String) +} + pub fn parse_failure_msg(tok: Token) -> String { match tok { token::Eof => "unexpected end of macro invocation".to_string(), - _ => format!( - "no rules expected the token `{}`", - pprust::token_to_string(&tok) - ), + _ => format!("no rules expected the token `{}`", pprust::token_to_string(&tok)), } } /// Perform a token equality check, ignoring syntax context (that is, an unhygienic comparison) -fn token_name_eq(t1: &Token, t2: &Token) -> bool { +fn token_name_eq(t1 : &Token, t2 : &Token) -> bool { if let (Some(id1), Some(id2)) = (t1.ident(), t2.ident()) { id1.name == id2.name } else if let (&token::Lifetime(id1), &token::Lifetime(id2)) = (t1, t2) { @@ -370,121 +286,77 @@ fn token_name_eq(t1: &Token, t2: &Token) -> bool { } } -/// Process the matcher positions of `cur_items` until it is empty. In the process, this will -/// produce more items in `next_items`, `eof_items`, and `bb_items`. -/// -/// For more info about the how this happens, see the module-level doc comments and the inline -/// comments of this function. -/// -/// # Parameters -/// -/// - `sess`: the parsing session into which errors are emitted. -/// - `cur_items`: the set of current items to be processed. This should be empty by the end of a -/// successful execution of this function. -/// - `next_items`: the set of newly generated items. These are used to replenish `cur_items` in -/// the function `parse`. -/// - `eof_items`: the set of items that would be valid if this was the EOF. -/// - `bb_items`: the set of items that are waiting for the black-box parser. -/// - `token`: the current token of the parser. -/// - `span`: the `Span` in the source code corresponding to the token trees we are trying to match -/// against the matcher positions in `cur_items`. -/// -/// # Returns -/// -/// A `ParseResult`. Note that matches are kept track of through the items generated. -fn inner_parse_loop( - sess: &ParseSess, - cur_items: &mut SmallVector>, - next_items: &mut Vec>, - eof_items: &mut SmallVector>, - bb_items: &mut SmallVector>, - token: &Token, - span: syntax_pos::Span, -) -> ParseResult<()> { - // Pop items from `cur_items` until it is empty. +fn create_matches(len: usize) -> Vec>> { + (0..len).into_iter().map(|_| Rc::new(Vec::new())).collect() +} + +fn inner_parse_loop(sess: &ParseSess, + cur_items: &mut SmallVector>, + next_items: &mut Vec>, + eof_items: &mut SmallVector>, + bb_items: &mut SmallVector>, + token: &Token, + span: syntax_pos::Span) + -> ParseResult<()> { while let Some(mut item) = cur_items.pop() { - // When unzipped trees end, remove them. This corresponds to backtracking out of a - // delimited submatcher into which we already descended. In backtracking out again, we need - // to advance the "dot" past the delimiters in the outer matcher. + // When unzipped trees end, remove them while item.idx >= item.top_elts.len() { match item.stack.pop() { Some(MatcherTtFrame { elts, idx }) => { item.top_elts = elts; item.idx = idx + 1; } - None => break, + None => break } } - // Get the current position of the "dot" (`idx`) in `item` and the number of token trees in - // the matcher (`len`). let idx = item.idx; let len = item.top_elts.len(); - // If `idx >= len`, then we are at or past the end of the matcher of `item`. + // at end of sequence if idx >= len { - // We are repeating iff there is a parent. If the matcher is inside of a repetition, - // then we could be at the end of a sequence or at the beginning of the next - // repetition. + // We are repeating iff there is a parent if item.up.is_some() { - // At this point, regardless of whether there is a separator, we should add all - // matches from the complete repetition of the sequence to the shared, top-level - // `matches` list (actually, `up.matches`, which could itself not be the top-level, - // but anyway...). Moreover, we add another item to `cur_items` in which the "dot" - // is at the end of the `up` matcher. This ensures that the "dot" in the `up` - // matcher is also advanced sufficiently. - // - // NOTE: removing the condition `idx == len` allows trailing separators. + // Disregarding the separator, add the "up" case to the tokens that should be + // examined. + // (remove this condition to make trailing seps ok) if idx == len { - // Get the `up` matcher let mut new_pos = item.up.clone().unwrap(); - // Add matches from this repetition to the `matches` of `up` + // update matches (the MBE "parse tree") by appending + // each tree as a subtree. + + // Only touch the binders we have actually bound for idx in item.match_lo..item.match_hi { let sub = item.matches[idx].clone(); let span = span.with_lo(item.sp_lo); new_pos.push_match(idx, MatchedSeq(sub, span)); } - // Move the "dot" past the repetition in `up` new_pos.match_cur = item.match_hi; new_pos.idx += 1; cur_items.push(new_pos); } - // Check if we need a separator. + // Check if we need a separator if idx == len && item.sep.is_some() { - // We have a separator, and it is the current token. We can advance past the - // separator token. - if item.sep - .as_ref() - .map(|sep| token_name_eq(token, sep)) - .unwrap_or(false) - { + // We have a separator, and it is the current token. + if item.sep.as_ref().map(|sep| token_name_eq(token, sep)).unwrap_or(false) { item.idx += 1; next_items.push(item); } - } - // We don't need a separator. Move the "dot" back to the beginning of the matcher - // and try to match again. - else { + } else { // we don't need a separator item.match_cur = item.match_lo; item.idx = 0; cur_items.push(item); } - } - // If we are not in a repetition, then being at the end of a matcher means that we have - // reached the potential end of the input. - else { + } else { + // We aren't repeating, so we must be potentially at the end of the input. eof_items.push(item); } - } - // We are in the middle of a matcher. - else { - // Look at what token in the matcher we are trying to match the current token (`token`) - // against. Depending on that, we may generate new items. + } else { match item.top_elts.get_tt(idx) { - // Need to descend into a sequence + /* need to descend into sequence */ TokenTree::Sequence(sp, seq) => { if seq.op == quoted::KleeneOp::ZeroOrMore { // Examine the case where there are 0 matches of this sequence @@ -512,16 +384,11 @@ fn inner_parse_loop( top_elts: Tt(TokenTree::Sequence(sp, seq)), })); } - - // We need to match a metavar (but the identifier is invalid)... this is an error TokenTree::MetaVarDecl(span, _, id) if id.name == keywords::Invalid.name() => { if sess.missing_fragment_specifiers.borrow_mut().remove(&span) { return Error(span, "missing fragment specifier".to_string()); } } - - // We need to match a metavar with a valid ident... call out to the black-box - // parser by adding an item to `bb_items`. TokenTree::MetaVarDecl(_, _, id) => { // Built-in nonterminals never start with these tokens, // so we can eliminate them from consideration. @@ -529,13 +396,6 @@ fn inner_parse_loop( bb_items.push(item); } } - - // We need to descend into a delimited submatcher or a doc comment. To do this, we - // push the current matcher onto a stack and push a new item containing the - // submatcher onto `cur_items`. - // - // At the beginning of the loop, if we reach the end of the delimited submatcher, - // we pop the stack to backtrack out of the descent. seq @ TokenTree::Delimited(..) | seq @ TokenTree::Token(_, DocComment(..)) => { let lower_elts = mem::replace(&mut item.top_elts, Tt(seq)); let idx = item.idx; @@ -546,76 +406,36 @@ fn inner_parse_loop( item.idx = 0; cur_items.push(item); } - - // We just matched a normal token. We can just advance the parser. TokenTree::Token(_, ref t) if token_name_eq(t, token) => { item.idx += 1; next_items.push(item); } - - // There was another token that was not `token`... This means we can't add any - // rules. NOTE that this is not necessarily an error unless _all_ items in - // `cur_items` end up doing this. There may still be some other matchers that do - // end up working out. TokenTree::Token(..) | TokenTree::MetaVar(..) => {} } } } - // Yay a successful parse (so far)! Success(()) } -/// Use the given sequence of token trees (`ms`) as a matcher. Match the given token stream `tts` -/// against it and return the match. -/// -/// # Parameters -/// -/// - `sess`: The session into which errors are emitted -/// - `tts`: The tokenstream we are matching against the pattern `ms` -/// - `ms`: A sequence of token trees representing a pattern against which we are matching -/// - `directory`: Information about the file locations (needed for the black-box parser) -/// - `recurse_into_modules`: Whether or not to recurse into modules (needed for the black-box -/// parser) -pub fn parse( - sess: &ParseSess, - tts: TokenStream, - ms: &[TokenTree], - directory: Option, - recurse_into_modules: bool, -) -> NamedParseResult { - // Create a parser that can be used for the "black box" parts. +pub fn parse(sess: &ParseSess, + tts: TokenStream, + ms: &[TokenTree], + directory: Option, + recurse_into_modules: bool) + -> NamedParseResult { let mut parser = Parser::new(sess, tts, directory, recurse_into_modules, true); - - // A queue of possible matcher positions. We initialize it with the matcher position in which - // the "dot" is before the first token of the first token tree in `ms`. `inner_parse_loop` then - // processes all of these possible matcher positions and produces posible next positions into - // `next_items`. After some post-processing, the contents of `next_items` replenish `cur_items` - // and we start over again. let mut cur_items = SmallVector::one(initial_matcher_pos(ms.to_owned(), parser.span.lo())); - let mut next_items = Vec::new(); + let mut next_items = Vec::new(); // or proceed normally loop { - // Matcher positions black-box parsed by parser.rs (`parser`) - let mut bb_items = SmallVector::new(); - - // Matcher positions that would be valid if the macro invocation was over now + let mut bb_items = SmallVector::new(); // black-box parsed by parser.rs let mut eof_items = SmallVector::new(); assert!(next_items.is_empty()); - // Process `cur_items` until either we have finished the input or we need to get some - // parsing from the black-box parser done. The result is that `next_items` will contain a - // bunch of possible next matcher positions in `next_items`. - match inner_parse_loop( - sess, - &mut cur_items, - &mut next_items, - &mut eof_items, - &mut bb_items, - &parser.token, - parser.span, - ) { - Success(_) => {} + match inner_parse_loop(sess, &mut cur_items, &mut next_items, &mut eof_items, &mut bb_items, + &parser.token, parser.span) { + Success(_) => {}, Failure(sp, tok) => return Failure(sp, tok), Error(sp, msg) => return Error(sp, msg), } @@ -623,75 +443,46 @@ pub fn parse( // inner parse loop handled all cur_items, so it's empty assert!(cur_items.is_empty()); - // We need to do some post processing after the `inner_parser_loop`. - // - // Error messages here could be improved with links to original rules. - - // If we reached the EOF, check that there is EXACTLY ONE possible matcher. Otherwise, - // either the parse is ambiguous (which should never happen) or their is a syntax error. + /* error messages here could be improved with links to orig. rules */ if token_name_eq(&parser.token, &token::Eof) { if eof_items.len() == 1 { - let matches = eof_items[0] - .matches - .iter_mut() - .map(|dv| Rc::make_mut(dv).pop().unwrap()); + let matches = eof_items[0].matches.iter_mut().map(|dv| { + Rc::make_mut(dv).pop().unwrap() + }); return nameize(sess, ms, matches); } else if eof_items.len() > 1 { - return Error( - parser.span, - "ambiguity: multiple successful parses".to_string(), - ); + return Error(parser.span, "ambiguity: multiple successful parses".to_string()); } else { return Failure(parser.span, token::Eof); } - } - // Another possibility is that we need to call out to parse some rust nonterminal - // (black-box) parser. However, if there is not EXACTLY ONE of these, something is wrong. - else if (!bb_items.is_empty() && !next_items.is_empty()) || bb_items.len() > 1 { - let nts = bb_items - .iter() - .map(|item| match item.top_elts.get_tt(item.idx) { - TokenTree::MetaVarDecl(_, bind, name) => format!("{} ('{}')", name, bind), - _ => panic!(), - }) - .collect::>() - .join(" or "); - - return Error( - parser.span, - format!( - "local ambiguity: multiple parsing options: {}", - match next_items.len() { - 0 => format!("built-in NTs {}.", nts), - 1 => format!("built-in NTs {} or 1 other option.", nts), - n => format!("built-in NTs {} or {} other options.", nts, n), - } - ), - ); - } - // If there are no posible next positions AND we aren't waiting for the black-box parser, - // then their is a syntax error. - else if bb_items.is_empty() && next_items.is_empty() { + } else if (!bb_items.is_empty() && !next_items.is_empty()) || bb_items.len() > 1 { + let nts = bb_items.iter().map(|item| match item.top_elts.get_tt(item.idx) { + TokenTree::MetaVarDecl(_, bind, name) => { + format!("{} ('{}')", name, bind) + } + _ => panic!() + }).collect::>().join(" or "); + + return Error(parser.span, format!( + "local ambiguity: multiple parsing options: {}", + match next_items.len() { + 0 => format!("built-in NTs {}.", nts), + 1 => format!("built-in NTs {} or 1 other option.", nts), + n => format!("built-in NTs {} or {} other options.", nts, n), + } + )); + } else if bb_items.is_empty() && next_items.is_empty() { return Failure(parser.span, parser.token); - } - // Dump all possible `next_items` into `cur_items` for the next iteration. - else if !next_items.is_empty() { - // Now process the next token + } else if !next_items.is_empty() { + /* Now process the next token */ cur_items.extend(next_items.drain(..)); parser.bump(); - } - // Finally, we have the case where we need to call the black-box parser to get some - // nonterminal. - else { - assert_eq!(bb_items.len(), 1); - + } else /* bb_items.len() == 1 */ { let mut item = bb_items.pop().unwrap(); if let TokenTree::MetaVarDecl(span, _, ident) = item.top_elts.get_tt(item.idx) { let match_cur = item.match_cur; - item.push_match( - match_cur, - MatchedNonterminal(Rc::new(parse_nt(&mut parser, span, &ident.name.as_str()))), - ); + item.push_match(match_cur, + MatchedNonterminal(Rc::new(parse_nt(&mut parser, span, &ident.name.as_str())))); item.idx += 1; item.match_cur += 1; } else { @@ -721,21 +512,20 @@ fn may_begin_with(name: &str, token: &Token) -> bool { "expr" => token.can_begin_expr(), "ty" => token.can_begin_type(), "ident" => token.is_ident(), - "vis" => match *token { - // The follow-set of :vis + "priv" keyword + interpolated + "vis" => match *token { // The follow-set of :vis + "priv" keyword + interpolated Token::Comma | Token::Ident(_) | Token::Interpolated(_) => true, _ => token.can_begin_type(), }, "block" => match *token { Token::OpenDelim(token::Brace) => true, Token::Interpolated(ref nt) => match nt.0 { - token::NtItem(_) - | token::NtPat(_) - | token::NtTy(_) - | token::NtIdent(_) - | token::NtMeta(_) - | token::NtPath(_) - | token::NtVis(_) => false, // none of these may start with '{'. + token::NtItem(_) | + token::NtPat(_) | + token::NtTy(_) | + token::NtIdent(_) | + token::NtMeta(_) | + token::NtPath(_) | + token::NtVis(_) => false, // none of these may start with '{'. _ => true, }, _ => false, @@ -772,18 +562,6 @@ fn may_begin_with(name: &str, token: &Token) -> bool { } } -/// A call to the "black-box" parser to parse some rust nonterminal. -/// -/// # Parameters -/// -/// - `p`: the "black-box" parser to use -/// - `sp`: the `Span` we want to parse -/// - `name`: the name of the metavar _matcher_ we want to match (e.g. `tt`, `ident`, `block`, -/// etc...) -/// -/// # Returns -/// -/// The parsed nonterminal. fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal { if name == "tt" { return token::NtTT(p.parse_token_tree()); @@ -813,15 +591,12 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal { "ident" => match p.token { token::Ident(sn) => { p.bump(); - token::NtIdent(Spanned:: { - node: sn, - span: p.prev_span, - }) + token::NtIdent(Spanned::{node: sn, span: p.prev_span}) } _ => { let token_str = pprust::token_to_string(&p.token); - p.fatal(&format!("expected ident, found {}", &token_str[..])) - .emit(); + p.fatal(&format!("expected ident, found {}", + &token_str[..])).emit(); FatalError.raise() } }, @@ -831,6 +606,6 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal { "lifetime" => token::NtLifetime(p.expect_lifetime()), // this is not supposed to happen, since it has been checked // when compiling the macro. - _ => p.span_bug(sp, "invalid fragment specifier"), + _ => p.span_bug(sp, "invalid fragment specifier") } } diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index c55dfaba8f6b2..0e21e3f6b0010 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -10,16 +10,14 @@ use ast; use ext::tt::macro_parser; -use parse::{token, ParseSess}; +use parse::{ParseSess, token}; use print::pprust; use symbol::keywords; -use syntax_pos::{BytePos, Span, DUMMY_SP}; +use syntax_pos::{DUMMY_SP, Span, BytePos}; use tokenstream; use std::rc::Rc; -/// Contains the sub-token-trees of a "delimited" token tree, such as the contents of `(`. Note -/// that the delimiter itself might be `NoDelim`. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct Delimited { pub delim: token::DelimToken, @@ -27,17 +25,14 @@ pub struct Delimited { } impl Delimited { - /// Return the opening delimiter (possibly `NoDelim`). pub fn open_token(&self) -> token::Token { token::OpenDelim(self.delim) } - /// Return the closing delimiter (possibly `NoDelim`). pub fn close_token(&self) -> token::Token { token::CloseDelim(self.delim) } - /// Return a `self::TokenTree` with a `Span` corresponding to the opening delimiter. pub fn open_tt(&self, span: Span) -> TokenTree { let open_span = if span == DUMMY_SP { DUMMY_SP @@ -47,7 +42,6 @@ impl Delimited { TokenTree::Token(open_span, self.open_token()) } - /// Return a `self::TokenTree` with a `Span` corresponding to the closing delimiter. pub fn close_tt(&self, span: Span) -> TokenTree { let close_span = if span == DUMMY_SP { DUMMY_SP @@ -74,14 +68,12 @@ pub struct SequenceRepetition { /// for token sequences. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum KleeneOp { - /// Kleene star (`*`) for zero or more repetitions ZeroOrMore, - /// Kleene plus (`+`) for one or more repetitions OneOrMore, } /// Similar to `tokenstream::TokenTree`, except that `$i`, `$i:ident`, and `$(...)` -/// are "first-class" token trees. Useful for parsing macros. +/// are "first-class" token trees. #[derive(Debug, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] pub enum TokenTree { Token(Span, token::Token), @@ -91,15 +83,10 @@ pub enum TokenTree { /// E.g. `$var` MetaVar(Span, ast::Ident), /// E.g. `$var:expr`. This is only used in the left hand side of MBE macros. - MetaVarDecl( - Span, - ast::Ident, /* name to bind */ - ast::Ident, /* kind of nonterminal */ - ), + MetaVarDecl(Span, ast::Ident /* name to bind */, ast::Ident /* kind of nonterminal */), } impl TokenTree { - /// Return the number of tokens in the tree. pub fn len(&self) -> usize { match *self { TokenTree::Delimited(_, ref delimed) => match delimed.delim { @@ -111,8 +98,6 @@ impl TokenTree { } } - /// Returns true if the given token tree contains no other tokens. This is vacuously true for - /// single tokens or metavar/decls, but may be false for delimited trees or sequences. pub fn is_empty(&self) -> bool { match *self { TokenTree::Delimited(_, ref delimed) => match delimed.delim { @@ -124,7 +109,6 @@ impl TokenTree { } } - /// Get the `index`-th sub-token-tree. This only makes sense for delimited trees and sequences. pub fn get_tt(&self, index: usize) -> TokenTree { match (self, index) { (&TokenTree::Delimited(_, ref delimed), _) if delimed.delim == token::NoDelim => { @@ -147,48 +131,21 @@ impl TokenTree { /// Retrieve the `TokenTree`'s span. pub fn span(&self) -> Span { match *self { - TokenTree::Token(sp, _) - | TokenTree::MetaVar(sp, _) - | TokenTree::MetaVarDecl(sp, _, _) - | TokenTree::Delimited(sp, _) - | TokenTree::Sequence(sp, _) => sp, + TokenTree::Token(sp, _) | + TokenTree::MetaVar(sp, _) | + TokenTree::MetaVarDecl(sp, _, _) | + TokenTree::Delimited(sp, _) | + TokenTree::Sequence(sp, _) => sp, } } } -/// Takes a `tokenstream::TokenStream` and returns a `Vec`. Specifically, this -/// takes a generic `TokenStream`, such as is used in the rest of the compiler, and returns a -/// collection of `TokenTree` for use in parsing a macro. -/// -/// # Parameters -/// -/// - `input`: a token stream to read from, the contents of which we are parsing. -/// - `expect_matchers`: `parse` can be used to parse either the "patterns" or the "body" of a -/// macro. Both take roughly the same form _except_ that in a pattern, metavars are declared with -/// their "matcher" type. For example `$var:expr` or `$id:ident`. In this example, `expr` and -/// `ident` are "matchers". They are not present in the body of a macro rule -- just in the -/// pattern, so we pass a parameter to indicate whether to expect them or not. -/// - `sess`: the parsing session. Any errors will be emitted to this session. -/// -/// # Returns -/// -/// A collection of `self::TokenTree`. There may also be some errors emitted to `sess`. -pub fn parse( - input: tokenstream::TokenStream, - expect_matchers: bool, - sess: &ParseSess, -) -> Vec { - // Will contain the final collection of `self::TokenTree` +pub fn parse(input: tokenstream::TokenStream, expect_matchers: bool, sess: &ParseSess) + -> Vec { let mut result = Vec::new(); - - // For each token tree in `input`, parse the token into a `self::TokenTree`, consuming - // additional trees if need be. let mut trees = input.trees(); while let Some(tree) = trees.next() { let tree = parse_tree(tree, &mut trees, expect_matchers, sess); - - // Given the parsed tree, if there is a metavar and we are expecting matchers, actually - // parse out the matcher (i.e. in `$id:ident` this would parse the `:` and `ident`). match tree { TokenTree::MetaVar(start_sp, ident) if expect_matchers => { let span = match trees.next() { @@ -197,149 +154,78 @@ pub fn parse( Some(kind) => { let span = end_sp.with_lo(start_sp.lo()); result.push(TokenTree::MetaVarDecl(span, ident, kind)); - continue; + continue } _ => end_sp, }, - tree => tree.as_ref() - .map(tokenstream::TokenTree::span) - .unwrap_or(span), + tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span), }, - tree => tree.as_ref() - .map(tokenstream::TokenTree::span) - .unwrap_or(start_sp), + tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(start_sp), }; sess.missing_fragment_specifiers.borrow_mut().insert(span); - result.push(TokenTree::MetaVarDecl( - span, - ident, - keywords::Invalid.ident(), - )); + result.push(TokenTree::MetaVarDecl(span, ident, keywords::Invalid.ident())); } - - // Not a metavar or no matchers allowed, so just return the tree _ => result.push(tree), } } result } -/// Takes a `tokenstream::TokenTree` and returns a `self::TokenTree`. Specifically, this takes a -/// generic `TokenTree`, such as is used in the rest of the compiler, and returns a `TokenTree` -/// for use in parsing a macro. -/// -/// Converting the given tree may involve reading more tokens. -/// -/// # Parameters -/// -/// - `tree`: the tree we wish to convert. -/// - `trees`: an iterator over trees. We may need to read more tokens from it in order to finish -/// converting `tree` -/// - `expect_matchers`: same as for `parse` (see above). -/// - `sess`: the parsing session. Any errors will be emitted to this session. -fn parse_tree( - tree: tokenstream::TokenTree, - trees: &mut I, - expect_matchers: bool, - sess: &ParseSess, -) -> TokenTree -where - I: Iterator, +fn parse_tree(tree: tokenstream::TokenTree, + trees: &mut I, + expect_matchers: bool, + sess: &ParseSess) + -> TokenTree + where I: Iterator, { - // Depending on what `tree` is, we could be parsing different parts of a macro match tree { - // `tree` is a `$` token. Look at the next token in `trees` tokenstream::TokenTree::Token(span, token::Dollar) => match trees.next() { - // `tree` is followed by a delimited set of token trees. This indicates the beginning - // of a repetition sequence in the macro (e.g. `$(pat)*`). Some(tokenstream::TokenTree::Delimited(span, delimited)) => { - // Must have `(` not `{` or `[` if delimited.delim != token::Paren { let tok = pprust::token_to_string(&token::OpenDelim(delimited.delim)); let msg = format!("expected `(`, found `{}`", tok); sess.span_diagnostic.span_err(span, &msg); } - // Parse the contents of the sequence itself let sequence = parse(delimited.tts.into(), expect_matchers, sess); - // Get the Kleene operator and optional separator let (separator, op) = parse_sep_and_kleene_op(trees, span, sess); - // Count the number of captured "names" (i.e. named metavars) let name_captures = macro_parser::count_names(&sequence); - TokenTree::Sequence( - span, - Rc::new(SequenceRepetition { - tts: sequence, - separator, - op, - num_captures: name_captures, - }), - ) + TokenTree::Sequence(span, Rc::new(SequenceRepetition { + tts: sequence, + separator, + op, + num_captures: name_captures, + })) } - - // `tree` is followed by an `ident`. This could be `$meta_var` or the `$crate` special - // metavariable that names the crate of the invokation. Some(tokenstream::TokenTree::Token(ident_span, ref token)) if token.is_ident() => { let ident = token.ident().unwrap(); let span = ident_span.with_lo(span.lo()); if ident.name == keywords::Crate.name() { - let ident = ast::Ident { - name: keywords::DollarCrate.name(), - ..ident - }; + let ident = ast::Ident { name: keywords::DollarCrate.name(), ..ident }; TokenTree::Token(span, token::Ident(ident)) } else { TokenTree::MetaVar(span, ident) } } - - // `tree` is followed by a random token. This is an error. Some(tokenstream::TokenTree::Token(span, tok)) => { - let msg = format!( - "expected identifier, found `{}`", - pprust::token_to_string(&tok) - ); + let msg = format!("expected identifier, found `{}`", pprust::token_to_string(&tok)); sess.span_diagnostic.span_err(span, &msg); TokenTree::MetaVar(span, keywords::Invalid.ident()) } - - // There are no more tokens. Just return the `$` we already have. None => TokenTree::Token(span, token::Dollar), }, - - // `tree` is an arbitrary token. Keep it. tokenstream::TokenTree::Token(span, tok) => TokenTree::Token(span, tok), - - // `tree` is the beginning of a delimited set of tokens (e.g. `(` or `{`). We need to - // descend into the delimited set and further parse it. - tokenstream::TokenTree::Delimited(span, delimited) => TokenTree::Delimited( - span, - Rc::new(Delimited { + tokenstream::TokenTree::Delimited(span, delimited) => { + TokenTree::Delimited(span, Rc::new(Delimited { delim: delimited.delim, tts: parse(delimited.tts.into(), expect_matchers, sess), - }), - ), + })) + } } } -/// Attempt to parse a single Kleene star, possibly with a separator. -/// -/// For example, in a pattern such as `$(a),*`, `a` is the pattern to be repeated, `,` is the -/// separator, and `*` is the Kleene operator. This function is specifically concerned with parsing -/// the last two tokens of such a pattern: namely, the optional separator and the Kleene operator -/// itself. Note that here we are parsing the _macro_ itself, rather than trying to match some -/// stream of tokens in an invocation of a macro. -/// -/// This function will take some input iterator `input` corresponding to `span` and a parsing -/// session `sess`. If the next one (or possibly two) tokens in `input` correspond to a Kleene -/// operator and separator, then a tuple with `(separator, KleeneOp)` is returned. Otherwise, an -/// error with the appropriate span is emitted to `sess` and a dummy value is returned. -fn parse_sep_and_kleene_op( - input: &mut I, - span: Span, - sess: &ParseSess, -) -> (Option, KleeneOp) -where - I: Iterator, +fn parse_sep_and_kleene_op(input: &mut I, span: Span, sess: &ParseSess) + -> (Option, KleeneOp) + where I: Iterator, { fn kleene_op(token: &token::Token) -> Option { match *token { @@ -349,40 +235,20 @@ where } } - // We attempt to look at the next two token trees in `input`. I will call the first #1 and the - // second #2. If #1 and #2 don't match a valid KleeneOp with/without separator, that is an - // error, and we should emit an error on the most specific span possible. let span = match input.next() { - // #1 is a token Some(tokenstream::TokenTree::Token(span, tok)) => match kleene_op(&tok) { - // #1 is a KleeneOp with no separator Some(op) => return (None, op), - - // #1 is not a KleeneOp, but may be a separator... need to look at #2 None => match input.next() { - // #2 is a token Some(tokenstream::TokenTree::Token(span, tok2)) => match kleene_op(&tok2) { - // #2 is a KleeneOp, so #1 must be a separator Some(op) => return (Some(tok), op), - - // #2 is not a KleeneOp... error None => span, }, - - // #2 is not a token at all... error - tree => tree.as_ref() - .map(tokenstream::TokenTree::span) - .unwrap_or(span), - }, + tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span), + } }, - - // #1 is not a token at all... error - tree => tree.as_ref() - .map(tokenstream::TokenTree::span) - .unwrap_or(span), + tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span), }; - // Error... sess.span_diagnostic.span_err(span, "expected `*` or `+`"); (None, KleeneOp::ZeroOrMore) } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 3e523fca92a03..9a2560b04583d 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -788,11 +788,6 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG is just used for rustc unit tests \ and will never be stable", cfg_fn!(rustc_attrs))), - ("rustc_serialize_exclude_null", Normal, Gated(Stability::Unstable, - "rustc_attrs", - "the `#[rustc_serialize_exclude_null]` attribute \ - is an internal-only feature", - cfg_fn!(rustc_attrs))), ("rustc_synthetic", Whitelisted, Gated(Stability::Unstable, "rustc_attrs", "this attribute \ diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index 98d5fa8f797fa..54c726d84621f 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -38,41 +38,34 @@ pub struct JsonEmitter { registry: Option, cm: Rc, pretty: bool, - /// Whether "approximate suggestions" are enabled in the config - approximate_suggestions: bool, } impl JsonEmitter { pub fn stderr(registry: Option, code_map: Rc, - pretty: bool, - approximate_suggestions: bool) -> JsonEmitter { + pretty: bool) -> JsonEmitter { JsonEmitter { dst: Box::new(io::stderr()), registry, cm: code_map, pretty, - approximate_suggestions, } } pub fn basic(pretty: bool) -> JsonEmitter { let file_path_mapping = FilePathMapping::empty(); - JsonEmitter::stderr(None, Rc::new(CodeMap::new(file_path_mapping)), - pretty, false) + JsonEmitter::stderr(None, Rc::new(CodeMap::new(file_path_mapping)), pretty) } pub fn new(dst: Box, registry: Option, code_map: Rc, - pretty: bool, - approximate_suggestions: bool) -> JsonEmitter { + pretty: bool) -> JsonEmitter { JsonEmitter { dst, registry, cm: code_map, pretty, - approximate_suggestions, } } } @@ -108,7 +101,6 @@ struct Diagnostic { } #[derive(RustcEncodable)] -#[allow(unused_attributes)] struct DiagnosticSpan { file_name: String, byte_start: u32, @@ -129,9 +121,6 @@ struct DiagnosticSpan { /// If we are suggesting a replacement, this will contain text /// that should be sliced in atop this span. suggested_replacement: Option, - /// If the suggestion is approximate - #[rustc_serialize_exclude_null] - suggestion_approximate: Option, /// Macro invocations that created the code at this span, if any. expansion: Option>, } @@ -199,7 +188,7 @@ impl Diagnostic { } let buf = BufWriter::default(); let output = buf.clone(); - EmitterWriter::new(Box::new(buf), Some(je.cm.clone()), false, false).emit(db); + EmitterWriter::new(Box::new(buf), Some(je.cm.clone()), false).emit(db); let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap(); let output = String::from_utf8(output).unwrap(); @@ -231,7 +220,7 @@ impl Diagnostic { impl DiagnosticSpan { fn from_span_label(span: SpanLabel, - suggestion: Option<(&String, bool)>, + suggestion: Option<&String>, je: &JsonEmitter) -> DiagnosticSpan { Self::from_span_etc(span.span, @@ -244,7 +233,7 @@ impl DiagnosticSpan { fn from_span_etc(span: Span, is_primary: bool, label: Option, - suggestion: Option<(&String, bool)>, + suggestion: Option<&String>, je: &JsonEmitter) -> DiagnosticSpan { // obtain the full backtrace from the `macro_backtrace` @@ -264,7 +253,7 @@ impl DiagnosticSpan { fn from_span_full(span: Span, is_primary: bool, label: Option, - suggestion: Option<(&String, bool)>, + suggestion: Option<&String>, mut backtrace: vec::IntoIter, je: &JsonEmitter) -> DiagnosticSpan { @@ -292,13 +281,6 @@ impl DiagnosticSpan { def_site_span, }) }); - - let suggestion_approximate = if je.approximate_suggestions { - suggestion.map(|x| x.1) - } else { - None - }; - DiagnosticSpan { file_name: start.file.name.to_string(), byte_start: span.lo().0 - start.file.start_pos.0, @@ -309,8 +291,7 @@ impl DiagnosticSpan { column_end: end.col.0 + 1, is_primary, text: DiagnosticSpanLine::from_span(span, je), - suggested_replacement: suggestion.map(|x| x.0.clone()), - suggestion_approximate, + suggested_replacement: suggestion.cloned(), expansion: backtrace_step, label, } @@ -328,15 +309,14 @@ impl DiagnosticSpan { suggestion.substitutions .iter() .flat_map(|substitution| { - substitution.parts.iter().map(move |suggestion_inner| { + substitution.parts.iter().map(move |suggestion| { let span_label = SpanLabel { - span: suggestion_inner.span, + span: suggestion.span, is_primary: true, label: None, }; DiagnosticSpan::from_span_label(span_label, - Some((&suggestion_inner.snippet, - suggestion.approximate)), + Some(&suggestion.snippet), je) }) }) diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 9181cca215c84..3b4c5da10f20b 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -25,7 +25,6 @@ #![feature(match_default_bindings)] #![feature(i128_type)] #![feature(const_atomic_usize_new)] -#![feature(rustc_attrs)] // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. #[allow(unused_extern_crates)] diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 0fd069b76aadc..b95c91548d00b 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1745,7 +1745,6 @@ mod tests { fn mk_sess(cm: Rc) -> ParseSess { let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()), Some(cm.clone()), - false, false); ParseSess { span_diagnostic: errors::Handler::with_emitter(true, false, Box::new(emitter)), diff --git a/src/libsyntax/test_snippet.rs b/src/libsyntax/test_snippet.rs index 3b4bba24d779b..5072f2e2793f1 100644 --- a/src/libsyntax/test_snippet.rs +++ b/src/libsyntax/test_snippet.rs @@ -62,7 +62,6 @@ fn test_harness(file_text: &str, span_labels: Vec, expected_output: & let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }), Some(code_map.clone()), - false, false); let handler = Handler::with_emitter(true, false, Box::new(emitter)); handler.span_err(msp, "foo"); diff --git a/src/libsyntax_ext/deriving/encodable.rs b/src/libsyntax_ext/deriving/encodable.rs index 743f22b6b3140..0e6e96438d817 100644 --- a/src/libsyntax_ext/deriving/encodable.rs +++ b/src/libsyntax_ext/deriving/encodable.rs @@ -190,7 +190,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, Struct(_, ref fields) => { let emit_struct_field = cx.ident_of("emit_struct_field"); let mut stmts = Vec::new(); - for (i, &FieldInfo { name, ref self_, span, attrs, .. }) in fields.iter().enumerate() { + for (i, &FieldInfo { name, ref self_, span, .. }) in fields.iter().enumerate() { let name = match name { Some(id) => id.name, None => Symbol::intern(&format!("_field{}", i)), @@ -212,19 +212,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, } else { cx.expr(span, ExprKind::Ret(Some(call))) }; - - // This exists for https://github.com/rust-lang/rust/pull/47540 - // - // If we decide to stabilize that flag this can be removed - let expr = if attrs.iter().any(|a| a.check_name("rustc_serialize_exclude_null")) { - let is_some = cx.ident_of("is_some"); - let condition = cx.expr_method_call(span, self_.clone(), is_some, vec![]); - cx.expr_if(span, condition, call, None) - } else { - call - }; - let stmt = cx.stmt_expr(expr); - stmts.push(stmt); + stmts.push(cx.stmt_expr(call)); } // unit structs have no fields and need to return Ok() diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 06d1301d70003..b2f1229891d26 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -836,10 +836,6 @@ struct LLVMRustThinLTOData { StringMap ImportLists; StringMap ExportLists; StringMap ModuleToDefinedGVSummaries; - -#if LLVM_VERSION_GE(7, 0) - LLVMRustThinLTOData() : Index(/* isPerformingAnalysis = */ false) {} -#endif }; // Just an argument to the `LLVMRustCreateThinLTOData` function below. @@ -922,14 +918,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, // // This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp` #if LLVM_VERSION_GE(5, 0) -#if LLVM_VERSION_GE(7, 0) - auto deadIsPrevailing = [&](GlobalValue::GUID G) { - return PrevailingType::Unknown; - }; - computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing); -#else computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols); -#endif ComputeCrossModuleImport( Ret->Index, Ret->ModuleToDefinedGVSummaries, diff --git a/src/test/codegen/function-arguments.rs b/src/test/codegen/function-arguments.rs index 0e98d3f9050a8..f8945a6ee8d93 100644 --- a/src/test/codegen/function-arguments.rs +++ b/src/test/codegen/function-arguments.rs @@ -122,13 +122,13 @@ pub fn unsafe_slice(_: &[UnsafeInner]) { pub fn str(_: &[u8]) { } -// CHECK: @trait_borrow({}* nonnull %arg0.0, {}* noalias nonnull readonly %arg0.1) +// CHECK: @trait_borrow(%"core::ops::drop::Drop"* nonnull %arg0.0, {}* noalias nonnull readonly %arg0.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn trait_borrow(_: &Drop) { } -// CHECK: @trait_box({}* noalias nonnull, {}* noalias nonnull readonly) +// CHECK: @trait_box(%"core::ops::drop::Drop"* noalias nonnull, {}* noalias nonnull readonly) #[no_mangle] pub fn trait_box(_: Box) { } diff --git a/src/test/compile-fail/E0195.rs b/src/test/compile-fail/E0195.rs index 4f4d7ce0dba83..06dd903b23db8 100644 --- a/src/test/compile-fail/E0195.rs +++ b/src/test/compile-fail/E0195.rs @@ -10,14 +10,13 @@ trait Trait { fn bar<'a,'b:'a>(x: &'a str, y: &'b str); - //~^ NOTE lifetimes in impl do not match this method in trait } struct Foo; impl Trait for Foo { fn bar<'a,'b>(x: &'a str, y: &'b str) { //~ ERROR E0195 - //~^ NOTE lifetimes do not match method in trait + //~^ lifetimes do not match trait } } diff --git a/src/test/compile-fail/E0619.rs b/src/test/compile-fail/E0619.rs deleted file mode 100644 index a5a5ff7218dcf..0000000000000 --- a/src/test/compile-fail/E0619.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x; - - match x { - (..) => {} //~ ERROR E0619 - _ => {} - } -} - diff --git a/src/test/compile-fail/associated-const-type-parameter-arms.rs b/src/test/compile-fail/associated-const-type-parameter-arms.rs index 630a234fa6641..52bb4a1b463b4 100644 --- a/src/test/compile-fail/associated-const-type-parameter-arms.rs +++ b/src/test/compile-fail/associated-const-type-parameter-arms.rs @@ -16,7 +16,6 @@ pub trait Foo { } struct Abc; - impl Foo for Abc { const X: EFoo = EFoo::B; } @@ -28,10 +27,8 @@ impl Foo for Def { pub fn test(arg: EFoo) { match arg { - A::X => println!("A::X"), - //~^ error: associated consts cannot be referenced in patterns [E0158] - B::X => println!("B::X"), - //~^ error: associated consts cannot be referenced in patterns [E0158] + A::X => println!("A::X"), //~ error: statics cannot be referenced in patterns [E0158] + B::X => println!("B::X"), //~ error: statics cannot be referenced in patterns [E0158] _ => (), } } diff --git a/src/test/compile-fail/issue-15965.rs b/src/test/compile-fail/issue-15965.rs index 08b896f387bbe..76ba5a0f4b371 100644 --- a/src/test/compile-fail/issue-15965.rs +++ b/src/test/compile-fail/issue-15965.rs @@ -11,7 +11,7 @@ fn main() { return { return () } -//~^ ERROR the type of this value must be known in this context +//~^ ERROR type annotations needed [E0282] () ; } diff --git a/src/test/compile-fail/issue-16048.rs b/src/test/compile-fail/issue-16048.rs index cda83fe54b09a..5012556dedddc 100644 --- a/src/test/compile-fail/issue-16048.rs +++ b/src/test/compile-fail/issue-16048.rs @@ -10,7 +10,6 @@ trait NoLifetime { fn get<'p, T : Test<'p>>(&self) -> T; - //~^ NOTE lifetimes in impl do not match this method in trait } trait Test<'p> { @@ -29,8 +28,8 @@ impl<'a> Test<'a> for Foo<'a> { impl<'a> NoLifetime for Foo<'a> { fn get<'p, T : Test<'a>>(&self) -> T { - //~^ ERROR E0195 - //~| NOTE lifetimes do not match method in trait +//~^ ERROR E0195 +//~| lifetimes do not match trait return *self as T; } } diff --git a/src/test/compile-fail/issue-2151.rs b/src/test/compile-fail/issue-2151.rs index fbd8f9163b5df..65957f42fd86d 100644 --- a/src/test/compile-fail/issue-2151.rs +++ b/src/test/compile-fail/issue-2151.rs @@ -9,6 +9,6 @@ // except according to those terms. fn main() { - let x = panic!(); - x.clone(); //~ ERROR the type of this value must be known in this context + let x = panic!(); //~ ERROR type annotations needed [E0282] + x.clone(); } diff --git a/src/test/compile-fail/match-vec-mismatch.rs b/src/test/compile-fail/match-vec-mismatch.rs index fed68da006889..a241b589a30fb 100644 --- a/src/test/compile-fail/match-vec-mismatch.rs +++ b/src/test/compile-fail/match-vec-mismatch.rs @@ -43,6 +43,6 @@ fn main() { fn another_fn_to_avoid_suppression() { match Default::default() { - [] => {} //~ ERROR the type of this value + [] => {} //~ ERROR type annotations needed [E0282] }; } diff --git a/src/test/compile-fail/pat-tuple-bad-type.rs b/src/test/compile-fail/pat-tuple-bad-type.rs index fd4ab5d253158..0b350fec9d479 100644 --- a/src/test/compile-fail/pat-tuple-bad-type.rs +++ b/src/test/compile-fail/pat-tuple-bad-type.rs @@ -12,7 +12,7 @@ fn main() { let x; match x { - (..) => {} //~ ERROR the type of this value must be known in this context + (..) => {} //~ ERROR type annotations needed [E0282] _ => {} } diff --git a/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.rs b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs similarity index 100% rename from src/test/ui/borrowck/regions-bound-missing-bound-in-impl.rs rename to src/test/compile-fail/regions-bound-missing-bound-in-impl.rs diff --git a/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs b/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs index 12b48b2a6c8aa..e9209616e57b5 100644 --- a/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs +++ b/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs @@ -24,7 +24,7 @@ fn a() { match closure0.take() { Some(c) => { return c(); - //~^ ERROR the type of this value must be known in this context + //~^ ERROR type annotations needed [E0282] } None => { } } diff --git a/src/test/run-make/stdin-non-utf8/Makefile b/src/test/run-make/stdin-non-utf8/Makefile deleted file mode 100644 index 7948c442616e3..0000000000000 --- a/src/test/run-make/stdin-non-utf8/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - cp non-utf8 $(TMPDIR)/non-utf.rs - cat $(TMPDIR)/non-utf.rs | $(RUSTC) - 2>&1 \ - | $(CGREP) "error: couldn't read from stdin, as it did not contain valid UTF-8" diff --git a/src/test/run-make/stdin-non-utf8/non-utf8 b/src/test/run-make/stdin-non-utf8/non-utf8 deleted file mode 100644 index bc87051a85299..0000000000000 --- a/src/test/run-make/stdin-non-utf8/non-utf8 +++ /dev/null @@ -1 +0,0 @@ -̉ diff --git a/src/test/run-pass/env-home-dir.rs b/src/test/run-pass/env-home-dir.rs index 9bbff1eeb81f3..22e440c6ffa51 100644 --- a/src/test/run-pass/env-home-dir.rs +++ b/src/test/run-pass/env-home-dir.rs @@ -27,10 +27,7 @@ fn main() { if cfg!(target_os = "android") { assert!(home_dir().is_none()); } else { - // When HOME is not set, some platforms return `None`, - // but others return `Some` with a default. - // Just check that it is not "/home/MountainView". - assert_ne!(home_dir(), Some(PathBuf::from("/home/MountainView"))); + assert!(home_dir().is_some()); } } diff --git a/src/test/run-pass/issue-47139-1.rs b/src/test/run-pass/issue-47139-1.rs deleted file mode 100644 index cb87991a491db..0000000000000 --- a/src/test/run-pass/issue-47139-1.rs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for issue #47139: -// -// Coherence was encountering an (unnecessary) overflow trying to -// decide if the two impls of dummy overlap. -// -// The overflow went something like: -// -// - `&'a ?T: Insertable` ? -// - let ?T = Option ? -// - `Option: Insertable` ? -// - `Option<&'a ?U>: Insertable` ? -// - `&'a ?U: Insertable` ? -// -// While somewhere in the middle, a projection would occur, which -// broke cycle detection. -// -// It turned out that this cycle was being kicked off due to some -// extended diagnostic attempts in coherence, so removing those -// sidestepped the issue for now. - -#![allow(dead_code)] - -pub trait Insertable { - type Values; - - fn values(self) -> Self::Values; -} - -impl Insertable for Option - where - T: Insertable, - T::Values: Default, -{ - type Values = T::Values; - - fn values(self) -> Self::Values { - self.map(Insertable::values).unwrap_or_default() - } -} - -impl<'a, T> Insertable for &'a Option - where - Option<&'a T>: Insertable, -{ - type Values = as Insertable>::Values; - - fn values(self) -> Self::Values { - self.as_ref().values() - } -} - -impl<'a, T> Insertable for &'a [T] -{ - type Values = Self; - - fn values(self) -> Self::Values { - self - } -} - -trait Unimplemented { } - -trait Dummy { } - -struct Foo { t: T } - -impl<'a, U> Dummy for Foo<&'a U> - where &'a U: Insertable -{ -} - -impl Dummy for T - where T: Unimplemented -{ } - -fn main() { -} diff --git a/src/test/run-pass/issue-47139-2.rs b/src/test/run-pass/issue-47139-2.rs deleted file mode 100644 index 08eaee5acd730..0000000000000 --- a/src/test/run-pass/issue-47139-2.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for issue #47139: -// -// Same as issue-47139-1.rs, but the impls of dummy are in the -// opposite order. This influenced the way that coherence ran and in -// some cases caused the overflow to occur when it wouldn't otherwise. -// In an effort to make the regr test more robust, I am including both -// orderings. - -#![allow(dead_code)] - -pub trait Insertable { - type Values; - - fn values(self) -> Self::Values; -} - -impl Insertable for Option - where - T: Insertable, - T::Values: Default, -{ - type Values = T::Values; - - fn values(self) -> Self::Values { - self.map(Insertable::values).unwrap_or_default() - } -} - -impl<'a, T> Insertable for &'a Option - where - Option<&'a T>: Insertable, -{ - type Values = as Insertable>::Values; - - fn values(self) -> Self::Values { - self.as_ref().values() - } -} - -impl<'a, T> Insertable for &'a [T] -{ - type Values = Self; - - fn values(self) -> Self::Values { - self - } -} - -trait Unimplemented { } - -trait Dummy { } - -struct Foo { t: T } - -impl Dummy for T - where T: Unimplemented -{ } - -impl<'a, U> Dummy for Foo<&'a U> - where &'a U: Insertable -{ -} - -fn main() { -} diff --git a/src/test/run-pass/issue-47638.rs b/src/test/run-pass/issue-47638.rs deleted file mode 100644 index 6f627b2a3c137..0000000000000 --- a/src/test/run-pass/issue-47638.rs +++ /dev/null @@ -1,18 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn id<'c, 'b>(f: &'c &'b Fn(&i32)) -> &'c &'b Fn(&'static i32) { - f -} - -fn main() { - let f: &Fn(&i32) = &|x| {}; - id(&f); -} diff --git a/src/test/run-pass/sse2.rs b/src/test/run-pass/sse2.rs index 22469b2fde058..c2414e5ff5d96 100644 --- a/src/test/run-pass/sse2.rs +++ b/src/test/run-pass/sse2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// no-system-llvm -- needs MCSubtargetInfo::getFeatureTable() +// min-llvm-version 4.0 // ignore-cloudabi no std::env #![feature(cfg_target_feature)] diff --git a/src/test/run-pass/use-nested-groups.rs b/src/test/run-pass/use-nested-groups.rs index a28f8da9ff882..74a82afd462b8 100644 --- a/src/test/run-pass/use-nested-groups.rs +++ b/src/test/run-pass/use-nested-groups.rs @@ -24,19 +24,12 @@ mod a { } } -// Test every possible part of the syntax use a::{B, d::{self, *, g::H}}; -// Test a more common use case -use std::sync::{Arc, atomic::{AtomicBool, Ordering}}; - fn main() { let _: B; let _: E; let _: F; let _: H; let _: d::g::I; - - let _: Arc; - let _: Ordering; } diff --git a/src/test/rustdoc/link-title-escape.rs b/src/test/rustdoc/link-title-escape.rs deleted file mode 100644 index eb53c3c2cb52d..0000000000000 --- a/src/test/rustdoc/link-title-escape.rs +++ /dev/null @@ -1,19 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z unstable-options --disable-commonmark - -#![crate_name = "foo"] - -//! hello [foo] -//! -//! [foo]: url 'title & & "things"' - -// @has 'foo/index.html' 'title & <stuff> & "things"' diff --git a/src/test/ui/associated-const-impl-wrong-lifetime.stderr b/src/test/ui/associated-const-impl-wrong-lifetime.stderr index ab0e1003a9e10..a7aee9b19f1a1 100644 --- a/src/test/ui/associated-const-impl-wrong-lifetime.stderr +++ b/src/test/ui/associated-const-impl-wrong-lifetime.stderr @@ -9,8 +9,11 @@ error[E0308]: mismatched types note: the lifetime 'a as defined on the impl at 17:1... --> $DIR/associated-const-impl-wrong-lifetime.rs:17:1 | -17 | impl<'a> Foo for &'a () { - | ^^^^^^^^^^^^^^^^^^^^^^^ +17 | / impl<'a> Foo for &'a () { +18 | | const NAME: &'a str = "unit"; +19 | | //~^ ERROR mismatched types [E0308] +20 | | } + | |_^ = note: ...does not necessarily outlive the static lifetime error: aborting due to previous error diff --git a/src/test/ui/blind-item-item-shadow.stderr b/src/test/ui/blind-item-item-shadow.stderr index d3588be266975..855b3799eb5db 100644 --- a/src/test/ui/blind-item-item-shadow.stderr +++ b/src/test/ui/blind-item-item-shadow.stderr @@ -10,8 +10,8 @@ error[E0255]: the name `foo` is defined multiple times = note: `foo` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import | -13 | use foo::foo as other_foo; - | ^^^^^^^^^^^^^^^^^^^^^ +13 | use foo::foo as Otherfoo; + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr b/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr deleted file mode 100644 index e8323247af997..0000000000000 --- a/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error[E0195]: lifetime parameters or bounds on method `no_bound` do not match the trait declaration - --> $DIR/regions-bound-missing-bound-in-impl.rs:28:5 - | -20 | fn no_bound<'b>(self, b: Inv<'b>); - | ---------------------------------- lifetimes in impl do not match this method in trait -... -28 | fn no_bound<'b:'a>(self, b: Inv<'b>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait - -error[E0195]: lifetime parameters or bounds on method `has_bound` do not match the trait declaration - --> $DIR/regions-bound-missing-bound-in-impl.rs:32:5 - | -21 | fn has_bound<'b:'a>(self, b: Inv<'b>); - | -------------------------------------- lifetimes in impl do not match this method in trait -... -32 | fn has_bound<'b>(self, b: Inv<'b>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait - -error[E0308]: method not compatible with trait - --> $DIR/regions-bound-missing-bound-in-impl.rs:36:5 - | -36 | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch - | - = note: expected type `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'d>)` - found type `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'d>)` -note: the lifetime 'c as defined on the method body at 36:5... - --> $DIR/regions-bound-missing-bound-in-impl.rs:36:5 - | -36 | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...does not necessarily outlive the lifetime 'c as defined on the method body at 36:5 - --> $DIR/regions-bound-missing-bound-in-impl.rs:36:5 - | -36 | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0276]: impl has stricter requirements than trait - --> $DIR/regions-bound-missing-bound-in-impl.rs:53:5 - | -24 | fn another_bound<'x: 'a>(self, x: Inv<'x>, y: Inv<'t>); - | ------------------------------------------------------- definition of `another_bound` from trait -... -53 | fn another_bound<'x: 't>(self, x: Inv<'x>, y: Inv<'t>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'x: 't` - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/closure-expected-type/expect-region-supply-region.stderr b/src/test/ui/closure-expected-type/expect-region-supply-region.stderr index 5c612522d9a31..ebb1e561e57ab 100644 --- a/src/test/ui/closure-expected-type/expect-region-supply-region.stderr +++ b/src/test/ui/closure-expected-type/expect-region-supply-region.stderr @@ -41,8 +41,14 @@ note: the anonymous lifetime #2 defined on the body at 47:29... note: ...does not necessarily outlive the lifetime 'x as defined on the function body at 42:1 --> $DIR/expect-region-supply-region.rs:42:1 | -42 | fn expect_bound_supply_named<'x>() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +42 | / fn expect_bound_supply_named<'x>() { +43 | | let mut f: Option<&u32> = None; +44 | | +45 | | // Here we give a type annotation that `x` should be free. We get +... | +54 | | }); +55 | | } + | |_^ error[E0308]: mismatched types --> $DIR/expect-region-supply-region.rs:47:33 @@ -55,8 +61,14 @@ error[E0308]: mismatched types note: the lifetime 'x as defined on the function body at 42:1... --> $DIR/expect-region-supply-region.rs:42:1 | -42 | fn expect_bound_supply_named<'x>() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +42 | / fn expect_bound_supply_named<'x>() { +43 | | let mut f: Option<&u32> = None; +44 | | +45 | | // Here we give a type annotation that `x` should be free. We get +... | +54 | | }); +55 | | } + | |_^ note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 47:29 --> $DIR/expect-region-supply-region.rs:47:29 | diff --git a/src/test/ui/cross-file-errors/main.rs b/src/test/ui/cross-file-errors/main.rs deleted file mode 100644 index 8eae79a21a983..0000000000000 --- a/src/test/ui/cross-file-errors/main.rs +++ /dev/null @@ -1,16 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -mod underscore; - -fn main() { - underscore!(); -} diff --git a/src/test/ui/cross-file-errors/main.stderr b/src/test/ui/cross-file-errors/main.stderr deleted file mode 100644 index a1cdae10edfcd..0000000000000 --- a/src/test/ui/cross-file-errors/main.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: expected expression, found `_` - --> $DIR/underscore.rs:18:9 - | -18 | _ - | ^ - | - ::: $DIR/main.rs:15:5 - | -15 | underscore!(); - | -------------- in this macro invocation - diff --git a/src/test/ui/cross-file-errors/underscore.rs b/src/test/ui/cross-file-errors/underscore.rs deleted file mode 100644 index 312b3b8f4ddd5..0000000000000 --- a/src/test/ui/cross-file-errors/underscore.rs +++ /dev/null @@ -1,20 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// We want this file only so we can test cross-file error -// messages, but we don't want it in an external crate. -// ignore-test -#![crate_type = "lib"] - -macro_rules! underscore { - () => ( - _ - ) -} diff --git a/src/test/ui/double-import.stderr b/src/test/ui/double-import.stderr index 2a0f9ee34f2be..fcd3f2696f200 100644 --- a/src/test/ui/double-import.stderr +++ b/src/test/ui/double-import.stderr @@ -9,8 +9,8 @@ error[E0252]: the name `foo` is defined multiple times = note: `foo` must be defined only once in the value namespace of this module help: You can use `as` to change the binding name of the import | -23 | use sub2::foo as other_foo; //~ ERROR the name `foo` is defined multiple times - | ^^^^^^^^^^^^^^^^^^^^^^ +23 | use sub2::foo as Otherfoo; //~ ERROR the name `foo` is defined multiple times + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/impl-trait/trait_type.stderr b/src/test/ui/impl-trait/trait_type.stderr index 1417c71ca1244..7a0d01a8ec215 100644 --- a/src/test/ui/impl-trait/trait_type.stderr +++ b/src/test/ui/impl-trait/trait_type.stderr @@ -2,7 +2,7 @@ error[E0053]: method `fmt` has an incompatible type for trait --> $DIR/trait_type.rs:17:4 | 17 | fn fmt(&self, x: &str) -> () { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability | = note: expected type `fn(&MyType, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>` found type `fn(&MyType, &str)` @@ -19,7 +19,7 @@ error[E0186]: method `fmt` has a `&self` declaration in the trait, but not in th --> $DIR/trait_type.rs:27:4 | 27 | fn fmt() -> () { } - | ^^^^^^^^^^^^^^ expected `&self` in impl + | ^^^^^^^^^^^^^^^^^^ expected `&self` in impl | = note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>` diff --git a/src/test/ui/imports/duplicate.stderr b/src/test/ui/imports/duplicate.stderr index 6e5b91a11c900..a74401314a18c 100644 --- a/src/test/ui/imports/duplicate.stderr +++ b/src/test/ui/imports/duplicate.stderr @@ -9,8 +9,8 @@ error[E0252]: the name `foo` is defined multiple times = note: `foo` must be defined only once in the value namespace of this module help: You can use `as` to change the binding name of the import | -25 | use a::foo as other_foo; //~ ERROR the name `foo` is defined multiple times - | ^^^^^^^^^^^^^^^^^^^ +25 | use a::foo as Otherfoo; //~ ERROR the name `foo` is defined multiple times + | ^^^^^^^^^^^^^^^^^^ error[E0659]: `foo` is ambiguous --> $DIR/duplicate.rs:56:9 diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs deleted file mode 100644 index f845762cefd8b..0000000000000 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs +++ /dev/null @@ -1,22 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::Deref; -trait Trait {} - -struct Struct; - -impl Deref for Struct { - type Target = Trait; - fn deref(&self) -> &Trait { - unimplemented!(); - } -} -//~^^^^ ERROR cannot infer an appropriate lifetime for lifetime parameter diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr deleted file mode 100644 index 7aab31eb909d0..0000000000000 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr +++ /dev/null @@ -1,22 +0,0 @@ -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 | fn deref(&self) -> &Trait { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 18:5... - --> $DIR/mismatched_trait_impl-2.rs:18:5 - | -18 | / fn deref(&self) -> &Trait { -19 | | unimplemented!(); -20 | | } - | |_____^ - = note: ...but the lifetime must also be valid for the static lifetime... - = note: ...so that the method type is compatible with trait: - expected fn(&Struct) -> &Trait + 'static - found fn(&Struct) -> &Trait - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr b/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr index fd6be01da9f46..e96f7181a6dae 100644 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr +++ b/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr @@ -1,8 +1,10 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'a in generic type due to conflicting requirements --> $DIR/mismatched_trait_impl.rs:19:5 | -19 | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer +20 | | x +21 | | } + | |_____^ | note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 19:5... --> $DIR/mismatched_trait_impl.rs:19:5 @@ -11,14 +13,27 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th 20 | | x 21 | | } | |_____^ -note: ...but the lifetime must also be valid for the lifetime 'a as defined on the method body at 19:5... +note: ...so that method type is compatible with trait (expected fn(&i32, &'a u32, &u32) -> &'a u32, found fn(&i32, &u32, &u32) -> &u32) + --> $DIR/mismatched_trait_impl.rs:19:5 + | +19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer +20 | | x +21 | | } + | |_____^ +note: but, the lifetime must be valid for the lifetime 'a as defined on the method body at 19:5... --> $DIR/mismatched_trait_impl.rs:19:5 | -19 | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...so that the method type is compatible with trait: - expected fn(&i32, &'a u32, &u32) -> &'a u32 - found fn(&i32, &u32, &u32) -> &u32 +19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer +20 | | x +21 | | } + | |_____^ +note: ...so that method type is compatible with trait (expected fn(&i32, &'a u32, &u32) -> &'a u32, found fn(&i32, &u32, &u32) -> &u32) + --> $DIR/mismatched_trait_impl.rs:19:5 + | +19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer +20 | | x +21 | | } + | |_____^ error: aborting due to previous error diff --git a/src/test/ui/issue-26886.stderr b/src/test/ui/issue-26886.stderr index e6424e535ee32..cb2eca87068f8 100644 --- a/src/test/ui/issue-26886.stderr +++ b/src/test/ui/issue-26886.stderr @@ -24,8 +24,8 @@ error[E0252]: the name `sync` is defined multiple times = note: `sync` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import | -14 | use std::sync as other_sync; //~ ERROR the name `sync` is defined multiple times - | ^^^^^^^^^^^^^^^^^^^^^^^ +14 | use std::sync as Othersync; //~ ERROR the name `sync` is defined multiple times + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issue-27942.stderr b/src/test/ui/issue-27942.stderr index b24544743d87d..b580b8e73137b 100644 --- a/src/test/ui/issue-27942.stderr +++ b/src/test/ui/issue-27942.stderr @@ -14,8 +14,14 @@ note: the anonymous lifetime #1 defined on the method body at 15:5... note: ...does not necessarily outlive the lifetime 'a as defined on the trait at 13:1 --> $DIR/issue-27942.rs:13:1 | -13 | pub trait Buffer<'a, R: Resources<'a>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | / pub trait Buffer<'a, R: Resources<'a>> { +14 | | +15 | | fn select(&self) -> BufferViewHandle; +16 | | //~^ ERROR mismatched types +... | +19 | | //~| lifetime mismatch +20 | | } + | |_^ error[E0308]: mismatched types --> $DIR/issue-27942.rs:15:5 @@ -28,8 +34,14 @@ error[E0308]: mismatched types note: the lifetime 'a as defined on the trait at 13:1... --> $DIR/issue-27942.rs:13:1 | -13 | pub trait Buffer<'a, R: Resources<'a>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | / pub trait Buffer<'a, R: Resources<'a>> { +14 | | +15 | | fn select(&self) -> BufferViewHandle; +16 | | //~^ ERROR mismatched types +... | +19 | | //~| lifetime mismatch +20 | | } + | |_^ note: ...does not necessarily outlive the anonymous lifetime #1 defined on the method body at 15:5 --> $DIR/issue-27942.rs:15:5 | diff --git a/src/test/ui/issue-37884.stderr b/src/test/ui/issue-37884.stderr index c4ad232ae7eba..439b123975f82 100644 --- a/src/test/ui/issue-37884.stderr +++ b/src/test/ui/issue-37884.stderr @@ -24,8 +24,14 @@ note: the anonymous lifetime #1 defined on the method body at 16:5... note: ...does not necessarily outlive the lifetime 'a as defined on the impl at 13:1 --> $DIR/issue-37884.rs:13:1 | -13 | impl<'a, T: 'a> Iterator for RepeatMut<'a, T> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | / impl<'a, T: 'a> Iterator for RepeatMut<'a, T> { +14 | | +15 | | type Item = &'a mut T; +16 | | fn next(&'a mut self) -> Option +... | +21 | | } +22 | | } + | |_^ error: aborting due to previous error diff --git a/src/test/ui/issue-46472.stderr b/src/test/ui/issue-46472.stderr index 7b5cce218e9f2..2f332a7a55850 100644 --- a/src/test/ui/issue-46472.stderr +++ b/src/test/ui/issue-46472.stderr @@ -10,8 +10,12 @@ error[E0597]: borrowed value does not live long enough (Ast) note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:1... --> $DIR/issue-46472.rs:13:1 | -13 | fn bar<'a>() -> &'a mut u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | / fn bar<'a>() -> &'a mut u32 { +14 | | &mut 4 +15 | | //~^ ERROR borrowed value does not live long enough (Ast) [E0597] +16 | | //~| ERROR borrowed value does not live long enough (Mir) [E0597] +17 | | } + | |_^ error[E0597]: borrowed value does not live long enough (Mir) --> $DIR/issue-46472.rs:14:10 @@ -25,8 +29,12 @@ error[E0597]: borrowed value does not live long enough (Mir) note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:1... --> $DIR/issue-46472.rs:13:1 | -13 | fn bar<'a>() -> &'a mut u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | / fn bar<'a>() -> &'a mut u32 { +14 | | &mut 4 +15 | | //~^ ERROR borrowed value does not live long enough (Ast) [E0597] +16 | | //~| ERROR borrowed value does not live long enough (Mir) [E0597] +17 | | } + | |_^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issue-47706-trait.rs b/src/test/ui/issue-47706-trait.rs deleted file mode 100644 index 86a9da49a054a..0000000000000 --- a/src/test/ui/issue-47706-trait.rs +++ /dev/null @@ -1,16 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait T { - fn f(&self, _: ()) { - None::<()>.map(Self::f); - } - //~^^ ERROR function is expected to take a single 0-tuple as argument -} diff --git a/src/test/ui/issue-47706-trait.stderr b/src/test/ui/issue-47706-trait.stderr deleted file mode 100644 index 320e98dee4acf..0000000000000 --- a/src/test/ui/issue-47706-trait.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0601]: main function not found - -error[E0593]: function is expected to take a single 0-tuple as argument, but it takes 2 distinct arguments - --> $DIR/issue-47706-trait.rs:13:20 - | -12 | fn f(&self, _: ()) { - | ------------------ takes 2 distinct arguments -13 | None::<()>.map(Self::f); - | ^^^ expected function that takes a single 0-tuple as argument - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/lint/suggestions.rs b/src/test/ui/lint/suggestions.rs index e35675eacd835..dfcaede1402da 100644 --- a/src/test/ui/lint/suggestions.rs +++ b/src/test/ui/lint/suggestions.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-tidy-tab - #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 #![feature(no_debug)] @@ -48,15 +46,11 @@ fn main() { let mut a = (1); // should suggest no `mut`, no parens //~^ WARN does not need to be mutable //~| WARN unnecessary parentheses - // the line after `mut` has a `\t` at the beginning, this is on purpose - let mut - b = 1; - //~^^ WARN does not need to be mutable let d = Equinox { warp_factor: 9.975 }; match d { Equinox { warp_factor: warp_factor } => {} // should suggest shorthand //~^ WARN this pattern is redundant } - println!("{} {}", a, b); + println!("{}", a); } } diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr index 90d6bd312e419..8b30f552d3771 100644 --- a/src/test/ui/lint/suggestions.stderr +++ b/src/test/ui/lint/suggestions.stderr @@ -1,53 +1,41 @@ warning: unnecessary parentheses around assigned value - --> $DIR/suggestions.rs:48:21 + --> $DIR/suggestions.rs:46:21 | -48 | let mut a = (1); // should suggest no `mut`, no parens +46 | let mut a = (1); // should suggest no `mut`, no parens | ^^^ help: remove these parentheses | note: lint level defined here - --> $DIR/suggestions.rs:13:21 + --> $DIR/suggestions.rs:11:21 | -13 | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 +11 | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 | ^^^^^^^^^^^^^ warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721 - --> $DIR/suggestions.rs:43:1 + --> $DIR/suggestions.rs:41:1 | -43 | #[no_debug] // should suggest removal of deprecated attribute +41 | #[no_debug] // should suggest removal of deprecated attribute | ^^^^^^^^^^^ help: remove this attribute | = note: #[warn(deprecated)] on by default warning: variable does not need to be mutable - --> $DIR/suggestions.rs:48:13 + --> $DIR/suggestions.rs:46:13 | -48 | let mut a = (1); // should suggest no `mut`, no parens - | ----^ +46 | let mut a = (1); // should suggest no `mut`, no parens + | ---^^ | | | help: remove this `mut` | note: lint level defined here - --> $DIR/suggestions.rs:13:9 + --> $DIR/suggestions.rs:11:9 | -13 | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 +11 | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 | ^^^^^^^^^^ -warning: variable does not need to be mutable - --> $DIR/suggestions.rs:52:13 - | -52 | let mut - | _____________^ - | |_____________| - | || -53 | || b = 1; - | ||____________-^ - | |____________| - | help: remove this `mut` - warning: static is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:16:14 + --> $DIR/suggestions.rs:14:14 | -16 | #[no_mangle] static SHENZHOU: usize = 1; // should suggest `pub` +14 | #[no_mangle] static SHENZHOU: usize = 1; // should suggest `pub` | -^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: try making it public: `pub` @@ -55,9 +43,9 @@ warning: static is marked #[no_mangle], but not exported = note: #[warn(private_no_mangle_statics)] on by default error: const items should never be #[no_mangle] - --> $DIR/suggestions.rs:18:14 + --> $DIR/suggestions.rs:16:14 | -18 | #[no_mangle] const DISCOVERY: usize = 1; // should suggest `pub static` rather than `const` +16 | #[no_mangle] const DISCOVERY: usize = 1; // should suggest `pub static` rather than `const` | -----^^^^^^^^^^^^^^^^^^^^^^ | | | help: try a static value: `pub static` @@ -65,19 +53,19 @@ error: const items should never be #[no_mangle] = note: #[deny(no_mangle_const_items)] on by default warning: functions generic over types must be mangled - --> $DIR/suggestions.rs:22:1 + --> $DIR/suggestions.rs:20:1 | -21 | #[no_mangle] // should suggest removal (generics can't be no-mangle) +19 | #[no_mangle] // should suggest removal (generics can't be no-mangle) | ------------ help: remove this attribute -22 | pub fn defiant(_t: T) {} +20 | pub fn defiant(_t: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[warn(no_mangle_generic_items)] on by default warning: function is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:26:1 + --> $DIR/suggestions.rs:24:1 | -26 | fn rio_grande() {} // should suggest `pub` +24 | fn rio_grande() {} // should suggest `pub` | -^^^^^^^^^^^^^^^^^ | | | help: try making it public: `pub` @@ -85,29 +73,29 @@ warning: function is marked #[no_mangle], but not exported = note: #[warn(private_no_mangle_fns)] on by default warning: static is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:33:18 + --> $DIR/suggestions.rs:31:18 | -33 | #[no_mangle] pub static DAUNTLESS: bool = true; +31 | #[no_mangle] pub static DAUNTLESS: bool = true; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: function is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:35:18 + --> $DIR/suggestions.rs:33:18 | -35 | #[no_mangle] pub fn val_jean() {} +33 | #[no_mangle] pub fn val_jean() {} | ^^^^^^^^^^^^^^^^^^^^ warning: denote infinite loops with `loop { ... }` - --> $DIR/suggestions.rs:46:5 + --> $DIR/suggestions.rs:44:5 | -46 | while true { // should suggest `loop` +44 | while true { // should suggest `loop` | ^^^^^^^^^^ help: use `loop` | = note: #[warn(while_true)] on by default warning: the `warp_factor:` in this pattern is redundant - --> $DIR/suggestions.rs:57:23 + --> $DIR/suggestions.rs:51:23 | -57 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand +51 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand | ------------^^^^^^^^^^^^ | | | help: remove this diff --git a/src/test/ui/macro_backtrace/main.stderr b/src/test/ui/macro_backtrace/main.stderr index 48138ee711b3f..5990f71b3ca0a 100644 --- a/src/test/ui/macro_backtrace/main.stderr +++ b/src/test/ui/macro_backtrace/main.stderr @@ -22,7 +22,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found 27 | ping!(); | -------- in this macro invocation | - ::: :1:1 + ::: | 1 | ( ) => { pong ! ( ) ; } | ------------------------- @@ -42,7 +42,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found 28 | deep!(); | -------- in this macro invocation (#1) | - ::: :1:1 + ::: | 1 | ( ) => { foo ! ( ) ; } | ------------------------ @@ -50,7 +50,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | | in this macro invocation (#2) | in this expansion of `deep!` (#1) | - ::: :1:1 + ::: | 1 | ( ) => { bar ! ( ) ; } | ------------------------ @@ -58,7 +58,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | | in this macro invocation (#3) | in this expansion of `foo!` (#2) | - ::: :1:1 + ::: | 1 | ( ) => { ping ! ( ) ; } | ------------------------- @@ -66,7 +66,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | | in this macro invocation (#4) | in this expansion of `bar!` (#3) | - ::: :1:1 + ::: | 1 | ( ) => { pong ! ( ) ; } | ------------------------- diff --git a/src/test/ui/resolve-conflict-item-vs-import.stderr b/src/test/ui/resolve-conflict-item-vs-import.stderr index e2245b8a8b10a..03ef66681e440 100644 --- a/src/test/ui/resolve-conflict-item-vs-import.stderr +++ b/src/test/ui/resolve-conflict-item-vs-import.stderr @@ -10,8 +10,8 @@ error[E0255]: the name `transmute` is defined multiple times = note: `transmute` must be defined only once in the value namespace of this module help: You can use `as` to change the binding name of the import | -11 | use std::mem::transmute as other_transmute; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +11 | use std::mem::transmute as Othertransmute; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/static-lifetime.stderr b/src/test/ui/static-lifetime.stderr index 24ba27b27ad36..a99dbf21e54e2 100644 --- a/src/test/ui/static-lifetime.stderr +++ b/src/test/ui/static-lifetime.stderr @@ -8,7 +8,7 @@ note: lifetime parameter instantiated with the lifetime 'a as defined on the imp --> $DIR/static-lifetime.rs:13:1 | 13 | impl<'a, A: Clone> Arbitrary for ::std::borrow::Cow<'a, A> {} //~ ERROR lifetime bound - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: but lifetime parameter must outlive the static lifetime error: aborting due to previous error diff --git a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr index 01dba62a8511d..d2ac15f7ffcb3 100644 --- a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr +++ b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr @@ -7,7 +7,7 @@ error[E0259]: the name `std` is defined multiple times = note: `std` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import | -11 | extern crate std as other_std; +11 | extern crate std as Otherstd; | error: aborting due to previous error diff --git a/src/test/ui/use-mod.stderr b/src/test/ui/use-mod.stderr index 1c9f306f493db..bb64909e64a0c 100644 --- a/src/test/ui/use-mod.stderr +++ b/src/test/ui/use-mod.stderr @@ -25,7 +25,7 @@ error[E0252]: the name `bar` is defined multiple times = note: `bar` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import | -15 | self as other_bar +15 | self as Otherbar | error: aborting due to 3 previous errors diff --git a/src/test/ui/use-nested-groups-error.rs b/src/test/ui/use-nested-groups-error.rs deleted file mode 100644 index a9b6b3ee70d57..0000000000000 --- a/src/test/ui/use-nested-groups-error.rs +++ /dev/null @@ -1,27 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(use_nested_groups)] - -mod a { - pub mod b1 { - pub enum C2 {} - } - - pub enum B2 {} -} - -use a::{b1::{C1, C2}, B2}; -//~^ ERROR unresolved import `a::b1::C1` - -fn main() { - let _: C2; - let _: B2; -} diff --git a/src/test/ui/use-nested-groups-error.stderr b/src/test/ui/use-nested-groups-error.stderr deleted file mode 100644 index cae34684c8e38..0000000000000 --- a/src/test/ui/use-nested-groups-error.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0432]: unresolved import `a::b1::C1` - --> $DIR/use-nested-groups-error.rs:21:14 - | -21 | use a::{b1::{C1, C2}, B2}; - | ^^ no `C1` in `a::b1`. Did you mean to use `C2`? - -error: aborting due to previous error - diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index abf62a060b83b..bf5fc00428df2 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1402,7 +1402,7 @@ impl<'test> TestCx<'test> { } /// For each `aux-build: foo/bar` annotation, we check to find the - /// file in a `auxiliary` directory relative to the test itself. + /// file in a `aux` directory relative to the test itself. fn compute_aux_test_paths(&self, rel_ab: &str) -> TestPaths { let test_ab = self.testpaths .file