diff --git a/Cargo.lock b/Cargo.lock index d216b09c66a60..ea19474bff849 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -442,9 +442,9 @@ dependencies = [ [[package]] name = "chalk-derive" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a7f257e3bcdc56d8877ae31c012bd69fba0be66929d588e603905f2632c0c59" +checksum = "ca40c97e20f43e4aac2282d342103d45fafad74ad9bfcbaaf0b5d386f9ce1f39" dependencies = [ "proc-macro2", "quote", @@ -454,9 +454,9 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43fcc7edf4d51b42f44ed50e2337bd90ddc8e088d0cd78a71db92a6f780f782" +checksum = "88e3d545394fbc4f7d8fe203c6a78d2b73f82bb119f21af98de1f924c2518e34" dependencies = [ "chalk-derive", "chalk-ir", @@ -467,9 +467,9 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a4050029ecb2b5a1ff3bfc64c39279179b294821ec2e8891a4a5c6e3a08db0" +checksum = "8c4183955e084fcc387b515f867ed0e17e9e7301f5eee29c0338d5e63315bb41" dependencies = [ "chalk-derive", "lazy_static", @@ -477,9 +477,9 @@ dependencies = [ [[package]] name = "chalk-solve" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "828c1f80d4eaf681027cce02050c54a3c97370f81988d31bf2a56df54048746c" +checksum = "50e8407bba06d9e760011a28060e8f3b3f87b82ea53fb8bfaa43614c19c14dcc" dependencies = [ "chalk-derive", "chalk-ir", @@ -2626,9 +2626,9 @@ dependencies = [ [[package]] name = "racer" -version = "2.1.38" +version = "2.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51dd5fd4247115b28f3e038eb8cda76a0c6f9cb473f769f41f930af8adff22d0" +checksum = "b9424b4650b9c1134d0a1b34dab82319691e1c95fa8af1658fc640deb1b6823c" dependencies = [ "bitflags", "clap", @@ -2954,9 +2954,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_arena" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2958af0d6e0458434a25cd3a96f6e19f24f71bf50b900add520dec52e212866b" +checksum = "e8e941a8fc3878a111d2bbfe78e39522d884136f0b412b12592195f26f653476" dependencies = [ "rustc-ap-rustc_data_structures", "smallvec 1.4.2", @@ -2964,9 +2964,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_ast" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c82c2510460f2133548e62399e5acd30c25ae6ece30245baab3d1e00c2fefac" +checksum = "3b58b6b035710df7f339a2bf86f6dafa876efd95439540970e24609e33598ca6" dependencies = [ "bitflags", "rustc-ap-rustc_data_structures", @@ -2981,11 +2981,11 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_ast_passes" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83977da57f81c6edd89bad47e49136680eaa33288de4abb702e95358c2a0fc6c" +checksum = "3d379a900d6a1f098490d92ab83e87487dcee2e4ec3f04c3ac4512b5117b64e2" dependencies = [ - "itertools 0.8.2", + "itertools 0.9.0", "rustc-ap-rustc_ast", "rustc-ap-rustc_ast_pretty", "rustc-ap-rustc_attr", @@ -3000,9 +3000,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_ast_pretty" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "becf4ca1638b214694c71a8752192683048ab8bd47947cc481f57bd48157eeb9" +checksum = "658d925c0da9e3c5cddc5e54f4fa8c03b41aff1fc6dc5e41837c1118ad010ac0" dependencies = [ "rustc-ap-rustc_ast", "rustc-ap-rustc_span", @@ -3012,9 +3012,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_attr" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f21ca5dadce8a40d75a2756b77eab75b4c2d827f645c622dd93ee2285599640" +checksum = "3f387037534f34c148aed753622677500e42d190a095670e7ac3fffc09811a59" dependencies = [ "rustc-ap-rustc_ast", "rustc-ap-rustc_ast_pretty", @@ -3031,9 +3031,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_data_structures" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4cd204764727fde9abf75333eb661f058bfc7242062d91019440fe1b240688b" +checksum = "14ffd17a37e00d77926a0713f191c59ff3aeb2b551a024c7cfffce14bab79be8" dependencies = [ "bitflags", "cfg-if", @@ -3041,10 +3041,9 @@ dependencies = [ "ena", "indexmap", "jobserver", - "lazy_static", "libc", "measureme", - "parking_lot 0.10.2", + "parking_lot 0.11.0", "rustc-ap-rustc_graphviz", "rustc-ap-rustc_index", "rustc-ap-rustc_macros", @@ -3062,9 +3061,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_errors" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58116f119e37f14c029f99077b347069621118e048a69df74695b98204e7c136" +checksum = "2b3263ddcfa9eb911e54a4e8088878dd9fd10e00d8b99b01033ba4a2733fe91d" dependencies = [ "annotate-snippets 0.8.0", "atty", @@ -3081,9 +3080,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_expand" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e3c4bda9b64b92805bebe7431fdb8e24fd112b35a8c6d2174827441f10a6b2" +checksum = "e1ab7e68cede8a2273fd8b8623002ce9dc832e061dfc3330e9bcc1fc2a722d73" dependencies = [ "rustc-ap-rustc_ast", "rustc-ap-rustc_ast_passes", @@ -3104,32 +3103,31 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_feature" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b612bb67d3fc49f395b03fc4ea4384a0145b05afbadab725803074ec827632b" +checksum = "eea2dc95421bc19bbd4d939399833a882c46b684283b4267ad1fcf982fc043d9" dependencies = [ - "lazy_static", "rustc-ap-rustc_data_structures", "rustc-ap-rustc_span", ] [[package]] name = "rustc-ap-rustc_fs_util" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7630ad1a73a8434ee920676148cb5440ac57509bd20e94ec41087fb0b1d11c28" +checksum = "1e44c1804f09635f83f6cf1e04c2e92f8aeb7b4e850ac6c53d373dab02c13053" [[package]] name = "rustc-ap-rustc_graphviz" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a603fca4817062eb4fb23ff129d475bd66a69fb32f34ed4362ae950cf814b49d" +checksum = "dc491f2b9be6e928f6df6b287549b8d50c48e8eff8638345155f40fa2cfb785d" [[package]] name = "rustc-ap-rustc_index" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9850c4a5d7c341513e10802bca9588bf8f452ceea2d5cfa87b934246a52622bc" +checksum = "fa73f3fed413cdb6290738a10267da17b9ae8e02087334778b9a8c9491c5efc0" dependencies = [ "arrayvec", "rustc-ap-rustc_macros", @@ -3138,18 +3136,18 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_lexer" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d86722e5a1a615b198327d0d794cd9cbc8b9db4542276fc51fe078924de68ea" +checksum = "e993881244a92f3b44cf43c8f22ae2ca5cefe4f55a34e2b65b72ee66fe5ad077" dependencies = [ "unicode-xid", ] [[package]] name = "rustc-ap-rustc_macros" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3fc8482e44cabdda7ac9a8e224aef62ebdf95274d629dac8db3b42321025fea" +checksum = "4effe366556e1d75344764adf4d54cba7c2fad33dbd07588e96d0853831ddc7c" dependencies = [ "proc-macro2", "quote", @@ -3159,9 +3157,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_parse" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3716cdcd978a91dbd4a2788400e90e809527f841426fbeb92f882f9b8582f3ab" +checksum = "0342675835251571471d3dca9ea1576a853a8dfa1f4b0084db283c861223cb60" dependencies = [ "bitflags", "rustc-ap-rustc_ast", @@ -3179,9 +3177,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_serialize" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68046d07988b349b2e1c8bc1c9664a1d06519354aa677b9df358c5c5c058da0" +checksum = "438255ed968d73bf6573aa18d3b8d33c0a85ecdfd14160ef09ff813938e0606c" dependencies = [ "indexmap", "smallvec 1.4.2", @@ -3189,9 +3187,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_session" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85735553501a4de0c8904e37b7ccef79cc1c585a7d7f2cfa02cc38e0d149f982" +checksum = "7d61ff76dede8eb827f6805754900d1097a7046f938f950231b62b448f55bf78" dependencies = [ "bitflags", "getopts", @@ -3210,9 +3208,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_span" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c49ae8a0d3b9e27c6ffe8febeaa30f899294fff012de70625f9ee81c54fda85" +checksum = "1c267f15c3cfc82a8a441d2bf86bcccf299d1eb625822468e3d8ee6f7c5a1c89" dependencies = [ "cfg-if", "md-5", @@ -3229,9 +3227,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_target" -version = "677.0.0" +version = "679.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1765f447594740c501c7b666b87639aa7c1dae2bf8c3166d5d2dca16646fd034" +checksum = "8b1b4b266c4d44aac0f7f83b6741d8f0545b03d1ce32f3b5254f2014225cb96c" dependencies = [ "bitflags", "rustc-ap-rustc_data_structures", @@ -4248,7 +4246,7 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "1.4.21" +version = "1.4.22" dependencies = [ "annotate-snippets 0.6.1", "anyhow", @@ -5121,9 +5119,9 @@ dependencies = [ [[package]] name = "tracing-serde" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6ccba2f8f16e0ed268fc765d9b7ff22e965e7185d32f8f1ec8294fe17d86e79" +checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" dependencies = [ "serde", "tracing-core", diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 0c172dc33baf0..f496f3283da78 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -16,7 +16,7 @@ use rustc_data_structures::small_c_str::SmallCStr; use rustc_hir::def_id::DefId; use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{self, Ty, TyCtxt}; -use rustc_span::sym; +use rustc_span::{sym, Span}; use rustc_target::abi::{self, Align, Size}; use rustc_target::spec::{HasTargetSpec, Target}; use std::borrow::Cow; @@ -139,6 +139,8 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { unsafe { llvm::LLVMGetInsertBlock(self.llbuilder) } } + fn set_span(&self, _span: Span) {} + fn position_at_end(&mut self, llbb: &'ll BasicBlock) { unsafe { llvm::LLVMPositionBuilderAtEnd(self.llbuilder, llbb); diff --git a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs index d8a530d98faa7..26a646b029367 100644 --- a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs +++ b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs @@ -55,6 +55,7 @@ impl DebugScope { impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn set_debug_loc(&self, bx: &mut Bx, source_info: mir::SourceInfo) { let (scope, span) = self.debug_loc(source_info); + bx.set_span(span); if let Some(scope) = scope { bx.set_source_location(scope, span); } diff --git a/compiler/rustc_codegen_ssa/src/traits/builder.rs b/compiler/rustc_codegen_ssa/src/traits/builder.rs index b35b0f24208b2..0b8289a8dd92c 100644 --- a/compiler/rustc_codegen_ssa/src/traits/builder.rs +++ b/compiler/rustc_codegen_ssa/src/traits/builder.rs @@ -15,6 +15,7 @@ use crate::MemFlags; use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout}; use rustc_middle::ty::Ty; +use rustc_span::Span; use rustc_target::abi::{Abi, Align, Scalar, Size}; use rustc_target::spec::HasTargetSpec; @@ -44,6 +45,7 @@ pub trait BuilderMethods<'a, 'tcx>: fn build_sibling_block(&self, name: &str) -> Self; fn cx(&self) -> &Self::CodegenCx; fn llbb(&self) -> Self::BasicBlock; + fn set_span(&self, span: Span); fn position_at_end(&mut self, llbb: Self::BasicBlock); fn ret_void(&mut self); diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index e8ace361b219d..f9a450305d0c5 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" } rustc_serialize = { path = "../rustc_serialize" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.29.0" +chalk-ir = "0.31.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } measureme = "0.7.1" rustc_session = { path = "../rustc_session" } diff --git a/compiler/rustc_mir/src/transform/early_otherwise_branch.rs b/compiler/rustc_mir/src/transform/early_otherwise_branch.rs index a45b0e86fffc2..237a5c7864b1f 100644 --- a/compiler/rustc_mir/src/transform/early_otherwise_branch.rs +++ b/compiler/rustc_mir/src/transform/early_otherwise_branch.rs @@ -26,7 +26,7 @@ pub struct EarlyOtherwiseBranch; impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - if tcx.sess.opts.debugging_opts.mir_opt_level < 1 { + if tcx.sess.opts.debugging_opts.mir_opt_level < 2 { return; } trace!("running EarlyOtherwiseBranch on {:?}", body.source); diff --git a/compiler/rustc_mir/src/transform/inline.rs b/compiler/rustc_mir/src/transform/inline.rs index ced8a2289d577..bec1eb790478c 100644 --- a/compiler/rustc_mir/src/transform/inline.rs +++ b/compiler/rustc_mir/src/transform/inline.rs @@ -45,8 +45,12 @@ impl<'tcx> MirPass<'tcx> for Inline { // based function. debug!("function inlining is disabled when compiling with `instrument_coverage`"); } else { - Inliner { tcx, codegen_fn_attrs: tcx.codegen_fn_attrs(body.source.def_id()) } - .run_pass(body); + Inliner { + tcx, + param_env: tcx.param_env_reveal_all_normalized(body.source.def_id()), + codegen_fn_attrs: tcx.codegen_fn_attrs(body.source.def_id()), + } + .run_pass(body); } } } @@ -54,6 +58,7 @@ impl<'tcx> MirPass<'tcx> for Inline { struct Inliner<'tcx> { tcx: TyCtxt<'tcx>, + param_env: ParamEnv<'tcx>, codegen_fn_attrs: &'tcx CodegenFnAttrs, } @@ -75,17 +80,13 @@ impl Inliner<'tcx> { let def_id = caller_body.source.def_id(); - let param_env = self.tcx.param_env_reveal_all_normalized(def_id); - // Only do inlining into fn bodies. let self_hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); if self.tcx.hir().body_owner_kind(self_hir_id).is_fn_or_closure() && caller_body.source.promoted.is_none() { for (bb, bb_data) in caller_body.basic_blocks().iter_enumerated() { - if let Some(callsite) = - self.get_valid_function_call(bb, bb_data, caller_body, param_env) - { + if let Some(callsite) = self.get_valid_function_call(bb, bb_data, caller_body) { callsites.push_back(callsite); } } @@ -131,7 +132,7 @@ impl Inliner<'tcx> { let callee_body = if self.consider_optimizing(callsite, callee_body) { self.tcx.subst_and_normalize_erasing_regions( &callsite.substs, - param_env, + self.param_env, callee_body, ) } else { @@ -159,7 +160,7 @@ impl Inliner<'tcx> { // Add callsites from inlined function for (bb, bb_data) in caller_body.basic_blocks().iter_enumerated().skip(start) { if let Some(new_callsite) = - self.get_valid_function_call(bb, bb_data, caller_body, param_env) + self.get_valid_function_call(bb, bb_data, caller_body) { // Don't inline the same function multiple times. if callsite.callee != new_callsite.callee { @@ -190,7 +191,6 @@ impl Inliner<'tcx> { bb: BasicBlock, bb_data: &BasicBlockData<'tcx>, caller_body: &Body<'tcx>, - param_env: ParamEnv<'tcx>, ) -> Option> { // Don't inline calls that are in cleanup blocks. if bb_data.is_cleanup { @@ -201,8 +201,9 @@ impl Inliner<'tcx> { let terminator = bb_data.terminator(); if let TerminatorKind::Call { func: ref op, .. } = terminator.kind { if let ty::FnDef(callee_def_id, substs) = *op.ty(caller_body, self.tcx).kind() { - let instance = - Instance::resolve(self.tcx, param_env, callee_def_id, substs).ok().flatten()?; + let instance = Instance::resolve(self.tcx, self.param_env, callee_def_id, substs) + .ok() + .flatten()?; if let InstanceDef::Virtual(..) = instance.def { return None; @@ -300,9 +301,6 @@ impl Inliner<'tcx> { debug!(" final inline threshold = {}", threshold); // FIXME: Give a bonus to functions with only a single caller - - let param_env = tcx.param_env(callee_body.source.def_id()); - let mut first_block = true; let mut cost = 0; @@ -335,7 +333,7 @@ impl Inliner<'tcx> { // If the place doesn't actually need dropping, treat it like // a regular goto. let ty = place.ty(callee_body, tcx).subst(tcx, callsite.substs).ty; - if ty.needs_drop(tcx, param_env) { + if ty.needs_drop(tcx, self.param_env) { cost += CALL_PENALTY; if let Some(unwind) = unwind { cost += LANDINGPAD_PENALTY; @@ -400,7 +398,7 @@ impl Inliner<'tcx> { let ty = v.ty.subst(tcx, callsite.substs); // Cost of the var is the size in machine-words, if we know // it. - if let Some(size) = type_size_of(tcx, param_env, ty) { + if let Some(size) = type_size_of(tcx, self.param_env, ty) { cost += (size / ptr_size) as usize; } else { cost += UNKNOWN_SIZE_COST; diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index aae778217d3f1..b24ede9c53aed 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -159,6 +159,7 @@ impl DefId { DefId { krate: LOCAL_CRATE, index } } + /// Returns whether the item is defined in the crate currently being compiled. #[inline] pub fn is_local(self) -> bool { self.krate == LOCAL_CRATE diff --git a/compiler/rustc_symbol_mangling/src/test.rs b/compiler/rustc_symbol_mangling/src/test.rs index 24850a8a0d253..d2c9b05c5607f 100644 --- a/compiler/rustc_symbol_mangling/src/test.rs +++ b/compiler/rustc_symbol_mangling/src/test.rs @@ -5,6 +5,7 @@ //! paths etc in all kinds of annoying scenarios. use rustc_hir as hir; +use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{Instance, TyCtxt}; use rustc_span::symbol::{sym, Symbol}; @@ -44,7 +45,7 @@ impl SymbolNamesTest<'tcx> { tcx.sess.span_err(attr.span, &format!("demangling-alt({:#})", demangling)); } } else if tcx.sess.check_name(attr, DEF_PATH) { - let path = tcx.def_path_str(def_id.to_def_id()); + let path = with_no_trimmed_paths(|| tcx.def_path_str(def_id.to_def_id())); tcx.sess.span_err(attr.span, &format!("def-path({})", path)); } diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index 6d49571827640..b176b150cd39e 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -12,9 +12,9 @@ rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.29.0" -chalk-solve = "0.29.0" -chalk-engine = "0.29.0" +chalk-ir = "0.31.0" +chalk-solve = "0.31.0" +chalk-engine = "0.31.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 223635e9aecd9..3368c5b769902 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -22,7 +22,6 @@ use rustc_ast::ast; pub struct RustIrDatabase<'tcx> { pub(crate) interner: RustInterner<'tcx>, - pub(crate) restatic_placeholder: ty::Region<'tcx>, pub(crate) reempty_placeholder: ty::Region<'tcx>, } @@ -39,11 +38,8 @@ impl<'tcx> RustIrDatabase<'tcx> { bound_vars: SubstsRef<'tcx>, ) -> Vec>> { let predicates = self.interner.tcx.predicates_of(def_id).predicates; - let mut regions_substitutor = lowering::RegionsSubstitutor::new( - self.interner.tcx, - self.restatic_placeholder, - self.reempty_placeholder, - ); + let mut regions_substitutor = + lowering::RegionsSubstitutor::new(self.interner.tcx, self.reempty_placeholder); predicates .iter() .map(|(wc, _)| wc.subst(self.interner.tcx, bound_vars)) @@ -274,11 +270,8 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t let trait_ref = self.interner.tcx.impl_trait_ref(def_id).expect("not an impl"); let trait_ref = trait_ref.subst(self.interner.tcx, bound_vars); - let mut regions_substitutor = lowering::RegionsSubstitutor::new( - self.interner.tcx, - self.restatic_placeholder, - self.reempty_placeholder, - ); + let mut regions_substitutor = + lowering::RegionsSubstitutor::new(self.interner.tcx, self.reempty_placeholder); let trait_ref = trait_ref.fold_with(&mut regions_substitutor); let where_clauses = self.where_clauses_for(def_id, bound_vars); @@ -316,11 +309,8 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t let self_ty = trait_ref.self_ty(); let self_ty = self_ty.subst(self.interner.tcx, bound_vars); - let mut regions_substitutor = lowering::RegionsSubstitutor::new( - self.interner.tcx, - self.restatic_placeholder, - self.reempty_placeholder, - ); + let mut regions_substitutor = + lowering::RegionsSubstitutor::new(self.interner.tcx, self.reempty_placeholder); let self_ty = self_ty.fold_with(&mut regions_substitutor); let lowered_ty = self_ty.lower_into(&self.interner); @@ -590,6 +580,20 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t let substitution = &substs.as_slice(&self.interner)[0..substs.len(&self.interner) - 3]; chalk_ir::Substitution::from_iter(&self.interner, substitution) } + + fn generator_datum( + &self, + _generator_id: chalk_ir::GeneratorId>, + ) -> Arc>> { + unimplemented!() + } + + fn generator_witness_datum( + &self, + _generator_id: chalk_ir::GeneratorId>, + ) -> Arc>> { + unimplemented!() + } } /// Creates a `InternalSubsts` that maps each generic parameter to a higher-ranked diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index bdb2513cc4602..391251b6fa554 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -427,13 +427,20 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty> { chalk_ir::FloatTy::F64 => ty::Float(ast::FloatTy::F64), }, }, - chalk_ir::TypeName::Array => unimplemented!(), + chalk_ir::TypeName::Array => { + let substs = application_ty.substitution.as_slice(interner); + let ty = substs[0].assert_ty_ref(interner).lower_into(interner); + let c = substs[1].assert_const_ref(interner).lower_into(interner); + ty::Array(ty, interner.tcx.mk_const(c)) + } chalk_ir::TypeName::FnDef(id) => { ty::FnDef(id.0, application_ty.substitution.lower_into(interner)) } chalk_ir::TypeName::Closure(closure) => { ty::Closure(closure.0, application_ty.substitution.lower_into(interner)) } + chalk_ir::TypeName::Generator(_) => unimplemented!(), + chalk_ir::TypeName::GeneratorWitness(_) => unimplemented!(), chalk_ir::TypeName::Never => ty::Never, chalk_ir::TypeName::Tuple(_size) => { ty::Tuple(application_ty.substitution.lower_into(interner)) @@ -483,7 +490,15 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty> { universe: ty::UniverseIndex::from_usize(placeholder.ui.counter), name: ty::BoundVar::from_usize(placeholder.idx), }), - TyData::Alias(_alias_ty) => unimplemented!(), + chalk_ir::TyData::Alias(alias_ty) => match alias_ty { + chalk_ir::AliasTy::Projection(projection) => ty::Projection(ty::ProjectionTy { + item_def_id: projection.associated_ty_id.0, + substs: projection.substitution.lower_into(interner), + }), + chalk_ir::AliasTy::Opaque(opaque) => { + ty::Opaque(opaque.opaque_ty_id.0, opaque.substitution.lower_into(interner)) + } + }, TyData::Function(_quantified_ty) => unimplemented!(), TyData::BoundVar(_bound) => ty::Bound( ty::DebruijnIndex::from_usize(_bound.debruijn.depth() as usize), @@ -519,8 +534,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Lifetime>> for Region<'t ty::BrEnv => unimplemented!(), }, ReFree(_) => unimplemented!(), - // FIXME(chalk): need to handle ReStatic - ReStatic => unimplemented!(), + ReStatic => chalk_ir::LifetimeData::Static.intern(interner), ReVar(_) => unimplemented!(), RePlaceholder(placeholder_region) => { chalk_ir::LifetimeData::Placeholder(chalk_ir::PlaceholderIndex { @@ -550,6 +564,7 @@ impl<'tcx> LowerInto<'tcx, Region<'tcx>> for &chalk_ir::Lifetime ty::RegionKind::ReStatic, chalk_ir::LifetimeData::Phantom(_, _) => unimplemented!(), }; interner.tcx.mk_region(kind) @@ -701,7 +716,16 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders unimplemented!(), + ty::ExistentialPredicate::Projection(predicate) => chalk_ir::Binders::new( + chalk_ir::VariableKinds::empty(interner), + chalk_ir::WhereClause::AliasEq(chalk_ir::AliasEq { + alias: chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy { + associated_ty_id: chalk_ir::AssocTypeId(predicate.item_def_id), + substitution: predicate.substs.lower_into(interner), + }), + ty: predicate.ty.lower_into(interner), + }), + ), ty::ExistentialPredicate::AutoTrait(def_id) => chalk_ir::Binders::new( chalk_ir::VariableKinds::empty(interner), chalk_ir::WhereClause::Implemented(chalk_ir::TraitRef { @@ -1116,17 +1140,12 @@ impl<'tcx> TypeVisitor<'tcx> for PlaceholdersCollector { /// Used to substitute specific `Regions`s with placeholders. crate struct RegionsSubstitutor<'tcx> { tcx: TyCtxt<'tcx>, - restatic_placeholder: ty::Region<'tcx>, reempty_placeholder: ty::Region<'tcx>, } impl<'tcx> RegionsSubstitutor<'tcx> { - crate fn new( - tcx: TyCtxt<'tcx>, - restatic_placeholder: ty::Region<'tcx>, - reempty_placeholder: ty::Region<'tcx>, - ) -> Self { - RegionsSubstitutor { tcx, restatic_placeholder, reempty_placeholder } + crate fn new(tcx: TyCtxt<'tcx>, reempty_placeholder: ty::Region<'tcx>) -> Self { + RegionsSubstitutor { tcx, reempty_placeholder } } } @@ -1137,7 +1156,6 @@ impl<'tcx> TypeFolder<'tcx> for RegionsSubstitutor<'tcx> { fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx> { match r { - ty::ReStatic => self.restatic_placeholder, ty::ReEmpty(ui) => { assert_eq!(ui.as_usize(), 0); self.reempty_placeholder diff --git a/compiler/rustc_traits/src/chalk/mod.rs b/compiler/rustc_traits/src/chalk/mod.rs index 63c5b884357b0..f174a92274ed6 100644 --- a/compiler/rustc_traits/src/chalk/mod.rs +++ b/compiler/rustc_traits/src/chalk/mod.rs @@ -42,10 +42,6 @@ crate fn evaluate_goal<'tcx>( let mut placeholders_collector = PlaceholdersCollector::new(); obligation.visit_with(&mut placeholders_collector); - let restatic_placeholder = tcx.mk_region(ty::RegionKind::RePlaceholder(ty::Placeholder { - universe: ty::UniverseIndex::ROOT, - name: ty::BoundRegion::BrAnon(placeholders_collector.next_anon_region_placeholder), - })); let reempty_placeholder = tcx.mk_region(ty::RegionKind::RePlaceholder(ty::Placeholder { universe: ty::UniverseIndex::ROOT, name: ty::BoundRegion::BrAnon(placeholders_collector.next_anon_region_placeholder + 1), @@ -57,8 +53,7 @@ crate fn evaluate_goal<'tcx>( // FIXME(chalk): we really should be substituting these back in the solution let _params: FxHashMap = params_substitutor.params; - let mut regions_substitutor = - RegionsSubstitutor::new(tcx, restatic_placeholder, reempty_placeholder); + let mut regions_substitutor = RegionsSubstitutor::new(tcx, reempty_placeholder); let obligation = obligation.fold_with(&mut regions_substitutor); let max_universe = obligation.max_universe.index(); @@ -101,7 +96,7 @@ crate fn evaluate_goal<'tcx>( use chalk_solve::Solver; let mut solver = chalk_engine::solve::SLGSolver::new(32, None); - let db = ChalkRustIrDatabase { interner, restatic_placeholder, reempty_placeholder }; + let db = ChalkRustIrDatabase { interner, reempty_placeholder }; let solution = chalk_solve::logging::with_tracing_logs(|| solver.solve(&db, &lowered_goal)); // Ideally, the code to convert *back* to rustc types would live close to diff --git a/library/alloc/src/collections/vec_deque.rs b/library/alloc/src/collections/vec_deque.rs index adb08543334f0..ff9b1553bf2fc 100644 --- a/library/alloc/src/collections/vec_deque.rs +++ b/library/alloc/src/collections/vec_deque.rs @@ -14,6 +14,7 @@ use core::cmp::{self, Ordering}; use core::fmt; use core::hash::{Hash, Hasher}; use core::iter::{repeat_with, FromIterator, FusedIterator}; +use core::marker::PhantomData; use core::mem::{self, replace, ManuallyDrop}; use core::ops::{Index, IndexMut, Range, RangeBounds, Try}; use core::ptr::{self, NonNull}; @@ -982,7 +983,14 @@ impl VecDeque { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn iter_mut(&mut self) -> IterMut<'_, T> { - IterMut { tail: self.tail, head: self.head, ring: unsafe { self.buffer_as_mut_slice() } } + // SAFETY: The internal `IterMut` safety invariant is established because the + // `ring` we create is a dereferencable slice for lifetime '_. + IterMut { + tail: self.tail, + head: self.head, + ring: ptr::slice_from_raw_parts_mut(self.ptr(), self.cap()), + phantom: PhantomData, + } } /// Returns a pair of slices which contain, in order, the contents of the @@ -1170,11 +1178,14 @@ impl VecDeque { R: RangeBounds, { let (tail, head) = self.range_tail_head(range); + + // SAFETY: The internal `IterMut` safety invariant is established because the + // `ring` we create is a dereferencable slice for lifetime '_. IterMut { tail, head, - // The shared reference we have in &mut self is maintained in the '_ of IterMut. - ring: unsafe { self.buffer_as_mut_slice() }, + ring: ptr::slice_from_raw_parts_mut(self.ptr(), self.cap()), + phantom: PhantomData, } } @@ -2493,6 +2504,25 @@ impl RingSlices for &mut [T] { } } +impl RingSlices for *mut [T] { + fn slice(self, from: usize, to: usize) -> Self { + assert!(from <= to && to < self.len()); + // Not using `get_unchecked_mut` to keep this a safe operation. + let len = to - from; + ptr::slice_from_raw_parts_mut(self.as_mut_ptr().wrapping_add(from), len) + } + + fn split_at(self, mid: usize) -> (Self, Self) { + let len = self.len(); + let ptr = self.as_mut_ptr(); + assert!(mid <= len); + ( + ptr::slice_from_raw_parts_mut(ptr, mid), + ptr::slice_from_raw_parts_mut(ptr.wrapping_add(mid), len - mid), + ) + } +} + /// Calculate the number of elements left to be read in the buffer #[inline] fn count(tail: usize, head: usize, size: usize) -> usize { @@ -2662,15 +2692,27 @@ impl FusedIterator for Iter<'_, T> {} /// [`iter_mut`]: VecDeque::iter_mut #[stable(feature = "rust1", since = "1.0.0")] pub struct IterMut<'a, T: 'a> { - ring: &'a mut [T], + // Internal safety invariant: the entire slice is dereferencable. + ring: *mut [T], tail: usize, head: usize, + phantom: PhantomData<&'a mut [T]>, } +// SAFETY: we do nothing thread-local and there is no interior mutability, +// so the usual structural `Send`/`Sync` apply. +#[stable(feature = "rust1", since = "1.0.0")] +unsafe impl Send for IterMut<'_, T> {} +#[stable(feature = "rust1", since = "1.0.0")] +unsafe impl Sync for IterMut<'_, T> {} + #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for IterMut<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let (front, back) = RingSlices::ring_slices(&*self.ring, self.head, self.tail); + let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail); + // SAFETY: these are the elements we have not handed out yet, so aliasing is fine. + // The `IterMut` invariant also ensures everything is dereferencable. + let (front, back) = unsafe { (&*front, &*back) }; f.debug_tuple("IterMut").field(&front).field(&back).finish() } } @@ -2689,7 +2731,7 @@ impl<'a, T> Iterator for IterMut<'a, T> { unsafe { let elem = self.ring.get_unchecked_mut(tail); - Some(&mut *(elem as *mut _)) + Some(&mut *elem) } } @@ -2704,6 +2746,9 @@ impl<'a, T> Iterator for IterMut<'a, T> { F: FnMut(Acc, Self::Item) -> Acc, { let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail); + // SAFETY: these are the elements we have not handed out yet, so aliasing is fine. + // The `IterMut` invariant also ensures everything is dereferencable. + let (front, back) = unsafe { (&mut *front, &mut *back) }; accum = front.iter_mut().fold(accum, &mut f); back.iter_mut().fold(accum, &mut f) } @@ -2735,7 +2780,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> { unsafe { let elem = self.ring.get_unchecked_mut(self.head); - Some(&mut *(elem as *mut _)) + Some(&mut *elem) } } @@ -2744,6 +2789,9 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> { F: FnMut(Acc, Self::Item) -> Acc, { let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail); + // SAFETY: these are the elements we have not handed out yet, so aliasing is fine. + // The `IterMut` invariant also ensures everything is dereferencable. + let (front, back) = unsafe { (&mut *front, &mut *back) }; accum = back.iter_mut().rfold(accum, &mut f); front.iter_mut().rfold(accum, &mut f) } diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 2603ecf428c7d..1b847addcf806 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -1229,10 +1229,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_alphabetic(&self) -> bool { - match *self { - 'A'..='Z' | 'a'..='z' => true, - _ => false, - } + matches!(*self, 'A'..='Z' | 'a'..='z') } /// Checks if the value is an ASCII uppercase character: @@ -1265,10 +1262,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_uppercase(&self) -> bool { - match *self { - 'A'..='Z' => true, - _ => false, - } + matches!(*self, 'A'..='Z') } /// Checks if the value is an ASCII lowercase character: @@ -1301,10 +1295,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_lowercase(&self) -> bool { - match *self { - 'a'..='z' => true, - _ => false, - } + matches!(*self, 'a'..='z') } /// Checks if the value is an ASCII alphanumeric character: @@ -1340,10 +1331,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_alphanumeric(&self) -> bool { - match *self { - '0'..='9' | 'A'..='Z' | 'a'..='z' => true, - _ => false, - } + matches!(*self, '0'..='9' | 'A'..='Z' | 'a'..='z') } /// Checks if the value is an ASCII decimal digit: @@ -1376,10 +1364,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_digit(&self) -> bool { - match *self { - '0'..='9' => true, - _ => false, - } + matches!(*self, '0'..='9') } /// Checks if the value is an ASCII hexadecimal digit: @@ -1415,10 +1400,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_hexdigit(&self) -> bool { - match *self { - '0'..='9' | 'A'..='F' | 'a'..='f' => true, - _ => false, - } + matches!(*self, '0'..='9' | 'A'..='F' | 'a'..='f') } /// Checks if the value is an ASCII punctuation character: @@ -1455,10 +1437,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_punctuation(&self) -> bool { - match *self { - '!'..='/' | ':'..='@' | '['..='`' | '{'..='~' => true, - _ => false, - } + matches!(*self, '!'..='/' | ':'..='@' | '['..='`' | '{'..='~') } /// Checks if the value is an ASCII graphic character: @@ -1491,10 +1470,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_graphic(&self) -> bool { - match *self { - '!'..='~' => true, - _ => false, - } + matches!(*self, '!'..='~') } /// Checks if the value is an ASCII whitespace character: @@ -1544,10 +1520,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_whitespace(&self) -> bool { - match *self { - '\t' | '\n' | '\x0C' | '\r' | ' ' => true, - _ => false, - } + matches!(*self, '\t' | '\n' | '\x0C' | '\r' | ' ') } /// Checks if the value is an ASCII control character: @@ -1582,10 +1555,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_control(&self) -> bool { - match *self { - '\0'..='\x1F' | '\x7F' => true, - _ => false, - } + matches!(*self, '\0'..='\x1F' | '\x7F') } } diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index c1a9d4fcd23fe..319a0b4e611eb 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -12,6 +12,7 @@ use getopts::Options; use crate::builder::Builder; use crate::config::{Config, TargetSelection}; +use crate::setup::Profile; use crate::{Build, DocTests}; /// Deserialized version of all flags for this compile. @@ -94,7 +95,7 @@ pub enum Subcommand { paths: Vec, }, Setup { - path: String, + profile: Profile, }, } @@ -253,7 +254,7 @@ To learn more about a subcommand, run `./x.py -h`", `//rustfix_missing_coverage.txt`", ); } - "check" => { + "check" | "c" => { opts.optflag("", "all-targets", "Check all targets"); } "bench" => { @@ -533,18 +534,26 @@ Arguments: Subcommand::Run { paths } } "setup" => { - let path = if paths.len() > 1 { + let profile = if paths.len() > 1 { println!("\nat most one profile can be passed to setup\n"); usage(1, &opts, verbose, &subcommand_help) } else if let Some(path) = paths.pop() { - t!(path.into_os_string().into_string().map_err(|path| format!( - "{} is not a valid UTF8 string", - path.to_string_lossy() - ))) + let profile_string = t!(path.into_os_string().into_string().map_err( + |path| format!("{} is not a valid UTF8 string", path.to_string_lossy()) + )); + + profile_string.parse().unwrap_or_else(|err| { + eprintln!("error: {}", err); + eprintln!("help: the available profiles are:"); + for choice in Profile::all() { + eprintln!("- {}", choice); + } + std::process::exit(1); + }) } else { t!(crate::setup::interactive_path()) }; - Subcommand::Setup { path } + Subcommand::Setup { profile } } _ => { usage(1, &opts, verbose, &subcommand_help); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 4cc72f5f39c97..147bcf30709f9 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -471,8 +471,8 @@ impl Build { return clean::clean(self, all); } - if let Subcommand::Setup { path: include_name } = &self.config.cmd { - return setup::setup(&self.config.src, include_name); + if let Subcommand::Setup { profile } = &self.config.cmd { + return setup::setup(&self.config.src, *profile); } { diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs index 24ec43373ccb5..dcfb9fd673421 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -1,11 +1,55 @@ use crate::t; use std::path::{Path, PathBuf}; +use std::str::FromStr; use std::{ - env, fs, + env, fmt, fs, io::{self, Write}, }; -pub fn setup(src_path: &Path, include_name: &str) { +#[derive(Clone, Copy, Eq, PartialEq)] +pub enum Profile { + Compiler, + Codegen, + Library, + User, +} + +impl Profile { + fn include_path(&self, src_path: &Path) -> PathBuf { + PathBuf::from(format!("{}/src/bootstrap/defaults/config.{}.toml", src_path.display(), self)) + } + + pub fn all() -> impl Iterator { + [Profile::Compiler, Profile::Codegen, Profile::Library, Profile::User].iter().copied() + } +} + +impl FromStr for Profile { + type Err = String; + + fn from_str(s: &str) -> Result { + match s { + "a" | "lib" | "library" => Ok(Profile::Library), + "b" | "compiler" => Ok(Profile::Compiler), + "c" | "llvm" | "codegen" => Ok(Profile::Codegen), + "d" | "maintainer" | "user" => Ok(Profile::User), + _ => Err(format!("unknown profile: '{}'", s)), + } + } +} + +impl fmt::Display for Profile { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Profile::Compiler => write!(f, "compiler"), + Profile::Codegen => write!(f, "codegen"), + Profile::Library => write!(f, "library"), + Profile::User => write!(f, "user"), + } + } +} + +pub fn setup(src_path: &Path, profile: Profile) { let cfg_file = env::var_os("BOOTSTRAP_CONFIG").map(PathBuf::from); if cfg_file.as_ref().map_or(false, |f| f.exists()) { @@ -14,15 +58,10 @@ pub fn setup(src_path: &Path, include_name: &str) { "error: you asked `x.py` to setup a new config file, but one already exists at `{}`", file.display() ); + println!("help: try adding `profile = \"{}\"` at the top of {}", profile, file.display()); println!( - "help: try adding `profile = \"{}\"` at the top of {}", - include_name, - file.display() - ); - println!( - "note: this will use the configuration in {}/src/bootstrap/defaults/config.{}.toml", - src_path.display(), - include_name + "note: this will use the configuration in {}", + profile.include_path(src_path).display() ); std::process::exit(1); } @@ -31,19 +70,17 @@ pub fn setup(src_path: &Path, include_name: &str) { let settings = format!( "# Includes one of the default files in src/bootstrap/defaults\n\ profile = \"{}\"\n", - include_name + profile ); t!(fs::write(path, settings)); - let include_path = - format!("{}/src/bootstrap/defaults/config.{}.toml", src_path.display(), include_name); - println!("`x.py` will now use the configuration at {}", include_path); + let include_path = profile.include_path(src_path); + println!("`x.py` will now use the configuration at {}", include_path.display()); - let suggestions = match include_name { - "codegen" | "compiler" => &["check", "build", "test"][..], - "library" => &["check", "build", "test library/std", "doc"], - "user" => &["dist", "build"], - _ => return, + let suggestions = match profile { + Profile::Codegen | Profile::Compiler => &["check", "build", "test"][..], + Profile::Library => &["check", "build", "test library/std", "doc"], + Profile::User => &["dist", "build"], }; println!(); @@ -57,7 +94,7 @@ pub fn setup(src_path: &Path, include_name: &str) { println!("- `x.py {}`", cmd); } - if include_name != "user" { + if profile != Profile::User { println!( "For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html" ); @@ -65,7 +102,7 @@ pub fn setup(src_path: &Path, include_name: &str) { } // Used to get the path for `Subcommand::Setup` -pub fn interactive_path() -> io::Result { +pub fn interactive_path() -> io::Result { let mut input = String::new(); println!( "Welcome to the Rust project! What do you want to do with x.py? @@ -78,19 +115,16 @@ d) Install Rust from source" print!("Please choose one (a/b/c/d): "); io::stdout().flush()?; io::stdin().read_line(&mut input)?; - break match input.trim().to_lowercase().as_str() { - "a" | "lib" | "library" => "library", - "b" | "compiler" => "compiler", - "c" | "llvm" => "llvm", - "d" | "user" | "maintainer" => "maintainer", - _ => { - println!("error: unrecognized option '{}'", input.trim()); + break match input.trim().to_lowercase().parse() { + Ok(profile) => profile, + Err(err) => { + println!("error: {}", err); println!("note: press Ctrl+C to exit"); continue; } }; }; - Ok(template.to_owned()) + Ok(template) } // install a git hook to automatically run tidy --bless, if they want diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 31e8c32f062ab..7f64d20d8e7cd 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -290,10 +290,12 @@ pub fn build_ty(cx: &DocContext<'_>, did: DefId) -> Option { } } +/// Builds all inherent implementations of an ADT (struct/union/enum) or Trait item/path/reexport. pub fn build_impls(cx: &DocContext<'_>, did: DefId, attrs: Option>) -> Vec { let tcx = cx.tcx; let mut impls = Vec::new(); + // for each implementation of an item represented by `did`, build the clean::Item for that impl for &did in tcx.inherent_impls(did).iter() { build_impl(cx, did, attrs, &mut impls); } @@ -320,6 +322,7 @@ fn merge_attrs( merged_attrs.clean(cx) } +/// Builds a specific implementation of a type. The `did` could be a type method or trait method. pub fn build_impl( cx: &DocContext<'_>, did: DefId, diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs index d180de9be3bf3..0c4907fd00294 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs @@ -1,5 +1,6 @@ // NOTE: rustc cannot currently handle bounds of the form `for<'a> >::Assoc: Baz`. // This should hopefully be fixed with Chalk. +// ignore-compare-mode-chalk #![feature(associated_type_bounds)] diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr index e68b5b342a40c..1c493581bc953 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr @@ -1,5 +1,5 @@ error[E0277]: `<::C as Iterator>::Item` is not an iterator - --> $DIR/bad-bounds-on-assoc-in-trait.rs:26:5 + --> $DIR/bad-bounds-on-assoc-in-trait.rs:27:5 | LL | type C: Clone + Iterator Lam<&'a u8, App: Debug>> + Sync>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `<::C as Iterator>::Item` is not an iterator @@ -11,7 +11,7 @@ LL | trait Case1 where <::C as Iterator>::Item: Iterator { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `<::C as Iterator>::Item` cannot be sent between threads safely - --> $DIR/bad-bounds-on-assoc-in-trait.rs:26:36 + --> $DIR/bad-bounds-on-assoc-in-trait.rs:27:36 | LL | type C: Clone + Iterator Lam<&'a u8, App: Debug>> + Sync>; | ^^^^ `<::C as Iterator>::Item` cannot be sent between threads safely @@ -28,7 +28,7 @@ LL | trait Case1 where <::C as Iterator>::Item: Send { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `<::C as Iterator>::Item` cannot be shared between threads safely - --> $DIR/bad-bounds-on-assoc-in-trait.rs:26:93 + --> $DIR/bad-bounds-on-assoc-in-trait.rs:27:93 | LL | type C: Clone + Iterator Lam<&'a u8, App: Debug>> + Sync>; | ^^^^ `<::C as Iterator>::Item` cannot be shared between threads safely diff --git a/src/test/ui/associated-type-bounds/trait-params.rs b/src/test/ui/associated-type-bounds/trait-params.rs index b0703a4ee22b3..a9aa2747e52af 100644 --- a/src/test/ui/associated-type-bounds/trait-params.rs +++ b/src/test/ui/associated-type-bounds/trait-params.rs @@ -1,4 +1,5 @@ // build-pass (FIXME(62277): could be check-pass?) +// ignore-compare-mode-chalk #![feature(associated_type_bounds)] diff --git a/src/test/ui/associated-type-bounds/union-bounds.rs b/src/test/ui/associated-type-bounds/union-bounds.rs index 97c5acf1f72ca..f1aab2a6da071 100644 --- a/src/test/ui/associated-type-bounds/union-bounds.rs +++ b/src/test/ui/associated-type-bounds/union-bounds.rs @@ -1,4 +1,5 @@ // run-pass +// ignore-compare-mode-chalk #![feature(associated_type_bounds)] #![feature(untagged_unions)] diff --git a/src/test/ui/associated-types/associated-types-stream.rs b/src/test/ui/associated-types/associated-types-stream.rs index 96954528aaaba..220ee6af2fc9f 100644 --- a/src/test/ui/associated-types/associated-types-stream.rs +++ b/src/test/ui/associated-types/associated-types-stream.rs @@ -1,6 +1,7 @@ // run-pass // Test references to the trait `Stream` in the bounds for associated // types defined on `Stream`. Issue #20551. +// ignore-compare-mode-chalk trait Stream { diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-2.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-2.rs index 5db619dc98f30..a04144ba06b65 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-2.rs +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-2.rs @@ -1,3 +1,4 @@ +// ignore-compare-mode-chalk trait Z<'a, T: ?Sized> where T: Z<'a, u16>, diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr index 9a70194379612..b48ff97f1211b 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `for<'b> >::W: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-2.rs:3:8 + --> $DIR/hr-associated-type-bound-param-2.rs:4:8 | LL | trait Z<'a, T: ?Sized> | - required by a bound in this @@ -15,7 +15,7 @@ LL | for<'b> >::W: Clone, <&mut T as Clone> error[E0277]: the trait bound `for<'b> >::W: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-2.rs:15:14 + --> $DIR/hr-associated-type-bound-param-2.rs:16:14 | LL | trait Z<'a, T: ?Sized> | - required by a bound in this @@ -31,7 +31,7 @@ LL | type W = str; <&mut T as Clone> error[E0277]: the trait bound `for<'b> >::W: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-2.rs:3:8 + --> $DIR/hr-associated-type-bound-param-2.rs:4:8 | LL | trait Z<'a, T: ?Sized> | - required by a bound in this diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-5.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-5.rs index ec627c7f7ea3d..fc3a85171e273 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-5.rs +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-5.rs @@ -1,3 +1,4 @@ +// ignore-compare-mode-chalk trait Cycle: Sized { type Next: Cycle; } diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr index 81eceb4666763..df25f7ac953e7 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `for<'b> as X<'b, Box>>::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-5.rs:26:14 + --> $DIR/hr-associated-type-bound-param-5.rs:27:14 | LL | trait X<'a, T: Cycle + for<'b> X<'b, T>> | - required by a bound in this @@ -15,7 +15,7 @@ LL | type U = str; <&mut T as Clone> error[E0277]: the trait bound `for<'b> as X<'b, Vec>>::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-5.rs:26:14 + --> $DIR/hr-associated-type-bound-param-5.rs:27:14 | LL | trait X<'a, T: Cycle + for<'b> X<'b, T>> | - required by a bound in this @@ -31,7 +31,7 @@ LL | type U = str; <&mut T as Clone> error[E0277]: the trait bound `for<'b> as X<'b, Vec>>::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-5.rs:32:14 + --> $DIR/hr-associated-type-bound-param-5.rs:33:14 | LL | trait X<'a, T: Cycle + for<'b> X<'b, T>> | - required by a bound in this @@ -47,7 +47,7 @@ LL | type U = str; <&mut T as Clone> error[E0277]: the trait bound `for<'b> as X<'b, Box>>::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-5.rs:32:14 + --> $DIR/hr-associated-type-bound-param-5.rs:33:14 | LL | trait X<'a, T: Cycle + for<'b> X<'b, T>> | - required by a bound in this diff --git a/src/test/ui/deriving/deriving-associated-types.rs b/src/test/ui/deriving/deriving-associated-types.rs index 4b1cbe80c506d..13735ff2c5a1c 100644 --- a/src/test/ui/deriving/deriving-associated-types.rs +++ b/src/test/ui/deriving/deriving-associated-types.rs @@ -1,4 +1,5 @@ // run-pass +// ignore-compare-mode-chalk pub trait DeclaredTrait { type Type; } diff --git a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs index 3b6c9791722bb..ffe297a5a6a2f 100644 --- a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs +++ b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs @@ -1,3 +1,4 @@ +// ignore-compare-mode-chalk use std::fmt::Debug; type Foo = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable diff --git a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr index 8bab0d0c4a95c..b32cf94985497 100644 --- a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr +++ b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr @@ -1,5 +1,5 @@ error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:3:12 + --> $DIR/feature-gate-type_alias_impl_trait.rs:4:12 | LL | type Foo = impl Debug; | ^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | type Foo = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:11:16 + --> $DIR/feature-gate-type_alias_impl_trait.rs:12:16 | LL | type Baa = impl Debug; | ^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | type Baa = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: associated type defaults are unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:22:5 + --> $DIR/feature-gate-type_alias_impl_trait.rs:23:5 | LL | type Assoc = impl Debug; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | type Assoc = impl Debug; = help: add `#![feature(associated_type_defaults)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:22:18 + --> $DIR/feature-gate-type_alias_impl_trait.rs:23:18 | LL | type Assoc = impl Debug; | ^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | type Assoc = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/feature-gate-type_alias_impl_trait.rs:28:24 + --> $DIR/feature-gate-type_alias_impl_trait.rs:29:24 | LL | type NestedFree = (Vec, impl Debug, impl Iterator); | ^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | type NestedFree = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:28:37 + --> $DIR/feature-gate-type_alias_impl_trait.rs:29:37 | LL | type NestedFree = (Vec, impl Debug, impl Iterator); | ^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | type NestedFree = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:28:49 + --> $DIR/feature-gate-type_alias_impl_trait.rs:29:49 | LL | type NestedFree = (Vec, impl Debug, impl Iterator); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -62,7 +62,7 @@ LL | type NestedFree = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:28:70 + --> $DIR/feature-gate-type_alias_impl_trait.rs:29:70 | LL | type NestedFree = (Vec, impl Debug, impl Iterator); | ^^^^^^^^^^ @@ -71,7 +71,7 @@ LL | type NestedFree = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:39:21 + --> $DIR/feature-gate-type_alias_impl_trait.rs:40:21 | LL | type Baa = (Vec, impl Debug, impl Iterator + Debug); | ^^^^^^^^^^ @@ -80,7 +80,7 @@ LL | type Baa = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:39:34 + --> $DIR/feature-gate-type_alias_impl_trait.rs:40:34 | LL | type Baa = (Vec, impl Debug, impl Iterator + Debug); | ^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | type Baa = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:39:46 + --> $DIR/feature-gate-type_alias_impl_trait.rs:40:46 | LL | type Baa = (Vec, impl Debug, impl Iterator + Debug); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -98,7 +98,7 @@ LL | type Baa = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:39:67 + --> $DIR/feature-gate-type_alias_impl_trait.rs:40:67 | LL | type Baa = (Vec, impl Debug, impl Iterator + Debug); | ^^^^^^^^^^ @@ -107,7 +107,7 @@ LL | type Baa = (Vec, impl Debug, impl Iterator $DIR/feature-gate-type_alias_impl_trait.rs:22:18 + --> $DIR/feature-gate-type_alias_impl_trait.rs:23:18 | LL | type Assoc = impl Debug; | ^^^^^^^^^^ diff --git a/src/test/ui/impl-trait/example-calendar.rs b/src/test/ui/impl-trait/example-calendar.rs index fafab8a102a90..238f3fa31ed72 100644 --- a/src/test/ui/impl-trait/example-calendar.rs +++ b/src/test/ui/impl-trait/example-calendar.rs @@ -1,4 +1,5 @@ // run-pass +// ignore-compare-mode-chalk #![feature(fn_traits, step_trait, diff --git a/src/test/ui/impl-trait/issue-55872-2.rs b/src/test/ui/impl-trait/issue-55872-2.rs index 7708576ae7823..ee09a66ef537a 100644 --- a/src/test/ui/impl-trait/issue-55872-2.rs +++ b/src/test/ui/impl-trait/issue-55872-2.rs @@ -1,5 +1,6 @@ // edition:2018 // ignore-tidy-linelength +// ignore-compare-mode-chalk #![feature(type_alias_impl_trait)] diff --git a/src/test/ui/impl-trait/issue-55872-2.stderr b/src/test/ui/impl-trait/issue-55872-2.stderr index 58c5ee45051af..f954ce9f090e6 100644 --- a/src/test/ui/impl-trait/issue-55872-2.stderr +++ b/src/test/ui/impl-trait/issue-55872-2.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `impl Future: Copy` is not satisfied - --> $DIR/issue-55872-2.rs:13:14 + --> $DIR/issue-55872-2.rs:14:14 | LL | type E = impl std::marker::Copy; | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `impl Future` error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-55872-2.rs:15:28 + --> $DIR/issue-55872-2.rs:16:28 | LL | fn foo() -> Self::E { | ____________________________^ diff --git a/src/test/ui/impl-trait/issue-55872.rs b/src/test/ui/impl-trait/issue-55872.rs index bc91aae70c708..b12bfbcda9dc3 100644 --- a/src/test/ui/impl-trait/issue-55872.rs +++ b/src/test/ui/impl-trait/issue-55872.rs @@ -1,4 +1,5 @@ // ignore-tidy-linelength +// ignore-compare-mode-chalk #![feature(type_alias_impl_trait)] pub trait Bar { diff --git a/src/test/ui/impl-trait/issue-55872.stderr b/src/test/ui/impl-trait/issue-55872.stderr index 60654ec34610f..41d7beb22fa22 100644 --- a/src/test/ui/impl-trait/issue-55872.stderr +++ b/src/test/ui/impl-trait/issue-55872.stderr @@ -1,5 +1,5 @@ error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-55872.rs:13:28 + --> $DIR/issue-55872.rs:14:28 | LL | fn foo() -> Self::E { | ____________________________^ diff --git a/src/test/ui/issues/issue-23122-1.rs b/src/test/ui/issues/issue-23122-1.rs index 0937e029ef45e..efa4e614be5b0 100644 --- a/src/test/ui/issues/issue-23122-1.rs +++ b/src/test/ui/issues/issue-23122-1.rs @@ -1,3 +1,5 @@ +// ignore-compare-mode-chalk + trait Next { type Next: Next; } diff --git a/src/test/ui/issues/issue-23122-1.stderr b/src/test/ui/issues/issue-23122-1.stderr index 1f78b0d152d1b..8613c1ef8c201 100644 --- a/src/test/ui/issues/issue-23122-1.stderr +++ b/src/test/ui/issues/issue-23122-1.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow evaluating the requirement ` as Next>::Next == _` - --> $DIR/issue-23122-1.rs:8:5 + --> $DIR/issue-23122-1.rs:10:5 | LL | type Next = as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-23122-2.rs b/src/test/ui/issues/issue-23122-2.rs index 84abebf6b74a7..7866b931ec4b9 100644 --- a/src/test/ui/issues/issue-23122-2.rs +++ b/src/test/ui/issues/issue-23122-2.rs @@ -1,3 +1,4 @@ +// ignore-compare-mode-chalk trait Next { type Next: Next; } diff --git a/src/test/ui/issues/issue-23122-2.stderr b/src/test/ui/issues/issue-23122-2.stderr index 7ed04519b69ca..ce3bffe602ca0 100644 --- a/src/test/ui/issues/issue-23122-2.stderr +++ b/src/test/ui/issues/issue-23122-2.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` - --> $DIR/issue-23122-2.rs:8:5 + --> $DIR/issue-23122-2.rs:9:5 | LL | type Next = as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-28561.rs b/src/test/ui/issues/issue-28561.rs index 1241fb0b1f85f..184f5cb26c546 100644 --- a/src/test/ui/issues/issue-28561.rs +++ b/src/test/ui/issues/issue-28561.rs @@ -1,4 +1,5 @@ // check-pass +// ignore-compare-mode-chalk #[derive(Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] struct Array { f00: [T; 00], diff --git a/src/test/ui/issues/issue-33187.rs b/src/test/ui/issues/issue-33187.rs index 5226f9faf56d6..f6b56610ec7d9 100644 --- a/src/test/ui/issues/issue-33187.rs +++ b/src/test/ui/issues/issue-33187.rs @@ -1,4 +1,5 @@ // run-pass +// ignore-compare-mode-chalk struct Foo(::Data); impl Copy for Foo where ::Data: Copy { } diff --git a/src/test/ui/issues/issue-37051.rs b/src/test/ui/issues/issue-37051.rs index 9cae6cf5e7665..e0c47197eaa03 100644 --- a/src/test/ui/issues/issue-37051.rs +++ b/src/test/ui/issues/issue-37051.rs @@ -1,4 +1,5 @@ // check-pass +// ignore-compare-mode-chalk #![feature(associated_type_defaults)] diff --git a/src/test/ui/issues/issue-50301.rs b/src/test/ui/issues/issue-50301.rs index 47ee3e7ad70e8..4fcb41485d0e2 100644 --- a/src/test/ui/issues/issue-50301.rs +++ b/src/test/ui/issues/issue-50301.rs @@ -1,5 +1,6 @@ // Tests that HRTBs are correctly accepted -- https://github.com/rust-lang/rust/issues/50301 // check-pass +// ignore-compare-mode-chalk trait Trait where for<'a> &'a Self::IntoIter: IntoIterator, diff --git a/src/test/ui/issues/issue-55796.nll.stderr b/src/test/ui/issues/issue-55796.nll.stderr index baa0e6c29bfc4..61d4070d485e7 100644 --- a/src/test/ui/issues/issue-55796.nll.stderr +++ b/src/test/ui/issues/issue-55796.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-55796.rs:16:9 + --> $DIR/issue-55796.rs:18:9 | LL | pub trait Graph<'a> { | -- lifetime `'a` defined here @@ -10,7 +10,7 @@ LL | Box::new(self.out_edges(u).map(|e| e.target())) = help: consider replacing `'a` with `'static` error: lifetime may not live long enough - --> $DIR/issue-55796.rs:21:9 + --> $DIR/issue-55796.rs:23:9 | LL | pub trait Graph<'a> { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-55796.rs b/src/test/ui/issues/issue-55796.rs index 088d4301c51b1..1086669ee7463 100644 --- a/src/test/ui/issues/issue-55796.rs +++ b/src/test/ui/issues/issue-55796.rs @@ -1,3 +1,5 @@ +// ignore-compare-mode-chalk + pub trait EdgeTrait { fn target(&self) -> N; } diff --git a/src/test/ui/issues/issue-55796.stderr b/src/test/ui/issues/issue-55796.stderr index 1aa0050336e38..ffe3bb737ad6a 100644 --- a/src/test/ui/issues/issue-55796.stderr +++ b/src/test/ui/issues/issue-55796.stderr @@ -1,22 +1,22 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/issue-55796.rs:16:9 + --> $DIR/issue-55796.rs:18:9 | LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the trait at 5:17... - --> $DIR/issue-55796.rs:5:17 +note: first, the lifetime cannot outlive the lifetime `'a` as defined on the trait at 7:17... + --> $DIR/issue-55796.rs:7:17 | LL | pub trait Graph<'a> { | ^^ -note: ...so that the type `Map<>::EdgesIter, [closure@$DIR/issue-55796.rs:16:40: 16:54]>` will meet its required lifetime bounds - --> $DIR/issue-55796.rs:16:9 +note: ...so that the type `Map<>::EdgesIter, [closure@$DIR/issue-55796.rs:18:40: 18:54]>` will meet its required lifetime bounds + --> $DIR/issue-55796.rs:18:9 | LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: but, the lifetime must be valid for the static lifetime... note: ...so that the expression is assignable - --> $DIR/issue-55796.rs:16:9 + --> $DIR/issue-55796.rs:18:9 | LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,24 +24,24 @@ LL | Box::new(self.out_edges(u).map(|e| e.target())) found `Box>::Node>>` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/issue-55796.rs:21:9 + --> $DIR/issue-55796.rs:23:9 | LL | Box::new(self.in_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the trait at 5:17... - --> $DIR/issue-55796.rs:5:17 +note: first, the lifetime cannot outlive the lifetime `'a` as defined on the trait at 7:17... + --> $DIR/issue-55796.rs:7:17 | LL | pub trait Graph<'a> { | ^^ -note: ...so that the type `Map<>::EdgesIter, [closure@$DIR/issue-55796.rs:21:39: 21:53]>` will meet its required lifetime bounds - --> $DIR/issue-55796.rs:21:9 +note: ...so that the type `Map<>::EdgesIter, [closure@$DIR/issue-55796.rs:23:39: 23:53]>` will meet its required lifetime bounds + --> $DIR/issue-55796.rs:23:9 | LL | Box::new(self.in_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: but, the lifetime must be valid for the static lifetime... note: ...so that the expression is assignable - --> $DIR/issue-55796.rs:21:9 + --> $DIR/issue-55796.rs:23:9 | LL | Box::new(self.in_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs b/src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs index 36e9932602fb0..44ea9f12d38ff 100644 --- a/src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs +++ b/src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs @@ -1,5 +1,6 @@ // build-pass // ignore-tidy-filelength +// ignore-compare-mode-chalk #![crate_type = "rlib"] fn banana(v: &str) -> u32 { diff --git a/src/test/ui/mir/mir-inlining/ice-issue-77564.rs b/src/test/ui/mir/mir-inlining/ice-issue-77564.rs new file mode 100644 index 0000000000000..262402df2cc5a --- /dev/null +++ b/src/test/ui/mir/mir-inlining/ice-issue-77564.rs @@ -0,0 +1,38 @@ +// run-pass +// compile-flags:-Zmir-opt-level=2 + +use std::mem::MaybeUninit; +const N: usize = 2; + +trait CollectArray: Iterator { + fn inner_array(&mut self) -> [A; N]; + fn collect_array(&mut self) -> [A; N] { + let result = self.inner_array(); + assert!(self.next().is_none()); + result + } +} + +impl CollectArray for I +where + I: Iterator, +{ + fn inner_array(&mut self) -> [A; N] { + let mut result: [MaybeUninit; N] = unsafe { MaybeUninit::uninit().assume_init() }; + for (dest, item) in result.iter_mut().zip(self) { + *dest = MaybeUninit::new(item); + } + let temp_ptr: *const [MaybeUninit; N] = &result; + unsafe { std::ptr::read(temp_ptr as *const [A; N]) } + } +} + +fn main() { + assert_eq!( + [[1, 2], [3, 4]] + .iter() + .map(|row| row.iter().collect_array()) + .collect_array(), + [[&1, &2], [&3, &4]] + ); +} diff --git a/src/test/ui/nll/ty-outlives/issue-53789-2.rs b/src/test/ui/nll/ty-outlives/issue-53789-2.rs index 7dcdd58bb247e..d15e402460794 100644 --- a/src/test/ui/nll/ty-outlives/issue-53789-2.rs +++ b/src/test/ui/nll/ty-outlives/issue-53789-2.rs @@ -1,6 +1,7 @@ // Regression test for #53789. // // check-pass +// ignore-compare-mode-chalk use std::collections::BTreeMap; use std::ops::Range; diff --git a/src/test/ui/specialization/deafult-associated-type-bound-1.rs b/src/test/ui/specialization/deafult-associated-type-bound-1.rs index c043114b565c8..6eb2aa980d152 100644 --- a/src/test/ui/specialization/deafult-associated-type-bound-1.rs +++ b/src/test/ui/specialization/deafult-associated-type-bound-1.rs @@ -1,5 +1,6 @@ // Check that we check that default associated types satisfy the required // bounds on them. +// ignore-compare-mode-chalk #![feature(specialization)] //~^ WARNING `specialization` is incomplete diff --git a/src/test/ui/specialization/deafult-associated-type-bound-1.stderr b/src/test/ui/specialization/deafult-associated-type-bound-1.stderr index 4c21f8db8fad8..337972ea2b793 100644 --- a/src/test/ui/specialization/deafult-associated-type-bound-1.stderr +++ b/src/test/ui/specialization/deafult-associated-type-bound-1.stderr @@ -1,5 +1,5 @@ warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/deafult-associated-type-bound-1.rs:4:12 + --> $DIR/deafult-associated-type-bound-1.rs:5:12 | LL | #![feature(specialization)] | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(specialization)] = note: see issue #31844 for more information error[E0277]: the trait bound `str: Clone` is not satisfied - --> $DIR/deafult-associated-type-bound-1.rs:18:5 + --> $DIR/deafult-associated-type-bound-1.rs:19:5 | LL | type U: Clone; | ----- required by this bound in `X::U` diff --git a/src/test/ui/symbol-names/impl1.legacy.stderr b/src/test/ui/symbol-names/impl1.legacy.stderr index e4c20cd882013..c866f9bd3b791 100644 --- a/src/test/ui/symbol-names/impl1.legacy.stderr +++ b/src/test/ui/symbol-names/impl1.legacy.stderr @@ -64,7 +64,7 @@ error: demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::A LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: def-path(<[&dyn Foo extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as Bar>::method) +error: def-path(<[&dyn Foo extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method) --> $DIR/impl1.rs:71:13 | LL | #[rustc_def_path] diff --git a/src/test/ui/symbol-names/impl1.rs b/src/test/ui/symbol-names/impl1.rs index 1d86abd002c47..1ada54cc102ed 100644 --- a/src/test/ui/symbol-names/impl1.rs +++ b/src/test/ui/symbol-names/impl1.rs @@ -69,8 +69,8 @@ fn main() { //[v0]~| ERROR demangling(<[&dyn impl1[317d481089b8c8fe]::Foo extern "C" fn(&'a u8, ...)> + impl1[317d481089b8c8fe]::AutoTrait; 3: usize] as impl1[317d481089b8c8fe]::main::{closure#1}::Bar>::method) //[v0]~| ERROR demangling-alt(<[&dyn impl1::Foo extern "C" fn(&'a u8, ...)> + impl1::AutoTrait; 3] as impl1::main::{closure#1}::Bar>::method) #[rustc_def_path] - //[legacy]~^ ERROR def-path(<[&dyn Foo extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as Bar>::method) - //[v0]~^^ ERROR def-path(<[&dyn Foo extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as Bar>::method) + //[legacy]~^ ERROR def-path(<[&dyn Foo extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method) + //[v0]~^^ ERROR def-path(<[&dyn Foo extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method) fn method(&self) {} } }; diff --git a/src/test/ui/symbol-names/impl1.v0.stderr b/src/test/ui/symbol-names/impl1.v0.stderr index 01d047d34a58b..db5eda0db5074 100644 --- a/src/test/ui/symbol-names/impl1.v0.stderr +++ b/src/test/ui/symbol-names/impl1.v0.stderr @@ -64,7 +64,7 @@ error: demangling-alt(<[&dyn impl1::Foo extern "C" fn(&'a u8, .. LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: def-path(<[&dyn Foo extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as Bar>::method) +error: def-path(<[&dyn Foo extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method) --> $DIR/impl1.rs:71:13 | LL | #[rustc_def_path] diff --git a/src/test/ui/type-alias-impl-trait/issue-53598.rs b/src/test/ui/type-alias-impl-trait/issue-53598.rs index 61dff79d07bad..add9662938069 100644 --- a/src/test/ui/type-alias-impl-trait/issue-53598.rs +++ b/src/test/ui/type-alias-impl-trait/issue-53598.rs @@ -1,4 +1,5 @@ // ignore-tidy-linelength +// ignore-compare-mode-chalk #![feature(type_alias_impl_trait)] use std::fmt::Debug; diff --git a/src/test/ui/type-alias-impl-trait/issue-53598.stderr b/src/test/ui/type-alias-impl-trait/issue-53598.stderr index 4c8144a235930..79e2682da3ea8 100644 --- a/src/test/ui/type-alias-impl-trait/issue-53598.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-53598.stderr @@ -1,5 +1,5 @@ error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-53598.rs:20:42 + --> $DIR/issue-53598.rs:21:42 | LL | fn foo(_: T) -> Self::Item { | __________________________________________^ diff --git a/src/test/ui/type-alias-impl-trait/issue-57700.rs b/src/test/ui/type-alias-impl-trait/issue-57700.rs index bfabef54724c8..c785ea2ee57d0 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57700.rs +++ b/src/test/ui/type-alias-impl-trait/issue-57700.rs @@ -1,4 +1,5 @@ // ignore-tidy-linelength +// ignore-compare-mode-chalk #![feature(arbitrary_self_types)] #![feature(type_alias_impl_trait)] diff --git a/src/test/ui/type-alias-impl-trait/issue-57700.stderr b/src/test/ui/type-alias-impl-trait/issue-57700.stderr index c701e3e74ef59..dc6be87ee9365 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57700.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-57700.stderr @@ -1,5 +1,5 @@ error: type parameter `impl Deref` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-57700.rs:16:58 + --> $DIR/issue-57700.rs:17:58 | LL | fn foo(self: impl Deref) -> Self::Bar { | __________________________________________________________^ diff --git a/src/test/ui/type-alias-impl-trait/issue-60371.rs b/src/test/ui/type-alias-impl-trait/issue-60371.rs index 50b9d1ac7933c..14d21418ae853 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60371.rs +++ b/src/test/ui/type-alias-impl-trait/issue-60371.rs @@ -1,3 +1,5 @@ +// ignore-compare-mode-chalk + trait Bug { type Item: Bug; diff --git a/src/test/ui/type-alias-impl-trait/issue-60371.stderr b/src/test/ui/type-alias-impl-trait/issue-60371.stderr index 905248fb33755..d8e514a2cf45b 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60371.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-60371.stderr @@ -1,5 +1,5 @@ error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/issue-60371.rs:8:17 + --> $DIR/issue-60371.rs:10:17 | LL | type Item = impl Bug; | ^^^^^^^^ @@ -8,7 +8,7 @@ LL | type Item = impl Bug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0277]: the trait bound `(): Bug` is not satisfied - --> $DIR/issue-60371.rs:8:17 + --> $DIR/issue-60371.rs:10:17 | LL | type Item = impl Bug; | ^^^^^^^^ the trait `Bug` is not implemented for `()` @@ -17,7 +17,7 @@ LL | type Item = impl Bug; <&() as Bug> error: could not find defining uses - --> $DIR/issue-60371.rs:8:17 + --> $DIR/issue-60371.rs:10:17 | LL | type Item = impl Bug; | ^^^^^^^^ diff --git a/src/tools/rls b/src/tools/rls index 4d5e9df12b6a7..9bfb47a79299d 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 4d5e9df12b6a75d7ab48a7de060a97265ce49cee +Subproject commit 9bfb47a79299d52f45304367762c9bfc96d9ed7c diff --git a/src/tools/rustfmt b/src/tools/rustfmt index 01f2eadccc74c..97d0301011533 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit 01f2eadccc74cf70eb11e6300ffa7e02b18b0027 +Subproject commit 97d0301011533e1c131c0edd660d77b4bd476c8b