diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 1e5fe125c550d..86e09b7be2d2d 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1827,7 +1827,13 @@ impl<'a> Extend> for String { } } -/// A convenience impl that delegates to the impl for `&str` +/// A convenience impl that delegates to the impl for `&str`. +/// +/// # Examples +/// +/// ``` +/// assert_eq!(String::from("Hello world").find("world"), Some(6)); +/// ``` #[unstable( feature = "pattern", reason = "API not fully fleshed out and ready to be stabilized", diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 30fd55f7b7f64..708e4e5560ecd 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -451,7 +451,13 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> { impl<'a> DoubleEndedSearcher<'a> for CharSearcher<'a> {} -/// Searches for chars that are equal to a given char +/// Searches for chars that are equal to a given `char`. +/// +/// # Examples +/// +/// ``` +/// assert_eq!("Hello world".find('o'), Some(4)); +/// ``` impl<'a> Pattern<'a> for char { type Searcher = CharSearcher<'a>; @@ -696,7 +702,14 @@ unsafe impl<'a, 'b> ReverseSearcher<'a> for CharSliceSearcher<'a, 'b> { impl<'a, 'b> DoubleEndedSearcher<'a> for CharSliceSearcher<'a, 'b> {} -/// Searches for chars that are equal to any of the chars in the array +/// Searches for chars that are equal to any of the chars in the array. +/// +/// # Examples +/// +/// ``` +/// assert_eq!("Hello world".find(&['l', 'l'] as &[_]), Some(2)); +/// assert_eq!("Hello world".find(&['l', 'l'][..]), Some(2)); +/// ``` impl<'a, 'b> Pattern<'a> for &'b [char] { pattern_methods!(CharSliceSearcher<'a, 'b>, MultiCharEqPattern, CharSliceSearcher); } @@ -738,7 +751,14 @@ where impl<'a, F> DoubleEndedSearcher<'a> for CharPredicateSearcher<'a, F> where F: FnMut(char) -> bool {} -/// Searches for chars that match the given predicate +/// Searches for chars that match the given predicate. +/// +/// # Examples +/// +/// ``` +/// assert_eq!("Hello world".find(char::is_uppercase), Some(0)); +/// assert_eq!("Hello world".find(|c| "aeiou".contains(c)), Some(1)); +/// ``` impl<'a, F> Pattern<'a> for F where F: FnMut(char) -> bool, @@ -763,6 +783,12 @@ impl<'a, 'b, 'c> Pattern<'a> for &'c &'b str { /// /// Will handle the pattern `""` as returning empty matches at each character /// boundary. +/// +/// # Examples +/// +/// ``` +/// assert_eq!("Hello world".find("world"), Some(6)); +/// ``` impl<'a, 'b> Pattern<'a> for &'b str { type Searcher = StrSearcher<'a, 'b>; @@ -771,7 +797,7 @@ impl<'a, 'b> Pattern<'a> for &'b str { StrSearcher::new(haystack, self) } - /// Checks whether the pattern matches at the front of the haystack + /// Checks whether the pattern matches at the front of the haystack. #[inline] fn is_prefix_of(self, haystack: &'a str) -> bool { haystack.as_bytes().starts_with(self.as_bytes()) @@ -788,7 +814,7 @@ impl<'a, 'b> Pattern<'a> for &'b str { } } - /// Checks whether the pattern matches at the back of the haystack + /// Checks whether the pattern matches at the back of the haystack. #[inline] fn is_suffix_of(self, haystack: &'a str) -> bool { haystack.as_bytes().ends_with(self.as_bytes()) diff --git a/src/librustc_mir/const_eval/machine.rs b/src/librustc_mir/const_eval/machine.rs index e926347147894..3f9aa9ed02d2a 100644 --- a/src/librustc_mir/const_eval/machine.rs +++ b/src/librustc_mir/const_eval/machine.rs @@ -179,9 +179,12 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter { const GLOBAL_KIND: Option = None; // no copying of globals from `tcx` to machine memory - // We do not check for alignment to avoid having to carry an `Align` - // in `ConstValue::ByRef`. - const CHECK_ALIGN: bool = false; + #[inline(always)] + fn enforce_alignment(_memory_extra: &Self::MemoryExtra) -> bool { + // We do not check for alignment to avoid having to carry an `Align` + // in `ConstValue::ByRef`. + false + } #[inline(always)] fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool { diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index fd67b088c93cf..dd3803eb96255 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -118,7 +118,7 @@ pub trait Machine<'mir, 'tcx>: Sized { const GLOBAL_KIND: Option; /// Whether memory accesses should be alignment-checked. - const CHECK_ALIGN: bool; + fn enforce_alignment(memory_extra: &Self::MemoryExtra) -> bool; /// Whether to enforce the validity invariant fn enforce_validity(ecx: &InterpCx<'mir, 'tcx, Self>) -> bool; diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 539537e9de80c..bcad7855c3736 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -323,12 +323,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { size: Size, align: Align, ) -> InterpResult<'tcx, Option>> { - let align = M::CHECK_ALIGN.then_some(align); + let align = M::enforce_alignment(&self.extra).then_some(align); self.check_ptr_access_align(sptr, size, align, CheckInAllocMsg::MemoryAccessTest) } /// Like `check_ptr_access`, but *definitely* checks alignment when `align` - /// is `Some` (overriding `M::CHECK_ALIGN`). Also lets the caller control + /// is `Some` (overriding `M::enforce_alignment`). Also lets the caller control /// the error message for the out-of-bounds case. pub fn check_ptr_access_align( &self, diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 5a00f206a7646..9a6d5ab34a5ac 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -173,7 +173,10 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine { const GLOBAL_KIND: Option = None; // no copying of globals from `tcx` to machine memory - const CHECK_ALIGN: bool = false; + #[inline(always)] + fn enforce_alignment(_memory_extra: &Self::MemoryExtra) -> bool { + false + } #[inline(always)] fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool { diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 369bb183bcd73..2f890d4dabb5b 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -753,8 +753,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match (&expected_ty.kind, &checked_ty.kind) { (&ty::Int(ref exp), &ty::Int(ref found)) => { - let is_fallible = match (found.bit_width(), exp.bit_width()) { - (Some(found), Some(exp)) if found > exp => true, + let is_fallible = match (exp.bit_width(), found.bit_width()) { + (Some(exp), Some(found)) if exp < found => true, + (None, Some(8 | 16)) => false, (None, _) | (_, None) => true, _ => false, }; @@ -762,8 +763,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { true } (&ty::Uint(ref exp), &ty::Uint(ref found)) => { - let is_fallible = match (found.bit_width(), exp.bit_width()) { - (Some(found), Some(exp)) if found > exp => true, + let is_fallible = match (exp.bit_width(), found.bit_width()) { + (Some(exp), Some(found)) if exp < found => true, + (None, Some(8 | 16)) => false, (None, _) | (_, None) => true, _ => false, }; diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 210ba92e8117b..3f81689cdc90f 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -209,7 +209,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { "impl {:?} is not an inherent impl", impl_def_id ); - self.impl_self_ty(self.span, impl_def_id).substs + self.fresh_substs_for_item(self.span, impl_def_id) } probe::ObjectPick => { diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 7e7d84c199676..fb1cde855657b 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -1128,8 +1128,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { ) -> Option> { let tcx = self.tcx; - // In general, during probing we erase regions. See - // `impl_self_ty()` for an explanation. + // In general, during probing we erase regions. let region = tcx.lifetimes.re_erased; let autoref_ty = tcx.mk_ref(region, ty::TypeAndMut { ty: self_ty, mutbl }); @@ -1614,8 +1613,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { } else { match param.kind { GenericParamDefKind::Lifetime => { - // In general, during probe we erase regions. See - // `impl_self_ty()` for an explanation. + // In general, during probe we erase regions. self.tcx.lifetimes.re_erased.into() } GenericParamDefKind::Type { .. } | GenericParamDefKind::Const => { diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index f075d1e74d455..6e33acf9afccb 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -117,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .span_if_local(item.def_id) .or_else(|| self.tcx.hir().span_if_local(impl_did)); - let impl_ty = self.impl_self_ty(span, impl_did).ty; + let impl_ty = self.tcx.at(span).type_of(impl_did); let insertion = match self.tcx.impl_trait_ref(impl_did) { None => String::new(), @@ -537,7 +537,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // When the "method" is resolved through dereferencing, we really want the // original type that has the associated function for accurate suggestions. // (#61411) - let ty = self.impl_self_ty(span, *impl_did).ty; + let ty = tcx.at(span).type_of(*impl_did); match (&ty.peel_refs().kind, &actual.peel_refs().kind) { (ty::Adt(def, _), ty::Adt(def_actual, _)) if def == def_actual => { // Use `actual` as it will have more `substs` filled in. diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 4b5953b5e958c..3aea6b2815fe4 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -154,7 +154,6 @@ use std::slice; use crate::require_c_abi_if_c_variadic; use crate::util::common::indenter; -use crate::TypeAndSubsts; use self::autoderef::Autoderef; use self::callee::DeferredCallResolution; @@ -4251,24 +4250,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - // Determine the `Self` type, using fresh variables for all variables - // declared on the impl declaration e.g., `impl for Vec<(A,B)>` - // would return `($0, $1)` where `$0` and `$1` are freshly instantiated type - // variables. - pub fn impl_self_ty( - &self, - span: Span, // (potential) receiver for this impl - did: DefId, - ) -> TypeAndSubsts<'tcx> { - let ity = self.tcx.type_of(did); - debug!("impl_self_ty: ity={:?}", ity); - - let substs = self.fresh_substs_for_item(span, did); - let substd_ty = self.instantiate_type_scheme(span, &substs, &ity); - - TypeAndSubsts { substs, ty: substd_ty } - } - /// Unifies the output type with the expected type early, for more coercions /// and forward type information on the input expressions. fn expected_inputs_for_expected_output( diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 69d0b3723b0ad..df8290fd018c5 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -97,7 +97,6 @@ use rustc_infer::infer::{InferOk, TyCtxtInferExt}; use rustc_infer::traits::TraitEngineExt as _; use rustc_middle::middle; use rustc_middle::ty::query::Providers; -use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::util; use rustc_session::config::EntryFnType; @@ -111,10 +110,6 @@ use rustc_trait_selection::traits::{ use std::iter; use astconv::{AstConv, Bounds}; -pub struct TypeAndSubsts<'tcx> { - substs: SubstsRef<'tcx>, - ty: Ty<'tcx>, -} fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) { if decl.c_variadic && !(abi == Abi::C || abi == Abi::Cdecl) { diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index d091cc0c0965b..ab52475172333 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -184,6 +184,25 @@ nav.sub { overflow: auto; } +/* Improve the scrollbar display on firefox */ +* { + scrollbar-width: initial; +} +.sidebar { + scrollbar-width: thin; +} + +/* Improve the scrollbar display on webkit-based browsers */ +::-webkit-scrollbar { + width: 12px; +} +.sidebar::-webkit-scrollbar { + width: 8px; +} +::-webkit-scrollbar-track { + -webkit-box-shadow: inset 0; +} + .sidebar .block > ul > li { margin-right: -10px; } diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index ff32a0fa09e4d..a2986c7b927e2 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -32,6 +32,28 @@ pre { background-color: #505050; } +/* Improve the scrollbar display on firefox */ +* { + scrollbar-color: rgb(64, 65, 67) #717171; +} +.sidebar { + scrollbar-color: rgba(32,34,37,.6) transparent; +} + +/* Improve the scrollbar display on webkit-based browsers */ +::-webkit-scrollbar-track { + background-color: #717171; +} +::-webkit-scrollbar-thumb { + background-color: rgba(32, 34, 37, .6); +} +.sidebar::-webkit-scrollbar-track { + background-color: #717171; +} +.sidebar::-webkit-scrollbar-thumb { + background-color: rgba(32, 34, 37, .6); +} + .sidebar .current { background-color: #333; } diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index 2b2819f7126b4..be173d8eb46d3 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -34,6 +34,29 @@ pre { background-color: #F1F1F1; } +/* Improve the scrollbar display on firefox */ +* { + scrollbar-color: rgba(36, 37, 39, 0.6) #e6e6e6; +} + +.sidebar { + scrollbar-color: rgba(36, 37, 39, 0.6) #d9d9d9; +} + +/* Improve the scrollbar display on webkit-based browsers */ +::-webkit-scrollbar-track { + background-color: #ecebeb; +} +::-webkit-scrollbar-thumb { + background-color: rgba(36, 37, 39, 0.6); +} +.sidebar::-webkit-scrollbar-track { + background-color: #dcdcdc; +} +.sidebar::-webkit-scrollbar-thumb { + background-color: rgba(36, 37, 39, 0.6); +} + .sidebar .current { background-color: #fff; } diff --git a/src/test/ui/integer-literal-suffix-inference.rs b/src/test/ui/integer-literal-suffix-inference.rs index 3f4bedc4c2224..c320f2bb7b446 100644 --- a/src/test/ui/integer-literal-suffix-inference.rs +++ b/src/test/ui/integer-literal-suffix-inference.rs @@ -16,6 +16,7 @@ fn main() { fn id_i16(n: i16) -> i16 { n } fn id_i32(n: i32) -> i32 { n } fn id_i64(n: i64) -> i64 { n } + fn id_isize(n: isize) -> isize { n } // the smallest values that need these types let b8: u8 = 16; @@ -27,6 +28,11 @@ fn main() { fn id_u16(n: u16) -> u16 { n } fn id_u32(n: u32) -> u32 { n } fn id_u64(n: u64) -> u64 { n } + fn id_usize(n: usize) -> usize { n } + + // Values for testing *size + let asize: isize = 1; + let bsize: usize = 3; id_i8(a8); // ok id_i8(a16); @@ -38,6 +44,9 @@ fn main() { id_i8(a64); //~^ ERROR mismatched types //~| expected `i8`, found `i64` + id_i8(asize); + //~^ ERROR mismatched types + //~| expected `i8`, found `isize` id_i16(a8); //~^ ERROR mismatched types @@ -49,6 +58,9 @@ fn main() { id_i16(a64); //~^ ERROR mismatched types //~| expected `i16`, found `i64` + id_i16(asize); + //~^ ERROR mismatched types + //~| expected `i16`, found `isize` id_i32(a8); //~^ ERROR mismatched types @@ -60,6 +72,9 @@ fn main() { id_i32(a64); //~^ ERROR mismatched types //~| expected `i32`, found `i64` + id_i32(asize); + //~^ ERROR mismatched types + //~| expected `i32`, found `isize` id_i64(a8); //~^ ERROR mismatched types @@ -71,6 +86,23 @@ fn main() { //~^ ERROR mismatched types //~| expected `i64`, found `i32` id_i64(a64); // ok + id_i64(asize); + //~^ ERROR mismatched types + //~| expected `i64`, found `isize` + + id_isize(a8); + //~^ ERROR mismatched types + //~| expected `isize`, found `i8` + id_isize(a16); + //~^ ERROR mismatched types + //~| expected `isize`, found `i16` + id_isize(a32); + //~^ ERROR mismatched types + //~| expected `isize`, found `i32` + id_isize(a64); + //~^ ERROR mismatched types + //~| expected `isize`, found `i64` + id_isize(asize); //ok id_i8(c8); // ok id_i8(c16); @@ -126,6 +158,9 @@ fn main() { id_u8(b64); //~^ ERROR mismatched types //~| expected `u8`, found `u64` + id_u8(bsize); + //~^ ERROR mismatched types + //~| expected `u8`, found `usize` id_u16(b8); //~^ ERROR mismatched types @@ -137,6 +172,9 @@ fn main() { id_u16(b64); //~^ ERROR mismatched types //~| expected `u16`, found `u64` + id_u16(bsize); + //~^ ERROR mismatched types + //~| expected `u16`, found `usize` id_u32(b8); //~^ ERROR mismatched types @@ -148,6 +186,9 @@ fn main() { id_u32(b64); //~^ ERROR mismatched types //~| expected `u32`, found `u64` + id_u32(bsize); + //~^ ERROR mismatched types + //~| expected `u32`, found `usize` id_u64(b8); //~^ ERROR mismatched types @@ -159,4 +200,21 @@ fn main() { //~^ ERROR mismatched types //~| expected `u64`, found `u32` id_u64(b64); // ok + id_u64(bsize); + //~^ ERROR mismatched types + //~| expected `u64`, found `usize` + + id_usize(b8); + //~^ ERROR mismatched types + //~| expected `usize`, found `u8` + id_usize(b16); + //~^ ERROR mismatched types + //~| expected `usize`, found `u16` + id_usize(b32); + //~^ ERROR mismatched types + //~| expected `usize`, found `u32` + id_usize(b64); + //~^ ERROR mismatched types + //~| expected `usize`, found `u64` + id_usize(bsize); //ok } diff --git a/src/test/ui/integer-literal-suffix-inference.stderr b/src/test/ui/integer-literal-suffix-inference.stderr index a34f0645c6b97..b8502768e1d42 100644 --- a/src/test/ui/integer-literal-suffix-inference.stderr +++ b/src/test/ui/integer-literal-suffix-inference.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:32:11 + --> $DIR/integer-literal-suffix-inference.rs:38:11 | LL | id_i8(a16); | ^^^ expected `i8`, found `i16` @@ -10,7 +10,7 @@ LL | id_i8(a16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:35:11 + --> $DIR/integer-literal-suffix-inference.rs:41:11 | LL | id_i8(a32); | ^^^ expected `i8`, found `i32` @@ -21,7 +21,7 @@ LL | id_i8(a32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:38:11 + --> $DIR/integer-literal-suffix-inference.rs:44:11 | LL | id_i8(a64); | ^^^ expected `i8`, found `i64` @@ -32,7 +32,18 @@ LL | id_i8(a64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:42:12 + --> $DIR/integer-literal-suffix-inference.rs:47:11 + | +LL | id_i8(asize); + | ^^^^^ expected `i8`, found `isize` + | +help: you can convert an `isize` to `i8` and panic if the converted value wouldn't fit + | +LL | id_i8(asize.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:51:12 | LL | id_i16(a8); | ^^ @@ -41,7 +52,7 @@ LL | id_i16(a8); | help: you can convert an `i8` to `i16`: `a8.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:46:12 + --> $DIR/integer-literal-suffix-inference.rs:55:12 | LL | id_i16(a32); | ^^^ expected `i16`, found `i32` @@ -52,7 +63,7 @@ LL | id_i16(a32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:49:12 + --> $DIR/integer-literal-suffix-inference.rs:58:12 | LL | id_i16(a64); | ^^^ expected `i16`, found `i64` @@ -63,7 +74,18 @@ LL | id_i16(a64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:53:12 + --> $DIR/integer-literal-suffix-inference.rs:61:12 + | +LL | id_i16(asize); + | ^^^^^ expected `i16`, found `isize` + | +help: you can convert an `isize` to `i16` and panic if the converted value wouldn't fit + | +LL | id_i16(asize.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:65:12 | LL | id_i32(a8); | ^^ @@ -72,7 +94,7 @@ LL | id_i32(a8); | help: you can convert an `i8` to `i32`: `a8.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:56:12 + --> $DIR/integer-literal-suffix-inference.rs:68:12 | LL | id_i32(a16); | ^^^ @@ -81,7 +103,7 @@ LL | id_i32(a16); | help: you can convert an `i16` to `i32`: `a16.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:60:12 + --> $DIR/integer-literal-suffix-inference.rs:72:12 | LL | id_i32(a64); | ^^^ expected `i32`, found `i64` @@ -92,7 +114,18 @@ LL | id_i32(a64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:64:12 + --> $DIR/integer-literal-suffix-inference.rs:75:12 + | +LL | id_i32(asize); + | ^^^^^ expected `i32`, found `isize` + | +help: you can convert an `isize` to `i32` and panic if the converted value wouldn't fit + | +LL | id_i32(asize.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:79:12 | LL | id_i64(a8); | ^^ @@ -101,7 +134,7 @@ LL | id_i64(a8); | help: you can convert an `i8` to `i64`: `a8.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:67:12 + --> $DIR/integer-literal-suffix-inference.rs:82:12 | LL | id_i64(a16); | ^^^ @@ -110,7 +143,7 @@ LL | id_i64(a16); | help: you can convert an `i16` to `i64`: `a16.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:70:12 + --> $DIR/integer-literal-suffix-inference.rs:85:12 | LL | id_i64(a32); | ^^^ @@ -119,7 +152,58 @@ LL | id_i64(a32); | help: you can convert an `i32` to `i64`: `a32.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:76:11 + --> $DIR/integer-literal-suffix-inference.rs:89:12 + | +LL | id_i64(asize); + | ^^^^^ expected `i64`, found `isize` + | +help: you can convert an `isize` to `i64` and panic if the converted value wouldn't fit + | +LL | id_i64(asize.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:93:14 + | +LL | id_isize(a8); + | ^^ + | | + | expected `isize`, found `i8` + | help: you can convert an `i8` to `isize`: `a8.into()` + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:96:14 + | +LL | id_isize(a16); + | ^^^ + | | + | expected `isize`, found `i16` + | help: you can convert an `i16` to `isize`: `a16.into()` + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:99:14 + | +LL | id_isize(a32); + | ^^^ expected `isize`, found `i32` + | +help: you can convert an `i32` to `isize` and panic if the converted value wouldn't fit + | +LL | id_isize(a32.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:102:14 + | +LL | id_isize(a64); + | ^^^ expected `isize`, found `i64` + | +help: you can convert an `i64` to `isize` and panic if the converted value wouldn't fit + | +LL | id_isize(a64.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:108:11 | LL | id_i8(c16); | ^^^ expected `i8`, found `i16` @@ -130,7 +214,7 @@ LL | id_i8(c16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:79:11 + --> $DIR/integer-literal-suffix-inference.rs:111:11 | LL | id_i8(c32); | ^^^ expected `i8`, found `i32` @@ -141,7 +225,7 @@ LL | id_i8(c32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:82:11 + --> $DIR/integer-literal-suffix-inference.rs:114:11 | LL | id_i8(c64); | ^^^ expected `i8`, found `i64` @@ -152,7 +236,7 @@ LL | id_i8(c64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:86:12 + --> $DIR/integer-literal-suffix-inference.rs:118:12 | LL | id_i16(c8); | ^^ @@ -161,7 +245,7 @@ LL | id_i16(c8); | help: you can convert an `i8` to `i16`: `c8.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:90:12 + --> $DIR/integer-literal-suffix-inference.rs:122:12 | LL | id_i16(c32); | ^^^ expected `i16`, found `i32` @@ -172,7 +256,7 @@ LL | id_i16(c32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:93:12 + --> $DIR/integer-literal-suffix-inference.rs:125:12 | LL | id_i16(c64); | ^^^ expected `i16`, found `i64` @@ -183,7 +267,7 @@ LL | id_i16(c64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:97:12 + --> $DIR/integer-literal-suffix-inference.rs:129:12 | LL | id_i32(c8); | ^^ @@ -192,7 +276,7 @@ LL | id_i32(c8); | help: you can convert an `i8` to `i32`: `c8.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:100:12 + --> $DIR/integer-literal-suffix-inference.rs:132:12 | LL | id_i32(c16); | ^^^ @@ -201,7 +285,7 @@ LL | id_i32(c16); | help: you can convert an `i16` to `i32`: `c16.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:104:12 + --> $DIR/integer-literal-suffix-inference.rs:136:12 | LL | id_i32(c64); | ^^^ expected `i32`, found `i64` @@ -212,7 +296,7 @@ LL | id_i32(c64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:108:12 + --> $DIR/integer-literal-suffix-inference.rs:140:12 | LL | id_i64(a8); | ^^ @@ -221,7 +305,7 @@ LL | id_i64(a8); | help: you can convert an `i8` to `i64`: `a8.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:111:12 + --> $DIR/integer-literal-suffix-inference.rs:143:12 | LL | id_i64(a16); | ^^^ @@ -230,7 +314,7 @@ LL | id_i64(a16); | help: you can convert an `i16` to `i64`: `a16.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:114:12 + --> $DIR/integer-literal-suffix-inference.rs:146:12 | LL | id_i64(a32); | ^^^ @@ -239,7 +323,7 @@ LL | id_i64(a32); | help: you can convert an `i32` to `i64`: `a32.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:120:11 + --> $DIR/integer-literal-suffix-inference.rs:152:11 | LL | id_u8(b16); | ^^^ expected `u8`, found `u16` @@ -250,7 +334,7 @@ LL | id_u8(b16.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:123:11 + --> $DIR/integer-literal-suffix-inference.rs:155:11 | LL | id_u8(b32); | ^^^ expected `u8`, found `u32` @@ -261,7 +345,7 @@ LL | id_u8(b32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:126:11 + --> $DIR/integer-literal-suffix-inference.rs:158:11 | LL | id_u8(b64); | ^^^ expected `u8`, found `u64` @@ -272,7 +356,18 @@ LL | id_u8(b64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:130:12 + --> $DIR/integer-literal-suffix-inference.rs:161:11 + | +LL | id_u8(bsize); + | ^^^^^ expected `u8`, found `usize` + | +help: you can convert an `usize` to `u8` and panic if the converted value wouldn't fit + | +LL | id_u8(bsize.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:165:12 | LL | id_u16(b8); | ^^ @@ -281,7 +376,7 @@ LL | id_u16(b8); | help: you can convert an `u8` to `u16`: `b8.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:134:12 + --> $DIR/integer-literal-suffix-inference.rs:169:12 | LL | id_u16(b32); | ^^^ expected `u16`, found `u32` @@ -292,7 +387,7 @@ LL | id_u16(b32.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:137:12 + --> $DIR/integer-literal-suffix-inference.rs:172:12 | LL | id_u16(b64); | ^^^ expected `u16`, found `u64` @@ -303,7 +398,18 @@ LL | id_u16(b64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:141:12 + --> $DIR/integer-literal-suffix-inference.rs:175:12 + | +LL | id_u16(bsize); + | ^^^^^ expected `u16`, found `usize` + | +help: you can convert an `usize` to `u16` and panic if the converted value wouldn't fit + | +LL | id_u16(bsize.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:179:12 | LL | id_u32(b8); | ^^ @@ -312,7 +418,7 @@ LL | id_u32(b8); | help: you can convert an `u8` to `u32`: `b8.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:144:12 + --> $DIR/integer-literal-suffix-inference.rs:182:12 | LL | id_u32(b16); | ^^^ @@ -321,7 +427,7 @@ LL | id_u32(b16); | help: you can convert an `u16` to `u32`: `b16.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:148:12 + --> $DIR/integer-literal-suffix-inference.rs:186:12 | LL | id_u32(b64); | ^^^ expected `u32`, found `u64` @@ -332,7 +438,18 @@ LL | id_u32(b64.try_into().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:152:12 + --> $DIR/integer-literal-suffix-inference.rs:189:12 + | +LL | id_u32(bsize); + | ^^^^^ expected `u32`, found `usize` + | +help: you can convert an `usize` to `u32` and panic if the converted value wouldn't fit + | +LL | id_u32(bsize.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:193:12 | LL | id_u64(b8); | ^^ @@ -341,7 +458,7 @@ LL | id_u64(b8); | help: you can convert an `u8` to `u64`: `b8.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:155:12 + --> $DIR/integer-literal-suffix-inference.rs:196:12 | LL | id_u64(b16); | ^^^ @@ -350,7 +467,7 @@ LL | id_u64(b16); | help: you can convert an `u16` to `u64`: `b16.into()` error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:158:12 + --> $DIR/integer-literal-suffix-inference.rs:199:12 | LL | id_u64(b32); | ^^^ @@ -358,6 +475,57 @@ LL | id_u64(b32); | expected `u64`, found `u32` | help: you can convert an `u32` to `u64`: `b32.into()` -error: aborting due to 36 previous errors +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:203:12 + | +LL | id_u64(bsize); + | ^^^^^ expected `u64`, found `usize` + | +help: you can convert an `usize` to `u64` and panic if the converted value wouldn't fit + | +LL | id_u64(bsize.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:207:14 + | +LL | id_usize(b8); + | ^^ + | | + | expected `usize`, found `u8` + | help: you can convert an `u8` to `usize`: `b8.into()` + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:210:14 + | +LL | id_usize(b16); + | ^^^ + | | + | expected `usize`, found `u16` + | help: you can convert an `u16` to `usize`: `b16.into()` + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:213:14 + | +LL | id_usize(b32); + | ^^^ expected `usize`, found `u32` + | +help: you can convert an `u32` to `usize` and panic if the converted value wouldn't fit + | +LL | id_usize(b32.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:216:14 + | +LL | id_usize(b64); + | ^^^ expected `usize`, found `u64` + | +help: you can convert an `u64` to `usize` and panic if the converted value wouldn't fit + | +LL | id_usize(b64.try_into().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 52 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-18446.stderr b/src/test/ui/issues/issue-18446.stderr index 3422add9dd96b..40cb86e5716a0 100644 --- a/src/test/ui/issues/issue-18446.stderr +++ b/src/test/ui/issues/issue-18446.stderr @@ -7,7 +7,7 @@ LL | x.foo(); | | multiple `foo` found | help: disambiguate the method call for candidate #2: `T::foo(&x)` | -note: candidate #1 is defined in an impl for the type `dyn T` +note: candidate #1 is defined in an impl for the type `(dyn T + 'a)` --> $DIR/issue-18446.rs:9:5 | LL | fn foo(&self) {} diff --git a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr index e7f295df8c482..f6820be7e7709 100644 --- a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr +++ b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr @@ -20,12 +20,12 @@ error[E0034]: multiple applicable items in scope LL | let z = x.foo(); | ^^^ multiple `foo` found | -note: candidate #1 is defined in an impl of the trait `internal::X` for the type `_` +note: candidate #1 is defined in an impl of the trait `internal::X` for the type `T` --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:43:9 | LL | fn foo(self: Smaht) -> u64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: candidate #2 is defined in an impl of the trait `nuisance_foo::NuisanceFoo` for the type `_` +note: candidate #2 is defined in an impl of the trait `nuisance_foo::NuisanceFoo` for the type `T` --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:70:9 | LL | fn foo(self) {} diff --git a/src/test/ui/numeric/numeric-cast.fixed b/src/test/ui/numeric/numeric-cast.fixed index 6f78228a85d44..31acdb8faf6a2 100644 --- a/src/test/ui/numeric/numeric-cast.fixed +++ b/src/test/ui/numeric/numeric-cast.fixed @@ -24,9 +24,9 @@ fn main() { //~^ ERROR mismatched types foo::(x_u32.try_into().unwrap()); //~^ ERROR mismatched types - foo::(x_u16.try_into().unwrap()); + foo::(x_u16.into()); //~^ ERROR mismatched types - foo::(x_u8.try_into().unwrap()); + foo::(x_u8.into()); //~^ ERROR mismatched types foo::(x_isize.try_into().unwrap()); //~^ ERROR mismatched types @@ -56,9 +56,9 @@ fn main() { //~^ ERROR mismatched types foo::(x_i32.try_into().unwrap()); //~^ ERROR mismatched types - foo::(x_i16.try_into().unwrap()); + foo::(x_i16.into()); //~^ ERROR mismatched types - foo::(x_i8.try_into().unwrap()); + foo::(x_i8.into()); //~^ ERROR mismatched types // foo::(x_f64); // foo::(x_f32); diff --git a/src/test/ui/numeric/numeric-cast.stderr b/src/test/ui/numeric/numeric-cast.stderr index eef40cbdbe4e8..ff92a86c3a7b4 100644 --- a/src/test/ui/numeric/numeric-cast.stderr +++ b/src/test/ui/numeric/numeric-cast.stderr @@ -24,23 +24,19 @@ error[E0308]: mismatched types --> $DIR/numeric-cast.rs:27:18 | LL | foo::(x_u16); - | ^^^^^ expected `usize`, found `u16` - | -help: you can convert an `u16` to `usize` and panic if the converted value wouldn't fit - | -LL | foo::(x_u16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ + | | + | expected `usize`, found `u16` + | help: you can convert an `u16` to `usize`: `x_u16.into()` error[E0308]: mismatched types --> $DIR/numeric-cast.rs:29:18 | LL | foo::(x_u8); - | ^^^^ expected `usize`, found `u8` - | -help: you can convert an `u8` to `usize` and panic if the converted value wouldn't fit - | -LL | foo::(x_u8.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ + | | + | expected `usize`, found `u8` + | help: you can convert an `u8` to `usize`: `x_u8.into()` error[E0308]: mismatched types --> $DIR/numeric-cast.rs:31:18 @@ -178,23 +174,19 @@ error[E0308]: mismatched types --> $DIR/numeric-cast.rs:59:18 | LL | foo::(x_i16); - | ^^^^^ expected `isize`, found `i16` - | -help: you can convert an `i16` to `isize` and panic if the converted value wouldn't fit - | -LL | foo::(x_i16.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ + | | + | expected `isize`, found `i16` + | help: you can convert an `i16` to `isize`: `x_i16.into()` error[E0308]: mismatched types --> $DIR/numeric-cast.rs:61:18 | LL | foo::(x_i8); - | ^^^^ expected `isize`, found `i8` - | -help: you can convert an `i8` to `isize` and panic if the converted value wouldn't fit - | -LL | foo::(x_i8.try_into().unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ + | | + | expected `isize`, found `i8` + | help: you can convert an `i8` to `isize`: `x_i8.into()` error[E0308]: mismatched types --> $DIR/numeric-cast.rs:66:16 diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr index dfc1887d3af90..f1c0cd6b543e4 100644 --- a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr +++ b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr @@ -11,7 +11,7 @@ LL | x.default_hello(); | help: use associated function syntax instead: `GenericAssocMethod::::default_hello` | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter -note: the candidate is defined in an impl for the type `GenericAssocMethod<_>` +note: the candidate is defined in an impl for the type `GenericAssocMethod` --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:4:5 | LL | fn default_hello() {}