diff options
Diffstat (limited to 'src')
28 files changed, 182 insertions, 209 deletions
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 9c09ce99486..dbbb7f926bc 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1862,15 +1862,16 @@ impl<'a> LoweringContext<'a> { if let Ok(snippet) = self.sess.source_map().span_to_snippet(data.span) { // Do not suggest going from `Trait()` to `Trait<>` if data.inputs.len() > 0 { - let split = snippet.find('(').unwrap(); - let trait_name = &snippet[0..split]; - let args = &snippet[split + 1 .. snippet.len() - 1]; - err.span_suggestion( - data.span, - "use angle brackets instead", - format!("{}<{}>", trait_name, args), - Applicability::MaybeIncorrect, - ); + if let Some(split) = snippet.find('(') { + let trait_name = &snippet[0..split]; + let args = &snippet[split + 1 .. snippet.len() - 1]; + err.span_suggestion( + data.span, + "use angle brackets instead", + format!("{}<{}>", trait_name, args), + Applicability::MaybeIncorrect, + ); + } } }; err.emit(); diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 82994f9170f..38877dee711 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -59,6 +59,7 @@ #![feature(log_syntax)] #![feature(associated_type_bounds)] #![feature(rustc_attrs)] +#![feature(hash_raw_entry)] #![recursion_limit="512"] diff --git a/src/librustc/mir/interpret/pointer.rs b/src/librustc/mir/interpret/pointer.rs index 1bb4d9ea4d6..7c77b2c0711 100644 --- a/src/librustc/mir/interpret/pointer.rs +++ b/src/librustc/mir/interpret/pointer.rs @@ -1,4 +1,5 @@ use std::fmt::{self, Display}; +use std::convert::TryFrom; use crate::mir; use crate::ty::layout::{self, HasDataLayout, Size}; @@ -40,6 +41,18 @@ pub trait PointerArithmetic: layout::HasDataLayout { self.data_layout().pointer_size } + #[inline] + fn usize_max(&self) -> u64 { + let max_usize_plus_1 = 1u128 << self.pointer_size().bits(); + u64::try_from(max_usize_plus_1-1).unwrap() + } + + #[inline] + fn isize_max(&self) -> i64 { + let max_isize_plus_1 = 1u128 << (self.pointer_size().bits()-1); + i64::try_from(max_isize_plus_1-1).unwrap() + } + /// Helper function: truncate given value-"overflowed flag" pair to pointer size and /// update "overflowed flag" if there was an overflow. /// This should be called by all the other methods before returning! diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 214de35b6d0..52a784d3fc0 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -14,12 +14,13 @@ use errors::Level; use errors::Diagnostic; use errors::FatalError; use errors::Handler; -use rustc_data_structures::fx::{FxHashMap}; +use rustc_data_structures::fx::{FxHasher, FxHashMap}; use rustc_data_structures::sync::{Lrc, Lock}; use rustc_data_structures::sharded::Sharded; use rustc_data_structures::thin_vec::ThinVec; #[cfg(not(parallel_compiler))] use rustc_data_structures::cold_path; +use std::hash::{Hash, Hasher}; use std::mem; use std::ptr; use std::collections::hash_map::Entry; @@ -82,8 +83,17 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> { pub(super) fn try_get(tcx: TyCtxt<'tcx>, span: Span, key: &Q::Key) -> TryGetJob<'a, 'tcx, Q> { let cache = Q::query_cache(tcx); loop { - let mut lock = cache.get_shard_by_value(key).lock(); - if let Some(value) = lock.results.get(key) { + // We compute the key's hash once and then use it for both the + // shard lookup and the hashmap lookup. This relies on the fact + // that both of them use `FxHasher`. + let mut state = FxHasher::default(); + key.hash(&mut state); + let key_hash = state.finish(); + + let mut lock = cache.get_shard_by_hash(key_hash).lock(); + if let Some((_, value)) = + lock.results.raw_entry().from_key_hashed_nocheck(key_hash, key) + { tcx.prof.query_cache_hit(Q::NAME); let result = (value.value.clone(), value.index); #[cfg(debug_assertions)] diff --git a/src/librustc_data_structures/sharded.rs b/src/librustc_data_structures/sharded.rs index 2f972eeccdc..a28a5e0f041 100644 --- a/src/librustc_data_structures/sharded.rs +++ b/src/librustc_data_structures/sharded.rs @@ -60,6 +60,7 @@ impl<T> Sharded<T> { } } + /// The shard is selected by hashing `val` with `FxHasher`. #[inline] pub fn get_shard_by_value<K: Hash + ?Sized>(&self, val: &K) -> &Lock<T> { if SHARDS == 1 { @@ -69,6 +70,11 @@ impl<T> Sharded<T> { } } + /// Get a shard with a pre-computed hash value. If `get_shard_by_value` is + /// ever used in combination with `get_shard_by_hash` on a single `Sharded` + /// instance, then `hash` must be computed with `FxHasher`. Otherwise, + /// `hash` can be computed with any hasher, so long as that hasher is used + /// consistently for each `Sharded` instance. #[inline] pub fn get_shard_by_hash(&self, hash: u64) -> &Lock<T> { let hash_len = mem::size_of::<usize>(); diff --git a/src/librustc_error_codes/error_codes/E0744.md b/src/librustc_error_codes/error_codes/E0744.md index 254223f3565..b299102fd69 100644 --- a/src/librustc_error_codes/error_codes/E0744.md +++ b/src/librustc_error_codes/error_codes/E0744.md @@ -15,3 +15,10 @@ const _: i32 = { x }; ``` + +This will be allowed at some point in the future, but the implementation is not +yet complete. See the tracking issue for [conditionals] or [loops] in a const +context for the current status. + +[conditionals]: https://github.com/rust-lang/rust/issues/49146 +[loops]: https://github.com/rust-lang/rust/issues/52000 diff --git a/src/librustc_mir/transform/check_consts/validation.rs b/src/librustc_mir/transform/check_consts/validation.rs index 88f16299dc0..74b22d8e143 100644 --- a/src/librustc_mir/transform/check_consts/validation.rs +++ b/src/librustc_mir/transform/check_consts/validation.rs @@ -326,17 +326,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { let is_thread_local = self.tcx.has_attr(*def_id, sym::thread_local); if is_thread_local { self.check_op(ops::ThreadLocalAccess); - } else if self.const_kind() == ConstKind::Static && context.is_mutating_use() { - // this is not strictly necessary as miri will also bail out - // For interior mutability we can't really catch this statically as that - // goes through raw pointers and intermediate temporaries, so miri has - // to catch this anyway - - self.tcx.sess.span_err( - self.span, - "cannot mutate statics in the initializer of another static", - ); - } else { + } else if self.const_kind() != ConstKind::Static || !context.is_mutating_use() { self.check_op(ops::StaticAccess); } } diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 185a499bf48..964efdec2b9 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -787,19 +787,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { // Only allow statics (not consts) to refer to other statics. if self.mode == Mode::Static || self.mode == Mode::StaticMut { - if self.mode == Mode::Static - && context.is_mutating_use() - && !self.suppress_errors - { - // this is not strictly necessary as miri will also bail out - // For interior mutability we can't really catch this statically as that - // goes through raw pointers and intermediate temporaries, so miri has - // to catch this anyway - self.tcx.sess.span_err( - self.span, - "cannot mutate statics in the initializer of another static", - ); - } return; } unleash_miri!(self); diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index 24d6331bbd3..6b068387974 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -1767,7 +1767,9 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { fn with_resolved_label(&mut self, label: Option<Label>, id: NodeId, f: impl FnOnce(&mut Self)) { if let Some(label) = label { - self.diagnostic_metadata.unused_labels.insert(id, label.ident.span); + if label.ident.as_str().as_bytes()[1] != b'_' { + self.diagnostic_metadata.unused_labels.insert(id, label.ident.span); + } self.with_label_rib(NormalRibKind, |this| { let ident = label.ident.modern_and_legacy(); this.label_ribs.last_mut().unwrap().bindings.insert(ident, id); diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index ff9c945eec4..6e37c0dbbdf 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -244,7 +244,13 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> { // can be reborrowed without needing to spill to a temporary. // If this were not the case, then we could conceivably have // to create intermediate temporaries.) - let ty = self.fcx.tables.borrow().expr_ty(expr); - self.record(ty, scope, Some(expr), expr.span); + // + // The type table might not have information for this expression + // if it is in a malformed scope. (#66387) + if let Some(ty) = self.fcx.tables.borrow().expr_ty_opt(expr) { + self.record(ty, scope, Some(expr), expr.span); + } else { + self.fcx.tcx.sess.delay_span_bug(expr.span, "no type for node"); + } } } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 41c8fc02662..a8418c5f349 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3108,7 +3108,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fallback_has_occurred: bool, mutate_fullfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>), ) { - if let Err(mut errors) = self.fulfillment_cx.borrow_mut().select_where_possible(self) { + let result = self.fulfillment_cx.borrow_mut().select_where_possible(self); + if let Err(mut errors) = result { mutate_fullfillment_errors(&mut errors); self.report_fulfillment_errors(&errors, self.inh.body_id, fallback_has_occurred); } diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 04c0a0f005b..752b93f2ac5 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1081,14 +1081,13 @@ function getSearchElement() { val = paths[paths.length - 1]; var contains = paths.slice(0, paths.length > 1 ? paths.length - 1 : 1); + var lev; + var lev_distance; for (j = 0; j < nSearchWords; ++j) { - var lev; - var lev_distance; ty = searchIndex[j]; if (!ty || (filterCrates !== undefined && ty.crate !== filterCrates)) { continue; } - var lev_distance; var lev_add = 0; if (paths.length > 1) { lev = checkPath(contains, paths[paths.length - 1], ty); @@ -1633,7 +1632,7 @@ function getSearchElement() { } var filterCrates = getFilterCrates(); - showResults(execSearch(query, index, filterCrates), filterCrates); + showResults(execSearch(query, index, filterCrates)); } function buildIndex(rawSearchIndex) { diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 6b9a35fccc4..df24b6635f4 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -725,6 +725,9 @@ impl dyn Error { /// Returns an iterator starting with the current error and continuing with /// recursively calling [`source`]. /// + /// If you want to omit the current error and only use its sources, + /// use `skip(1)`. + /// /// # Examples /// /// ``` @@ -763,7 +766,7 @@ impl dyn Error { /// // let err : Box<Error> = b.into(); // or /// let err = &b as &(dyn Error); /// - /// let mut iter = err.iter_chain(); + /// let mut iter = err.chain(); /// /// assert_eq!("B".to_string(), iter.next().unwrap().to_string()); /// assert_eq!("A".to_string(), iter.next().unwrap().to_string()); @@ -774,98 +777,27 @@ impl dyn Error { /// [`source`]: trait.Error.html#method.source #[unstable(feature = "error_iter", issue = "58520")] #[inline] - pub fn iter_chain(&self) -> ErrorIter<'_> { - ErrorIter { + pub fn chain(&self) -> Chain<'_> { + Chain { current: Some(self), } } - - /// Returns an iterator starting with the [`source`] of this error - /// and continuing with recursively calling [`source`]. - /// - /// # Examples - /// - /// ``` - /// #![feature(error_iter)] - /// use std::error::Error; - /// use std::fmt; - /// - /// #[derive(Debug)] - /// struct A; - /// - /// #[derive(Debug)] - /// struct B(Option<Box<dyn Error + 'static>>); - /// - /// #[derive(Debug)] - /// struct C(Option<Box<dyn Error + 'static>>); - /// - /// impl fmt::Display for A { - /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - /// write!(f, "A") - /// } - /// } - /// - /// impl fmt::Display for B { - /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - /// write!(f, "B") - /// } - /// } - /// - /// impl fmt::Display for C { - /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - /// write!(f, "C") - /// } - /// } - /// - /// impl Error for A {} - /// - /// impl Error for B { - /// fn source(&self) -> Option<&(dyn Error + 'static)> { - /// self.0.as_ref().map(|e| e.as_ref()) - /// } - /// } - /// - /// impl Error for C { - /// fn source(&self) -> Option<&(dyn Error + 'static)> { - /// self.0.as_ref().map(|e| e.as_ref()) - /// } - /// } - /// - /// let b = B(Some(Box::new(A))); - /// let c = C(Some(Box::new(b))); - /// - /// // let err : Box<Error> = c.into(); // or - /// let err = &c as &(dyn Error); - /// - /// let mut iter = err.iter_sources(); - /// - /// assert_eq!("B".to_string(), iter.next().unwrap().to_string()); - /// assert_eq!("A".to_string(), iter.next().unwrap().to_string()); - /// assert!(iter.next().is_none()); - /// assert!(iter.next().is_none()); - /// ``` - /// - /// [`source`]: trait.Error.html#method.source - #[inline] - #[unstable(feature = "error_iter", issue = "58520")] - pub fn iter_sources(&self) -> ErrorIter<'_> { - ErrorIter { - current: self.source(), - } - } } -/// An iterator over [`Error`] +/// An iterator over an [`Error`] and its sources. +/// +/// If you want to omit the initial error and only process +/// its sources, use `skip(1)`. /// /// [`Error`]: trait.Error.html #[unstable(feature = "error_iter", issue = "58520")] #[derive(Copy, Clone, Debug)] -pub struct ErrorIter<'a> { +pub struct Chain<'a> { current: Option<&'a (dyn Error + 'static)>, } #[unstable(feature = "error_iter", issue = "58520")] -impl<'a> Iterator for ErrorIter<'a> { +impl<'a> Iterator for Chain<'a> { type Item = &'a (dyn Error + 'static); fn next(&mut self) -> Option<Self::Item> { diff --git a/src/libstd/future.rs b/src/libstd/future.rs index c65f71fb1a4..6de3f1d545b 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -40,10 +40,11 @@ impl<T: Generator<Yield = ()>> Future for GenFuture<T> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { // Safe because we're !Unpin + !Drop mapping to a ?Unpin value let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) }; - set_task_context(cx, || match gen.resume() { + let _guard = unsafe { set_task_context(cx) }; + match gen.resume() { GeneratorState::Yielded(()) => Poll::Pending, GeneratorState::Complete(x) => Poll::Ready(x), - }) + } } } @@ -61,35 +62,23 @@ impl Drop for SetOnDrop { } } -#[doc(hidden)] -#[unstable(feature = "gen_future", issue = "50547")] -/// Sets the thread-local task context used by async/await futures. -pub fn set_task_context<F, R>(cx: &mut Context<'_>, f: F) -> R -where - F: FnOnce() -> R -{ +// Safety: the returned guard must drop before `cx` is dropped and before +// any previous guard is dropped. +unsafe fn set_task_context(cx: &mut Context<'_>) -> SetOnDrop { // transmute the context's lifetime to 'static so we can store it. - let cx = unsafe { - core::mem::transmute::<&mut Context<'_>, &mut Context<'static>>(cx) - }; + let cx = core::mem::transmute::<&mut Context<'_>, &mut Context<'static>>(cx); let old_cx = TLS_CX.with(|tls_cx| { tls_cx.replace(Some(NonNull::from(cx))) }); - let _reset = SetOnDrop(old_cx); - f() + SetOnDrop(old_cx) } #[doc(hidden)] #[unstable(feature = "gen_future", issue = "50547")] -/// Retrieves the thread-local task context used by async/await futures. -/// -/// This function acquires exclusive access to the task context. -/// -/// Panics if no context has been set or if the context has already been -/// retrieved by a surrounding call to get_task_context. -pub fn get_task_context<F, R>(f: F) -> R +/// Polls a future in the current thread-local task waker. +pub fn poll_with_tls_context<F>(f: Pin<&mut F>) -> Poll<F::Output> where - F: FnOnce(&mut Context<'_>) -> R + F: Future { let cx_ptr = TLS_CX.with(|tls_cx| { // Clear the entry so that nested `get_task_waker` calls @@ -108,15 +97,5 @@ where // // The pointer that was inserted came from an `&mut Context<'_>`, // so it is safe to treat as mutable. - unsafe { f(cx_ptr.as_mut()) } -} - -#[doc(hidden)] -#[unstable(feature = "gen_future", issue = "50547")] -/// Polls a future in the current thread-local task waker. -pub fn poll_with_tls_context<F>(f: Pin<&mut F>) -> Poll<F::Output> -where - F: Future -{ - get_task_context(|cx| F::poll(f, cx)) + unsafe { F::poll(f, cx_ptr.as_mut()) } } diff --git a/src/test/ui/async-await/issue-66387-if-without-else.rs b/src/test/ui/async-await/issue-66387-if-without-else.rs new file mode 100644 index 00000000000..aa5a8db6121 --- /dev/null +++ b/src/test/ui/async-await/issue-66387-if-without-else.rs @@ -0,0 +1,10 @@ +// edition:2018 +async fn f() -> i32 { + if true { //~ ERROR if may be missing an else clause + return 0; + } + // An `if` block without `else` causes the type table not to have a type for this expr. + // Check that we do not unconditionally access the type table and we don't ICE. +} + +fn main() {} diff --git a/src/test/ui/async-await/issue-66387-if-without-else.stderr b/src/test/ui/async-await/issue-66387-if-without-else.stderr new file mode 100644 index 00000000000..32952059525 --- /dev/null +++ b/src/test/ui/async-await/issue-66387-if-without-else.stderr @@ -0,0 +1,16 @@ +error[E0317]: if may be missing an else clause + --> $DIR/issue-66387-if-without-else.rs:3:5 + | +LL | / if true { +LL | | return 0; +LL | | } + | |_____^ expected (), found i32 + | + = note: expected type `()` + found type `i32` + = note: `if` expressions without `else` evaluate to `()` + = help: consider adding an `else` block that evaluates to the expected type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0317`. diff --git a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs index b4c416b1c55..648caae30b4 100644 --- a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs +++ b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs @@ -7,7 +7,8 @@ use std::cell::UnsafeCell; static mut FOO: u32 = 42; static BOO: () = unsafe { - FOO = 5; //~ ERROR cannot mutate statics in the initializer of another static + FOO = 5; + //~^ could not evaluate static initializer [E0080] }; fn main() {} diff --git a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr index 02b72765b37..cb4d35b9a18 100644 --- a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr +++ b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr @@ -1,8 +1,9 @@ -error: cannot mutate statics in the initializer of another static +error[E0080]: could not evaluate static initializer --> $DIR/assign-to-static-within-other-static.rs:10:5 | LL | FOO = 5; - | ^^^^^^^ + | ^^^^^^^ tried to modify a static's initial value from another static's initializer error: aborting due to previous error +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/error-codes/E0017.rs b/src/test/ui/error-codes/E0017.rs index 71250eb4621..94b6587eb81 100644 --- a/src/test/ui/error-codes/E0017.rs +++ b/src/test/ui/error-codes/E0017.rs @@ -4,6 +4,5 @@ const C: i32 = 2; const CR: &'static mut i32 = &mut C; //~ ERROR E0017 static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 //~| ERROR cannot borrow - //~| ERROR cannot mutate statics static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 fn main() {} diff --git a/src/test/ui/error-codes/E0017.stderr b/src/test/ui/error-codes/E0017.stderr index 67ff7da611b..47863f02214 100644 --- a/src/test/ui/error-codes/E0017.stderr +++ b/src/test/ui/error-codes/E0017.stderr @@ -10,12 +10,6 @@ error[E0017]: references in statics may only refer to immutable values LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ statics require immutable values -error: cannot mutate statics in the initializer of another static - --> $DIR/E0017.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; - | ^^^^^^ - error[E0596]: cannot borrow immutable static item `X` as mutable --> $DIR/E0017.rs:5:39 | @@ -23,12 +17,12 @@ LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ cannot borrow as mutable error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0017.rs:8:38 + --> $DIR/E0017.rs:7:38 | LL | static CONST_REF: &'static mut i32 = &mut C; | ^^^^^^ statics require immutable values -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0017, E0596. For more information about an error, try `rustc --explain E0017`. diff --git a/src/test/ui/error-codes/E0388.rs b/src/test/ui/error-codes/E0388.rs index 817f2554ade..3aa4ac9655c 100644 --- a/src/test/ui/error-codes/E0388.rs +++ b/src/test/ui/error-codes/E0388.rs @@ -4,7 +4,6 @@ const C: i32 = 2; const CR: &'static mut i32 = &mut C; //~ ERROR E0017 static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 //~| ERROR cannot borrow - //~| ERROR cannot mutate statics static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 fn main() {} diff --git a/src/test/ui/error-codes/E0388.stderr b/src/test/ui/error-codes/E0388.stderr index e0ca4316732..b52d5260b13 100644 --- a/src/test/ui/error-codes/E0388.stderr +++ b/src/test/ui/error-codes/E0388.stderr @@ -10,12 +10,6 @@ error[E0017]: references in statics may only refer to immutable values LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ statics require immutable values -error: cannot mutate statics in the initializer of another static - --> $DIR/E0388.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; - | ^^^^^^ - error[E0596]: cannot borrow immutable static item `X` as mutable --> $DIR/E0388.rs:5:39 | @@ -23,12 +17,12 @@ LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ cannot borrow as mutable error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0388.rs:8:38 + --> $DIR/E0388.rs:7:38 | LL | static CONST_REF: &'static mut i32 = &mut C; | ^^^^^^ statics require immutable values -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0017, E0596. For more information about an error, try `rustc --explain E0017`. diff --git a/src/test/ui/issues/issue-66353.rs b/src/test/ui/issues/issue-66353.rs new file mode 100644 index 00000000000..d8abdd5206e --- /dev/null +++ b/src/test/ui/issues/issue-66353.rs @@ -0,0 +1,15 @@ +// #66353: ICE when trying to recover from incorrect associated type + +trait _Func<T> { + fn func(_: Self); +} + +trait _A { + type AssocT; +} + +fn main() { + _Func::< <() as _A>::AssocT >::func(()); + //~^ ERROR the trait bound `(): _A` is not satisfied + //~| ERROR the trait bound `(): _Func<_>` is not satisfied +} diff --git a/src/test/ui/issues/issue-66353.stderr b/src/test/ui/issues/issue-66353.stderr new file mode 100644 index 00000000000..8fd50300ca6 --- /dev/null +++ b/src/test/ui/issues/issue-66353.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `(): _A` is not satisfied + --> $DIR/issue-66353.rs:12:14 + | +LL | _Func::< <() as _A>::AssocT >::func(()); + | ^^^^^^^^^^^^^^^^^^ the trait `_A` is not implemented for `()` + +error[E0277]: the trait bound `(): _Func<_>` is not satisfied + --> $DIR/issue-66353.rs:12:41 + | +LL | fn func(_: Self); + | ----------------- required by `_Func::func` +... +LL | _Func::< <() as _A>::AssocT >::func(()); + | ^^ the trait `_Func<_>` is not implemented for `()` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/label/label-beginning-with-underscore.rs b/src/test/ui/label/label-beginning-with-underscore.rs new file mode 100644 index 00000000000..4b620864aab --- /dev/null +++ b/src/test/ui/label/label-beginning-with-underscore.rs @@ -0,0 +1,10 @@ +// check-pass + +#![deny(unused_labels)] + +fn main() { + // `unused_label` shouldn't warn labels beginning with `_` + '_unused: loop { + break; + } +} diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index 89bbde4d5a9..327de29037c 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -6,12 +6,15 @@ license = "MIT OR Apache-2.0" edition = "2018" [features] -linkcheck = ["mdbook-linkcheck"] +linkcheck = ["mdbook-linkcheck", "codespan-reporting"] [dependencies] clap = "2.25.0" failure = "0.1" -mdbook-linkcheck = { version = "0.3.0", optional = true } +mdbook-linkcheck = { version = "0.5.0", optional = true } +# Keep in sync with mdbook-linkcheck. +codespan-reporting = { version = "0.5", optional = true } + # A noop dependency that changes in the Rust repository, it's a bit of a hack. # See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust` diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index d5dc9a79b5a..fc283156693 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -12,8 +12,6 @@ use mdbook::MDBook; use failure::Error; #[cfg(feature = "linkcheck")] use mdbook::renderer::RenderContext; -#[cfg(feature = "linkcheck")] -use mdbook_linkcheck::{self, errors::BrokenLinks}; fn main() { let d_message = "-d, --dest-dir=[dest-dir] @@ -57,26 +55,7 @@ fn main() { { if let Err(err) = linkcheck(sub_matches) { eprintln!("Error: {}", err); - - // HACK: ignore timeouts - let actually_broken = err - .downcast::<BrokenLinks>() - .map(|broken_links| { - broken_links - .links() - .iter() - .inspect(|cause| eprintln!("\tCaused By: {}", cause)) - .fold(false, |already_broken, cause| { - already_broken || !format!("{}", cause).contains("timed out") - }) - }) - .unwrap_or(false); - - if actually_broken { - std::process::exit(101); - } else { - std::process::exit(0); - } + std::process::exit(101); } } @@ -99,8 +78,9 @@ pub fn linkcheck(args: &ArgMatches<'_>) -> Result<(), Error> { let book = MDBook::load(&book_dir).unwrap(); let cfg = book.config; let render_ctx = RenderContext::new(&book_dir, book.book, cfg, &book_dir); - - mdbook_linkcheck::check_links(&render_ctx) + let cache_file = render_ctx.destination.join("cache.json"); + let color = codespan_reporting::term::termcolor::ColorChoice::Auto; + mdbook_linkcheck::run(&cache_file, color, &render_ctx) } // Build command implementation @@ -124,11 +104,7 @@ fn get_book_dir(args: &ArgMatches<'_>) -> PathBuf { if let Some(dir) = args.value_of("dir") { // Check if path is relative from current dir, or absolute... let p = Path::new(dir); - if p.is_relative() { - env::current_dir().unwrap().join(dir) - } else { - p.to_path_buf() - } + if p.is_relative() { env::current_dir().unwrap().join(dir) } else { p.to_path_buf() } } else { env::current_dir().unwrap() } diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index e6ea1c75e28..e65f7a62cac 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -55,6 +55,9 @@ const EXCEPTIONS: &[&str] = &[ "sized-chunks", // MPL-2.0+, cargo via im-rc // FIXME: this dependency violates the documentation comment above: "fortanix-sgx-abi", // MPL-2.0+, libstd but only for `sgx` target + "dunce", // CC0-1.0 mdbook-linkcheck + "codespan-reporting", // Apache-2.0 mdbook-linkcheck + "codespan", // Apache-2.0 mdbook-linkcheck ]; /// Which crates to check against the whitelist? |
