diff --git a/Cargo.lock b/Cargo.lock index 3d7f00e6410b5..5c64706dbdac1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -169,7 +169,7 @@ dependencies = [ "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -463,7 +463,7 @@ dependencies = [ "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -484,7 +484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -974,7 +974,7 @@ dependencies = [ [[package]] name = "getopts" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1989,7 +1989,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2008,7 +2008,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3094,7 +3094,7 @@ dependencies = [ "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "ignore 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3521,7 +3521,7 @@ dependencies = [ name = "test" version = "0.0.0" dependencies = [ - "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "proc_macro 0.0.0", "term 0.0.0", ] @@ -3531,7 +3531,7 @@ name = "tester" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4131,7 +4131,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "1a70b146671de62ec8c8ed572219ca5d594d9b06c0b364d5e67b722fc559b48c" "checksum fwdansi 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34dd4c507af68d37ffef962063dfa1944ce0dd4d5b82043dbab1dabe088610c3" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" -"checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797" +"checksum getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "72327b15c228bfe31f1390f93dd5e9279587f0463836393c9df719ce62a3e450" "checksum git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7339329bfa14a00223244311560d11f8f489b453fb90092af97f267a6090ab0" "checksum git2-curl 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d58551e903ed7e2d6fe3a2f3c7efa3a784ec29b19d0fbb035aaf0497c183fbdd" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 9a410c339bf5f..3151b56d8e84e 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -39,7 +39,7 @@ build_helper = { path = "../build_helper" } cmake = "0.1.38" filetime = "0.2" num_cpus = "1.0" -getopts = "0.2.18" +getopts = "0.2.19" cc = "1.0.35" libc = "0.2" serde = "1.0.8" diff --git a/src/ci/docker/dist-aarch64-linux/Dockerfile b/src/ci/docker/dist-aarch64-linux/Dockerfile index cddfa557f6aed..f5eb66ed7142f 100644 --- a/src/ci/docker/dist-aarch64-linux/Dockerfile +++ b/src/ci/docker/dist-aarch64-linux/Dockerfile @@ -32,5 +32,8 @@ ENV CC_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnueabi-gcc \ ENV HOSTS=aarch64-unknown-linux-gnu -ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs +ENV RUST_CONFIGURE_ARGS \ + --enable-extended \ + --enable-profiler \ + --disable-docs ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 6d8558211818b..f85fd524a5d9b 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -1,13 +1,14 @@ +use rustc_data_structures::fx::FxHashMap; +use syntax_pos::Span; + use crate::hir::def_id::DefId; use crate::hir; use crate::hir::Node; use crate::infer::{self, InferCtxt, InferOk, TypeVariableOrigin}; use crate::infer::outlives::free_region_map::FreeRegionRelations; -use rustc_data_structures::fx::FxHashMap; use crate::traits::{self, PredicateObligation}; use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind}; -use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder}; -use crate::ty::outlives::Component; +use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder, TypeVisitor}; use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, UnpackedKind}; use crate::util::nodemap::DefIdMap; @@ -373,58 +374,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let least_region = least_region.unwrap_or(self.tcx.lifetimes.re_static); debug!("constrain_opaque_types: least_region={:?}", least_region); - // Require that the type `concrete_ty` outlives - // `least_region`, modulo any type parameters that appear - // in the type, which we ignore. This is because impl - // trait values are assumed to capture all the in-scope - // type parameters. This little loop here just invokes - // `outlives` repeatedly, draining all the nested - // obligations that result. - let mut types = vec![concrete_ty]; - let bound_region = |r| self.sub_regions(infer::CallReturn(span), least_region, r); - while let Some(ty) = types.pop() { - let mut components = smallvec![]; - self.tcx.push_outlives_components(ty, &mut components); - while let Some(component) = components.pop() { - match component { - Component::Region(r) => { - bound_region(r); - } - - Component::Param(_) => { - // ignore type parameters like `T`, they are captured - // implicitly by the `impl Trait` - } - - Component::UnresolvedInferenceVariable(_) => { - // we should get an error that more type - // annotations are needed in this case - self.tcx - .sess - .delay_span_bug(span, "unresolved inf var in opaque"); - } - - Component::Projection(ty::ProjectionTy { - substs, - item_def_id: _, - }) => { - for k in substs { - match k.unpack() { - UnpackedKind::Lifetime(lt) => bound_region(lt), - UnpackedKind::Type(ty) => types.push(ty), - UnpackedKind::Const(_) => { - // Const parameters don't impose constraints. - } - } - } - } - - Component::EscapingProjection(more_components) => { - components.extend(more_components); - } - } - } - } + concrete_ty.visit_with(&mut OpaqueTypeOutlivesVisitor { + infcx: self, + least_region, + span, + }); } /// Given the fully resolved, instantiated type for an opaque @@ -502,6 +456,80 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } +// Visitor that requires that (almost) all regions in the type visited outlive +// `least_region`. We cannot use `push_outlives_components` because regions in +// closure signatures are not included in their outlives components. We need to +// ensure all regions outlive the given bound so that we don't end up with, +// say, `ReScope` appearing in a return type and causing ICEs when other +// functions end up with region constraints involving regions from other +// functions. +// +// We also cannot use `for_each_free_region` because for closures it includes +// the regions parameters from the enclosing item. +// +// We ignore any type parameters because impl trait values are assumed to +// capture all the in-scope type parameters. +struct OpaqueTypeOutlivesVisitor<'a, 'gcx, 'tcx> { + infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, + least_region: ty::Region<'tcx>, + span: Span, +} + +impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, '_, 'tcx> +{ + fn visit_binder>(&mut self, t: &ty::Binder) -> bool { + t.skip_binder().visit_with(self); + false // keep visiting + } + + fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { + match *r { + // ignore bound regions, keep visiting + ty::ReLateBound(_, _) => false, + _ => { + self.infcx.sub_regions(infer::CallReturn(self.span), self.least_region, r); + false + } + } + } + + fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { + // We're only interested in types involving regions + if !ty.flags.intersects(ty::TypeFlags::HAS_FREE_REGIONS) { + return false; // keep visiting + } + + match ty.sty { + ty::Closure(def_id, ref substs) => { + // Skip lifetime parameters of the enclosing item(s) + + for upvar_ty in substs.upvar_tys(def_id, self.infcx.tcx) { + upvar_ty.visit_with(self); + } + + substs.closure_sig_ty(def_id, self.infcx.tcx).visit_with(self); + } + + ty::Generator(def_id, ref substs, _) => { + // Skip lifetime parameters of the enclosing item(s) + // Also skip the witness type, because that has no free regions. + + for upvar_ty in substs.upvar_tys(def_id, self.infcx.tcx) { + upvar_ty.visit_with(self); + } + + substs.return_ty(def_id, self.infcx.tcx).visit_with(self); + substs.yield_ty(def_id, self.infcx.tcx).visit_with(self); + } + _ => { + ty.super_visit_with(self); + } + } + + false + } +} + struct ReverseMapper<'cx, 'gcx: 'tcx, 'tcx: 'cx> { tcx: TyCtxt<'cx, 'gcx, 'tcx>, @@ -563,8 +591,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ReverseMapper<'cx, 'gcx, 'tcx> // ignore `'static`, as that can appear anywhere ty::ReStatic | - // ignore `ReScope`, as that can appear anywhere - // See `src/test/run-pass/issue-49556.rs` for example. + // ignore `ReScope`, which may appear in impl Trait in bindings. ty::ReScope(..) => return r, _ => { } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 0dc23f5ce47e5..f23ff47b5ff66 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2055,10 +2055,13 @@ impl<'tcx> Place<'tcx> { /// Finds the innermost `Local` from this `Place`. pub fn base_local(&self) -> Option { - match self { - Place::Base(PlaceBase::Local(local)) => Some(*local), - Place::Projection(box Projection { base, elem: _ }) => base.base_local(), - Place::Base(PlaceBase::Static(..)) => None, + let mut place = self; + loop { + match place { + Place::Projection(proj) => place = &proj.base, + Place::Base(PlaceBase::Static(_)) => return None, + Place::Base(PlaceBase::Local(local)) => return Some(*local), + } } } diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 4682eb547836b..a0b781e4805d5 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -2184,10 +2184,21 @@ pub fn build_session_options_and_crate_config( TargetTriple::from_triple(host_triple()) }; let opt_level = { - if matches.opt_present("O") { - if cg.opt_level.is_some() { - early_error(error_format, "-O and -C opt-level both provided"); + // The `-O` and `-C opt-level` flags specify the same setting, so we want to be able + // to use them interchangeably. However, because they're technically different flags, + // we need to work out manually which should take precedence if both are supplied (i.e. + // the rightmost flag). We do this by finding the (rightmost) position of both flags and + // comparing them. Note that if a flag is not found, its position will be `None`, which + // always compared less than `Some(_)`. + let max_o = matches.opt_positions("O").into_iter().max(); + let max_c = matches.opt_strs_pos("C").into_iter().flat_map(|(i, s)| { + if let Some("opt-level") = s.splitn(2, '=').next() { + Some(i) + } else { + None } + }).max(); + if max_o > max_c { OptLevel::Default } else { match cg.opt_level.as_ref().map(String::as_ref) { @@ -2211,11 +2222,19 @@ pub fn build_session_options_and_crate_config( } } }; + // The `-g` and `-C debuginfo` flags specify the same setting, so we want to be able + // to use them interchangeably. See the note above (regarding `-O` and `-C opt-level`) + // for more details. let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No); - let debuginfo = if matches.opt_present("g") { - if cg.debuginfo.is_some() { - early_error(error_format, "-g and -C debuginfo both provided"); + let max_g = matches.opt_positions("g").into_iter().max(); + let max_c = matches.opt_strs_pos("C").into_iter().flat_map(|(i, s)| { + if let Some("debuginfo") = s.splitn(2, '=').next() { + Some(i) + } else { + None } + }).max(); + let debuginfo = if max_g > max_c { DebugInfo::Full } else { match cg.debuginfo { diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 0d67865d71708..80f4d7a5215a2 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -997,7 +997,7 @@ struct MemberDescription<'ll> { size: Size, align: Align, flags: DIFlags, - discriminant: Option, + discriminant: Option, } // A factory for MemberDescriptions. It produces a list of member descriptions @@ -1355,7 +1355,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { flags: DIFlags::FlagZero, discriminant: Some(self.layout.ty.ty_adt_def().unwrap() .discriminant_for_variant(cx.tcx, i) - .val as u64), + .val), } }).collect() } @@ -1454,12 +1454,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { let value = (i.as_u32() as u128) .wrapping_sub(niche_variants.start().as_u32() as u128) .wrapping_add(niche_start); - let value = truncate(value, discr.value.size(cx)); - // NOTE(eddyb) do *NOT* remove this assert, until - // we pass the full 128-bit value to LLVM, otherwise - // truncation will be silent and remain undetected. - assert_eq!(value as u64 as u128, value); - Some(value as u64) + Some(truncate(value, discr.value.size(cx))) }; MemberDescription { @@ -1932,7 +1927,8 @@ fn set_members_of_composite_type(cx: &CodegenCx<'ll, 'tcx>, member_description.offset.bits(), match member_description.discriminant { None => None, - Some(value) => Some(cx.const_u64(value)), + Some(value) => + Some(cx.const_uint_big(cx.type_i128(), value)), }, member_description.flags, member_description.type_metadata)) diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index 56dacf20edcb8..5ced497baa1fd 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -210,7 +210,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> { self.insert_as_pending_if_two_phase(location, &assigned_place, kind, idx); - if let Some(local) = borrowed_place.root_local() { + if let Some(local) = borrowed_place.base_local() { self.local_map.entry(local).or_default().insert(idx); } } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 1d65a018dd62d..fc1f5eb5d5a7a 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1831,7 +1831,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } place = base; - continue; } } } diff --git a/src/librustc_mir/borrow_check/place_ext.rs b/src/librustc_mir/borrow_check/place_ext.rs index 913884a821837..cf9a6165d71a2 100644 --- a/src/librustc_mir/borrow_check/place_ext.rs +++ b/src/librustc_mir/borrow_check/place_ext.rs @@ -1,6 +1,6 @@ use rustc::hir; use rustc::mir::ProjectionElem; -use rustc::mir::{Local, Mir, Place, PlaceBase, Mutability, Static, StaticKind}; +use rustc::mir::{Mir, Place, PlaceBase, Mutability, Static, StaticKind}; use rustc::ty::{self, TyCtxt}; use crate::borrow_check::borrow_set::LocalsStateAtExit; @@ -16,10 +16,6 @@ crate trait PlaceExt<'tcx> { mir: &Mir<'tcx>, locals_state_at_exit: &LocalsStateAtExit, ) -> bool; - - /// If this is a place like `x.f.g`, returns the local - /// `x`. Returns `None` if this is based in a static. - fn root_local(&self) -> Option; } impl<'tcx> PlaceExt<'tcx> for Place<'tcx> { @@ -82,15 +78,4 @@ impl<'tcx> PlaceExt<'tcx> for Place<'tcx> { }, } } - - fn root_local(&self) -> Option { - let mut p = self; - loop { - match p { - Place::Projection(pi) => p = &pi.base, - Place::Base(PlaceBase::Static(_)) => return None, - Place::Base(PlaceBase::Local(l)) => return Some(*l), - } - } - } } diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 8ae66a96c763a..473f952ca01b7 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -523,7 +523,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let msg = format!("you can convert an `{}` to `{}`", checked_ty, expected_ty); let cast_msg = format!("you can cast an `{} to `{}`", checked_ty, expected_ty); - let try_msg = format!("{} or panic if it the converted value wouldn't fit", msg); + let try_msg = format!("{} and panic if the converted value wouldn't fit", msg); let lit_msg = format!( "change the type of the numeric literal from `{}` to `{}`", checked_ty, diff --git a/src/libstd/sys/sgx/abi/mem.rs b/src/libstd/sys/sgx/abi/mem.rs index 808f1ce3ff2c7..d9051733da24d 100644 --- a/src/libstd/sys/sgx/abi/mem.rs +++ b/src/libstd/sys/sgx/abi/mem.rs @@ -27,19 +27,23 @@ pub fn image_base() -> u64 { } /// Returns `true` if the specified memory range is in the enclave. +/// +/// `p + len` must not overflow. #[unstable(feature = "sgx_platform", issue = "56975")] pub fn is_enclave_range(p: *const u8, len: usize) -> bool { - let start=p as u64; - let end=start + (len as u64); + let start = p as u64; + let end = start + (len as u64); start >= image_base() && end <= image_base() + (unsafe { ENCLAVE_SIZE } as u64) // unsafe ok: link-time constant } /// Returns `true` if the specified memory range is in userspace. +/// +/// `p + len` must not overflow. #[unstable(feature = "sgx_platform", issue = "56975")] pub fn is_user_range(p: *const u8, len: usize) -> bool { - let start=p as u64; - let end=start + (len as u64); + let start = p as u64; + let end = start + (len as u64); end <= image_base() || start >= image_base() + (unsafe { ENCLAVE_SIZE } as u64) // unsafe ok: link-time constant } diff --git a/src/libstd/sys/sgx/abi/usercalls/alloc.rs b/src/libstd/sys/sgx/abi/usercalls/alloc.rs index 38e05f6fd2757..c9ff53d0a4fd6 100644 --- a/src/libstd/sys/sgx/abi/usercalls/alloc.rs +++ b/src/libstd/sys/sgx/abi/usercalls/alloc.rs @@ -85,8 +85,10 @@ pub unsafe trait UserSafe { /// /// * the pointer is not aligned. /// * the pointer is null. + /// * the pointed-to range does not fit in the address space. /// * the pointed-to range is not in user memory. unsafe fn from_raw_sized(ptr: *mut u8, size: usize) -> NonNull { + assert!(ptr.wrapping_add(size) >= ptr); let ret = Self::from_raw_sized_unchecked(ptr, size); Self::check_ptr(ret); NonNull::new_unchecked(ret as _) @@ -268,6 +270,7 @@ impl User<[T]> where [T]: UserSafe { /// /// * The pointer is not aligned /// * The pointer is null + /// * The pointed-to range does not fit in the address space /// * The pointed-to range is not in user memory pub unsafe fn from_raw_parts(ptr: *mut T, len: usize) -> Self { User(NonNull::new_userref(<[T]>::from_raw_sized(ptr as _, len * mem::size_of::()))) @@ -372,6 +375,7 @@ impl UserRef<[T]> where [T]: UserSafe { /// /// * The pointer is not aligned /// * The pointer is null + /// * The pointed-to range does not fit in the address space /// * The pointed-to range is not in user memory pub unsafe fn from_raw_parts<'a>(ptr: *const T, len: usize) -> &'a Self { &*(<[T]>::from_raw_sized(ptr as _, len * mem::size_of::()).as_ptr() as *const Self) @@ -389,6 +393,7 @@ impl UserRef<[T]> where [T]: UserSafe { /// /// * The pointer is not aligned /// * The pointer is null + /// * The pointed-to range does not fit in the address space /// * The pointed-to range is not in user memory pub unsafe fn from_raw_parts_mut<'a>(ptr: *mut T, len: usize) -> &'a mut Self { &mut*(<[T]>::from_raw_sized(ptr as _, len * mem::size_of::()).as_ptr() as *mut Self) @@ -552,10 +557,11 @@ impl UserRef { /// enclave memory. /// /// # Panics - /// This function panics if: + /// This function panics if, in the user `ByteBuffer`: /// - /// * The pointer in the user `ByteBuffer` is null - /// * The pointed-to range in the user `ByteBuffer` is not in user memory + /// * The pointer is null + /// * The pointed-to range does not fit in the address space + /// * The pointed-to range is not in user memory pub fn copy_user_buffer(&self) -> Vec { unsafe { let buf = self.to_enclave(); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c5173aa556953..d46feeab33599 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -7149,7 +7149,9 @@ impl<'a> Parser<'a> { // `()` or a tuple might be allowed. For example, `struct Struct(pub (), pub (usize));`. // Because of this, we only `bump` the `(` if we're assured it is appropriate to do so // by the following tokens. - if self.look_ahead(1, |t| t.is_keyword(keywords::Crate)) { + if self.look_ahead(1, |t| t.is_keyword(keywords::Crate)) && + self.look_ahead(2, |t| t != &token::ModSep) // account for `pub(crate::foo)` + { // `pub(crate)` self.bump(); // `(` self.bump(); // `crate` @@ -7192,7 +7194,7 @@ impl<'a> Parser<'a> { `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path"##; let path = self.parse_path(PathStyle::Mod)?; - let sp = self.prev_span; + let sp = path.span; let help_msg = format!("make this visible only to module `{}` with `in`", path); self.expect(&token::CloseDelim(token::Paren))?; // `)` let mut err = struct_span_err!(self.sess.span_diagnostic, sp, E0704, "{}", msg); diff --git a/src/libtest/Cargo.toml b/src/libtest/Cargo.toml index 2e836b6772fda..a72e4c7050289 100644 --- a/src/libtest/Cargo.toml +++ b/src/libtest/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" crate-type = ["dylib", "rlib"] [dependencies] -getopts = "0.2.18" +getopts = "0.2.19" term = { path = "../libterm" } # not actually used but needed to always have proc_macro in the sysroot diff --git a/src/test/codegen/enum-debug-niche-2.rs b/src/test/codegen/enum-debug-niche-2.rs index aa6cbf66b4aa3..b7750a3c38d66 100644 --- a/src/test/codegen/enum-debug-niche-2.rs +++ b/src/test/codegen/enum-debug-niche-2.rs @@ -9,8 +9,8 @@ // compile-flags: -g -C no-prepopulate-passes // CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i64 4294967295{{[,)].*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i128 4294967295{{[,)].*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i128 0{{[,)].*}} #![feature(never_type)] #![feature(nll)] diff --git a/src/test/codegen/repr-u128.rs b/src/test/codegen/repr-u128.rs new file mode 100644 index 0000000000000..607ed627f65a3 --- /dev/null +++ b/src/test/codegen/repr-u128.rs @@ -0,0 +1,24 @@ +// ignore-tidy-linelength +// ignore-windows +// min-system-llvm-version 8.0 + +// compile-flags: -g -C no-prepopulate-passes + +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "None",{{.*}}extraData: i128 18446745000000000124{{[,)].*}} + +#![feature(repr128)] + +#[repr(u128)] +pub enum Foo { + Lo, + Hi = 1 << 64, + Bar = 18_446_745_000_000_000_123, +} + +pub fn foo() -> Option { + None +} + +fn main() { + let roa = foo(); +} diff --git a/src/test/debuginfo/repr-u128.rs b/src/test/debuginfo/repr-u128.rs new file mode 100644 index 0000000000000..da71ec6aadc13 --- /dev/null +++ b/src/test/debuginfo/repr-u128.rs @@ -0,0 +1,34 @@ +// ignore-windows +// ignore-tidy-linelength +//min-system-llvm-version 8.0 + +//compile-flags: -g -C no-prepopulate-passes + +// === GDB TESTS =================================================================================== + +// gdb-command: run + +// gdb-command:print vals +// gdbg-check:$1 = (Some(Foo::Lo), None::) +// gdbr-check:$1 = repr_u128::Foo::(std::option::Option, std::option::Option) + +// === LLDB TESTS ================================================================================== + +// lldb-command:run + +// lldb-command:print vals +// lldbg-check:[...]$0 = (Some(Foo::Lo), None::) +// lldbr-check:(repr_u128::Foo) vals = repr_u128::Foo::(std::option::Option, std::option::Option) + +#![feature(repr128)] + +#[repr(u128)] +pub enum Foo { + Lo, + Hi = 1 << 64, + Bar = 18_446_745_000_000_000_123, +} + +fn main() { + let vals = (Some(Foo::Lo), None::); +} diff --git a/src/test/run-make/override-aliased-flags/Makefile b/src/test/run-make/override-aliased-flags/Makefile new file mode 100644 index 0000000000000..866060ad998be --- /dev/null +++ b/src/test/run-make/override-aliased-flags/Makefile @@ -0,0 +1,22 @@ +-include ../../run-make-fulldeps/tools.mk + +# FIXME: it would be good to check that it's actually the rightmost flags +# that are used when multiple flags are specified, but I can't think of a +# reliable way to check this. + +all: + # Test that `-O` and `-C opt-level` can be specified multiple times. + # The rightmost flag will be used over any previous flags. + $(RUSTC) -O -O main.rs + $(RUSTC) -O -C opt-level=0 main.rs + $(RUSTC) -C opt-level=0 -O main.rs + $(RUSTC) -C opt-level=0 -C opt-level=2 main.rs + $(RUSTC) -C opt-level=2 -C opt-level=0 main.rs + + # Test that `-g` and `-C debuginfo` can be specified multiple times. + # The rightmost flag will be used over any previous flags. + $(RUSTC) -g -g main.rs + $(RUSTC) -g -C debuginfo=0 main.rs + $(RUSTC) -C debuginfo=0 -g main.rs + $(RUSTC) -C debuginfo=0 -C debuginfo=2 main.rs + $(RUSTC) -C debuginfo=2 -C debuginfo=0 main.rs diff --git a/src/test/run-make/override-aliased-flags/main.rs b/src/test/run-make/override-aliased-flags/main.rs new file mode 100644 index 0000000000000..f328e4d9d04c3 --- /dev/null +++ b/src/test/run-make/override-aliased-flags/main.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/src/test/ui/associated-types/associated-types-path-2.stderr b/src/test/ui/associated-types/associated-types-path-2.stderr index c25f12d008703..1405cb1b4736c 100644 --- a/src/test/ui/associated-types/associated-types-path-2.stderr +++ b/src/test/ui/associated-types/associated-types-path-2.stderr @@ -49,7 +49,7 @@ error[E0308]: mismatched types | LL | let _: i32 = f2(2i32); | ^^^^^^^^ expected i32, found u32 -help: you can convert an `u32` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit | LL | let _: i32 = f2(2i32).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/impl-trait/can-return-unconstrained-closure.rs b/src/test/ui/impl-trait/can-return-unconstrained-closure.rs new file mode 100644 index 0000000000000..a982b176ecda1 --- /dev/null +++ b/src/test/ui/impl-trait/can-return-unconstrained-closure.rs @@ -0,0 +1,19 @@ +// Test that we are special casing "outlives" for opaque types. +// +// The return type of a closure is not required to outlive the closure. As such +// the following code would not compile if we used a standard outlives check +// when checking the return type, because the return type of the closure would +// be `&ReEmpty i32`, and we don't allow `ReEmpty` to occur in the concrete +// type used for an opaque type. +// +// However, opaque types are special cased to include check all regions in the +// concrete type against the bound, which forces the return type to be +// `&'static i32` here. + +// compile-pass + +fn make_identity() -> impl Sized { + |x: &'static i32| x +} + +fn main() {} diff --git a/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs b/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs index 7ebc348996f5e..50646edd61a85 100644 --- a/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs +++ b/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs @@ -1,9 +1,9 @@ // This used to ICE because it creates an `impl Trait` that captures a // hidden empty region. -#![feature(conservative_impl_trait)] +// compile-pass -fn server() -> impl FilterBase2 { //~ ERROR [E0700] +fn server() -> impl FilterBase2 { segment2(|| { loop { } }).map2(|| "") } diff --git a/src/test/ui/impl-trait/issue-55608-captures-empty-region.stderr b/src/test/ui/impl-trait/issue-55608-captures-empty-region.stderr deleted file mode 100644 index 6311a7f00674f..0000000000000 --- a/src/test/ui/impl-trait/issue-55608-captures-empty-region.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/issue-55608-captures-empty-region.rs:6:16 - | -LL | fn server() -> impl FilterBase2 { - | ^^^^^^^^^^^^^^^^ - | - = note: hidden type `Map2<[closure@$DIR/issue-55608-captures-empty-region.rs:7:36: 7:41]>` captures an empty lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/impl-trait/issue-57464-unexpected-regions.rs b/src/test/ui/impl-trait/issue-57464-unexpected-regions.rs new file mode 100644 index 0000000000000..29e271c68ec90 --- /dev/null +++ b/src/test/ui/impl-trait/issue-57464-unexpected-regions.rs @@ -0,0 +1,22 @@ +// Regression test for issue 57464. +// +// Closure are (surprisingly) allowed to outlive their signature. As such it +// was possible to end up with `ReScope`s appearing in the concrete type of an +// opaque type. As all regions are now required to outlive the bound in an +// opaque type we avoid the issue here. + +// compile-pass + +struct A(F); + +unsafe impl <'a, 'b, F: Fn(&'a i32) -> &'b i32> Send for A {} + +fn wrapped_closure() -> impl Sized { + let f = |x| x; + f(&0); + A(f) +} + +fn main() { + let x: Box = Box::new(wrapped_closure()); +} diff --git a/src/test/ui/indexing-requires-a-uint.stderr b/src/test/ui/indexing-requires-a-uint.stderr index 9dafe1c24f1c2..3300db58d44c3 100644 --- a/src/test/ui/indexing-requires-a-uint.stderr +++ b/src/test/ui/indexing-requires-a-uint.stderr @@ -12,7 +12,7 @@ error[E0308]: mismatched types | LL | bar::(i); // i should not be re-coerced back to an isize | ^ expected isize, found usize -help: you can convert an `usize` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `isize` and panic if the converted value wouldn't fit | LL | bar::(i.try_into().unwrap()); // i should not be re-coerced back to an isize | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/integer-literal-suffix-inference.stderr b/src/test/ui/integer-literal-suffix-inference.stderr index b5b3f27f0e6cd..80b601dc4394b 100644 --- a/src/test/ui/integer-literal-suffix-inference.stderr +++ b/src/test/ui/integer-literal-suffix-inference.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | id_i8(a16); | ^^^ expected i8, found i16 -help: you can convert an `i16` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(a16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ error[E0308]: mismatched types | LL | id_i8(a32); | ^^^ expected i8, found i32 -help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(a32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ error[E0308]: mismatched types | LL | id_i8(a64); | ^^^ expected i8, found i64 -help: you can convert an `i64` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(a64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ error[E0308]: mismatched types | LL | id_i16(a32); | ^^^ expected i16, found i32 -help: you can convert an `i32` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i16` and panic if the converted value wouldn't fit | LL | id_i16(a32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ error[E0308]: mismatched types | LL | id_i16(a64); | ^^^ expected i16, found i64 -help: you can convert an `i64` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i16` and panic if the converted value wouldn't fit | LL | id_i16(a64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ error[E0308]: mismatched types | LL | id_i32(a64); | ^^^ expected i32, found i64 -help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit | LL | id_i32(a64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -117,7 +117,7 @@ error[E0308]: mismatched types | LL | id_i8(c16); | ^^^ expected i8, found i16 -help: you can convert an `i16` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(c16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ error[E0308]: mismatched types | LL | id_i8(c32); | ^^^ expected i8, found i32 -help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(c32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -137,7 +137,7 @@ error[E0308]: mismatched types | LL | id_i8(c64); | ^^^ expected i8, found i64 -help: you can convert an `i64` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i8` and panic if the converted value wouldn't fit | LL | id_i8(c64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -156,7 +156,7 @@ error[E0308]: mismatched types | LL | id_i16(c32); | ^^^ expected i16, found i32 -help: you can convert an `i32` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i16` and panic if the converted value wouldn't fit | LL | id_i16(c32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ error[E0308]: mismatched types | LL | id_i16(c64); | ^^^ expected i16, found i64 -help: you can convert an `i64` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i16` and panic if the converted value wouldn't fit | LL | id_i16(c64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -194,7 +194,7 @@ error[E0308]: mismatched types | LL | id_i32(c64); | ^^^ expected i32, found i64 -help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit | LL | id_i32(c64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -231,7 +231,7 @@ error[E0308]: mismatched types | LL | id_u8(b16); | ^^^ expected u8, found u16 -help: you can convert an `u16` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `u8` and panic if the converted value wouldn't fit | LL | id_u8(b16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,7 +241,7 @@ error[E0308]: mismatched types | LL | id_u8(b32); | ^^^ expected u8, found u32 -help: you can convert an `u32` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `u8` and panic if the converted value wouldn't fit | LL | id_u8(b32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -251,7 +251,7 @@ error[E0308]: mismatched types | LL | id_u8(b64); | ^^^ expected u8, found u64 -help: you can convert an `u64` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u8` and panic if the converted value wouldn't fit | LL | id_u8(b64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -270,7 +270,7 @@ error[E0308]: mismatched types | LL | id_u16(b32); | ^^^ expected u16, found u32 -help: you can convert an `u32` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `u16` and panic if the converted value wouldn't fit | LL | id_u16(b32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -280,7 +280,7 @@ error[E0308]: mismatched types | LL | id_u16(b64); | ^^^ expected u16, found u64 -help: you can convert an `u64` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u16` and panic if the converted value wouldn't fit | LL | id_u16(b64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -308,7 +308,7 @@ error[E0308]: mismatched types | LL | id_u32(b64); | ^^^ expected u32, found u64 -help: you can convert an `u64` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u32` and panic if the converted value wouldn't fit | LL | id_u32(b64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-13359.stderr b/src/test/ui/issues/issue-13359.stderr index b16b7a5b2cf04..7cfd754f72d8e 100644 --- a/src/test/ui/issues/issue-13359.stderr +++ b/src/test/ui/issues/issue-13359.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | foo(1*(1 as isize)); | ^^^^^^^^^^^^^^ expected i16, found isize -help: you can convert an `isize` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `i16` and panic if the converted value wouldn't fit | LL | foo((1*(1 as isize)).try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ error[E0308]: mismatched types | LL | bar(1*(1 as usize)); | ^^^^^^^^^^^^^^ expected u32, found usize -help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u32` and panic if the converted value wouldn't fit | LL | bar((1*(1 as usize)).try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-31910.stderr b/src/test/ui/issues/issue-31910.stderr index 8dd9287ffec79..e7555b958a3d4 100644 --- a/src/test/ui/issues/issue-31910.stderr +++ b/src/test/ui/issues/issue-31910.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | X = Trait::Number, | ^^^^^^^^^^^^^ expected isize, found i32 -help: you can convert an `i32` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `isize` and panic if the converted value wouldn't fit | LL | X = Trait::Number.try_into().unwrap(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-49556.rs b/src/test/ui/issues/issue-49556.rs index b8fcc645a59d3..46d9e749aae23 100644 --- a/src/test/ui/issues/issue-49556.rs +++ b/src/test/ui/issues/issue-49556.rs @@ -2,10 +2,10 @@ fn iter<'a>(data: &'a [usize]) -> impl Iterator + 'a { data.iter() .map( - |x| x // fn(&'a usize) -> &'(ReScope) usize + |x| x // fn(&'a usize) -> &'a usize ) .map( - |x| *x // fn(&'(ReScope) usize) -> usize + |x| *x // fn(&'a usize) -> usize ) } diff --git a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr index be701b2bb3973..063a4865b1987 100644 --- a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr +++ b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr @@ -11,7 +11,7 @@ error[E0308]: mismatched types | LL | let y: usize = x.foo(); | ^^^^^^^ expected usize, found isize -help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit | LL | let y: usize = x.foo().try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/mismatched_types/issue-26480.stderr b/src/test/ui/mismatched_types/issue-26480.stderr index 1a81df8e2c464..881d9fd32029e 100644 --- a/src/test/ui/mismatched_types/issue-26480.stderr +++ b/src/test/ui/mismatched_types/issue-26480.stderr @@ -6,7 +6,7 @@ LL | $arr.len() * size_of($arr[0])); ... LL | write!(hello); | -------------- in this macro invocation -help: you can convert an `usize` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u64` and panic if the converted value wouldn't fit | LL | ($arr.len() * size_of($arr[0])).try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/numeric/const-scope.stderr b/src/test/ui/numeric/const-scope.stderr index ead3a79da0270..3f69bcc7d4a2f 100644 --- a/src/test/ui/numeric/const-scope.stderr +++ b/src/test/ui/numeric/const-scope.stderr @@ -37,7 +37,7 @@ error[E0308]: mismatched types | LL | let d: i8 = c; | ^ expected i8, found i32 -help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit | LL | let d: i8 = c.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/numeric/len.stderr b/src/test/ui/numeric/len.stderr index 5a9349b4c0f29..c767bdd9bd5a5 100644 --- a/src/test/ui/numeric/len.stderr +++ b/src/test/ui/numeric/len.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | test(array.len()); | ^^^^^^^^^^^ expected u32, found usize -help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u32` and panic if the converted value wouldn't fit | LL | test(array.len().try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/numeric/numeric-cast-2.stderr b/src/test/ui/numeric/numeric-cast-2.stderr index be4411e630bec..f58389ce96c3b 100644 --- a/src/test/ui/numeric/numeric-cast-2.stderr +++ b/src/test/ui/numeric/numeric-cast-2.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | let x: u16 = foo(); | ^^^^^ expected u16, found i32 -help: you can convert an `i32` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u16` and panic if the converted value wouldn't fit | LL | let x: u16 = foo().try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ error[E0308]: mismatched types | LL | let y: i64 = x + x; | ^^^^^ expected i64, found u16 -help: you can convert an `u16` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i64` and panic if the converted value wouldn't fit | LL | let y: i64 = (x + x).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ error[E0308]: mismatched types | LL | let z: i32 = x + x; | ^^^^^ expected i32, found u16 -help: you can convert an `u16` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i32` and panic if the converted value wouldn't fit | LL | let z: i32 = (x + x).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/numeric/numeric-cast.stderr b/src/test/ui/numeric/numeric-cast.stderr index 9e7dcf7e41b55..e66b83f2b39f5 100644 --- a/src/test/ui/numeric/numeric-cast.stderr +++ b/src/test/ui/numeric/numeric-cast.stderr @@ -3,7 +3,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected usize, found u64 -help: you can convert an `u64` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected usize, found u32 -help: you can convert an `u32` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected usize, found u16 -help: you can convert an `u16` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected usize, found u8 -help: you can convert an `u8` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected usize, found isize -help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected usize, found i64 -help: you can convert an `i64` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +63,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected usize, found i32 -help: you can convert an `i32` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected usize, found i16 -help: you can convert an `i16` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected usize, found i8 -help: you can convert an `i8` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `usize` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -93,7 +93,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected isize, found usize -help: you can convert an `usize` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -103,7 +103,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected isize, found u64 -help: you can convert an `u64` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected isize, found u32 -help: you can convert an `u32` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,7 +123,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected isize, found u16 -help: you can convert an `u16` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected isize, found u8 -help: you can convert an `u8` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -143,7 +143,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected isize, found i64 -help: you can convert an `i64` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -153,7 +153,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected isize, found i32 -help: you can convert an `i32` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -163,7 +163,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected isize, found i16 -help: you can convert an `i16` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -173,7 +173,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected isize, found i8 -help: you can convert an `i8` to `isize` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `isize` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -183,7 +183,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected u64, found usize -help: you can convert an `usize` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -220,7 +220,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected u64, found isize -help: you can convert an `isize` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -230,7 +230,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected u64, found i64 -help: you can convert an `i64` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -240,7 +240,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected u64, found i32 -help: you can convert an `i32` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -250,7 +250,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected u64, found i16 -help: you can convert an `i16` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -260,7 +260,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected u64, found i8 -help: you can convert an `i8` to `u64` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `u64` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -270,7 +270,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected i64, found usize -help: you can convert an `usize` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -280,7 +280,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected i64, found u64 -help: you can convert an `u64` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -290,7 +290,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected i64, found u32 -help: you can convert an `u32` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -300,7 +300,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected i64, found u16 -help: you can convert an `u16` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -310,7 +310,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected i64, found u8 -help: you can convert an `u8` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -320,7 +320,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected i64, found isize -help: you can convert an `isize` to `i64` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `i64` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -357,7 +357,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected u32, found usize -help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -367,7 +367,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected u32, found u64 -help: you can convert an `u64` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -395,7 +395,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected u32, found isize -help: you can convert an `isize` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected u32, found i64 -help: you can convert an `i64` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -415,7 +415,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected u32, found i32 -help: you can convert an `i32` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -425,7 +425,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected u32, found i16 -help: you can convert an `i16` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -435,7 +435,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected u32, found i8 -help: you can convert an `i8` to `u32` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `u32` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -445,7 +445,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected i32, found usize -help: you can convert an `usize` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -455,7 +455,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected i32, found u64 -help: you can convert an `u64` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -465,7 +465,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected i32, found u32 -help: you can convert an `u32` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -475,7 +475,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected i32, found u16 -help: you can convert an `u16` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -485,7 +485,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected i32, found u8 -help: you can convert an `u8` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -495,7 +495,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected i32, found isize -help: you can convert an `isize` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -505,7 +505,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected i32, found i64 -help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -533,7 +533,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected u16, found usize -help: you can convert an `usize` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -543,7 +543,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected u16, found u64 -help: you can convert an `u64` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -553,7 +553,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected u16, found u32 -help: you can convert an `u32` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -572,7 +572,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected u16, found isize -help: you can convert an `isize` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -582,7 +582,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected u16, found i64 -help: you can convert an `i64` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -592,7 +592,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected u16, found i32 -help: you can convert an `i32` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -602,7 +602,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected u16, found i16 -help: you can convert an `i16` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -612,7 +612,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected u16, found i8 -help: you can convert an `i8` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `u16` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -622,7 +622,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected i16, found usize -help: you can convert an `usize` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -632,7 +632,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected i16, found u64 -help: you can convert an `u64` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -642,7 +642,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected i16, found u32 -help: you can convert an `u32` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -652,7 +652,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected i16, found u16 -help: you can convert an `u16` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -662,7 +662,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected i16, found u8 -help: you can convert an `u8` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -672,7 +672,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected i16, found isize -help: you can convert an `isize` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -682,7 +682,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected i16, found i64 -help: you can convert an `i64` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -692,7 +692,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected i16, found i32 -help: you can convert an `i32` to `i16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i16` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -711,7 +711,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected u8, found usize -help: you can convert an `usize` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -721,7 +721,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected u8, found u64 -help: you can convert an `u64` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -731,7 +731,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected u8, found u32 -help: you can convert an `u32` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -741,7 +741,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected u8, found u16 -help: you can convert an `u16` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -751,7 +751,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected u8, found isize -help: you can convert an `isize` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -761,7 +761,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected u8, found i64 -help: you can convert an `i64` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -771,7 +771,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected u8, found i32 -help: you can convert an `i32` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -781,7 +781,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected u8, found i16 -help: you can convert an `i16` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -791,7 +791,7 @@ error[E0308]: mismatched types | LL | foo::(x_i8); | ^^^^ expected u8, found i8 -help: you can convert an `i8` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `i8` to `u8` and panic if the converted value wouldn't fit | LL | foo::(x_i8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -801,7 +801,7 @@ error[E0308]: mismatched types | LL | foo::(x_usize); | ^^^^^^^ expected i8, found usize -help: you can convert an `usize` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `usize` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_usize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -811,7 +811,7 @@ error[E0308]: mismatched types | LL | foo::(x_u64); | ^^^^^ expected i8, found u64 -help: you can convert an `u64` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `u64` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_u64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -821,7 +821,7 @@ error[E0308]: mismatched types | LL | foo::(x_u32); | ^^^^^ expected i8, found u32 -help: you can convert an `u32` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `u32` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_u32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -831,7 +831,7 @@ error[E0308]: mismatched types | LL | foo::(x_u16); | ^^^^^ expected i8, found u16 -help: you can convert an `u16` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `u16` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_u16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -841,7 +841,7 @@ error[E0308]: mismatched types | LL | foo::(x_u8); | ^^^^ expected i8, found u8 -help: you can convert an `u8` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `u8` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_u8.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -851,7 +851,7 @@ error[E0308]: mismatched types | LL | foo::(x_isize); | ^^^^^^^ expected i8, found isize -help: you can convert an `isize` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_isize.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -861,7 +861,7 @@ error[E0308]: mismatched types | LL | foo::(x_i64); | ^^^^^ expected i8, found i64 -help: you can convert an `i64` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_i64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -871,7 +871,7 @@ error[E0308]: mismatched types | LL | foo::(x_i32); | ^^^^^ expected i8, found i32 -help: you can convert an `i32` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_i32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -881,7 +881,7 @@ error[E0308]: mismatched types | LL | foo::(x_i16); | ^^^^^ expected i8, found i16 -help: you can convert an `i16` to `i8` or panic if it the converted value wouldn't fit +help: you can convert an `i16` to `i8` and panic if the converted value wouldn't fit | LL | foo::(x_i16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/pub/pub-restricted.rs b/src/test/ui/pub/pub-restricted.rs index 8793cb9d3357f..b4bc4a08c7b6d 100644 --- a/src/test/ui/pub/pub-restricted.rs +++ b/src/test/ui/pub/pub-restricted.rs @@ -4,6 +4,8 @@ mod a {} pub (a) fn afn() {} //~ incorrect visibility restriction pub (b) fn bfn() {} //~ incorrect visibility restriction +pub (crate::a) fn cfn() {} //~ incorrect visibility restriction + pub fn privfn() {} mod x { mod y { diff --git a/src/test/ui/pub/pub-restricted.stderr b/src/test/ui/pub/pub-restricted.stderr index 7eeefa9550543..596264ba16b42 100644 --- a/src/test/ui/pub/pub-restricted.stderr +++ b/src/test/ui/pub/pub-restricted.stderr @@ -21,7 +21,18 @@ LL | pub (b) fn bfn() {} `pub(in path::to::module)`: visible only on the specified path error[E0704]: incorrect visibility restriction - --> $DIR/pub-restricted.rs:22:14 + --> $DIR/pub-restricted.rs:7:6 + | +LL | pub (crate::a) fn cfn() {} + | ^^^^^^^^ help: make this visible only to module `crate::a` with `in`: `in crate::a` + | + = help: some possible visibility restrictions are: + `pub(crate)`: visible only on the current crate + `pub(super)`: visible only in the current module's parent + `pub(in path::to::module)`: visible only on the specified path + +error[E0704]: incorrect visibility restriction + --> $DIR/pub-restricted.rs:24:14 | LL | pub (a) invalid: usize, | ^ help: make this visible only to module `a` with `in`: `in a` @@ -32,7 +43,7 @@ LL | pub (a) invalid: usize, `pub(in path::to::module)`: visible only on the specified path error[E0704]: incorrect visibility restriction - --> $DIR/pub-restricted.rs:31:6 + --> $DIR/pub-restricted.rs:33:6 | LL | pub (xyz) fn xyz() {} | ^^^ help: make this visible only to module `xyz` with `in`: `in xyz` @@ -43,11 +54,11 @@ LL | pub (xyz) fn xyz() {} `pub(in path::to::module)`: visible only on the specified path error: visibilities can only be restricted to ancestor modules - --> $DIR/pub-restricted.rs:23:17 + --> $DIR/pub-restricted.rs:25:17 | LL | pub (in x) non_parent_invalid: usize, | ^ -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0704`. diff --git a/src/test/ui/repeat_count.stderr b/src/test/ui/repeat_count.stderr index 6772aa1c38d2c..df73ac0b182f0 100644 --- a/src/test/ui/repeat_count.stderr +++ b/src/test/ui/repeat_count.stderr @@ -42,7 +42,7 @@ error[E0308]: mismatched types | LL | let f = [0; -4_isize]; | ^^^^^^^^ expected usize, found isize -help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit | LL | let f = [0; (-4_isize).try_into().unwrap()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ error[E0308]: mismatched types | LL | let f = [0_usize; -1_isize]; | ^^^^^^^^ expected usize, found isize -help: you can convert an `isize` to `usize` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit | LL | let f = [0_usize; (-1_isize).try_into().unwrap()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/shift-various-bad-types.stderr b/src/test/ui/shift-various-bad-types.stderr index 97523fe82cd4e..409fabb951adc 100644 --- a/src/test/ui/shift-various-bad-types.stderr +++ b/src/test/ui/shift-various-bad-types.stderr @@ -27,7 +27,7 @@ error[E0308]: mismatched types | LL | let _: i32 = 22_i64 >> 1_i32; | ^^^^^^^^^^^^^^^ expected i32, found i64 -help: you can convert an `i64` to `i32` or panic if it the converted value wouldn't fit +help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit | LL | let _: i32 = (22_i64 >> 1_i32).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection-error.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection-error.stderr index 9acd63c2c25f1..e9c28248044f9 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection-error.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection-error.stderr @@ -6,7 +6,7 @@ LL | fn global_bound_is_hidden() -> u8 ... LL | B::get_x() | ^^^^^^^^^^ expected u8, found i32 -help: you can convert an `i32` to `u8` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u8` and panic if the converted value wouldn't fit | LL | B::get_x().try_into().unwrap() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/tutorial-suffix-inference-test.stderr b/src/test/ui/tutorial-suffix-inference-test.stderr index f51f2defd4759..f3e1cc41cada2 100644 --- a/src/test/ui/tutorial-suffix-inference-test.stderr +++ b/src/test/ui/tutorial-suffix-inference-test.stderr @@ -12,7 +12,7 @@ error[E0308]: mismatched types | LL | identity_u16(y); | ^ expected u16, found i32 -help: you can convert an `i32` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `i32` to `u16` and panic if the converted value wouldn't fit | LL | identity_u16(y.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ error[E0308]: mismatched types | LL | identity_u16(a); | ^ expected u16, found isize -help: you can convert an `isize` to `u16` or panic if it the converted value wouldn't fit +help: you can convert an `isize` to `u16` and panic if the converted value wouldn't fit | LL | identity_u16(a.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^