From 04c108711e5be450b87ec2bf9cd628033972cd69 Mon Sep 17 00:00:00 2001 From: Patiga Date: Tue, 20 Sep 2022 02:56:23 +0200 Subject: [PATCH 01/11] Remove use of `io::ErrorKind::Other` in std The documentation states that this `ErrorKind` is not used by the standard library. Instead, `io::ErrorKind::Uncategorized` should be used. --- library/std/src/sys/unix/process/process_unix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 26ae62817713..2ff8e600f7c5 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -822,14 +822,14 @@ fn pidfd(&self) -> io::Result<&PidFd> { self.handle .pidfd .as_ref() - .ok_or_else(|| Error::new(ErrorKind::Other, "No pidfd was created.")) + .ok_or_else(|| Error::new(ErrorKind::Uncategorized, "No pidfd was created.")) } fn take_pidfd(&mut self) -> io::Result { self.handle .pidfd .take() - .ok_or_else(|| Error::new(ErrorKind::Other, "No pidfd was created.")) + .ok_or_else(|| Error::new(ErrorKind::Uncategorized, "No pidfd was created.")) } } From 5922d6cf60169ad0fd792581c9da11bd633533da Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 19 Sep 2022 18:43:15 -0500 Subject: [PATCH 02/11] slightly cleanup building SelectionContext --- .../src/traits/select/mod.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 8b15e10ba9cb..6bdd613be5aa 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -226,13 +226,7 @@ pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx>) -> SelectionContext<'cx, 'tcx> { } pub fn intercrate(infcx: &'cx InferCtxt<'cx, 'tcx>) -> SelectionContext<'cx, 'tcx> { - SelectionContext { - infcx, - freshener: infcx.freshener_keep_static(), - intercrate: true, - intercrate_ambiguity_causes: None, - query_mode: TraitQueryMode::Standard, - } + SelectionContext { intercrate: true, ..SelectionContext::new(infcx) } } pub fn with_query_mode( @@ -240,13 +234,7 @@ pub fn with_query_mode( query_mode: TraitQueryMode, ) -> SelectionContext<'cx, 'tcx> { debug!(?query_mode, "with_query_mode"); - SelectionContext { - infcx, - freshener: infcx.freshener_keep_static(), - intercrate: false, - intercrate_ambiguity_causes: None, - query_mode, - } + SelectionContext { query_mode, ..SelectionContext::new(infcx) } } /// Enables tracking of intercrate ambiguity causes. See From 749dec64519b5bdfe688cb945eeee5afd6ab68d0 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 19 Sep 2022 20:57:37 -0500 Subject: [PATCH 03/11] Make `OUT` an associated type instead of a generic parameter This avoids toil when changing other functions in `ObligationForest` to take an `OUT` parameter. --- compiler/rustc_data_structures/src/obligation_forest/mod.rs | 4 ++++ compiler/rustc_data_structures/src/obligation_forest/tests.rs | 1 + compiler/rustc_trait_selection/src/traits/fulfill.rs | 1 + 3 files changed, 6 insertions(+) diff --git a/compiler/rustc_data_structures/src/obligation_forest/mod.rs b/compiler/rustc_data_structures/src/obligation_forest/mod.rs index e351b650a16c..f2d72647a668 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/mod.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/mod.rs @@ -95,6 +95,10 @@ pub trait ForestObligation: Clone + Debug { pub trait ObligationProcessor { type Obligation: ForestObligation; type Error: Debug; + type OUT: OutcomeTrait< + Obligation = Self::Obligation, + Error = Error, + >; fn needs_process_obligation(&self, obligation: &Self::Obligation) -> bool; diff --git a/compiler/rustc_data_structures/src/obligation_forest/tests.rs b/compiler/rustc_data_structures/src/obligation_forest/tests.rs index e2991aae1742..f2a04796691a 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/tests.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/tests.rs @@ -64,6 +64,7 @@ impl ObligationProcessor for ClosureObligationProcessor; fn needs_process_obligation(&self, _obligation: &Self::Obligation) -> bool { true diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index 3763a98c488b..0ea2b6ce885f 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -224,6 +224,7 @@ fn mk_pending(os: Vec>) -> Vec ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> { type Obligation = PendingPredicateObligation<'tcx>; type Error = FulfillmentErrorCode<'tcx>; + type OUT = Outcome; /// Identifies whether a predicate obligation needs processing. /// From 1512ce5925eeafc01f011c46216c157e4e5644cb Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 19 Sep 2022 20:45:00 -0500 Subject: [PATCH 04/11] Make cycle errors recoverable In particular, this allows rustdoc to recover from cycle errors when normalizing associated types for documentation. In the past, `@jackh726` has said we need to be careful about overflow errors: > Off the top of my head, we definitely should be careful about treating overflow errors the same as "not implemented for some reason" errors. Otherwise, you could end up with behavior that is different depending on recursion depth. But, that might be context-dependent. But cycle errors should be safe to unconditionally report; they don't depend on the recursion depth, they will always be an error whenever they're encountered. --- .../src/obligation_forest/mod.rs | 33 ++++++++++++------- .../src/obligation_forest/tests.rs | 7 +++- compiler/rustc_infer/src/traits/mod.rs | 2 ++ .../src/traits/structural_impls.rs | 1 + .../src/traits/codegen.rs | 10 ++++++ .../src/traits/error_reporting/mod.rs | 3 ++ .../src/traits/fulfill.rs | 9 ++--- src/test/rustdoc-ui/normalize-cycle.rs | 1 + 8 files changed, 50 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_data_structures/src/obligation_forest/mod.rs b/compiler/rustc_data_structures/src/obligation_forest/mod.rs index f2d72647a668..10e673cd9297 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/mod.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/mod.rs @@ -115,7 +115,11 @@ fn process_obligation( /// In other words, if we had O1 which required O2 which required /// O3 which required O1, we would give an iterator yielding O1, /// O2, O3 (O1 is not yielded twice). - fn process_backedge<'c, I>(&mut self, cycle: I, _marker: PhantomData<&'c Self::Obligation>) + fn process_backedge<'c, I>( + &mut self, + cycle: I, + _marker: PhantomData<&'c Self::Obligation>, + ) -> Result<(), Self::Error> where I: Clone + Iterator; } @@ -406,12 +410,11 @@ fn insert_into_error_cache(&mut self, index: usize) { /// Performs a fixpoint computation over the obligation list. #[inline(never)] - pub fn process_obligations(&mut self, processor: &mut P) -> OUT + pub fn process_obligations

(&mut self, processor: &mut P) -> P::OUT where P: ObligationProcessor, - OUT: OutcomeTrait>, { - let mut outcome = OUT::new(); + let mut outcome = P::OUT::new(); // Fixpoint computation: we repeat until the inner loop stalls. loop { @@ -477,7 +480,7 @@ pub fn process_obligations(&mut self, processor: &mut P) -> OUT } self.mark_successes(); - self.process_cycles(processor); + self.process_cycles(processor, &mut outcome); self.compress(|obl| outcome.record_completed(obl)); } @@ -562,7 +565,7 @@ fn uninlined_mark_dependents_as_waiting(&self, node: &Node) { /// Report cycles between all `Success` nodes, and convert all `Success` /// nodes to `Done`. This must be called after `mark_successes`. - fn process_cycles

(&mut self, processor: &mut P) + fn process_cycles

(&mut self, processor: &mut P, outcome: &mut P::OUT) where P: ObligationProcessor, { @@ -572,7 +575,7 @@ fn process_cycles

(&mut self, processor: &mut P) // to handle the no-op cases immediately to avoid the cost of the // function call. if node.state.get() == NodeState::Success { - self.find_cycles_from_node(&mut stack, processor, index); + self.find_cycles_from_node(&mut stack, processor, index, outcome); } } @@ -580,8 +583,13 @@ fn process_cycles

(&mut self, processor: &mut P) self.reused_node_vec = stack; } - fn find_cycles_from_node

(&self, stack: &mut Vec, processor: &mut P, index: usize) - where + fn find_cycles_from_node

( + &self, + stack: &mut Vec, + processor: &mut P, + index: usize, + outcome: &mut P::OUT, + ) where P: ObligationProcessor, { let node = &self.nodes[index]; @@ -590,17 +598,20 @@ fn find_cycles_from_node

(&self, stack: &mut Vec, processor: &mut P, in None => { stack.push(index); for &dep_index in node.dependents.iter() { - self.find_cycles_from_node(stack, processor, dep_index); + self.find_cycles_from_node(stack, processor, dep_index, outcome); } stack.pop(); node.state.set(NodeState::Done); } Some(rpos) => { // Cycle detected. - processor.process_backedge( + let result = processor.process_backedge( stack[rpos..].iter().map(|&i| &self.nodes[i].obligation), PhantomData, ); + if let Err(err) = result { + outcome.record_error(Error { error: err, backtrace: self.error_at(index) }); + } } } } diff --git a/compiler/rustc_data_structures/src/obligation_forest/tests.rs b/compiler/rustc_data_structures/src/obligation_forest/tests.rs index f2a04796691a..bc252f772a16 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/tests.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/tests.rs @@ -77,10 +77,15 @@ fn process_obligation( (self.process_obligation)(obligation) } - fn process_backedge<'c, I>(&mut self, _cycle: I, _marker: PhantomData<&'c Self::Obligation>) + fn process_backedge<'c, I>( + &mut self, + _cycle: I, + _marker: PhantomData<&'c Self::Obligation>, + ) -> Result<(), Self::Error> where I: Clone + Iterator, { + Ok(()) } } diff --git a/compiler/rustc_infer/src/traits/mod.rs b/compiler/rustc_infer/src/traits/mod.rs index 4df4de21a0f0..ed2beefc6e77 100644 --- a/compiler/rustc_infer/src/traits/mod.rs +++ b/compiler/rustc_infer/src/traits/mod.rs @@ -105,6 +105,8 @@ pub struct FulfillmentError<'tcx> { #[derive(Clone)] pub enum FulfillmentErrorCode<'tcx> { + /// Inherently impossible to fulfill; this trait is implemented if and only if it is already implemented. + CodeCycle(Vec>>), CodeSelectionError(SelectionError<'tcx>), CodeProjectionError(MismatchedProjectionTypes<'tcx>), CodeSubtypeError(ExpectedFound>, TypeError<'tcx>), // always comes from a SubtypePredicate diff --git a/compiler/rustc_infer/src/traits/structural_impls.rs b/compiler/rustc_infer/src/traits/structural_impls.rs index 573d2d1e3301..1c6ab6a082b9 100644 --- a/compiler/rustc_infer/src/traits/structural_impls.rs +++ b/compiler/rustc_infer/src/traits/structural_impls.rs @@ -47,6 +47,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "CodeConstEquateError({:?}, {:?})", a, b) } super::CodeAmbiguity => write!(f, "Ambiguity"), + super::CodeCycle(ref cycle) => write!(f, "Cycle({:?})", cycle), } } } diff --git a/compiler/rustc_trait_selection/src/traits/codegen.rs b/compiler/rustc_trait_selection/src/traits/codegen.rs index 08adbcbd410c..0155798c8b6d 100644 --- a/compiler/rustc_trait_selection/src/traits/codegen.rs +++ b/compiler/rustc_trait_selection/src/traits/codegen.rs @@ -4,10 +4,12 @@ // general routines. use crate::infer::{DefiningAnchor, TyCtxtInferExt}; +use crate::traits::error_reporting::InferCtxtExt; use crate::traits::{ ImplSource, Obligation, ObligationCause, SelectionContext, TraitEngine, TraitEngineExt, Unimplemented, }; +use rustc_infer::traits::FulfillmentErrorCode; use rustc_middle::traits::CodegenObligationError; use rustc_middle::ty::{self, TyCtxt}; @@ -62,6 +64,14 @@ pub fn codegen_select_candidate<'tcx>( // optimization to stop iterating early. let errors = fulfill_cx.select_all_or_error(&infcx); if !errors.is_empty() { + // `rustc_monomorphize::collector` assumes there are no type errors. + // Cycle errors are the only post-monomorphization errors possible; emit them now so + // `rustc_ty_utils::resolve_associated_item` doesn't return `None` post-monomorphization. + for err in errors { + if let FulfillmentErrorCode::CodeCycle(cycle) = err.code { + infcx.report_overflow_error_cycle(&cycle); + } + } return Err(CodegenObligationError::FulfillmentError); } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index efdb1ace1399..d62b399c1b56 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1540,6 +1540,9 @@ fn report_fulfillment_error( } diag.emit(); } + FulfillmentErrorCode::CodeCycle(ref cycle) => { + self.report_overflow_error_cycle(cycle); + } } } diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index 0ea2b6ce885f..1cd8e1c21236 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -25,10 +25,9 @@ use super::{FulfillmentError, FulfillmentErrorCode}; use super::{ObligationCause, PredicateObligation}; -use crate::traits::error_reporting::InferCtxtExt as _; use crate::traits::project::PolyProjectionObligation; use crate::traits::project::ProjectionCacheKeyExt as _; -use crate::traits::query::evaluate_obligation::InferCtxtExt as _; +use crate::traits::query::evaluate_obligation::InferCtxtExt; impl<'tcx> ForestObligation for PendingPredicateObligation<'tcx> { /// Note that we include both the `ParamEnv` and the `Predicate`, @@ -603,14 +602,16 @@ fn process_backedge<'c, I>( &mut self, cycle: I, _marker: PhantomData<&'c PendingPredicateObligation<'tcx>>, - ) where + ) -> Result<(), FulfillmentErrorCode<'tcx>> + where I: Clone + Iterator>, { if self.selcx.coinductive_match(cycle.clone().map(|s| s.obligation.predicate)) { debug!("process_child_obligations: coinductive match"); + Ok(()) } else { let cycle: Vec<_> = cycle.map(|c| c.obligation.clone()).collect(); - self.selcx.infcx().report_overflow_error_cycle(&cycle); + Err(FulfillmentErrorCode::CodeCycle(cycle)) } } } diff --git a/src/test/rustdoc-ui/normalize-cycle.rs b/src/test/rustdoc-ui/normalize-cycle.rs index 14ffac1e1dce..1ed9ac6bc34a 100644 --- a/src/test/rustdoc-ui/normalize-cycle.rs +++ b/src/test/rustdoc-ui/normalize-cycle.rs @@ -1,4 +1,5 @@ // check-pass +// compile-flags: -Znormalize-docs // Regression test for . pub trait Query {} From a72666ed56ec5f1b6d254c7020cf86143edc6dbd Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 20 Sep 2022 13:03:43 -0700 Subject: [PATCH 05/11] rustc_transmute: fix big-endian discriminants --- compiler/rustc_transmute/src/layout/tree.rs | 22 +++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index 211c813b8001..acd4fa63d782 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -404,7 +404,7 @@ fn from_repr_c_variant( .unwrap(); trace!(?discr_layout, "computed discriminant layout"); variant_layout = variant_layout.extend(discr_layout).unwrap().0; - tree = tree.then(Self::from_disr(discr, tcx, layout_summary.discriminant_size)); + tree = tree.then(Self::from_discr(discr, tcx, layout_summary.discriminant_size)); } // Next come fields. @@ -444,11 +444,21 @@ fn from_repr_c_variant( Ok(tree) } - pub fn from_disr(discr: Discr<'tcx>, tcx: TyCtxt<'tcx>, size: usize) -> Self { - // FIXME(@jswrenn): I'm certain this is missing needed endian nuance. - let bytes = discr.val.to_ne_bytes(); - let bytes = &bytes[..size]; - Self::Seq(bytes.into_iter().copied().map(|b| Self::from_bits(b)).collect()) + pub fn from_discr(discr: Discr<'tcx>, tcx: TyCtxt<'tcx>, size: usize) -> Self { + use rustc_target::abi::Endian; + + let bytes: [u8; 16]; + let bytes = match tcx.data_layout.endian { + Endian::Little => { + bytes = discr.val.to_le_bytes(); + &bytes[..size] + } + Endian::Big => { + bytes = discr.val.to_be_bytes(); + &bytes[bytes.len() - size..] + } + }; + Self::Seq(bytes.iter().map(|&b| Self::from_bits(b)).collect()) } } From 5b96e5e71a9152fb1c5f29e46f131dc95c004ab6 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 20 Sep 2022 19:52:56 +0000 Subject: [PATCH 06/11] Skip Equate relation in handle_opaque_type --- compiler/rustc_infer/src/infer/opaque_types.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs index 561279e3c8e6..76c340a5efae 100644 --- a/compiler/rustc_infer/src/infer/opaque_types.rs +++ b/compiler/rustc_infer/src/infer/opaque_types.rs @@ -7,6 +7,7 @@ use rustc_data_structures::vec_map::VecMap; use rustc_hir as hir; use rustc_middle::traits::ObligationCause; +use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::fold::BottomUpFolder; use rustc_middle::ty::GenericArgKind; use rustc_middle::ty::{ @@ -176,16 +177,8 @@ pub fn handle_opaque_type( } else if let Some(res) = process(b, a) { res } else { - // Rerun equality check, but this time error out due to - // different types. - match self.at(cause, param_env).define_opaque_types(false).eq(a, b) { - Ok(_) => span_bug!( - cause.span, - "opaque types are never equal to anything but themselves: {:#?}", - (a.kind(), b.kind()) - ), - Err(e) => Err(e), - } + let (a, b) = self.resolve_vars_if_possible((a, b)); + Err(TypeError::Sorts(ExpectedFound::new(true, a, b))) } } From 3d5a41724bd72c228a9e26a44a55337672c7dee3 Mon Sep 17 00:00:00 2001 From: Chris Wailes Date: Thu, 8 Sep 2022 16:33:44 -0700 Subject: [PATCH 07/11] Update rustc's information on Android's sanitizers This patch updates sanitizier support definitions for Android inside the compiler. It also adjusts the logic to make sure no pre-built sanitizer runtime libraries are emitted as these are instead provided dynamically on Android targets. --- compiler/rustc_codegen_ssa/src/back/link.rs | 11 ++++++----- compiler/rustc_target/src/spec/android_base.rs | 4 +++- .../rustc_target/src/spec/i686_unknown_linux_gnu.rs | 3 ++- compiler/rustc_target/src/spec/mod.rs | 5 +++++ src/tools/compiletest/src/util.rs | 6 ++++++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index c5e18c7fae89..bb57fca74a21 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1090,11 +1090,12 @@ fn add_sanitizer_libraries(sess: &Session, crate_type: CrateType, linker: &mut d // both executables and dynamic shared objects. Everywhere else the runtimes // are currently distributed as static libraries which should be linked to // executables only. - let needs_runtime = match crate_type { - CrateType::Executable => true, - CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro => sess.target.is_like_osx, - CrateType::Rlib | CrateType::Staticlib => false, - }; + let needs_runtime = !sess.target.is_like_android + && match crate_type { + CrateType::Executable => true, + CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro => sess.target.is_like_osx, + CrateType::Rlib | CrateType::Staticlib => false, + }; if !needs_runtime { return; diff --git a/compiler/rustc_target/src/spec/android_base.rs b/compiler/rustc_target/src/spec/android_base.rs index 9f3e0bd5ef0e..9c1df1a06778 100644 --- a/compiler/rustc_target/src/spec/android_base.rs +++ b/compiler/rustc_target/src/spec/android_base.rs @@ -1,10 +1,12 @@ -use crate::spec::TargetOptions; +use crate::spec::{SanitizerSet, TargetOptions}; pub fn opts() -> TargetOptions { let mut base = super::linux_base::opts(); base.os = "android".into(); + base.is_like_android = true; base.default_dwarf_version = 2; base.has_thread_local = false; + base.supported_sanitizers = SanitizerSet::ADDRESS; // This is for backward compatibility, see https://github.com/rust-lang/rust/issues/49867 // for context. (At that time, there was no `-C force-unwind-tables`, so the only solution // was to always emit `uwtable`). diff --git a/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs index 765803d16928..f62029c90673 100644 --- a/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs @@ -1,9 +1,10 @@ -use crate::spec::{LinkerFlavor, StackProbeType, Target}; +use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::linux_gnu_base::opts(); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); + base.supported_sanitizers = SanitizerSet::ADDRESS; base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32"]); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index dc16739bd560..24d2f3f43f1d 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1379,6 +1379,8 @@ pub struct TargetOptions { pub is_like_msvc: bool, /// Whether a target toolchain is like WASM. pub is_like_wasm: bool, + /// Whether a target toolchain is like Android, implying a Linux kernel and a Bionic libc + pub is_like_android: bool, /// Default supported version of DWARF on this platform. /// Useful because some platforms (osx, bsd) only want up to DWARF2. pub default_dwarf_version: u32, @@ -1671,6 +1673,7 @@ fn default() -> TargetOptions { is_like_windows: false, is_like_msvc: false, is_like_wasm: false, + is_like_android: false, default_dwarf_version: 4, allows_weak_linkage: true, has_rpath: false, @@ -2318,6 +2321,7 @@ macro_rules! key { key!(is_like_windows, bool); key!(is_like_msvc, bool); key!(is_like_wasm, bool); + key!(is_like_android, bool); key!(default_dwarf_version, u32); key!(allows_weak_linkage, bool); key!(has_rpath, bool); @@ -2568,6 +2572,7 @@ macro_rules! target_option_val { target_option_val!(is_like_windows); target_option_val!(is_like_msvc); target_option_val!(is_like_wasm); + target_option_val!(is_like_android); target_option_val!(default_dwarf_version); target_option_val!(allows_weak_linkage); target_option_val!(has_rpath); diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 9d047b63c859..e5ff0906be8a 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -11,9 +11,15 @@ pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[ "aarch64-apple-darwin", "aarch64-fuchsia", + "aarch64-linux-android", "aarch64-unknown-linux-gnu", + "arm-linux-androideabi", + "armv7-linux-androideabi", + "i686-linux-android", + "i686-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-fuchsia", + "x86_64-linux-android", "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu", ]; From e214385a4d1933ddb6a4c6ffeed50c7228674656 Mon Sep 17 00:00:00 2001 From: Urgau Date: Wed, 21 Sep 2022 19:01:49 +0200 Subject: [PATCH 08/11] Add missing space between notable trait tooltip and where clause --- src/librustdoc/html/format.rs | 2 +- .../rustdoc/where.SWhere_TraitWhere_item-decl.html | 7 ++++++- src/test/rustdoc/where.rs | 12 ++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index ec6b8c2469c5..b499e186cc04 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -371,7 +371,7 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>( format!("
where{where_preds}") } else { let mut clause = br_with_padding; - clause.truncate(clause.len() - 5 * " ".len()); + clause.truncate(clause.len() - 4 * " ".len()); write!(clause, "where{where_preds}")?; clause } diff --git a/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html b/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html index 0fbdc0c9cd1e..24ab77703d10 100644 --- a/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html +++ b/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html @@ -1,3 +1,8 @@

pub trait TraitWhere {
-    type Item<'a>
   where
        Self: 'a
; + type Item<'a>
    where
        Self: 'a
; + + fn func(self)
    where
        Self: Sized
, + { ... } + fn lines(self) -> Lines<Self>
    where
        Self: Sized
, + { ... } }
\ No newline at end of file diff --git a/src/test/rustdoc/where.rs b/src/test/rustdoc/where.rs index 8818d74ddd08..68a146bfa55b 100644 --- a/src/test/rustdoc/where.rs +++ b/src/test/rustdoc/where.rs @@ -1,5 +1,7 @@ #![crate_name = "foo"] +use std::io::Lines; + pub trait MyTrait { fn dummy(&self) { } } // @has foo/struct.Alpha.html '//pre' "pub struct Alpha(_)where A: MyTrait" @@ -29,6 +31,16 @@ pub fn delta() {} // @snapshot SWhere_TraitWhere_item-decl - '//div[@class="item-decl"]' pub trait TraitWhere { type Item<'a> where Self: 'a; + + fn func(self) + where + Self: Sized + {} + + fn lines(self) -> Lines + where + Self: Sized, + { todo!() } } // @has foo/struct.Echo.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ From 696472a5867dafa35c5262da709677075fab9dc8 Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Thu, 22 Sep 2022 01:28:45 +0200 Subject: [PATCH 09/11] Fix a typo in error message --- compiler/rustc_resolve/src/late/diagnostics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index c3c9b0b56178..3c276a9ada97 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -173,7 +173,7 @@ struct BaseError<'a> { span, span_label: match res { Res::Def(kind, def_id) if kind == DefKind::TyParam => { - self.def_span(def_id).map(|span| (span, "found this type pararmeter")) + self.def_span(def_id).map(|span| (span, "found this type parameter")) } _ => None, }, From 07767784ad667f4763e3ad6d7914849f3a43c65f Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Thu, 22 Sep 2022 01:32:37 +0200 Subject: [PATCH 10/11] Bless test output changes --- .../ui/const-generics/generic_const_exprs/issue-69654.stderr | 2 +- src/test/ui/lexical-scopes.stderr | 2 +- .../point-at-type-parameter-shadowing-another-type.stderr | 2 +- src/test/ui/span/issue-35987.stderr | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-69654.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-69654.stderr index 5ad457d547a6..c3e2f8e1646f 100644 --- a/src/test/ui/const-generics/generic_const_exprs/issue-69654.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/issue-69654.stderr @@ -4,7 +4,7 @@ error[E0423]: expected value, found type parameter `T` LL | impl Bar for [u8; T] {} | - ^ not a value | | - | found this type pararmeter + | found this type parameter error[E0599]: the function or associated item `foo` exists for struct `Foo<_>`, but its trait bounds were not satisfied --> $DIR/issue-69654.rs:17:10 diff --git a/src/test/ui/lexical-scopes.stderr b/src/test/ui/lexical-scopes.stderr index ad11f72a31d3..08e4be2c0c35 100644 --- a/src/test/ui/lexical-scopes.stderr +++ b/src/test/ui/lexical-scopes.stderr @@ -2,7 +2,7 @@ error[E0574]: expected struct, variant or union type, found type parameter `T` --> $DIR/lexical-scopes.rs:3:13 | LL | fn f() { - | - found this type pararmeter + | - found this type parameter LL | let t = T { i: 0 }; | ^ not a struct, variant or union type diff --git a/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr b/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr index d9c404e94acb..af9f4612ab34 100644 --- a/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr +++ b/src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr @@ -2,7 +2,7 @@ error[E0574]: expected struct, variant or union type, found type parameter `Baz` --> $DIR/point-at-type-parameter-shadowing-another-type.rs:16:13 | LL | impl Foo for Bar { - | --- found this type pararmeter + | --- found this type parameter ... LL | Baz { num } => num, | ^^^ not a struct, variant or union type diff --git a/src/test/ui/span/issue-35987.stderr b/src/test/ui/span/issue-35987.stderr index ea9c4c82c361..d8fddc8007f5 100644 --- a/src/test/ui/span/issue-35987.stderr +++ b/src/test/ui/span/issue-35987.stderr @@ -4,7 +4,7 @@ error[E0404]: expected trait, found type parameter `Add` LL | impl Add for Foo { | --- ^^^ not a trait | | - | found this type pararmeter + | found this type parameter | help: consider importing this trait instead | From 186debc65020e1f906d9ca6bb8cbde9cacebe178 Mon Sep 17 00:00:00 2001 From: Orson Peters Date: Thu, 22 Sep 2022 11:34:42 +0200 Subject: [PATCH 11/11] Added which number is computed in compute_float. --- library/core/src/num/dec2flt/lemire.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/num/dec2flt/lemire.rs b/library/core/src/num/dec2flt/lemire.rs index 75405f471541..b8b0a1d3d7e2 100644 --- a/library/core/src/num/dec2flt/lemire.rs +++ b/library/core/src/num/dec2flt/lemire.rs @@ -6,7 +6,7 @@ LARGEST_POWER_OF_FIVE, POWER_OF_FIVE_128, SMALLEST_POWER_OF_FIVE, }; -/// Compute a float using an extended-precision representation. +/// Compute w * 10^q using an extended-precision float representation. /// /// Fast conversion of a the significant digits and decimal exponent /// a float to an extended representation with a binary float. This