continue;
}
- let canonical = f.replace("-", "_");
- let canonical_name = name.replace("-", "_");
+ let canonical = f.replace('-', "_");
+ let canonical_name = name.replace('-', "_");
let is_rust_object =
canonical.starts_with(&canonical_name) && looks_like_rust_object_file(&f);
tcx.reachable_non_generics(def_id.krate).contains_key(&def_id)
}
-fn exported_symbols_provider_local(
+fn exported_symbols_provider_local<'tcx>(
tcx: TyCtxt<'tcx>,
cnum: CrateNum,
) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
pub fn codegen_crate<B: ExtraBackendMethods>(
backend: B,
- tcx: TyCtxt<'tcx>,
+ tcx: TyCtxt<'_>,
target_cpu: String,
metadata: EncodedMetadata,
need_metadata_module: bool,
/// Generate an array of CounterExpressions, and an iterator over all `Counter`s and their
/// associated `Regions` (from which the LLVM-specific `CoverageMapGenerator` will create
/// `CounterMappingRegion`s.
- pub fn get_expressions_and_counter_regions<'a>(
- &'a self,
- ) -> (Vec<CounterExpression>, impl Iterator<Item = (Counter, &'a CodeRegion)>) {
+ pub fn get_expressions_and_counter_regions(
+ &self,
+ ) -> (Vec<CounterExpression>, impl Iterator<Item = (Counter, &CodeRegion)>) {
assert!(
self.source_hash != 0 || !self.is_used,
"No counters provided the source_hash for used function: {:?}",
(counter_expressions, counter_regions)
}
- fn counter_regions<'a>(&'a self) -> impl Iterator<Item = (Counter, &'a CodeRegion)> {
+ fn counter_regions(&self) -> impl Iterator<Item = (Counter, &CodeRegion)> {
self.counters.iter_enumerated().filter_map(|(index, entry)| {
// Option::map() will return None to filter out missing counters. This may happen
// if, for example, a MIR-instrumented counter is removed during an optimization.
}
fn expressions_with_regions(
- &'a self,
- ) -> (Vec<CounterExpression>, impl Iterator<Item = (Counter, &'a CodeRegion)>) {
+ &self,
+ ) -> (Vec<CounterExpression>, impl Iterator<Item = (Counter, &CodeRegion)>) {
let mut counter_expressions = Vec::with_capacity(self.expressions.len());
let mut expression_regions = Vec::with_capacity(self.expressions.len());
let mut new_indexes = IndexVec::from_elem_n(None, self.expressions.len());
(counter_expressions, expression_regions.into_iter())
}
- fn unreachable_regions<'a>(&'a self) -> impl Iterator<Item = (Counter, &'a CodeRegion)> {
+ fn unreachable_regions(&self) -> impl Iterator<Item = (Counter, &CodeRegion)> {
self.unreachable_regions.iter().map(|region| (Counter::zero(), region))
}
// format (natvis) is able to understand enums and render the active variant correctly in the
// debugger. For more information, look in `src/etc/natvis/intrinsic.natvis` and
// `EnumMemberDescriptionFactor::create_member_descriptions`.
- fn msvc_enum_fallback(
+ fn msvc_enum_fallback<'tcx>(
tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>,
def: &AdtDef,
vtable_name
}
-pub fn push_item_name(tcx: TyCtxt<'tcx>, def_id: DefId, qualified: bool, output: &mut String) {
+pub fn push_item_name(tcx: TyCtxt<'_>, def_id: DefId, qualified: bool, output: &mut String) {
let def_key = tcx.def_key(def_id);
if qualified {
if let Some(parent) = def_key.parent {
}
fn push_unqualified_item_name(
- tcx: TyCtxt<'tcx>,
+ tcx: TyCtxt<'_>,
def_id: DefId,
disambiguated_data: DisambiguatedDefPathData,
output: &mut String,
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(try_blocks)]
-#![feature(in_band_lifetimes)]
#![feature(let_else)]
#![feature(once_cell)]
#![feature(nll)]
locals: IndexVec<mir::Local, LocalKind>,
}
-impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
+impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
fn assign(&mut self, local: mir::Local, location: Location) {
let kind = &mut self.locals[local];
match *kind {
pub layout: TyAndLayout<'tcx>,
}
-impl<V: CodegenObject> fmt::Debug for OperandRef<'tcx, V> {
+impl<V: CodegenObject> fmt::Debug for OperandRef<'_, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "OperandRef({:?} @ {:?})", self.val, self.layout)
}
}
}
-impl<T> DerivedTypeMethods<'tcx> for T where Self: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {}
+impl<'tcx, T> DerivedTypeMethods<'tcx> for T where Self: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {}
pub trait LayoutTypeMethods<'tcx>: Backend<'tcx> {
fn backend_type(&self, layout: TyAndLayout<'tcx>) -> Self::Type;
pub trait TypeMethods<'tcx>: DerivedTypeMethods<'tcx> + LayoutTypeMethods<'tcx> {}
-impl<T> TypeMethods<'tcx> for T where Self: DerivedTypeMethods<'tcx> + LayoutTypeMethods<'tcx> {}
+impl<'tcx, T> TypeMethods<'tcx> for T where Self: DerivedTypeMethods<'tcx> + LayoutTypeMethods<'tcx> {}
let print_lints = |lints: Vec<&Lint>| {
for lint in lints {
- let name = lint.name_lower().replace("_", "-");
+ let name = lint.name_lower().replace('_', "-");
println!(
" {} {:7.7} {}",
padded(&name),
let print_lint_groups = |lints: Vec<(&'static str, Vec<LintId>)>| {
for (name, to) in lints {
- let name = name.to_lowercase().replace("_", "-");
+ let name = name.to_lowercase().replace('_', "-");
let desc = to
.into_iter()
- .map(|x| x.to_string().replace("_", "-"))
+ .map(|x| x.to_string().replace('_', "-"))
.collect::<Vec<String>>()
.join(", ");
println!(" {} {}", padded(&name), desc);
println!(
" {} {:>width$}=val -- {}",
cmdline_opt,
- name.replace("_", "-"),
+ name.replace('_', "-"),
desc,
width = max_len
);
.iter()
.map(|&(name, ..)| ('C', name))
.chain(DB_OPTIONS.iter().map(|&(name, ..)| ('Z', name)))
- .find(|&(_, name)| *opt == name.replace("_", "-"))
+ .find(|&(_, name)| *opt == name.replace('_', "-"))
.map(|(flag, _)| format!("{}. Did you mean `-{} {}`?", e, flag, opt)),
_ => None,
};
/// Escape tags in such a way that it is suitable for inclusion in a
/// Graphviz HTML label.
pub fn escape_html(s: &str) -> String {
- s.replace("&", "&").replace("\"", """).replace("<", "<").replace(">", ">")
+ s.replace('&', "&").replace('\"', """).replace('<', "<").replace('>', ">")
}
impl<'a> LabelText<'a> {
fn escape_dep_filename(filename: &str) -> String {
// Apparently clang and gcc *only* escape spaces:
// https://llvm.org/klaus/clang/commit/9d50634cfc268ecc9a7250226dd5ca0e945240d4
- filename.replace(" ", "\\ ")
+ filename.replace(' ', "\\ ")
}
// Makefile comments only need escaping newlines and `\`.
Level::Allow => "-A",
Level::ForceWarn => "--force-warn",
};
- let hyphen_case_lint_name = name.replace("_", "-");
+ let hyphen_case_lint_name = name.replace('_', "-");
if lint_flag_val.as_str() == name {
sess.diag_note_once(
&mut err,
),
);
} else {
- let hyphen_case_flag_val = lint_flag_val.as_str().replace("_", "-");
+ let hyphen_case_flag_val = lint_flag_val.as_str().replace('_', "-");
sess.diag_note_once(
&mut err,
DiagnosticMessageId::from(lint),
write!(
w,
r#"<tr><td align="left" balign="left">{}</td></tr>"#,
- dot::escape_html(§ion).replace("\n", "<br/>")
+ dot::escape_html(§ion).replace('\n', "<br/>")
)?;
}
let src = self.node(source);
let trg = self.node(target);
let escaped_edge_label = if let Some(edge_label) = edge_labels.get(index) {
- dot::escape_html(edge_label).replace("\n", r#"<br align="left"/>"#)
+ dot::escape_html(edge_label).replace('\n', r#"<br align="left"/>"#)
} else {
"".to_owned()
};
}
fn escape_html(s: &str) -> String {
- s.replace("&", "&").replace("<", "<").replace(">", ">")
+ s.replace('&', "&").replace('<', "<").replace('>', ">")
}
fn escape_attr(s: &str) -> String {
- s.replace("&", "&")
- .replace("\"", """)
- .replace("'", "'")
- .replace("<", "<")
- .replace(">", ">")
+ s.replace('&', "&")
+ .replace('\"', """)
+ .replace('\'', "'")
+ .replace('<', "<")
+ .replace('>', ">")
}
//! Diagnostics related methods for `TyS`.
+use crate::ty::subst::{GenericArg, GenericArgKind};
use crate::ty::TyKind::*;
-use crate::ty::{InferTy, TyCtxt, TyS};
+use crate::ty::{
+ ConstKind, ExistentialPredicate, ExistentialProjection, ExistentialTraitRef, InferTy,
+ ProjectionTy, TyCtxt, TyS, TypeAndMut,
+};
+
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
/// Whether the type can be safely suggested during error recovery.
pub fn is_suggestable(&self) -> bool {
- !matches!(
- self.kind(),
+ fn generic_arg_is_suggestible(arg: GenericArg<'_>) -> bool {
+ match arg.unpack() {
+ GenericArgKind::Type(ty) => ty.is_suggestable(),
+ GenericArgKind::Const(c) => const_is_suggestable(c.val),
+ _ => true,
+ }
+ }
+
+ fn const_is_suggestable(kind: ConstKind<'_>) -> bool {
+ match kind {
+ ConstKind::Infer(..)
+ | ConstKind::Bound(..)
+ | ConstKind::Placeholder(..)
+ | ConstKind::Error(..) => false,
+ _ => true,
+ }
+ }
+
+ // FIXME(compiler-errors): Some types are still not good to suggest,
+ // specifically references with lifetimes within the function. Not
+ //sure we have enough information to resolve whether a region is
+ // temporary, so I'll leave this as a fixme.
+
+ match self.kind() {
Opaque(..)
- | FnDef(..)
- | FnPtr(..)
- | Dynamic(..)
- | Closure(..)
- | Infer(..)
- | Projection(..)
- )
+ | FnDef(..)
+ | Closure(..)
+ | Infer(..)
+ | Generator(..)
+ | GeneratorWitness(..)
+ | Bound(_, _)
+ | Placeholder(_)
+ | Error(_) => false,
+ Dynamic(dty, _) => dty.iter().all(|pred| match pred.skip_binder() {
+ ExistentialPredicate::Trait(ExistentialTraitRef { substs, .. }) => {
+ substs.iter().all(generic_arg_is_suggestible)
+ }
+ ExistentialPredicate::Projection(ExistentialProjection { substs, ty, .. }) => {
+ ty.is_suggestable() && substs.iter().all(generic_arg_is_suggestible)
+ }
+ _ => true,
+ }),
+ Projection(ProjectionTy { substs: args, .. }) | Adt(_, args) | Tuple(args) => {
+ args.iter().all(generic_arg_is_suggestible)
+ }
+ Slice(ty) | RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => ty.is_suggestable(),
+ Array(ty, c) => ty.is_suggestable() && const_is_suggestable(c.val),
+ _ => true,
+ }
}
}
tcx.def_path_hash(a.item_def_id).cmp(&tcx.def_path_hash(b.item_def_id))
}
(AutoTrait(ref a), AutoTrait(ref b)) => {
- tcx.trait_def(*a).def_path_hash.cmp(&tcx.trait_def(*b).def_path_hash)
+ tcx.def_path_hash(*a).cmp(&tcx.def_path_hash(*b))
}
(Trait(_), _) => Ordering::Less,
(Projection(_), Trait(_)) => Ordering::Greater,
let mut counter_format = ExpressionFormat::default();
if let Ok(env_debug_options) = std::env::var(RUSTC_COVERAGE_DEBUG_OPTIONS) {
- for setting_str in env_debug_options.replace(" ", "").replace("-", "_").split(',') {
+ for setting_str in env_debug_options.replace(' ', "").replace('-', "_").split(',') {
let (option, value) = match setting_str.split_once('=') {
None => (setting_str, None),
Some((k, v)) => (k, Some(v)),
format!(
"{}\n {}",
source_range_no_file(tcx, &self.span),
- self.format_coverage_statements(tcx, mir_body).replace("\n", "\n "),
+ self.format_coverage_statements(tcx, mir_body).replace('\n', "\n "),
)
}
err.span_suggestion(
seq_span,
"...or a vertical bar to match on multiple alternatives",
- seq_snippet.replace(",", " |"),
+ seq_snippet.replace(',', " |"),
Applicability::MachineApplicable,
);
}
// Helper function to escape quotes in a string
fn escape(s: String) -> String {
- s.replace("\"", "\"\"")
+ s.replace('\"', "\"\"")
}
// Helper function to determine if a span came from a
if lint_name == "help" {
describe_lints = true;
} else {
- lint_opts_with_position.push((arg_pos, lint_name.replace("-", "_"), level));
+ lint_opts_with_position.push((arg_pos, lint_name.replace('-', "_"), level));
}
}
}
Some((k, v)) => (k.to_string(), Some(v)),
};
- let option_to_lookup = key.replace("-", "_");
+ let option_to_lookup = key.replace('-', "_");
match descrs.iter().find(|(name, ..)| *name == option_to_lookup) {
Some((_, setter, type_desc, _)) => {
if !setter(&mut op, value) {
);
sess.err(&msg);
} else {
- return validate(s.replace("-", "_"), None);
+ return validate(s.replace('-', "_"), None);
}
}
}
let msg = format!(
"the trait bound `{}: {}` is not satisfied",
- orig_ty.to_string(),
+ orig_ty,
old_ref.print_only_trait_path(),
);
if has_custom_message {
use std::ptr::NonNull;
#[test]
-fn unitialized_zero_size_box() {
+fn uninitialized_zero_size_box() {
assert_eq!(
&*Box::<()>::new_uninit() as *const _,
NonNull::<MaybeUninit<()>>::dangling().as_ptr(),
}
#[test]
-fn test_join_isue_80335() {
+fn test_join_issue_80335() {
use core::{borrow::Borrow, cell::Cell};
struct WeirdBorrow {
///
/// - If `T` is `Sized`, this function is always safe to call.
/// - If the unsized tail of `T` is:
- /// - a [slice], then the length of the slice tail must be an intialized
+ /// - a [slice], then the length of the slice tail must be an initialized
/// integer, and the size of the *entire value*
/// (dynamic tail length + statically sized prefix) must fit in `isize`.
/// - a [trait object], then the vtable part of the pointer must point
- /// to a valid vtable for the type `T` acquired by an unsizing coersion,
+ /// to a valid vtable for the type `T` acquired by an unsizing coercion,
/// and the size of the *entire value*
/// (dynamic tail length + statically sized prefix) must fit in `isize`.
/// - an (unstable) [extern type], then this function is always safe to
/// assert_eq!(true.then_some(0), Some(0));
/// ```
#[unstable(feature = "bool_to_option", issue = "80967")]
+ #[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
#[inline]
- pub fn then_some<T>(self, t: T) -> Option<T> {
+ pub const fn then_some<T>(self, t: T) -> Option<T>
+ where
+ T: ~const Drop,
+ {
if self { Some(t) } else { None }
}
/// assert_eq!(true.then(|| 0), Some(0));
/// ```
#[stable(feature = "lazy_bool_to_option", since = "1.50.0")]
+ #[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
#[inline]
- pub fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T> {
+ pub const fn then<T, F>(self, f: F) -> Option<T>
+ where
+ F: ~const FnOnce() -> T,
+ F: ~const Drop,
+ {
if self { Some(f()) } else { None }
}
}
Ok(Ref { value: unsafe { &*self.value.get() }, borrow: b })
}
None => Err(BorrowError {
- // If a borrow occured, then we must already have an outstanding borrow,
+ // If a borrow occurred, then we must already have an outstanding borrow,
// so `borrowed_at` will be `Some`
#[cfg(feature = "debug_refcell")]
location: self.borrowed_at.get().unwrap(),
Ok(RefMut { value: unsafe { &mut *self.value.get() }, borrow: b })
}
None => Err(BorrowMutError {
- // If a borrow occured, then we must already have an outstanding borrow,
+ // If a borrow occurred, then we must already have an outstanding borrow,
// so `borrowed_at` will be `Some`
#[cfg(feature = "debug_refcell")]
location: self.borrowed_at.get().unwrap(),
Ok(unsafe { &*self.value.get() })
} else {
Err(BorrowError {
- // If a borrow occured, then we must already have an outstanding borrow,
+ // If a borrow occurred, then we must already have an outstanding borrow,
// so `borrowed_at` will be `Some`
#[cfg(feature = "debug_refcell")]
location: self.borrowed_at.get().unwrap(),
/// * It must also be safe to drop `self` after calling `self.__iterator_get_unchecked(idx)`.
/// * If `T` is a subtype of `Self`, then it must be safe to coerce `self` to `T`.
//
-// FIXME: Clarify interaction with SourceIter/InPlaceIterable. Calling `SouceIter::as_inner`
+// FIXME: Clarify interaction with SourceIter/InPlaceIterable. Calling `SourceIter::as_inner`
// after `__iterator_get_unchecked` is supposed to be allowed.
#[doc(hidden)]
#[unstable(feature = "trusted_random_access", issue = "none")]
usize u8 u16
isize i8 i16
- // These are incorect per the reasoning above,
+ // These are incorrect per the reasoning above,
// but removing them would be a breaking change as they were stabilized in Rust 1.0.0.
// So e.g. `(0..66_000_u32).len()` for example will compile without error or warnings
// on 16-bit platforms, but continue to give a wrong result.
u8
i8
- // These are incorect per the reasoning above,
+ // These are incorrect per the reasoning above,
// but removing them would be a breaking change as they were stabilized in Rust 1.26.0.
// So e.g. `(0..=u16::MAX).len()` for example will compile without error or warnings
// on 16-bit platforms, but continue to give a wrong result.
&& !self.many_digits
}
- /// The fast path algorithmn using machine-sized integers and floats.
+ /// The fast path algorithm using machine-sized integers and floats.
///
/// This is extracted into a separate function so that it can be attempted before constructing
/// a Decimal. This only works if both the mantissa and the exponent
-//! Shared utilties used by both float and integer formatting.
+//! Shared utilities used by both float and integer formatting.
#![doc(hidden)]
#![unstable(
feature = "numfmt",
// the length, to also allows for the fast `ptr == end` check.
//
// See the `next_unchecked!` and `is_empty!` macros as well as the
- // `post_inc_start` method for more informations.
+ // `post_inc_start` method for more information.
unsafe {
assume(!ptr.is_null());
// - overflows cannot happen for `i` since the function's safety contract ask for
// `mid+right-1 = x+left+right` to be valid for writing
// - underflows cannot happen because `i` must be bigger or equal to `left` for
- // a substraction of `left` to happen.
+ // a subtraction of `left` to happen.
//
// So `x+i` is valid for reading and writing if the caller respected the contract
tmp = unsafe { x.add(i).replace(tmp) };
loop {
// SAFETY:
// `left >= right` so `[mid-right, mid+right)` is valid for reading and writing
- // Substracting `right` from `mid` each turn is counterbalanced by the addition and
+ // Subtracting `right` from `mid` each turn is counterbalanced by the addition and
// check after it.
unsafe {
ptr::swap_nonoverlapping(mid.sub(right), mid, right);
loop {
// SAFETY: `[mid-left, mid+left)` is valid for reading and writing because
// `left < right` so `mid+left < mid+right`.
- // Adding `left` to `mid` each turn is counterbalanced by the substraction and check
+ // Adding `left` to `mid` each turn is counterbalanced by the subtraction and check
// after it.
unsafe {
ptr::swap_nonoverlapping(mid.sub(left), mid, left);
}
impl<'a, P: Pattern<'a>> Split<'a, P> {
- /// Returns remainder of the splitted string
+ /// Returns remainder of the split string
///
/// # Examples
///
}
impl<'a, P: Pattern<'a>> RSplit<'a, P> {
- /// Returns remainder of the splitted string
+ /// Returns remainder of the split string
///
/// # Examples
///
}
impl<'a, P: Pattern<'a>> SplitTerminator<'a, P> {
- /// Returns remainder of the splitted string
+ /// Returns remainder of the split string
///
/// # Examples
///
}
impl<'a, P: Pattern<'a>> RSplitTerminator<'a, P> {
- /// Returns remainder of the splitted string
+ /// Returns remainder of the split string
///
/// # Examples
///
}
impl<'a, P: Pattern<'a>> SplitN<'a, P> {
- /// Returns remainder of the splitted string
+ /// Returns remainder of the split string
///
/// # Examples
///
}
impl<'a, P: Pattern<'a>> RSplitN<'a, P> {
- /// Returns remainder of the splitted string
+ /// Returns remainder of the split string
///
/// # Examples
///
impl FusedIterator for SplitWhitespace<'_> {}
impl<'a> SplitWhitespace<'a> {
- /// Returns remainder of the splitted string
+ /// Returns remainder of the split string
///
/// # Examples
///
impl FusedIterator for SplitAsciiWhitespace<'_> {}
impl<'a> SplitAsciiWhitespace<'a> {
- /// Returns remainder of the splitted string
+ /// Returns remainder of the split string
///
/// # Examples
///
impl<'a, P: Pattern<'a>> FusedIterator for SplitInclusive<'a, P> {}
impl<'a, P: Pattern<'a>> SplitInclusive<'a, P> {
- /// Returns remainder of the splitted string
+ /// Returns remainder of the split string
///
/// # Examples
///
// This test does not work on targets without panic=unwind support.
// To work around this problem, test is marked is should_panic, so it will
// be automagically skipped on unsuitable targets, such as
-// wasm32-unknown-unkown.
+// wasm32-unknown-unknown.
//
// It means that we use panic for indicating success.
#[test]
assert_eq!(true.then_some(0), Some(0));
assert_eq!(false.then(|| 0), None);
assert_eq!(true.then(|| 0), Some(0));
+
+ const fn zero() -> i32 {
+ 0
+ }
+
+ const A: Option<i32> = false.then_some(0);
+ const B: Option<i32> = true.then_some(0);
+ const C: Option<i32> = false.then(zero);
+ const D: Option<i32> = true.then(zero);
+
+ assert_eq!(A, None);
+ assert_eq!(B, Some(0));
+ assert_eq!(C, None);
+ assert_eq!(D, Some(0));
}
#![feature(cfg_panic)]
#![feature(cfg_target_has_atomic)]
#![feature(const_assume)]
+#![feature(const_bool_to_option)]
#![feature(const_cell_into_inner)]
#![feature(const_convert)]
#![feature(const_maybe_uninit_as_mut_ptr)]
};
struct Exception {
- // This is necessary because C++ code can capture our execption with
+ // This is necessary because C++ code can capture our exception with
// std::exception_ptr and rethrow it multiple times, possibly even in
// another thread.
caught: AtomicBool,
// "hard_link" should appear as a symlink.
assert!(check!(fs::symlink_metadata(tmpdir.join("hard_link"))).file_type().is_symlink());
- // We sould be able to open "file" via any of the above names.
+ // We should be able to open "file" via any of the above names.
let _ = check!(fs::File::open(tmpdir.join("file")));
assert!(fs::File::open(tmpdir.join("file.renamed")).is_err());
let _ = check!(fs::File::open(tmpdir.join("symlink")));
let start_len = buf.len();
let start_cap = buf.capacity();
- let mut initialized = 0; // Extra initalized bytes from previous loop iteration
+ let mut initialized = 0; // Extra initialized bytes from previous loop iteration
loop {
if buf.len() == buf.capacity() {
buf.reserve(32); // buf is full, need more space
let mut read_buf = ReadBuf::uninit(buf.spare_capacity_mut());
- // SAFETY: These bytes were initalized but not filled in the previous loop
+ // SAFETY: These bytes were initialized but not filled in the previous loop
unsafe {
read_buf.assume_init(initialized);
}
})
}) == Ok(Some(()))
{
- // Succesfully wrote to capture buffer.
+ // Successfully wrote to capture buffer.
return;
}
}
#[test]
-fn ipv6_from_contructors() {
+fn ipv6_from_constructors() {
assert_eq!(Ipv6Addr::LOCALHOST, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
assert!(Ipv6Addr::LOCALHOST.is_loopback());
assert_eq!(Ipv6Addr::UNSPECIFIED, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0));
// The call to `intrinsics::r#try` is made safe by:
// - `do_call`, the first argument, can be called with the initial `data_ptr`.
// - `do_catch`, the second argument, can be called with the `data_ptr` as well.
- // See their safety preconditions for more informations
+ // See their safety preconditions for more information
unsafe {
return if intrinsics::r#try(do_call::<F, R>, data_ptr, do_catch::<F, R>) == 0 {
Ok(ManuallyDrop::into_inner(data.r))
// expects normal function pointers.
#[inline]
fn do_call<F: FnOnce() -> R, R>(data: *mut u8) {
- // SAFETY: this is the responsibilty of the caller, see above.
+ // SAFETY: this is the responsibility of the caller, see above.
unsafe {
let data = data as *mut Data<F, R>;
let data = &mut (*data);
// expects normal function pointers.
#[inline]
fn do_catch<F: FnOnce() -> R, R>(data: *mut u8, payload: *mut u8) {
- // SAFETY: this is the responsibilty of the caller, see above.
+ // SAFETY: this is the responsibility of the caller, see above.
//
// When `__rustc_panic_cleaner` is correctly implemented we can rely
// on `obj` being the correct thing to pass to `data.p` (after wrapping
// In this case, `inner`'s ownership has been moved to us,
// And we are responsible for dropping it. The acquire
// ordering is not necessary because the parent thread made
- // no memory acccess needing synchronization since the call
+ // no memory access needing synchronization since the call
// to `acre_tsk`.
// Safety: See above.
let _ = unsafe { Box::from_raw(inner as *const _ as *mut ThreadInner) };
// one will ever join it.
// The ownership of `self.inner` is moved to the child thread.
// However, the release ordering is not necessary because we
- // made no memory acccess needing synchronization since the call
+ // made no memory access needing synchronization since the call
// to `acre_tsk`.
}
LIFECYCLE_FINISHED => {
fn potential_sendfile_source(&self) -> bool {
match self {
- // procfs erronously shows 0 length on non-empty readable files.
+ // procfs erroneously shows 0 length on non-empty readable files.
// and if a file is truly empty then a `read` syscall will determine that and skip the write syscall
// thus there would be benefit from attempting sendfile
FdMeta::Metadata(meta)
//
// The other view would be to say that the caller on Fuchsia ought to know that `into_raw`
// will give a raw Fuchsia status (whatever that is - I don't know, personally). That is
- // not possible here becaause we must return a c_int because that's what Unix (including
+ // not possible here because we must return a c_int because that's what Unix (including
// SuS and POSIX) say a wait status is, but Fuchsia apparently uses a u64, so it won't
// necessarily fit.
//
}
}
- // Cold because it should only happen during first-time initalization.
+ // Cold because it should only happen during first-time initialization.
#[cold]
unsafe fn initialize(&self) -> Option<F> {
assert_eq!(mem::size_of::<F>(), mem::size_of::<usize>());
unsafe impl GlobalAlloc for System {
#[inline]
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
- // SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access.
+ // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling malloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.malloc(layout.size(), layout.align()) }
#[inline]
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
- // SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access.
+ // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling calloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.calloc(layout.size(), layout.align()) }
#[inline]
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
- // SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access.
+ // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling free() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.free(ptr, layout.size(), layout.align()) }
#[inline]
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
- // SAFETY: DLMALLOC access is guranteed to be safe because the lock gives us unique and non-reentrant access.
+ // SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling realloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.realloc(ptr, layout.size(), layout.align(), new_size) }
unsafe impl Send for ReentrantMutex {}
unsafe impl Sync for ReentrantMutex {}
-// Reentrant mutexes are similarly implemented to mutexs above except that
+// Reentrant mutexes are similarly implemented to mutexes above except that
// instead of "1" meaning unlocked we use the id of a thread to represent
// whether it has locked a mutex. That way we have an atomic counter which
// always holds the id of the thread that currently holds the lock (or 0 if the
pub unsafe fn lock(&self) {
let me = thread::my_id();
while let Err(owner) = self._try_lock(me) {
- // SAFETY: the caller must gurantee that `self.ptr()` and `owner` are valid i32.
+ // SAFETY: the caller must guarantee that `self.ptr()` and `owner` are valid i32.
let val = unsafe { wasm32::memory_atomic_wait32(self.ptr(), owner as i32, -1) };
debug_assert!(val == 0 || val == 1);
}
match *self.recursions.get() {
0 => {
self.owner.swap(0, SeqCst);
- // SAFETY: the caller must gurantee that `self.ptr()` is valid i32.
+ // SAFETY: the caller must guarantee that `self.ptr()` is valid i32.
unsafe {
wasm32::memory_atomic_notify(self.ptr() as *mut i32, 1);
} // wake up one waiter, if any
//
// If the data is not valid UTF-8 we write out as many bytes as are valid.
// If the first byte is invalid it is either first byte of a multi-byte sequence but the
- // provided byte slice is too short or it is the first byte of an invalide multi-byte sequence.
+ // provided byte slice is too short or it is the first byte of an invalid multi-byte sequence.
let len = cmp::min(data.len(), MAX_BUFFER_SIZE / 2);
let utf8 = match str::from_utf8(&data[..len]) {
Ok(s) => s,
//
// Unlike WaitOnAddress, NtWaitForKeyedEvent/NtReleaseKeyedEvent operate on a
// HANDLE (created with NtCreateKeyedEvent). This means that we can be sure
-// a succesfully awoken park() was awoken by unpark() and not a
+// a successfully awoken park() was awoken by unpark() and not a
// NtReleaseKeyedEvent call from some other code, as these events are not only
// matched by the key (address of the parker (state)), but also by this HANDLE.
// We lazily allocate this handle the first time it is needed.
-//! Parker implementaiton based on a Mutex and Condvar.
+//! Parker implementation based on a Mutex and Condvar.
use crate::sync::atomic::AtomicUsize;
use crate::sync::atomic::Ordering::SeqCst;
Parker { state: AtomicUsize::new(EMPTY), lock: Mutex::new(()), cvar: Condvar::new() }
}
- // This implementaiton doesn't require `unsafe`, but other implementations
+ // This implementation doesn't require `unsafe`, but other implementations
// may assume this is only called by the thread that owns the Parker.
pub unsafe fn park(&self) {
// If we were previously notified then we consume this notification and
}
}
- // This implementaiton doesn't require `unsafe`, but other implementations
+ // This implementation doesn't require `unsafe`, but other implementations
// may assume this is only called by the thread that owns the Parker.
pub unsafe fn park_timeout(&self, dur: Duration) {
// Like `park` above we have a fast path for an already-notified thread, and
Key { inner: LazyKeyInner::new(), dtor_state: Cell::new(DtorState::Unregistered) }
}
- // note that this is just a publically-callable function only for the
+ // note that this is just a publicly-callable function only for the
// const-initialized form of thread locals, basically a way to call the
// free `register_dtor` function defined elsewhere in libstd.
pub unsafe fn register_dtor(a: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
pub unsafe fn get<F: FnOnce() -> T>(&self, init: F) -> Option<&'static T> {
// SAFETY: See the definitions of `LazyKeyInner::get` and
- // `try_initialize` for more informations.
+ // `try_initialize` for more information.
//
// The caller must ensure no mutable references are ever active to
// the inner cell or the inner T when this is called.
// While issues have been seen on arm64 platforms the Arm architecture
// requires that the counter monotonically increases and that it must
// provide a uniform view of system time (e.g. it must not be possible
- // for a core to recieve a message from another core with a time stamp
+ // for a core to receive a message from another core with a time stamp
// and observe time going backwards (ARM DDI 0487G.b D11.1.2). While
// there have been a few 64bit SoCs that have bugs which cause time to
// not monoticially increase, these have been fixed in the Linux kernel
})
.expect("failed serde conversion")
// All these `replace` calls are because we have to go through JS string for JSON content.
- .replace(r"\", r"\\")
- .replace("'", r"\'")
+ .replace(r#"\"#, r"\\")
+ .replace(r#"'"#, r"\'")
// We need to escape double quotes for the JSON.
.replace("\\\"", "\\\\\"")
)
.iter()
.filter_map(|attr| {
if ALLOWED_ATTRIBUTES.contains(&attr.name_or_empty()) {
- Some(pprust::attribute_to_string(attr).replace("\n", "").replace(" ", " "))
+ Some(pprust::attribute_to_string(attr).replace('\n', "").replace(" ", " "))
} else {
None
}
return None;
}
- let stripped = ori_link.link.replace("`", "");
+ let stripped = ori_link.link.replace('`', "");
let mut parts = stripped.split('#');
let link = parts.next().unwrap();
.map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or(""))
.collect::<String>()
.trim()
- .replace("\n", " ")
- .replace("/", "")
- .replace("\t", " ")
- .replace("{", "")
- .replace("}", "")
+ .replace('\n', " ")
+ .replace('/', "")
+ .replace('\t', " ")
+ .replace('{', "")
+ .replace('}', "")
.split(' ')
.filter(|s| !s.is_empty())
.collect::<Vec<&str>>()
//~^ ERROR mismatched types
//~| NOTE expected associated type, found `()`
//~| NOTE expected associated type `<Self as Tr>::A`
+ //~| NOTE this expression has type `<Self as Tr>::A`
}
}
| ------------ associated type defaults can't be assumed inside the trait defining them
...
LL | let () = p;
- | ^^ expected associated type, found `()`
+ | ^^ - this expression has type `<Self as Tr>::A`
+ | |
+ | expected associated type, found `()`
|
= note: expected associated type `<Self as Tr>::A`
found unit type `()`
error[E0308]: mismatched types
- --> $DIR/defaults-in-other-trait-items.rs:35:25
+ --> $DIR/defaults-in-other-trait-items.rs:36:25
|
LL | type Ty = u8;
| ------------- associated type defaults can't be assumed inside the trait defining them
--> $DIR/default-match-bindings-forbidden.rs:4:5
|
LL | (x, y) = &(1, 2);
- | ^^^^^^ ------- this expression has type `&({integer}, {integer})`
- | |
- | expected reference, found tuple
+ | ^^^^^^ expected reference, found tuple
|
= note: expected type `&({integer}, {integer})`
found tuple `(_, _)`
--> $DIR/tuple_destructure_fail.rs:6:5
|
LL | (a, a, b) = (1, 2);
- | ^^^^^^^^^ ------ this expression has type `({integer}, {integer})`
- | |
- | expected a tuple with 2 elements, found one with 3 elements
+ | ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
|
= note: expected type `({integer}, {integer})`
found tuple `(_, _, _)`
--> $DIR/tuple_destructure_fail.rs:8:5
|
LL | (_,) = (1, 2);
- | ^^^^ ------ this expression has type `({integer}, {integer})`
- | |
- | expected a tuple with 2 elements, found one with 1 element
+ | ^^^^ expected a tuple with 2 elements, found one with 1 element
|
= note: expected type `({integer}, {integer})`
found tuple `(_,)`
--- /dev/null
+// check-fail
+// See issue #91899. If we treat unnormalized args as WF, `Self` can also be a
+// source of unsoundness.
+
+pub trait Yokeable<'a>: 'static {
+ type Output: 'a;
+}
+
+impl<'a, T: 'static + ?Sized> Yokeable<'a> for &'static T {
+ type Output = &'a T;
+}
+
+pub trait ZeroCopyFrom<C: ?Sized>: for<'a> Yokeable<'a> {
+ /// Clone the cart `C` into a [`Yokeable`] struct, which may retain references into `C`.
+ fn zero_copy_from<'b>(cart: &'b C) -> <Self as Yokeable<'b>>::Output;
+}
+
+impl<T> ZeroCopyFrom<[T]> for &'static [T] {
+ fn zero_copy_from<'b>(cart: &'b [T]) -> &'b [T] {
+ //~^ the parameter
+ cart
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0310]: the parameter type `T` may not live long enough
+ --> $DIR/implied-bounds-unnorm-associated-type-3.rs:19:5
+ |
+LL | fn zero_copy_from<'b>(cart: &'b [T]) -> &'b [T] {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: consider adding an explicit lifetime bound `T: 'static`...
+ = note: ...so that the type `[T]` will meet its required lifetime bounds
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0310`.
error[E0308]: mismatched types
--> $DIR/exclusive_range_pattern_syntax_collision.rs:6:13
|
-LL | match [5..4, 99..105, 43..44] {
- | ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
LL | [_, 99.., _] => {},
| ^^ expected struct `std::ops::Range`, found integer
|
error[E0308]: mismatched types
--> $DIR/exclusive_range_pattern_syntax_collision2.rs:6:13
|
-LL | match [5..4, 99..105, 43..44] {
- | ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
LL | [_, 99..] => {},
| ^^ expected struct `std::ops::Range`, found integer
|
error[E0308]: mismatched types
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:12
|
-LL | match [5..4, 99..105, 43..44] {
- | ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
LL | [..9, 99..100, _] => {},
| ^ expected struct `std::ops::Range`, found integer
|
error[E0308]: mismatched types
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:15
|
-LL | match [5..4, 99..105, 43..44] {
- | ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
LL | [..9, 99..100, _] => {},
| ^^ --- this is of type `{integer}`
| |
error[E0308]: mismatched types
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:19
|
-LL | match [5..4, 99..105, 43..44] {
- | ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
LL | [..9, 99..100, _] => {},
| -- ^^^ expected struct `std::ops::Range`, found integer
| |
error[E0308]: mismatched types
--> $DIR/pat-tuple-5.rs:8:10
|
-LL | match (0, 1) {
- | ------ this expression has type `({integer}, {integer})`
LL | (PAT ..) => {}
| ^^^ expected tuple, found `u8`
|
error[E0308]: mismatched types
--> $DIR/issue-11844.rs:6:9
|
-LL | match a {
- | - this expression has type `Option<Box<{integer}>>`
LL | Ok(a) =>
| ^^^^^ expected enum `Option`, found enum `Result`
|
error[E0308]: mismatched types
--> $DIR/issue-12552.rs:6:5
|
-LL | match t {
- | - this expression has type `Result<_, {integer}>`
LL | Some(k) => match k {
| ^^^^^^^ expected enum `Result`, found enum `Option`
|
error[E0308]: mismatched types
--> $DIR/issue-12552.rs:9:5
|
-LL | match t {
- | - this expression has type `Result<_, {integer}>`
-...
LL | None => ()
| ^^^^ expected enum `Result`, found enum `Option`
|
error[E0308]: mismatched types
--> $DIR/issue-13466.rs:8:9
|
-LL | let _x: usize = match Some(1) {
- | ------- this expression has type `Option<{integer}>`
LL | Ok(u) => u,
| ^^^^^ expected enum `Option`, found enum `Result`
|
error[E0308]: mismatched types
--> $DIR/issue-13466.rs:14:9
|
-LL | let _x: usize = match Some(1) {
- | ------- this expression has type `Option<{integer}>`
-...
LL | Err(e) => panic!(e)
| ^^^^^^ expected enum `Option`, found enum `Result`
|
error[E0308]: mismatched types
--> $DIR/issue-3680.rs:3:9
|
-LL | match None {
- | ---- this expression has type `Option<_>`
LL | Err(_) => ()
| ^^^^^^ expected enum `Option`, found enum `Result`
|
--> $DIR/issue-66706.rs:2:5
|
LL | fn a() {
- | - help: try adding a return type: `-> [{integer}; _]`
+ | - possibly return type missing here?
LL | [0; [|_: _ &_| ()].len()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[{integer}; _]`
--> $DIR/issue-66706.rs:14:5
|
LL | fn c() {
- | - help: try adding a return type: `-> [{integer}; _]`
+ | - possibly return type missing here?
LL | [0; [|&_: _ &_| {}; 0 ].len()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[{integer}; _]`
--> $DIR/issue-66706.rs:20:5
|
LL | fn d() {
- | - help: try adding a return type: `-> [{integer}; _]`
+ | - possibly return type missing here?
LL | [0; match [|f @ &ref _| () ] {} ]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[{integer}; _]`
error[E0308]: mismatched types
--> $DIR/issue-72574-1.rs:4:9
|
-LL | match x {
- | - this expression has type `({integer}, {integer}, {integer})`
LL | (_a, _x @ ..) => {}
| ^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 2 elements
|
error[E0308]: mismatched types
--> $DIR/E0409.rs:5:23
|
-LL | match x {
- | - this expression has type `({integer}, {integer})`
LL | (0, ref y) | (y, 0) => {}
| ----- ^ expected `&{integer}`, found integer
| |
|
LL | let &_
| ^^ types differ in mutability
-...
-LL | = foo;
- | --- this expression has type `&mut {integer}`
|
= note: expected mutable reference `&mut {integer}`
found reference `&_`
|
LL | let &mut _
| ^^^^^^ types differ in mutability
-...
-LL | = bar;
- | --- this expression has type `&{integer}`
|
= note: expected reference `&{integer}`
found mutable reference `&mut _`
error[E0308]: mismatched types
--> $DIR/diverging-tuple-parts-39485.rs:8:5
|
+LL | fn g() {
+ | - possibly return type missing here?
LL | &panic!()
| ^^^^^^^^^ expected `()`, found reference
|
= note: expected unit type `()`
found reference `&_`
-help: try adding a return type
- |
-LL | fn g() -> &_ {
- | +++++
help: consider removing the borrow
|
LL - &panic!()
--> $DIR/already-bound-name.rs:30:32
|
LL | let (B(A(a, _) | B(a)) | A(a, A(a, _) | B(a))) = B(B(1));
- | - ^ ------- this expression has type `E<E<{integer}>>`
- | | |
- | | expected integer, found enum `E`
+ | - ^ expected integer, found enum `E`
+ | |
| first introduced with type `{integer}` here
|
= note: expected type `{integer}`
--> $DIR/inconsistent-modes.rs:13:32
|
LL | let (Ok((ref a, b)) | Err((ref mut a, ref b))) = Ok((0, &0));
- | ----- ^^^^^^^^^ ----------- this expression has type `Result<({integer}, &{integer}), (_, _)>`
- | | |
- | | types differ in mutability
+ | ----- ^^^^^^^^^ types differ in mutability
+ | |
| first introduced with type `&{integer}` here
|
= note: expected type `&{integer}`
--> $DIR/issue-74702.rs:2:9
|
LL | let (foo @ ..,) = (0, 0);
- | ^^^^^^^^^^^ ------ this expression has type `({integer}, {integer})`
- | |
- | expected a tuple with 2 elements, found one with 1 element
+ | ^^^^^^^^^^^ expected a tuple with 2 elements, found one with 1 element
|
= note: expected tuple `({integer}, {integer})`
found tuple `(_,)`
error[E0308]: mismatched types
--> $DIR/pat-tuple-overfield.rs:19:9
|
-LL | match (1, 2, 3) {
- | --------- this expression has type `({integer}, {integer}, {integer})`
LL | (1, 2, 3, 4) => {}
| ^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 4 elements
|
error[E0308]: mismatched types
--> $DIR/pat-tuple-overfield.rs:20:9
|
-LL | match (1, 2, 3) {
- | --------- this expression has type `({integer}, {integer}, {integer})`
-LL | (1, 2, 3, 4) => {}
LL | (1, 2, .., 3, 4) => {}
| ^^^^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 4 elements
|
error[E0308]: mismatched types
--> $DIR/return-type.rs:10:5
|
+LL | fn bar() {
+ | - possibly return type missing here?
LL | foo(4 as usize)
- | ^^^^^^^^^^^^^^^ expected `()`, found struct `S`
+ | ^^^^^^^^^^^^^^^- help: consider using a semicolon here: `;`
+ | |
+ | expected `()`, found struct `S`
|
= note: expected unit type `()`
found struct `S<usize>`
-help: consider using a semicolon here
- |
-LL | foo(4 as usize);
- | +
-help: try adding a return type
- |
-LL | fn bar() -> S<usize> {
- | +++++++++++
error: aborting due to previous error
--> $DIR/disallowed-positions.rs:76:12
|
LL | if let Range { start: F, end } = F..|| true {}
- | ^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found struct `std::ops::Range`
+ | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool`
+ | |
+ | expected fn pointer, found struct `std::ops::Range`
|
= note: expected fn pointer `fn() -> bool`
found struct `std::ops::Range<_>`
--> $DIR/disallowed-positions.rs:140:15
|
LL | while let Range { start: F, end } = F..|| true {}
- | ^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found struct `std::ops::Range`
+ | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool`
+ | |
+ | expected fn pointer, found struct `std::ops::Range`
|
= note: expected fn pointer `fn() -> bool`
found struct `std::ops::Range<_>`
error[E0308]: mismatched types
--> $DIR/slightly-nice-generic-literal-messages.rs:7:9
|
-LL | match Foo(1.1, marker::PhantomData) {
- | ----------------------------- this expression has type `Foo<{float}, _>`
LL | 1 => {}
| ^ expected struct `Foo`, found integer
|
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:54:9
|
-LL | match (Point { x: 1, y: 2 }) {
- | ---------------------- this expression has type `Point<{integer}>`
LL | PointF::<u32> { .. } => {}
| ^^^^^^^^^^^^^^^^^^^^ expected integer, found `f32`
|
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:59:9
|
-LL | match (Point { x: 1, y: 2 }) {
- | ---------------------- this expression has type `Point<{integer}>`
LL | PointF { .. } => {}
| ^^^^^^^^^^^^^ expected integer, found `f32`
|
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:67:9
|
-LL | match (Pair { x: 1, y: 2 }) {
- | --------------------- this expression has type `Pair<{integer}, {integer}>`
LL | PairF::<u32> { .. } => {}
| ^^^^^^^^^^^^^^^^^^^ expected integer, found `f32`
|
--> $DIR/issue-57673-ice-on-deref-of-boxed-trait.rs:5:5
|
LL | fn ice(x: Box<dyn Iterator<Item=()>>) {
- | - possibly return type missing here?
+ | - help: try adding a return type: `-> (dyn Iterator<Item = ()> + 'static)`
LL | *x
| ^^ expected `()`, found trait object `dyn Iterator`
|
LL | fn f(){||yield(((){),
| -^^^^^^^^^^^^^^^ expected `()`, found generator
| |
- | help: try adding a return type: `-> [generator@$DIR/issue-91334.rs:10:8: 10:23]`
+ | possibly return type missing here?
|
= note: expected unit type `()`
found generator `[generator@$DIR/issue-91334.rs:10:8: 10:23]`
--- /dev/null
+#[allow(unused)]
+fn foo() {
+ //~^ NOTE possibly return type missing here?
+ vec!['a'].iter().map(|c| c)
+ //~^ ERROR mismatched types [E0308]
+ //~| NOTE expected `()`, found struct `Map`
+ //~| NOTE expected unit type `()`
+}
+
+fn main() {}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/return_type_containing_closure.rs:4:5
+ |
+LL | fn foo() {
+ | - possibly return type missing here?
+LL |
+LL | vec!['a'].iter().map(|c| c)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: consider using a semicolon here: `;`
+ | |
+ | expected `()`, found struct `Map`
+ |
+ = note: expected unit type `()`
+ found struct `Map<std::slice::Iter<'_, char>, [closure@$DIR/return_type_containing_closure.rs:4:26: 4:31]>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.