Auto merge of #110331 - matthiaskrgr:rollup-9vldvow, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #108687 (Reformulate `point_at_expr_source_of_inferred_type` to be more accurate) - #109272 (Add Command environment variable inheritance docs) - #109947 (Add links from `core::cmp` derives to their traits) - #110110 (Use `Display` in top-level example for `PanicInfo`) - #110154 (Fix typos in library) - #110244 (Remove some unneeded imports / qualified paths) - #110328 ([rustdoc] Add explanations for auto-disambiguation when an intra doc link is resolved to a proc-macro and a trait at the same time) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
84dd17b56a
78 changed files with 413 additions and 396 deletions
|
|
@ -1,6 +1,5 @@
|
|||
use crate::FnCtxt;
|
||||
use rustc_ast::util::parser::PREC_POSTFIX;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::MultiSpan;
|
||||
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
|
||||
use rustc_hir as hir;
|
||||
|
|
@ -13,15 +12,13 @@ use rustc_middle::lint::in_external_macro;
|
|||
use rustc_middle::middle::stability::EvalResult;
|
||||
use rustc_middle::ty::adjustment::AllowTwoPhase;
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::fold::{BottomUpFolder, TypeFolder};
|
||||
use rustc_middle::ty::print::{with_forced_trimmed_paths, with_no_trimmed_paths};
|
||||
use rustc_middle::ty::relate::TypeRelation;
|
||||
use rustc_middle::ty::{self, Article, AssocItem, Ty, TypeAndMut, TypeVisitableExt};
|
||||
use rustc_middle::ty::fold::BottomUpFolder;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::{self, Article, AssocItem, Ty, TypeAndMut, TypeFoldable};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use rustc_span::{BytePos, Span, DUMMY_SP};
|
||||
use rustc_target::abi::FieldIdx;
|
||||
use rustc_trait_selection::infer::InferCtxtExt as _;
|
||||
use rustc_trait_selection::traits::error_reporting::method_chain::CollectAllMismatches;
|
||||
use rustc_trait_selection::traits::ObligationCause;
|
||||
|
||||
use super::method::probe;
|
||||
|
|
@ -62,9 +59,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|| self.suggest_into(err, expr, expr_ty, expected)
|
||||
|| self.suggest_floating_point_literal(err, expr, expected)
|
||||
|| self.suggest_null_ptr_for_literal_zero_given_to_ptr_arg(err, expr, expected)
|
||||
|| self.note_result_coercion(err, expr, expected, expr_ty);
|
||||
|| self.suggest_coercing_result_via_try_operator(err, expr, expected, expr_ty);
|
||||
|
||||
if !suggested {
|
||||
self.point_at_expr_source_of_inferred_type(err, expr, expr_ty, expected, expr.span);
|
||||
self.note_source_of_type_mismatch_constraint(
|
||||
err,
|
||||
expr,
|
||||
TypeMismatchSource::Ty(expected),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -218,37 +220,34 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
(expected, Some(err))
|
||||
}
|
||||
|
||||
pub fn point_at_expr_source_of_inferred_type(
|
||||
/// Notes the point at which a variable is constrained to some type incompatible
|
||||
/// with some expectation given by `source`.
|
||||
pub fn note_source_of_type_mismatch_constraint(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
expr: &hir::Expr<'_>,
|
||||
found: Ty<'tcx>,
|
||||
expected: Ty<'tcx>,
|
||||
mismatch_span: Span,
|
||||
source: TypeMismatchSource<'tcx>,
|
||||
) -> bool {
|
||||
let map = self.tcx.hir();
|
||||
let hir = self.tcx.hir();
|
||||
|
||||
let hir::ExprKind::Path(hir::QPath::Resolved(None, p)) = expr.kind else { return false; };
|
||||
let [hir::PathSegment { ident, args: None, .. }] = p.segments else { return false; };
|
||||
let hir::def::Res::Local(hir_id) = p.res else { return false; };
|
||||
let Some(hir::Node::Pat(pat)) = map.find(hir_id) else { return false; };
|
||||
let Some(hir::Node::Local(hir::Local {
|
||||
ty: None,
|
||||
init: Some(init),
|
||||
..
|
||||
})) = map.find_parent(pat.hir_id) else { return false; };
|
||||
let Some(ty) = self.node_ty_opt(init.hir_id) else { return false; };
|
||||
if ty.is_closure() || init.span.overlaps(expr.span) || pat.span.from_expansion() {
|
||||
return false;
|
||||
}
|
||||
let hir::def::Res::Local(local_hir_id) = p.res else { return false; };
|
||||
let hir::Node::Pat(pat) = hir.get(local_hir_id) else { return false; };
|
||||
let (init_ty_hir_id, init) = match hir.get_parent(pat.hir_id) {
|
||||
hir::Node::Local(hir::Local { ty: Some(ty), init, .. }) => (ty.hir_id, *init),
|
||||
hir::Node::Local(hir::Local { init: Some(init), .. }) => (init.hir_id, Some(*init)),
|
||||
_ => return false,
|
||||
};
|
||||
let Some(init_ty) = self.node_ty_opt(init_ty_hir_id) else { return false; };
|
||||
|
||||
// Locate all the usages of the relevant binding.
|
||||
struct FindExprs<'hir> {
|
||||
struct FindExprs<'tcx> {
|
||||
hir_id: hir::HirId,
|
||||
uses: Vec<&'hir hir::Expr<'hir>>,
|
||||
uses: Vec<&'tcx hir::Expr<'tcx>>,
|
||||
}
|
||||
impl<'v> Visitor<'v> for FindExprs<'v> {
|
||||
fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) {
|
||||
impl<'tcx> Visitor<'tcx> for FindExprs<'tcx> {
|
||||
fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
|
||||
if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = ex.kind
|
||||
&& let hir::def::Res::Local(hir_id) = path.res
|
||||
&& hir_id == self.hir_id
|
||||
|
|
@ -259,180 +258,205 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
let mut expr_finder = FindExprs { hir_id, uses: vec![] };
|
||||
let id = map.get_parent_item(hir_id);
|
||||
let hir_id: hir::HirId = id.into();
|
||||
|
||||
let Some(node) = map.find(hir_id) else { return false; };
|
||||
let Some(body_id) = node.body_id() else { return false; };
|
||||
let body = map.body(body_id);
|
||||
let mut expr_finder = FindExprs { hir_id: local_hir_id, uses: init.into_iter().collect() };
|
||||
let body =
|
||||
hir.body(hir.maybe_body_owned_by(self.body_id).expect("expected item to have body"));
|
||||
expr_finder.visit_expr(body.value);
|
||||
// Hack to make equality checks on types with inference variables and regions useful.
|
||||
let mut eraser = BottomUpFolder {
|
||||
|
||||
use rustc_infer::infer::type_variable::*;
|
||||
use rustc_middle::infer::unify_key::*;
|
||||
// Replaces all of the variables in the given type with a fresh inference variable.
|
||||
let mut fudger = BottomUpFolder {
|
||||
tcx: self.tcx,
|
||||
ty_op: |ty| {
|
||||
if let ty::Infer(infer) = ty.kind() {
|
||||
match infer {
|
||||
ty::InferTy::TyVar(_) => self.next_ty_var(TypeVariableOrigin {
|
||||
kind: TypeVariableOriginKind::MiscVariable,
|
||||
span: DUMMY_SP,
|
||||
}),
|
||||
ty::InferTy::IntVar(_) => self.next_int_var(),
|
||||
ty::InferTy::FloatVar(_) => self.next_float_var(),
|
||||
_ => bug!(),
|
||||
}
|
||||
} else {
|
||||
ty
|
||||
}
|
||||
},
|
||||
lt_op: |_| self.tcx.lifetimes.re_erased,
|
||||
ct_op: |c| c,
|
||||
ty_op: |t| match *t.kind() {
|
||||
ty::Infer(ty::TyVar(_)) => self.tcx.mk_ty_var(ty::TyVid::from_u32(0)),
|
||||
ty::Infer(ty::IntVar(_)) => self.tcx.mk_int_var(ty::IntVid { index: 0 }),
|
||||
ty::Infer(ty::FloatVar(_)) => self.tcx.mk_float_var(ty::FloatVid { index: 0 }),
|
||||
_ => t,
|
||||
ct_op: |ct| {
|
||||
if let ty::ConstKind::Infer(_) = ct.kind() {
|
||||
self.next_const_var(
|
||||
ct.ty(),
|
||||
ConstVariableOrigin {
|
||||
kind: ConstVariableOriginKind::MiscVariable,
|
||||
span: DUMMY_SP,
|
||||
},
|
||||
)
|
||||
} else {
|
||||
ct
|
||||
}
|
||||
},
|
||||
};
|
||||
let mut prev = eraser.fold_ty(ty);
|
||||
let mut prev_span: Option<Span> = None;
|
||||
|
||||
for binding in expr_finder.uses {
|
||||
// In every expression where the binding is referenced, we will look at that
|
||||
// expression's type and see if it is where the incorrect found type was fully
|
||||
// "materialized" and point at it. We will also try to provide a suggestion there.
|
||||
if let Some(hir::Node::Expr(expr)
|
||||
| hir::Node::Stmt(hir::Stmt {
|
||||
kind: hir::StmtKind::Expr(expr) | hir::StmtKind::Semi(expr),
|
||||
..
|
||||
})) = &map.find_parent(binding.hir_id)
|
||||
&& let hir::ExprKind::MethodCall(segment, rcvr, args, _span) = expr.kind
|
||||
&& rcvr.hir_id == binding.hir_id
|
||||
&& let Some(def_id) = self.typeck_results.borrow().type_dependent_def_id(expr.hir_id)
|
||||
{
|
||||
// We special case methods, because they can influence inference through the
|
||||
// call's arguments and we can provide a more explicit span.
|
||||
let sig = self.tcx.fn_sig(def_id).subst_identity();
|
||||
let def_self_ty = sig.input(0).skip_binder();
|
||||
let param_tys = sig.inputs().skip_binder().iter().skip(1);
|
||||
// If there's an arity mismatch, pointing out the call as the source of an inference
|
||||
// can be misleading, so we skip it.
|
||||
if param_tys.len() != args.len() {
|
||||
continue;
|
||||
}
|
||||
let rcvr_ty = self.node_ty(rcvr.hir_id);
|
||||
// Get the evaluated type *after* calling the method call, so that the influence
|
||||
// of the arguments can be reflected in the receiver type. The receiver
|
||||
// expression has the type *before* this analysis is done.
|
||||
let ty = match self.lookup_probe_for_diagnostic(
|
||||
segment.ident,
|
||||
rcvr_ty,
|
||||
expr,
|
||||
probe::ProbeScope::TraitsInScope,
|
||||
None,
|
||||
) {
|
||||
Ok(pick) => eraser.fold_ty(pick.self_ty),
|
||||
Err(_) => rcvr_ty,
|
||||
let expected_ty = match source {
|
||||
TypeMismatchSource::Ty(expected_ty) => expected_ty,
|
||||
// Try to deduce what the possible value of `expr` would be if the
|
||||
// incompatible arg were compatible. For example, given `Vec<i32>`
|
||||
// and `vec.push(1u32)`, we ideally want to deduce that the type of
|
||||
// `vec` *should* have been `Vec<u32>`. This will allow us to then
|
||||
// run the subsequent code with this expectation, finding out exactly
|
||||
// when this type diverged from our expectation.
|
||||
TypeMismatchSource::Arg { call_expr, incompatible_arg: idx } => {
|
||||
let hir::ExprKind::MethodCall(segment, _, args, _) = call_expr.kind else {
|
||||
return false;
|
||||
};
|
||||
// Remove one layer of references to account for `&mut self` and
|
||||
// `&self`, so that we can compare it against the binding.
|
||||
let (ty, def_self_ty) = match (ty.kind(), def_self_ty.kind()) {
|
||||
(ty::Ref(_, ty, a), ty::Ref(_, self_ty, b)) if a == b => (*ty, *self_ty),
|
||||
_ => (ty, def_self_ty),
|
||||
let Some(arg_ty) = self.node_ty_opt(args[idx].hir_id) else {
|
||||
return false;
|
||||
};
|
||||
let mut param_args = FxHashMap::default();
|
||||
let mut param_expected = FxHashMap::default();
|
||||
let mut param_found = FxHashMap::default();
|
||||
if self.can_eq(self.param_env, ty, found) {
|
||||
// We only point at the first place where the found type was inferred.
|
||||
for (param_ty, arg) in param_tys.zip(args) {
|
||||
if def_self_ty.contains(*param_ty) && let ty::Param(_) = param_ty.kind() {
|
||||
// We found an argument that references a type parameter in `Self`,
|
||||
// so we assume that this is the argument that caused the found
|
||||
// type, which we know already because of `can_eq` above was first
|
||||
// inferred in this method call.
|
||||
let arg_ty = self.node_ty(arg.hir_id);
|
||||
if !arg.span.overlaps(mismatch_span) {
|
||||
err.span_label(
|
||||
arg.span,
|
||||
&format!(
|
||||
"this is of type `{arg_ty}`, which causes `{ident}` to be \
|
||||
inferred as `{ty}`",
|
||||
),
|
||||
);
|
||||
}
|
||||
param_args.insert(param_ty, (arg, arg_ty));
|
||||
}
|
||||
}
|
||||
let possible_rcvr_ty = expr_finder.uses.iter().find_map(|binding| {
|
||||
let possible_rcvr_ty = self.node_ty_opt(binding.hir_id)?;
|
||||
// Fudge the receiver, so we can do new inference on it.
|
||||
let possible_rcvr_ty = possible_rcvr_ty.fold_with(&mut fudger);
|
||||
let method = self
|
||||
.lookup_method(
|
||||
possible_rcvr_ty,
|
||||
segment,
|
||||
DUMMY_SP,
|
||||
call_expr,
|
||||
binding,
|
||||
args,
|
||||
)
|
||||
.ok()?;
|
||||
// Unify the method signature with our incompatible arg, to
|
||||
// do inference in the *opposite* direction and to find out
|
||||
// what our ideal rcvr ty would look like.
|
||||
let _ = self
|
||||
.at(&ObligationCause::dummy(), self.param_env)
|
||||
.eq(DefineOpaqueTypes::No, method.sig.inputs()[idx + 1], arg_ty)
|
||||
.ok()?;
|
||||
self.select_obligations_where_possible(|errs| {
|
||||
// Yeet the errors, we're already reporting errors.
|
||||
errs.clear();
|
||||
});
|
||||
Some(self.resolve_vars_if_possible(possible_rcvr_ty))
|
||||
});
|
||||
if let Some(rcvr_ty) = possible_rcvr_ty {
|
||||
rcvr_ty
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Here we find, for a type param `T`, the type that `T` is in the current
|
||||
// method call *and* in the original expected type. That way, we can see if we
|
||||
// can give any structured suggestion for the function argument.
|
||||
let mut c = CollectAllMismatches {
|
||||
infcx: &self.infcx,
|
||||
param_env: self.param_env,
|
||||
errors: vec![],
|
||||
};
|
||||
let _ = c.relate(def_self_ty, ty);
|
||||
for error in c.errors {
|
||||
if let TypeError::Sorts(error) = error {
|
||||
param_found.insert(error.expected, error.found);
|
||||
}
|
||||
}
|
||||
c.errors = vec![];
|
||||
let _ = c.relate(def_self_ty, expected);
|
||||
for error in c.errors {
|
||||
if let TypeError::Sorts(error) = error {
|
||||
param_expected.insert(error.expected, error.found);
|
||||
}
|
||||
}
|
||||
for (param, (arg, arg_ty)) in param_args.iter() {
|
||||
let Some(expected) = param_expected.get(param) else { continue; };
|
||||
let Some(found) = param_found.get(param) else { continue; };
|
||||
if !self.can_eq(self.param_env, *arg_ty, *found) { continue; }
|
||||
self.emit_coerce_suggestions(err, arg, *found, *expected, None, None);
|
||||
}
|
||||
|
||||
let ty = eraser.fold_ty(ty);
|
||||
if ty.references_error() {
|
||||
break;
|
||||
}
|
||||
if ty != prev
|
||||
&& param_args.is_empty()
|
||||
&& self.can_eq(self.param_env, ty, found)
|
||||
{
|
||||
// We only point at the first place where the found type was inferred.
|
||||
if !segment.ident.span.overlaps(mismatch_span) {
|
||||
err.span_label(
|
||||
segment.ident.span,
|
||||
with_forced_trimmed_paths!(format!(
|
||||
"here the type of `{ident}` is inferred to be `{ty}`",
|
||||
)),
|
||||
);}
|
||||
break;
|
||||
} else if !param_args.is_empty() {
|
||||
break;
|
||||
}
|
||||
prev = ty;
|
||||
} else {
|
||||
let ty = eraser.fold_ty(self.node_ty(binding.hir_id));
|
||||
if ty.references_error() {
|
||||
break;
|
||||
}
|
||||
if ty != prev
|
||||
&& let Some(span) = prev_span
|
||||
&& self.can_eq(self.param_env, ty, found)
|
||||
{
|
||||
// We only point at the first place where the found type was inferred.
|
||||
// We use the *previous* span because if the type is known *here* it means
|
||||
// it was *evaluated earlier*. We don't do this for method calls because we
|
||||
// evaluate the method's self type eagerly, but not in any other case.
|
||||
if !span.overlaps(mismatch_span) {
|
||||
err.span_label(
|
||||
span,
|
||||
with_forced_trimmed_paths!(format!(
|
||||
"here the type of `{ident}` is inferred to be `{ty}`",
|
||||
)),
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
prev = ty;
|
||||
}
|
||||
};
|
||||
|
||||
// If our expected_ty does not equal init_ty, then it *began* as incompatible.
|
||||
// No need to note in this case...
|
||||
if !self.can_eq(self.param_env, expected_ty, init_ty.fold_with(&mut fudger)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for window in expr_finder.uses.windows(2) {
|
||||
// Bindings always update their recorded type after the fact, so we
|
||||
// need to look at the *following* usage's type to see when the
|
||||
// binding became incompatible.
|
||||
let [binding, next_usage] = *window else { continue; };
|
||||
|
||||
// Don't go past the binding (always gonna be a nonsense label if so)
|
||||
if binding.hir_id == expr.hir_id {
|
||||
// Do not look at expressions that come after the expression we were originally
|
||||
// evaluating and had a type error.
|
||||
break;
|
||||
}
|
||||
prev_span = Some(binding.span);
|
||||
|
||||
let Some(next_use_ty) = self.node_ty_opt(next_usage.hir_id) else { continue; };
|
||||
|
||||
// If the type is not constrained in a way making it not possible to
|
||||
// equate with `expected_ty` by this point, skip.
|
||||
if self.can_eq(self.param_env, expected_ty, next_use_ty.fold_with(&mut fudger)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let hir::Node::Expr(parent_expr) = hir.get_parent(binding.hir_id)
|
||||
&& let hir::ExprKind::MethodCall(segment, rcvr, args, _) = parent_expr.kind
|
||||
&& rcvr.hir_id == binding.hir_id
|
||||
{
|
||||
// If our binding became incompatible while it was a receiver
|
||||
// to a method call, we may be able to make a better guess to
|
||||
// the source of a type mismatch.
|
||||
let Some(rcvr_ty) = self.node_ty_opt(rcvr.hir_id) else { continue; };
|
||||
let rcvr_ty = rcvr_ty.fold_with(&mut fudger);
|
||||
let Ok(method) =
|
||||
self.lookup_method(rcvr_ty, segment, DUMMY_SP, parent_expr, rcvr, args)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let ideal_rcvr_ty = rcvr_ty.fold_with(&mut fudger);
|
||||
let ideal_method = self
|
||||
.lookup_method(ideal_rcvr_ty, segment, DUMMY_SP, parent_expr, rcvr, args)
|
||||
.ok()
|
||||
.and_then(|method| {
|
||||
let _ = self.at(&ObligationCause::dummy(), self.param_env)
|
||||
.eq(DefineOpaqueTypes::No, ideal_rcvr_ty, expected_ty)
|
||||
.ok()?;
|
||||
Some(method)
|
||||
});
|
||||
|
||||
// Find what argument caused our rcvr to become incompatible
|
||||
// with the expected ty.
|
||||
for (idx, (expected_arg_ty, arg_expr)) in
|
||||
std::iter::zip(&method.sig.inputs()[1..], args).enumerate()
|
||||
{
|
||||
let Some(arg_ty) = self.node_ty_opt(arg_expr.hir_id) else { continue; };
|
||||
let arg_ty = arg_ty.fold_with(&mut fudger);
|
||||
let _ = self.try_coerce(
|
||||
arg_expr,
|
||||
arg_ty,
|
||||
*expected_arg_ty,
|
||||
AllowTwoPhase::No,
|
||||
None,
|
||||
);
|
||||
self.select_obligations_where_possible(|errs| {
|
||||
// Yeet the errors, we're already reporting errors.
|
||||
errs.clear();
|
||||
});
|
||||
// If our rcvr, after inference due to unifying the signature
|
||||
// with the expected argument type, is still compatible with
|
||||
// the rcvr, then it must've not been the source of blame.
|
||||
if self.can_eq(self.param_env, rcvr_ty, expected_ty) {
|
||||
continue;
|
||||
}
|
||||
err.span_label(arg_expr.span, format!("this argument has type `{arg_ty}`..."));
|
||||
err.span_label(
|
||||
binding.span,
|
||||
format!("... which causes `{ident}` to have type `{next_use_ty}`"),
|
||||
);
|
||||
// Using our "ideal" method signature, suggest a fix to this
|
||||
// blame arg, if possible. Don't do this if we're coming from
|
||||
// arg mismatch code, because we'll possibly suggest a mutually
|
||||
// incompatible fix at the original mismatch site.
|
||||
if matches!(source, TypeMismatchSource::Ty(_))
|
||||
&& let Some(ideal_method) = ideal_method
|
||||
{
|
||||
self.emit_type_mismatch_suggestions(
|
||||
err,
|
||||
arg_expr,
|
||||
arg_ty,
|
||||
self.resolve_vars_if_possible(ideal_method.sig.inputs()[idx + 1]),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
err.span_label(
|
||||
binding.span,
|
||||
format!("here the type of `{ident}` is inferred to be `{next_use_ty}`"),
|
||||
);
|
||||
return true;
|
||||
}
|
||||
true
|
||||
|
||||
// We must've not found something that constrained the expr.
|
||||
false
|
||||
}
|
||||
|
||||
fn annotate_expected_due_to_let_ty(
|
||||
|
|
@ -708,7 +732,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
);
|
||||
}
|
||||
|
||||
pub(crate) fn note_result_coercion(
|
||||
pub(crate) fn suggest_coercing_result_via_try_operator(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
expr: &hir::Expr<'tcx>,
|
||||
|
|
@ -2094,3 +2118,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum TypeMismatchSource<'tcx> {
|
||||
/// Expected the binding to have the given type, but it was found to have
|
||||
/// a different type. Find out when that type first became incompatible.
|
||||
Ty(Ty<'tcx>),
|
||||
/// When we fail during method argument checking, try to find out if a previous
|
||||
/// expression has constrained the method's receiver in a way that makes the
|
||||
/// argument's type incompatible.
|
||||
Arg { call_expr: &'tcx hir::Expr<'tcx>, incompatible_arg: usize },
|
||||
}
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
err_code: &str,
|
||||
fn_def_id: Option<DefId>,
|
||||
call_span: Span,
|
||||
call_expr: &hir::Expr<'tcx>,
|
||||
call_expr: &'tcx hir::Expr<'tcx>,
|
||||
) {
|
||||
// Next, let's construct the error
|
||||
let (error_span, full_call_span, call_name, is_method) = match &call_expr.kind {
|
||||
|
|
@ -807,24 +807,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
full_call_span,
|
||||
format!("arguments to this {} are incorrect", call_name),
|
||||
);
|
||||
if let (Some(callee_ty), hir::ExprKind::MethodCall(_, rcvr, _, _)) =
|
||||
(callee_ty, &call_expr.kind)
|
||||
|
||||
if let hir::ExprKind::MethodCall(_, rcvr, _, _) = call_expr.kind
|
||||
&& provided_idx.as_usize() == expected_idx.as_usize()
|
||||
{
|
||||
// Type that would have accepted this argument if it hadn't been inferred earlier.
|
||||
// FIXME: We leave an inference variable for now, but it'd be nice to get a more
|
||||
// specific type to increase the accuracy of the diagnostic.
|
||||
let expected = self.infcx.next_ty_var(TypeVariableOrigin {
|
||||
kind: TypeVariableOriginKind::MiscVariable,
|
||||
span: full_call_span,
|
||||
});
|
||||
self.point_at_expr_source_of_inferred_type(
|
||||
self.note_source_of_type_mismatch_constraint(
|
||||
&mut err,
|
||||
rcvr,
|
||||
expected,
|
||||
callee_ty,
|
||||
provided_arg_span,
|
||||
crate::demand::TypeMismatchSource::Arg {
|
||||
call_expr,
|
||||
incompatible_arg: provided_idx.as_usize(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Call out where the function is defined
|
||||
self.label_fn_like(
|
||||
&mut err,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use std::collections::BTreeMap;
|
||||
use std::iter::Iterator;
|
||||
use std::ops::RangeBounds;
|
||||
use std::vec::Vec;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use rand::RngCore;
|
||||
use std::iter::{repeat, FromIterator};
|
||||
use std::iter::repeat;
|
||||
use test::{black_box, Bencher};
|
||||
|
||||
#[bench]
|
||||
|
|
|
|||
|
|
@ -150,16 +150,13 @@ use core::any::Any;
|
|||
use core::async_iter::AsyncIterator;
|
||||
use core::borrow;
|
||||
use core::cmp::Ordering;
|
||||
use core::convert::{From, TryFrom};
|
||||
use core::error::Error;
|
||||
use core::fmt;
|
||||
use core::future::Future;
|
||||
use core::hash::{Hash, Hasher};
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::iter::FromIterator;
|
||||
use core::iter::{FusedIterator, Iterator};
|
||||
use core::iter::FusedIterator;
|
||||
use core::marker::Tuple;
|
||||
use core::marker::{Unpin, Unsize};
|
||||
use core::marker::Unsize;
|
||||
use core::mem;
|
||||
use core::ops::{
|
||||
CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Generator, GeneratorState, Receiver,
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@
|
|||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use core::fmt;
|
||||
use core::iter::{FromIterator, FusedIterator, InPlaceIterable, SourceIter, TrustedLen};
|
||||
use core::iter::{FusedIterator, InPlaceIterable, SourceIter, TrustedLen};
|
||||
use core::mem::{self, swap, ManuallyDrop};
|
||||
use core::num::NonZeroUsize;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
|
|
@ -263,7 +263,6 @@ mod tests;
|
|||
/// more detailed analysis.
|
||||
///
|
||||
/// [`core::cmp::Reverse`]: core::cmp::Reverse
|
||||
/// [`Ord`]: core::cmp::Ord
|
||||
/// [`Cell`]: core::cell::Cell
|
||||
/// [`RefCell`]: core::cell::RefCell
|
||||
/// [push]: BinaryHeap::push
|
||||
|
|
@ -1418,7 +1417,6 @@ impl<T> FusedIterator for Iter<'_, T> {}
|
|||
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
|
||||
///
|
||||
/// [`into_iter`]: BinaryHeap::into_iter
|
||||
/// [`IntoIterator`]: core::iter::IntoIterator
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[derive(Clone)]
|
||||
pub struct IntoIter<T> {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use core::borrow::Borrow;
|
|||
use core::cmp::Ordering;
|
||||
use core::fmt::{self, Debug};
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::iter::{FromIterator, FusedIterator};
|
||||
use core::iter::FusedIterator;
|
||||
use core::marker::PhantomData;
|
||||
use core::mem::{self, ManuallyDrop};
|
||||
use core::ops::{Bound, Index, RangeBounds};
|
||||
|
|
@ -420,7 +420,6 @@ impl<'a, K: 'a, V: 'a> Default for IterMut<'a, K, V> {
|
|||
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
|
||||
///
|
||||
/// [`into_iter`]: IntoIterator::into_iter
|
||||
/// [`IntoIterator`]: core::iter::IntoIterator
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_insignificant_dtor]
|
||||
pub struct IntoIter<
|
||||
|
|
@ -650,7 +649,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn clear(&mut self) {
|
||||
// avoid moving the allocator
|
||||
mem::drop(BTreeMap {
|
||||
drop(BTreeMap {
|
||||
root: mem::replace(&mut self.root, None),
|
||||
length: mem::replace(&mut self.length, 0),
|
||||
alloc: self.alloc.clone(),
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ use crate::testing::ord_chaos::{Cyclic3, Governed, Governor};
|
|||
use crate::testing::rng::DeterministicRng;
|
||||
use crate::vec::Vec;
|
||||
use std::cmp::Ordering;
|
||||
use std::convert::TryFrom;
|
||||
use std::iter::{self, FromIterator};
|
||||
use std::iter;
|
||||
use std::mem;
|
||||
use std::ops::Bound::{self, Excluded, Included, Unbounded};
|
||||
use std::ops::RangeBounds;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use core::cmp::Ordering::{self, Equal, Greater, Less};
|
|||
use core::cmp::{max, min};
|
||||
use core::fmt::{self, Debug};
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::iter::{FromIterator, FusedIterator, Peekable};
|
||||
use core::iter::{FusedIterator, Peekable};
|
||||
use core::mem::ManuallyDrop;
|
||||
use core::ops::{BitAnd, BitOr, BitXor, RangeBounds, Sub};
|
||||
|
||||
|
|
@ -30,7 +30,6 @@ use crate::alloc::{Allocator, Global};
|
|||
/// Iterators returned by [`BTreeSet::iter`] produce their items in order, and take worst-case
|
||||
/// logarithmic and amortized constant time per item returned.
|
||||
///
|
||||
/// [`Ord`]: core::cmp::Ord
|
||||
/// [`Cell`]: core::cell::Cell
|
||||
/// [`RefCell`]: core::cell::RefCell
|
||||
///
|
||||
|
|
@ -147,7 +146,6 @@ impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
|
|||
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
|
||||
///
|
||||
/// [`into_iter`]: BTreeSet#method.into_iter
|
||||
/// [`IntoIterator`]: core::iter::IntoIterator
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[derive(Debug)]
|
||||
pub struct IntoIter<
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use crate::testing::rng::DeterministicRng;
|
|||
use crate::vec::Vec;
|
||||
use std::cmp::Ordering;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::iter::FromIterator;
|
||||
use std::ops::Bound::{Excluded, Included};
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe};
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
use core::cmp::Ordering;
|
||||
use core::fmt;
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::iter::{FromIterator, FusedIterator};
|
||||
use core::iter::FusedIterator;
|
||||
use core::marker::PhantomData;
|
||||
use core::mem;
|
||||
use core::ptr::NonNull;
|
||||
|
|
@ -130,7 +130,6 @@ impl<T: fmt::Debug> fmt::Debug for IterMut<'_, T> {
|
|||
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
|
||||
///
|
||||
/// [`into_iter`]: LinkedList::into_iter
|
||||
/// [`IntoIterator`]: core::iter::IntoIterator
|
||||
#[derive(Clone)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct IntoIter<T> {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use super::VecDeque;
|
|||
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
|
||||
///
|
||||
/// [`into_iter`]: VecDeque::into_iter
|
||||
/// [`IntoIterator`]: core::iter::IntoIterator
|
||||
#[derive(Clone)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct IntoIter<
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
use core::cmp::{self, Ordering};
|
||||
use core::fmt;
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::iter::{repeat_n, repeat_with, ByRefSized, FromIterator};
|
||||
use core::iter::{repeat_n, repeat_with, ByRefSized};
|
||||
use core::mem::{ManuallyDrop, SizedTypeProperties};
|
||||
use core::ops::{Index, IndexMut, Range, RangeBounds};
|
||||
use core::ptr;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use core::alloc::LayoutError;
|
|||
use core::cmp;
|
||||
use core::intrinsics;
|
||||
use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
|
||||
use core::ops::Drop;
|
||||
use core::ptr::{self, NonNull, Unique};
|
||||
use core::slice;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
//!
|
||||
//! [`Rc`] uses non-atomic reference counting. This means that overhead is very
|
||||
//! low, but an [`Rc`] cannot be sent between threads, and consequently [`Rc`]
|
||||
//! does not implement [`Send`][send]. As a result, the Rust compiler
|
||||
//! does not implement [`Send`]. As a result, the Rust compiler
|
||||
//! will check *at compile time* that you are not sending [`Rc`]s between
|
||||
//! threads. If you need multi-threaded, atomic reference counting, use
|
||||
//! [`sync::Arc`][arc].
|
||||
|
|
@ -232,7 +232,6 @@
|
|||
//! [clone]: Clone::clone
|
||||
//! [`Cell`]: core::cell::Cell
|
||||
//! [`RefCell`]: core::cell::RefCell
|
||||
//! [send]: core::marker::Send
|
||||
//! [arc]: crate::sync::Arc
|
||||
//! [`Deref`]: core::ops::Deref
|
||||
//! [downgrade]: Rc::downgrade
|
||||
|
|
@ -251,13 +250,12 @@ use core::any::Any;
|
|||
use core::borrow;
|
||||
use core::cell::Cell;
|
||||
use core::cmp::Ordering;
|
||||
use core::convert::{From, TryFrom};
|
||||
use core::fmt;
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::intrinsics::abort;
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::iter;
|
||||
use core::marker::{self, PhantomData, Unpin, Unsize};
|
||||
use core::marker::{PhantomData, Unsize};
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::mem::size_of_val;
|
||||
use core::mem::{self, align_of_val_raw, forget};
|
||||
|
|
@ -321,7 +319,7 @@ pub struct Rc<T: ?Sized> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: ?Sized> !marker::Send for Rc<T> {}
|
||||
impl<T: ?Sized> !Send for Rc<T> {}
|
||||
|
||||
// Note that this negative impl isn't strictly necessary for correctness,
|
||||
// as `Rc` transitively contains a `Cell`, which is itself `!Sync`.
|
||||
|
|
@ -329,7 +327,7 @@ impl<T: ?Sized> !marker::Send for Rc<T> {}
|
|||
// having an explicit negative impl is nice for documentation purposes
|
||||
// and results in nicer error messages.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: ?Sized> !marker::Sync for Rc<T> {}
|
||||
impl<T: ?Sized> !Sync for Rc<T> {}
|
||||
|
||||
#[stable(feature = "catch_unwind", since = "1.9.0")]
|
||||
impl<T: RefUnwindSafe + ?Sized> UnwindSafe for Rc<T> {}
|
||||
|
|
@ -1060,7 +1058,7 @@ impl<T: ?Sized> Rc<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "rc_mutate_strong_count", since = "1.53.0")]
|
||||
pub unsafe fn decrement_strong_count(ptr: *const T) {
|
||||
unsafe { mem::drop(Rc::from_raw(ptr)) };
|
||||
unsafe { drop(Rc::from_raw(ptr)) };
|
||||
}
|
||||
|
||||
/// Returns `true` if there are no other `Rc` or [`Weak`] pointers to
|
||||
|
|
@ -1496,7 +1494,7 @@ impl<T> Rc<[T]> {
|
|||
///
|
||||
/// Behavior is undefined should the size be wrong.
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
unsafe fn from_iter_exact(iter: impl iter::Iterator<Item = T>, len: usize) -> Rc<[T]> {
|
||||
unsafe fn from_iter_exact(iter: impl Iterator<Item = T>, len: usize) -> Rc<[T]> {
|
||||
// Panic guard while cloning T elements.
|
||||
// In the event of a panic, elements that have been written
|
||||
// into the new RcBox will be dropped, then the memory freed.
|
||||
|
|
@ -2088,7 +2086,7 @@ impl<T, const N: usize> TryFrom<Rc<[T]>> for Rc<[T; N]> {
|
|||
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
#[stable(feature = "shared_from_iter", since = "1.37.0")]
|
||||
impl<T> iter::FromIterator<T> for Rc<[T]> {
|
||||
impl<T> FromIterator<T> for Rc<[T]> {
|
||||
/// Takes each element in the `Iterator` and collects it into an `Rc<[T]>`.
|
||||
///
|
||||
/// # Performance characteristics
|
||||
|
|
@ -2127,7 +2125,7 @@ impl<T> iter::FromIterator<T> for Rc<[T]> {
|
|||
/// let evens: Rc<[u8]> = (0..10).collect(); // Just a single allocation happens here.
|
||||
/// # assert_eq!(&*evens, &*(0..10).collect::<Vec<_>>());
|
||||
/// ```
|
||||
fn from_iter<I: iter::IntoIterator<Item = T>>(iter: I) -> Self {
|
||||
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
|
||||
ToRcSlice::to_rc_slice(iter.into_iter())
|
||||
}
|
||||
}
|
||||
|
|
@ -2204,9 +2202,9 @@ pub struct Weak<T: ?Sized> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rc_weak", since = "1.4.0")]
|
||||
impl<T: ?Sized> !marker::Send for Weak<T> {}
|
||||
impl<T: ?Sized> !Send for Weak<T> {}
|
||||
#[stable(feature = "rc_weak", since = "1.4.0")]
|
||||
impl<T: ?Sized> !marker::Sync for Weak<T> {}
|
||||
impl<T: ?Sized> !Sync for Weak<T> {}
|
||||
|
||||
#[unstable(feature = "coerce_unsized", issue = "18598")]
|
||||
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@
|
|||
use core::error::Error;
|
||||
use core::fmt;
|
||||
use core::hash;
|
||||
use core::iter::FusedIterator;
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::iter::{from_fn, FromIterator};
|
||||
use core::iter::from_fn;
|
||||
use core::iter::FusedIterator;
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::ops::Add;
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
|
|
|
|||
|
|
@ -11,14 +11,13 @@
|
|||
use core::any::Any;
|
||||
use core::borrow;
|
||||
use core::cmp::Ordering;
|
||||
use core::convert::{From, TryFrom};
|
||||
use core::fmt;
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::hint;
|
||||
use core::intrinsics::abort;
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::iter;
|
||||
use core::marker::{PhantomData, Unpin, Unsize};
|
||||
use core::marker::{PhantomData, Unsize};
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::mem::size_of_val;
|
||||
use core::mem::{self, align_of_val_raw};
|
||||
|
|
@ -188,8 +187,6 @@ macro_rules! acquire {
|
|||
/// [mutex]: ../../std/sync/struct.Mutex.html
|
||||
/// [rwlock]: ../../std/sync/struct.RwLock.html
|
||||
/// [atomic]: core::sync::atomic
|
||||
/// [`Send`]: core::marker::Send
|
||||
/// [`Sync`]: core::marker::Sync
|
||||
/// [deref]: core::ops::Deref
|
||||
/// [downgrade]: Arc::downgrade
|
||||
/// [upgrade]: Weak::upgrade
|
||||
|
|
@ -1241,7 +1238,7 @@ impl<T: ?Sized> Arc<T> {
|
|||
#[inline]
|
||||
#[stable(feature = "arc_mutate_strong_count", since = "1.51.0")]
|
||||
pub unsafe fn decrement_strong_count(ptr: *const T) {
|
||||
unsafe { mem::drop(Arc::from_raw(ptr)) };
|
||||
unsafe { drop(Arc::from_raw(ptr)) };
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -1404,7 +1401,7 @@ impl<T> Arc<[T]> {
|
|||
///
|
||||
/// Behavior is undefined should the size be wrong.
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
unsafe fn from_iter_exact(iter: impl iter::Iterator<Item = T>, len: usize) -> Arc<[T]> {
|
||||
unsafe fn from_iter_exact(iter: impl Iterator<Item = T>, len: usize) -> Arc<[T]> {
|
||||
// Panic guard while cloning T elements.
|
||||
// In the event of a panic, elements that have been written
|
||||
// into the new ArcInner will be dropped, then the memory freed.
|
||||
|
|
@ -2818,7 +2815,7 @@ impl<T, const N: usize> TryFrom<Arc<[T]>> for Arc<[T; N]> {
|
|||
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
#[stable(feature = "shared_from_iter", since = "1.37.0")]
|
||||
impl<T> iter::FromIterator<T> for Arc<[T]> {
|
||||
impl<T> FromIterator<T> for Arc<[T]> {
|
||||
/// Takes each element in the `Iterator` and collects it into an `Arc<[T]>`.
|
||||
///
|
||||
/// # Performance characteristics
|
||||
|
|
@ -2857,7 +2854,7 @@ impl<T> iter::FromIterator<T> for Arc<[T]> {
|
|||
/// let evens: Arc<[u8]> = (0..10).collect(); // Just a single allocation happens here.
|
||||
/// # assert_eq!(&*evens, &*(0..10).collect::<Vec<_>>());
|
||||
/// ```
|
||||
fn from_iter<I: iter::IntoIterator<Item = T>>(iter: I) -> Self {
|
||||
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
|
||||
ToArcSlice::to_arc_slice(iter.into_iter())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::borrow::Cow;
|
||||
use core::iter::FromIterator;
|
||||
|
||||
use super::Vec;
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ impl<T, A: Allocator> IntoIter<T, A> {
|
|||
/// ```
|
||||
/// # let mut into_iter = Vec::<u8>::with_capacity(10).into_iter();
|
||||
/// let mut into_iter = std::mem::replace(&mut into_iter, Vec::new().into_iter());
|
||||
/// (&mut into_iter).for_each(core::mem::drop);
|
||||
/// (&mut into_iter).for_each(drop);
|
||||
/// std::mem::forget(into_iter);
|
||||
/// ```
|
||||
///
|
||||
|
|
|
|||
|
|
@ -56,12 +56,9 @@
|
|||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::cmp;
|
||||
use core::cmp::Ordering;
|
||||
use core::convert::TryFrom;
|
||||
use core::fmt;
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::iter;
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
use core::iter::FromIterator;
|
||||
use core::marker::PhantomData;
|
||||
use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
|
||||
use core::ops::{self, Index, IndexMut, Range, RangeBounds};
|
||||
|
|
@ -2990,7 +2987,7 @@ impl<'a, T: Copy + 'a, A: Allocator + 'a> Extend<&'a T> for Vec<T, A> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Implements comparison of vectors, [lexicographically](core::cmp::Ord#lexicographical-comparison).
|
||||
/// Implements comparison of vectors, [lexicographically](Ord#lexicographical-comparison).
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: PartialOrd, A: Allocator> PartialOrd for Vec<T, A> {
|
||||
#[inline]
|
||||
|
|
@ -3002,7 +2999,7 @@ impl<T: PartialOrd, A: Allocator> PartialOrd for Vec<T, A> {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: Eq, A: Allocator> Eq for Vec<T, A> {}
|
||||
|
||||
/// Implements ordering of vectors, [lexicographically](core::cmp::Ord#lexicographical-comparison).
|
||||
/// Implements ordering of vectors, [lexicographically](Ord#lexicographical-comparison).
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: Ord, A: Allocator> Ord for Vec<T, A> {
|
||||
#[inline]
|
||||
|
|
|
|||
|
|
@ -231,7 +231,8 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Derive macro generating an impl of the trait `PartialEq`.
|
||||
/// Derive macro generating an impl of the trait [`PartialEq`].
|
||||
/// The behavior of this macro is described in detail [here](PartialEq#derivable).
|
||||
#[rustc_builtin_macro]
|
||||
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
|
||||
#[allow_internal_unstable(core_intrinsics, structural_match)]
|
||||
|
|
@ -297,7 +298,7 @@ pub trait Eq: PartialEq<Self> {
|
|||
fn assert_receiver_is_total_eq(&self) {}
|
||||
}
|
||||
|
||||
/// Derive macro generating an impl of the trait `Eq`.
|
||||
/// Derive macro generating an impl of the trait [`Eq`].
|
||||
#[rustc_builtin_macro]
|
||||
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
|
||||
#[allow_internal_unstable(core_intrinsics, derive_eq, structural_match, no_coverage)]
|
||||
|
|
@ -859,7 +860,8 @@ pub trait Ord: Eq + PartialOrd<Self> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Derive macro generating an impl of the trait `Ord`.
|
||||
/// Derive macro generating an impl of the trait [`Ord`].
|
||||
/// The behavior of this macro is described in detail [here](Ord#derivable).
|
||||
#[rustc_builtin_macro]
|
||||
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
|
||||
#[allow_internal_unstable(core_intrinsics)]
|
||||
|
|
@ -1138,7 +1140,8 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Derive macro generating an impl of the trait `PartialOrd`.
|
||||
/// Derive macro generating an impl of the trait [`PartialOrd`].
|
||||
/// The behavior of this macro is described in detail [here](PartialOrd#derivable).
|
||||
#[rustc_builtin_macro]
|
||||
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
|
||||
#[allow_internal_unstable(core_intrinsics)]
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@
|
|||
//! - The exception is the last arm, which must be `_ => basic_block` and corresponds to the
|
||||
//! otherwise branch.
|
||||
//! - [`Call`] has an associated function as well. The third argument of this function is a normal
|
||||
//! function call expresion, for example `my_other_function(a, 5)`.
|
||||
//! function call expression, for example `my_other_function(a, 5)`.
|
||||
//!
|
||||
|
||||
#![unstable(
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ use crate::ops::Try;
|
|||
/// please open a GitHub issue explaining your use case.
|
||||
///
|
||||
/// [`repeat()`]: crate::iter::repeat
|
||||
/// [`DoubleEndedIterator`]: crate::iter::DoubleEndedIterator
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
|||
|
|
@ -764,7 +764,6 @@ pub trait Iterator {
|
|||
/// more idiomatic to use [`for`] than `map()`.
|
||||
///
|
||||
/// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
|
||||
/// [`FnMut`]: crate::ops::FnMut
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::fmt;
|
|||
use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||
use crate::str::FromStr;
|
||||
|
||||
trait ReadNumberHelper: crate::marker::Sized {
|
||||
trait ReadNumberHelper: Sized {
|
||||
const ZERO: Self;
|
||||
fn checked_mul(&self, other: u32) -> Option<Self>;
|
||||
fn checked_add(&self, other: u32) -> Option<Self>;
|
||||
|
|
|
|||
|
|
@ -15,14 +15,10 @@ use crate::panic::Location;
|
|||
/// use std::panic;
|
||||
///
|
||||
/// panic::set_hook(Box::new(|panic_info| {
|
||||
/// if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
|
||||
/// println!("panic occurred: {s:?}");
|
||||
/// } else {
|
||||
/// println!("panic occurred");
|
||||
/// }
|
||||
/// println!("panic occurred: {panic_info}");
|
||||
/// }));
|
||||
///
|
||||
/// panic!("Normal panic");
|
||||
/// panic!("critical system failure");
|
||||
/// ```
|
||||
#[lang = "panic_info"]
|
||||
#[stable(feature = "panic_hooks", since = "1.10.0")]
|
||||
|
|
|
|||
|
|
@ -577,7 +577,6 @@ impl Copy for () {
|
|||
/// [`is_null`]: pointer::is_null
|
||||
/// [`offset`]: pointer::offset
|
||||
#[doc = concat!("[`into_raw`]: ", include_str!("../primitive_docs/box_into_raw.md"))]
|
||||
/// [`drop`]: mem::drop
|
||||
/// [`write`]: ptr::write
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_pointer {}
|
||||
|
|
@ -1026,7 +1025,6 @@ mod prim_str {}
|
|||
/// * [`UnwindSafe`]
|
||||
/// * [`RefUnwindSafe`]
|
||||
///
|
||||
/// [`Unpin`]: marker::Unpin
|
||||
/// [`UnwindSafe`]: panic::UnwindSafe
|
||||
/// [`RefUnwindSafe`]: panic::RefUnwindSafe
|
||||
///
|
||||
|
|
@ -1405,10 +1403,6 @@ mod prim_ref {}
|
|||
///
|
||||
/// *See also the traits [`Fn`], [`FnMut`], and [`FnOnce`].*
|
||||
///
|
||||
/// [`Fn`]: ops::Fn
|
||||
/// [`FnMut`]: ops::FnMut
|
||||
/// [`FnOnce`]: ops::FnOnce
|
||||
///
|
||||
/// Function pointers are pointers that point to *code*, not data. They can be called
|
||||
/// just like functions. Like references, function pointers are, among other things, assumed to
|
||||
/// not be null, so if you want to pass a function pointer over FFI and be able to accommodate null
|
||||
|
|
|
|||
|
|
@ -1486,7 +1486,7 @@ where
|
|||
}
|
||||
|
||||
/// Finds a streak of presorted elements starting at the beginning of the slice. Returns the first
|
||||
/// value that is not part of said streak, and a bool denoting wether the streak was reversed.
|
||||
/// value that is not part of said streak, and a bool denoting whether the streak was reversed.
|
||||
/// Streaks can be increasing or decreasing.
|
||||
fn find_streak<T, F>(v: &[T], is_less: &mut F) -> (usize, bool)
|
||||
where
|
||||
|
|
|
|||
|
|
@ -1891,7 +1891,7 @@ unsafe fn small_slice_eq(x: &[u8], y: &[u8]) -> bool {
|
|||
|
||||
// SAFETY: Via the conditional above, we know that both `px` and `py`
|
||||
// have the same length, so `px < pxend` implies that `py < pyend`.
|
||||
// Thus, derefencing both `px` and `py` in the loop below is safe.
|
||||
// Thus, dereferencing both `px` and `py` in the loop below is safe.
|
||||
//
|
||||
// Moreover, we set `pxend` and `pyend` to be 4 bytes before the actual
|
||||
// end of `px` and `py`. Thus, the final dereference outside of the
|
||||
|
|
|
|||
|
|
@ -69,9 +69,6 @@ use core::task::{Context, Poll};
|
|||
/// for any value. This is a parallel with the fact that
|
||||
/// `&` and `&mut` references together can be thought of as a _compile-time_
|
||||
/// version of a read-write lock.
|
||||
///
|
||||
///
|
||||
/// [`Sync`]: core::marker::Sync
|
||||
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
|
||||
#[doc(alias = "SyncWrapper")]
|
||||
#[doc(alias = "SyncCell")]
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<T, const LANES: usize> core::convert::From<Mask<T, LANES>> for Simd<T, LANES>
|
||||
impl<T, const LANES: usize> From<Mask<T, LANES>> for Simd<T, LANES>
|
||||
where
|
||||
T: MaskElement,
|
||||
LaneCount<LANES>: SupportedLaneCount,
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@
|
|||
//! on the `rustc_hash` crate.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryInto;
|
||||
use std::default::Default;
|
||||
use std::hash::BuildHasherDefault;
|
||||
use std::hash::Hasher;
|
||||
use std::mem::size_of;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ use std::cmp::Ordering;
|
|||
use std::ops::RangeBounds;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::{error, fmt, iter};
|
||||
use std::{error, fmt};
|
||||
|
||||
/// Determines whether proc_macro has been made accessible to the currently
|
||||
/// running program.
|
||||
|
|
@ -310,7 +310,7 @@ impl ConcatStreamsHelper {
|
|||
|
||||
/// Collects a number of token trees into a single stream.
|
||||
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
|
||||
impl iter::FromIterator<TokenTree> for TokenStream {
|
||||
impl FromIterator<TokenTree> for TokenStream {
|
||||
fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self {
|
||||
let iter = trees.into_iter();
|
||||
let mut builder = ConcatTreesHelper::new(iter.size_hint().0);
|
||||
|
|
@ -322,7 +322,7 @@ impl iter::FromIterator<TokenTree> for TokenStream {
|
|||
/// A "flattening" operation on token streams, collects token trees
|
||||
/// from multiple token streams into a single stream.
|
||||
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
|
||||
impl iter::FromIterator<TokenStream> for TokenStream {
|
||||
impl FromIterator<TokenStream> for TokenStream {
|
||||
fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self {
|
||||
let iter = streams.into_iter();
|
||||
let mut builder = ConcatStreamsHelper::new(iter.size_hint().0);
|
||||
|
|
|
|||
|
|
@ -1446,7 +1446,6 @@ impl<'a, K, V> IterMut<'a, K, V> {
|
|||
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
|
||||
///
|
||||
/// [`into_iter`]: IntoIterator::into_iter
|
||||
/// [`IntoIterator`]: crate::iter::IntoIterator
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1272,7 +1272,6 @@ pub struct Iter<'a, K: 'a> {
|
|||
/// (provided by the [`IntoIterator`] trait). See its documentation for more.
|
||||
///
|
||||
/// [`into_iter`]: IntoIterator::into_iter
|
||||
/// [`IntoIterator`]: crate::iter::IntoIterator
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
|||
|
|
@ -398,8 +398,6 @@
|
|||
//! // ...but the key hasn't changed. b is still "baz", not "xyz".
|
||||
//! assert_eq!(map.keys().next().unwrap().b, "baz");
|
||||
//! ```
|
||||
//!
|
||||
//! [IntoIterator]: crate::iter::IntoIterator "iter::IntoIterator"
|
||||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use crate::cmp;
|
|||
use crate::collections::TryReserveError;
|
||||
use crate::fmt;
|
||||
use crate::hash::{Hash, Hasher};
|
||||
use crate::iter::Extend;
|
||||
use crate::ops;
|
||||
use crate::rc::Rc;
|
||||
use crate::str::FromStr;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ mod repr_unpacked;
|
|||
#[cfg(not(target_pointer_width = "64"))]
|
||||
use repr_unpacked::Repr;
|
||||
|
||||
use crate::convert::From;
|
||||
use crate::error;
|
||||
use crate::fmt;
|
||||
use crate::result;
|
||||
|
|
|
|||
|
|
@ -1678,7 +1678,7 @@ mod super_keyword {}
|
|||
/// below `Iterator` is a **supertrait** and `ThreeIterator` is a **subtrait**:
|
||||
///
|
||||
/// ```rust
|
||||
/// trait ThreeIterator: std::iter::Iterator {
|
||||
/// trait ThreeIterator: Iterator {
|
||||
/// fn next_three(&mut self) -> Option<[Self::Item; 3]>;
|
||||
/// }
|
||||
/// ```
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ use crate::fmt;
|
|||
use crate::fs;
|
||||
use crate::hash::{Hash, Hasher};
|
||||
use crate::io;
|
||||
use crate::iter::{self, FusedIterator};
|
||||
use crate::iter::FusedIterator;
|
||||
use crate::ops::{self, Deref};
|
||||
use crate::rc::Rc;
|
||||
use crate::str::FromStr;
|
||||
|
|
@ -450,26 +450,26 @@ impl<'a> PrefixComponent<'a> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a> cmp::PartialEq for PrefixComponent<'a> {
|
||||
impl<'a> PartialEq for PrefixComponent<'a> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &PrefixComponent<'a>) -> bool {
|
||||
cmp::PartialEq::eq(&self.parsed, &other.parsed)
|
||||
self.parsed == other.parsed
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a> cmp::PartialOrd for PrefixComponent<'a> {
|
||||
impl<'a> PartialOrd for PrefixComponent<'a> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &PrefixComponent<'a>) -> Option<cmp::Ordering> {
|
||||
cmp::PartialOrd::partial_cmp(&self.parsed, &other.parsed)
|
||||
PartialOrd::partial_cmp(&self.parsed, &other.parsed)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl cmp::Ord for PrefixComponent<'_> {
|
||||
impl Ord for PrefixComponent<'_> {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
||||
cmp::Ord::cmp(&self.parsed, &other.parsed)
|
||||
Ord::cmp(&self.parsed, &other.parsed)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -988,7 +988,7 @@ impl<'a> DoubleEndedIterator for Components<'a> {
|
|||
impl FusedIterator for Components<'_> {}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a> cmp::PartialEq for Components<'a> {
|
||||
impl<'a> PartialEq for Components<'a> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &Components<'a>) -> bool {
|
||||
let Components { path: _, front: _, back: _, has_physical_root: _, prefix: _ } = self;
|
||||
|
|
@ -1015,10 +1015,10 @@ impl<'a> cmp::PartialEq for Components<'a> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl cmp::Eq for Components<'_> {}
|
||||
impl Eq for Components<'_> {}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a> cmp::PartialOrd for Components<'a> {
|
||||
impl<'a> PartialOrd for Components<'a> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Components<'a>) -> Option<cmp::Ordering> {
|
||||
Some(compare_components(self.clone(), other.clone()))
|
||||
|
|
@ -1026,7 +1026,7 @@ impl<'a> cmp::PartialOrd for Components<'a> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl cmp::Ord for Components<'_> {
|
||||
impl Ord for Components<'_> {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
||||
compare_components(self.clone(), other.clone())
|
||||
|
|
@ -1741,7 +1741,7 @@ impl FromStr for PathBuf {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<P: AsRef<Path>> iter::FromIterator<P> for PathBuf {
|
||||
impl<P: AsRef<Path>> FromIterator<P> for PathBuf {
|
||||
fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> PathBuf {
|
||||
let mut buf = PathBuf::new();
|
||||
buf.extend(iter);
|
||||
|
|
@ -1750,7 +1750,7 @@ impl<P: AsRef<Path>> iter::FromIterator<P> for PathBuf {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<P: AsRef<Path>> iter::Extend<P> for PathBuf {
|
||||
impl<P: AsRef<Path>> Extend<P> for PathBuf {
|
||||
fn extend<I: IntoIterator<Item = P>>(&mut self, iter: I) {
|
||||
iter.into_iter().for_each(move |p| self.push(p.as_ref()));
|
||||
}
|
||||
|
|
@ -1904,7 +1904,7 @@ impl ToOwned for Path {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl cmp::PartialEq for PathBuf {
|
||||
impl PartialEq for PathBuf {
|
||||
#[inline]
|
||||
fn eq(&self, other: &PathBuf) -> bool {
|
||||
self.components() == other.components()
|
||||
|
|
@ -1919,10 +1919,10 @@ impl Hash for PathBuf {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl cmp::Eq for PathBuf {}
|
||||
impl Eq for PathBuf {}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl cmp::PartialOrd for PathBuf {
|
||||
impl PartialOrd for PathBuf {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &PathBuf) -> Option<cmp::Ordering> {
|
||||
Some(compare_components(self.components(), other.components()))
|
||||
|
|
@ -1930,7 +1930,7 @@ impl cmp::PartialOrd for PathBuf {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl cmp::Ord for PathBuf {
|
||||
impl Ord for PathBuf {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &PathBuf) -> cmp::Ordering {
|
||||
compare_components(self.components(), other.components())
|
||||
|
|
@ -3025,7 +3025,7 @@ impl fmt::Display for Display<'_> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl cmp::PartialEq for Path {
|
||||
impl PartialEq for Path {
|
||||
#[inline]
|
||||
fn eq(&self, other: &Path) -> bool {
|
||||
self.components() == other.components()
|
||||
|
|
@ -3084,10 +3084,10 @@ impl Hash for Path {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl cmp::Eq for Path {}
|
||||
impl Eq for Path {}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl cmp::PartialOrd for Path {
|
||||
impl PartialOrd for Path {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Path) -> Option<cmp::Ordering> {
|
||||
Some(compare_components(self.components(), other.components()))
|
||||
|
|
@ -3095,7 +3095,7 @@ impl cmp::PartialOrd for Path {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl cmp::Ord for Path {
|
||||
impl Ord for Path {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Path) -> cmp::Ordering {
|
||||
compare_components(self.components(), other.components())
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
//! marker traits that indicate fundamental properties of types.
|
||||
//! * <code>[std::ops]::{[Drop], [Fn], [FnMut], [FnOnce]}</code>, various
|
||||
//! operations for both destructors and overloading `()`.
|
||||
//! * <code>[std::mem]::[drop][mem::drop]</code>, a convenience function for explicitly
|
||||
//! * <code>[std::mem]::[drop]</code>, a convenience function for explicitly
|
||||
//! dropping a value.
|
||||
//! * <code>[std::boxed]::[Box]</code>, a way to allocate values on the heap.
|
||||
//! * <code>[std::borrow]::[ToOwned]</code>, the conversion trait that defines
|
||||
|
|
@ -66,7 +66,6 @@
|
|||
//! * <code>[std::convert]::{[TryFrom], [TryInto]}</code>,
|
||||
//! * <code>[std::iter]::[FromIterator]</code>.
|
||||
//!
|
||||
//! [mem::drop]: crate::mem::drop
|
||||
//! [std::borrow]: crate::borrow
|
||||
//! [std::boxed]: crate::boxed
|
||||
//! [std::clone]: crate::clone
|
||||
|
|
@ -86,9 +85,6 @@
|
|||
//! [std::slice]: crate::slice
|
||||
//! [std::string]: crate::string
|
||||
//! [std::vec]: mod@crate::vec
|
||||
//! [TryFrom]: crate::convert::TryFrom
|
||||
//! [TryInto]: crate::convert::TryInto
|
||||
//! [FromIterator]: crate::iter::FromIterator
|
||||
//! [`to_owned`]: crate::borrow::ToOwned::to_owned
|
||||
//! [book-closures]: ../../book/ch13-01-closures.html
|
||||
//! [book-dtor]: ../../book/ch15-03-drop.html
|
||||
|
|
|
|||
|
|
@ -577,7 +577,6 @@ impl Copy for () {
|
|||
/// [`is_null`]: pointer::is_null
|
||||
/// [`offset`]: pointer::offset
|
||||
#[doc = concat!("[`into_raw`]: ", include_str!("../primitive_docs/box_into_raw.md"))]
|
||||
/// [`drop`]: mem::drop
|
||||
/// [`write`]: ptr::write
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_pointer {}
|
||||
|
|
@ -1026,7 +1025,6 @@ mod prim_str {}
|
|||
/// * [`UnwindSafe`]
|
||||
/// * [`RefUnwindSafe`]
|
||||
///
|
||||
/// [`Unpin`]: marker::Unpin
|
||||
/// [`UnwindSafe`]: panic::UnwindSafe
|
||||
/// [`RefUnwindSafe`]: panic::RefUnwindSafe
|
||||
///
|
||||
|
|
@ -1405,10 +1403,6 @@ mod prim_ref {}
|
|||
///
|
||||
/// *See also the traits [`Fn`], [`FnMut`], and [`FnOnce`].*
|
||||
///
|
||||
/// [`Fn`]: ops::Fn
|
||||
/// [`FnMut`]: ops::FnMut
|
||||
/// [`FnOnce`]: ops::FnOnce
|
||||
///
|
||||
/// Function pointers are pointers that point to *code*, not data. They can be called
|
||||
/// just like functions. Like references, function pointers are, among other things, assumed to
|
||||
/// not be null, so if you want to pass a function pointer over FFI and be able to accommodate null
|
||||
|
|
|
|||
|
|
@ -652,10 +652,19 @@ impl Command {
|
|||
self
|
||||
}
|
||||
|
||||
/// Inserts or updates an environment variable mapping.
|
||||
/// Inserts or updates an explicit environment variable mapping.
|
||||
///
|
||||
/// Note that environment variable names are case-insensitive (but case-preserving) on Windows,
|
||||
/// and case-sensitive on all other platforms.
|
||||
/// This method allows you to add an environment variable mapping to the spawned process or
|
||||
/// overwrite a previously set value. You can use [`Command::envs`] to set multiple environment
|
||||
/// variables simultaneously.
|
||||
///
|
||||
/// Child processes will inherit environment variables from their parent process by default.
|
||||
/// Environment variables explicitly set using [`Command::env`] take precedence over inherited
|
||||
/// variables. You can disable environment variable inheritance entirely using
|
||||
/// [`Command::env_clear`] or for a single key using [`Command::env_remove`].
|
||||
///
|
||||
/// Note that environment variable names are case-insensitive (but
|
||||
/// case-preserving) on Windows and case-sensitive on all other platforms.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
@ -679,7 +688,19 @@ impl Command {
|
|||
self
|
||||
}
|
||||
|
||||
/// Adds or updates multiple environment variable mappings.
|
||||
/// Inserts or updates multiple explicit environment variable mappings.
|
||||
///
|
||||
/// This method allows you to add multiple environment variable mappings to the spawned process
|
||||
/// or overwrite previously set values. You can use [`Command::env`] to set a single environment
|
||||
/// variable.
|
||||
///
|
||||
/// Child processes will inherit environment variables from their parent process by default.
|
||||
/// Environment variables explicitly set using [`Command::envs`] take precedence over inherited
|
||||
/// variables. You can disable environment variable inheritance entirely using
|
||||
/// [`Command::env_clear`] or for a single key using [`Command::env_remove`].
|
||||
///
|
||||
/// Note that environment variable names are case-insensitive (but case-preserving) on Windows
|
||||
/// and case-sensitive on all other platforms.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
@ -716,7 +737,18 @@ impl Command {
|
|||
self
|
||||
}
|
||||
|
||||
/// Removes an environment variable mapping.
|
||||
/// Removes an explicitly set environment variable and prevents inheriting it from a parent
|
||||
/// process.
|
||||
///
|
||||
/// This method will remove the explicit value of an environment variable set via
|
||||
/// [`Command::env`] or [`Command::envs`]. In addition, it will prevent the spawned child
|
||||
/// process from inheriting that environment variable from its parent process.
|
||||
///
|
||||
/// After calling [`Command::env_remove`], the value associated with its key from
|
||||
/// [`Command::get_envs`] will be [`None`].
|
||||
///
|
||||
/// To clear all explicitly set environment variables and disable all environment variable
|
||||
/// inheritance, you can use [`Command::env_clear`].
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
@ -736,7 +768,17 @@ impl Command {
|
|||
self
|
||||
}
|
||||
|
||||
/// Clears the entire environment map for the child process.
|
||||
/// Clears all explicitly set environment variables and prevents inheriting any parent process
|
||||
/// environment variables.
|
||||
///
|
||||
/// This method will remove all explicitly added environment variables set via [`Command::env`]
|
||||
/// or [`Command::envs`]. In addition, it will prevent the spawned child process from inheriting
|
||||
/// any environment variable from its parent process.
|
||||
///
|
||||
/// After calling [`Command::env_remove`], the iterator from [`Command::get_envs`] will be
|
||||
/// empty.
|
||||
///
|
||||
/// You can use [`Command::env_remove`] to clear a single mapping.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
@ -988,17 +1030,21 @@ impl Command {
|
|||
CommandArgs { inner: self.inner.get_args() }
|
||||
}
|
||||
|
||||
/// Returns an iterator of the environment variables that will be set when
|
||||
/// the process is spawned.
|
||||
/// Returns an iterator of the environment variables explicitly set for the child process.
|
||||
///
|
||||
/// Each element is a tuple `(&OsStr, Option<&OsStr>)`, where the first
|
||||
/// value is the key, and the second is the value, which is [`None`] if
|
||||
/// the environment variable is to be explicitly removed.
|
||||
/// Environment variables explicitly set using [`Command::env`], [`Command::envs`], and
|
||||
/// [`Command::env_remove`] can be retrieved with this method.
|
||||
///
|
||||
/// This only includes environment variables explicitly set with
|
||||
/// [`Command::env`], [`Command::envs`], and [`Command::env_remove`]. It
|
||||
/// does not include environment variables that will be inherited by the
|
||||
/// child process.
|
||||
/// Note that this output does not include environment variables inherited from the parent
|
||||
/// process.
|
||||
///
|
||||
/// Each element is a tuple key/value pair `(&OsStr, Option<&OsStr>)`. A [`None`] value
|
||||
/// indicates its key was explicitly removed via [`Command::env_remove`]. The associated key for
|
||||
/// the [`None`] value will no longer inherit from its parent process.
|
||||
///
|
||||
/// An empty iterator can indicate that no explicit mappings were added or that
|
||||
/// [`Command::env_clear`] was called. After calling [`Command::env_clear`], the child process
|
||||
/// will not inherit any environment variables from its parent process.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
use crate::arch::asm;
|
||||
use crate::cell::UnsafeCell;
|
||||
use crate::cmp;
|
||||
use crate::convert::TryInto;
|
||||
use crate::mem;
|
||||
use crate::ops::{CoerceUnsized, Deref, DerefMut, Index, IndexMut};
|
||||
use crate::ptr::{self, NonNull};
|
||||
|
|
|
|||
|
|
@ -1893,7 +1893,7 @@ mod remove_dir_impl {
|
|||
// file descriptor is automatically closed by libc::closedir() now, so give up ownership
|
||||
let new_parent_fd = dir_fd.into_raw_fd();
|
||||
// a valid root is not needed because we do not call any functions involving the full path
|
||||
// of the DirEntrys.
|
||||
// of the `DirEntry`s.
|
||||
let dummy_root = PathBuf::new();
|
||||
let inner = InnerReadDir { dirp, root: dummy_root };
|
||||
Ok((ReadDir::new(inner), new_parent_fd))
|
||||
|
|
|
|||
|
|
@ -273,8 +273,6 @@ pub mod zircon {
|
|||
|
||||
#[cfg(target_os = "fuchsia")]
|
||||
pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -> bool {
|
||||
use crate::convert::TryFrom;
|
||||
|
||||
// Sleep forever if the timeout is longer than fits in a i64.
|
||||
let deadline = timeout
|
||||
.and_then(|d| {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ mod tests;
|
|||
|
||||
use crate::os::unix::prelude::*;
|
||||
|
||||
use crate::convert::TryFrom;
|
||||
use crate::error::Error as StdError;
|
||||
use crate::ffi::{CStr, CString, OsStr, OsString};
|
||||
use crate::fmt;
|
||||
|
|
|
|||
|
|
@ -166,7 +166,6 @@ impl Process {
|
|||
}
|
||||
|
||||
pub fn wait(&mut self) -> io::Result<ExitStatus> {
|
||||
use crate::default::Default;
|
||||
use crate::sys::process::zircon::*;
|
||||
|
||||
let mut proc_info: zx_info_process_t = Default::default();
|
||||
|
|
@ -199,7 +198,6 @@ impl Process {
|
|||
}
|
||||
|
||||
pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
|
||||
use crate::default::Default;
|
||||
use crate::sys::process::zircon::*;
|
||||
|
||||
let mut proc_info: zx_info_process_t = Default::default();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ pub const ERROR_RESOURCE_CALL_TIMED_OUT: DWORD = 5910;
|
|||
pub const FRS_ERR_SYSVOL_POPULATE_TIMEOUT: DWORD = 8014;
|
||||
pub const DNS_ERROR_RECORD_TIMED_OUT: DWORD = 9705;
|
||||
|
||||
// The followiung list was obtained from
|
||||
// The following list was obtained from
|
||||
// `/usr/x86_64-w64-mingw32/include/winerror.h`
|
||||
// in the Debian package
|
||||
// mingw-w64_6.0.0-3_all.deb
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
mod tests;
|
||||
|
||||
use crate::cmp;
|
||||
use crate::convert::{TryFrom, TryInto};
|
||||
use crate::fmt;
|
||||
use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut};
|
||||
use crate::mem;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ impl Parker {
|
|||
park_timeout(dur, self.state.as_ptr().addr());
|
||||
// Swap to ensure that we observe all state changes with acquire
|
||||
// ordering, even if the state has been changed after the timeout
|
||||
// occured.
|
||||
// occurred.
|
||||
self.state.swap(EMPTY, Acquire);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,14 +219,14 @@ pub fn assert_test_result<T: Termination>(result: T) -> Result<(), String> {
|
|||
|
||||
struct FilteredTests {
|
||||
tests: Vec<(TestId, TestDescAndFn)>,
|
||||
benchs: Vec<(TestId, TestDescAndFn)>,
|
||||
benches: Vec<(TestId, TestDescAndFn)>,
|
||||
next_id: usize,
|
||||
}
|
||||
|
||||
impl FilteredTests {
|
||||
fn add_bench(&mut self, desc: TestDesc, testfn: TestFn) {
|
||||
let test = TestDescAndFn { desc, testfn };
|
||||
self.benchs.push((TestId(self.next_id), test));
|
||||
self.benches.push((TestId(self.next_id), test));
|
||||
self.next_id += 1;
|
||||
}
|
||||
fn add_test(&mut self, desc: TestDesc, testfn: TestFn) {
|
||||
|
|
@ -245,7 +245,7 @@ impl FilteredTests {
|
|||
self.add_test(desc, testfn);
|
||||
}
|
||||
fn total_len(&self) -> usize {
|
||||
self.tests.len() + self.benchs.len()
|
||||
self.tests.len() + self.benches.len()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -290,7 +290,7 @@ where
|
|||
|
||||
let tests_len = tests.len();
|
||||
|
||||
let mut filtered = FilteredTests { tests: Vec::new(), benchs: Vec::new(), next_id: 0 };
|
||||
let mut filtered = FilteredTests { tests: Vec::new(), benches: Vec::new(), next_id: 0 };
|
||||
|
||||
for test in filter_tests(opts, tests) {
|
||||
let mut desc = test.desc;
|
||||
|
|
@ -457,7 +457,7 @@ where
|
|||
|
||||
if opts.bench_benchmarks {
|
||||
// All benchmarks run at the end, in serial.
|
||||
for (id, b) in filtered.benchs {
|
||||
for (id, b) in filtered.benches {
|
||||
let event = TestEvent::TeWait(b.desc.clone());
|
||||
notify_about_test_event(event)?;
|
||||
let join_handle = run_test(opts, false, id, b, run_strategy, tx.clone());
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
use std::any::{Any, TypeId};
|
||||
use std::borrow::Borrow;
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::{Ord, Ordering, PartialOrd};
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::AsRef;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::marker::PhantomData;
|
||||
|
|
|
|||
|
|
@ -103,6 +103,13 @@ macro_rules! foo {
|
|||
}
|
||||
```
|
||||
|
||||
There is one case where the disambiguation will be performed automatically: if an intra doc
|
||||
link is resolved at the same time as a trait and as a derive proc-macro. In this case, it'll
|
||||
always generate a link to the trait and not emit a "missing disambiguation" warning. A good
|
||||
example of this case is when you link to the `Clone` trait: there is also a `Clone`
|
||||
proc-macro but it ignores it in this case. If you want to link to the proc-macro, you can
|
||||
use the `macro@` disambiguator.
|
||||
|
||||
## Warnings, re-exports, and scoping
|
||||
|
||||
Links are resolved in the scope of the module where the item is defined, even
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ use rustc_span::{self, ExpnKind};
|
|||
use std::borrow::Cow;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::BTreeMap;
|
||||
use std::default::Default;
|
||||
use std::hash::Hash;
|
||||
use std::mem;
|
||||
use thin_vec::ThinVec;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use std::borrow::Cow;
|
||||
use std::cell::RefCell;
|
||||
use std::default::Default;
|
||||
use std::hash::Hash;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
|
|
@ -980,7 +979,7 @@ pub(crate) trait NestedAttributesExt {
|
|||
/// Returns `true` if the attribute list contains a specific `word`
|
||||
fn has_word(self, word: Symbol) -> bool
|
||||
where
|
||||
Self: std::marker::Sized,
|
||||
Self: Sized,
|
||||
{
|
||||
<Self as NestedAttributesExt>::get_word_attr(self, word).is_some()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use std::collections::BTreeMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::ffi::OsStr;
|
||||
use std::fmt;
|
||||
use std::path::PathBuf;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ use rustc_span::{Span, Symbol};
|
|||
use once_cell::sync::Lazy;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::VecDeque;
|
||||
use std::default::Default;
|
||||
use std::fmt::Write;
|
||||
use std::ops::{ControlFlow, Range};
|
||||
use std::str;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ pub(crate) use self::context::*;
|
|||
pub(crate) use self::span_map::{collect_spans_and_sources, LinkFromSrc};
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::default::Default;
|
||||
use std::fmt::{self, Write};
|
||||
use std::fs;
|
||||
use std::iter::Peekable;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ pub(crate) fn build_index<'tcx>(
|
|||
// `sort_unstable_by_key` produces lifetime errors
|
||||
let k1 = (&k1.path, k1.name.as_str(), &k1.ty, &k1.parent);
|
||||
let k2 = (&k2.path, k2.name.as_str(), &k2.ty, &k2.parent);
|
||||
std::cmp::Ord::cmp(&k1, &k2)
|
||||
Ord::cmp(&k1, &k2)
|
||||
});
|
||||
|
||||
// Set up alias indexes.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#![allow(rustc::default_hash_types)]
|
||||
|
||||
use std::convert::From;
|
||||
use std::fmt;
|
||||
|
||||
use rustc_ast::ast;
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ extern crate test;
|
|||
#[cfg(feature = "jemalloc")]
|
||||
extern crate jemalloc_sys;
|
||||
|
||||
use std::default::Default;
|
||||
use std::env::{self, VarError};
|
||||
use std::io::{self, IsTerminal};
|
||||
use std::process;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ use anyhow::{Context, Error};
|
|||
use curl::easy::Easy;
|
||||
use indexmap::IndexMap;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryInto;
|
||||
|
||||
const PATH: &str = "src/stage0.json";
|
||||
const COMPILER_COMPONENTS: &[&str] = &["rustc", "rust-std", "cargo"];
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ mod os_impl {
|
|||
match fs::File::create(&path) {
|
||||
Ok(file) => {
|
||||
let exec = is_executable(&path).unwrap_or(false);
|
||||
std::mem::drop(file);
|
||||
std::fs::remove_file(&path).expect("Deleted temp file");
|
||||
drop(file);
|
||||
fs::remove_file(&path).expect("Deleted temp file");
|
||||
// If the file is executable, then we assume that this
|
||||
// filesystem does not track executability, so skip this check.
|
||||
return if exec { Unsupported } else { Supported };
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
//! this in the long term.
|
||||
|
||||
use crate::walk::{filter_dirs, walk};
|
||||
use std::iter::Iterator;
|
||||
use std::path::Path;
|
||||
|
||||
// Paths that may contain platform-specific code.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use crate::fmt_list;
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap};
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::{self, Write};
|
||||
use std::ops::Range;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use crate::fmt_list;
|
||||
use crate::raw_emitter::RawEmitter;
|
||||
use std::convert::TryInto;
|
||||
use std::fmt::Write as _;
|
||||
use std::ops::Range;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
thread 'main' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:525:5
|
||||
thread 'main' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:524:5
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
|
|
|||
|
|
@ -67,9 +67,6 @@ LL | x == 5
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/assignment-in-if.rs:44:18
|
||||
|
|
||||
LL | if y = (Foo { foo: x }) {
|
||||
| - here the type of `x` is inferred to be `usize`
|
||||
...
|
||||
LL | if x == x && x = x && x == x {
|
||||
| ------ ^ expected `bool`, found `usize`
|
||||
| |
|
||||
|
|
@ -78,9 +75,6 @@ LL | if x == x && x = x && x == x {
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/assignment-in-if.rs:44:22
|
||||
|
|
||||
LL | if y = (Foo { foo: x }) {
|
||||
| - here the type of `x` is inferred to be `usize`
|
||||
...
|
||||
LL | if x == x && x = x && x == x {
|
||||
| ^ expected `bool`, found `usize`
|
||||
|
||||
|
|
@ -98,9 +92,6 @@ LL | if x == x && x == x && x == x {
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/assignment-in-if.rs:51:28
|
||||
|
|
||||
LL | if y = (Foo { foo: x }) {
|
||||
| - here the type of `x` is inferred to be `usize`
|
||||
...
|
||||
LL | if x == x && x == x && x = x {
|
||||
| ---------------- ^ expected `bool`, found `usize`
|
||||
| |
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
fn main() {
|
||||
let mut v = Vec::new();
|
||||
v.push(0i32);
|
||||
//~^ NOTE this is of type `i32`, which causes `v` to be inferred as `Vec<i32>`
|
||||
//~^ NOTE this argument has type `i32`...
|
||||
//~| NOTE ... which causes `v` to have type `Vec<i32>`
|
||||
v.push(0);
|
||||
v.push(1i32); //~ ERROR mismatched types
|
||||
//~^ NOTE expected `i32`, found `u32`
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
fn main() {
|
||||
let mut v = Vec::new();
|
||||
v.push(0i32);
|
||||
//~^ NOTE this is of type `i32`, which causes `v` to be inferred as `Vec<i32>`
|
||||
//~^ NOTE this argument has type `i32`...
|
||||
//~| NOTE ... which causes `v` to have type `Vec<i32>`
|
||||
v.push(0);
|
||||
v.push(1u32); //~ ERROR mismatched types
|
||||
//~^ NOTE expected `i32`, found `u32`
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/point-at-inference-3.rs:7:12
|
||||
--> $DIR/point-at-inference-3.rs:8:12
|
||||
|
|
||||
LL | v.push(0i32);
|
||||
| ---- this is of type `i32`, which causes `v` to be inferred as `Vec<i32>`
|
||||
| - ---- this argument has type `i32`...
|
||||
| |
|
||||
| ... which causes `v` to have type `Vec<i32>`
|
||||
...
|
||||
LL | v.push(1u32);
|
||||
| ---- ^^^^ expected `i32`, found `u32`
|
||||
|
|
|
|||
|
|
@ -11,8 +11,11 @@ fn main() {
|
|||
let s = S(None);
|
||||
s.infer(0i32);
|
||||
//~^ ERROR this method takes 2 arguments but 1 argument was supplied
|
||||
//~| NOTE this argument has type `i32`...
|
||||
//~| NOTE ... which causes `s` to have type `S<i32, _>`
|
||||
//~| NOTE an argument is missing
|
||||
//~| HELP provide the argument
|
||||
//~| HELP change the type of the numeric literal from `i32` to `u32`
|
||||
let t: S<u32, _> = s;
|
||||
//~^ ERROR mismatched types
|
||||
//~| NOTE expected `S<u32, _>`, found `S<i32, _>`
|
||||
|
|
|
|||
|
|
@ -15,8 +15,13 @@ LL | s.infer(0i32, /* b */);
|
|||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/point-at-inference-4.rs:16:24
|
||||
--> $DIR/point-at-inference-4.rs:19:24
|
||||
|
|
||||
LL | s.infer(0i32);
|
||||
| - ---- this argument has type `i32`...
|
||||
| |
|
||||
| ... which causes `s` to have type `S<i32, _>`
|
||||
...
|
||||
LL | let t: S<u32, _> = s;
|
||||
| --------- ^ expected `S<u32, _>`, found `S<i32, _>`
|
||||
| |
|
||||
|
|
@ -24,6 +29,10 @@ LL | let t: S<u32, _> = s;
|
|||
|
|
||||
= note: expected struct `S<u32, _>`
|
||||
found struct `S<i32, _>`
|
||||
help: change the type of the numeric literal from `i32` to `u32`
|
||||
|
|
||||
LL | s.infer(0u32);
|
||||
| ~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||
--> $DIR/point-at-inference.rs:12:9
|
||||
|
|
||||
LL | foo.push(i);
|
||||
| - this is of type `&{integer}`, which causes `foo` to be inferred as `Vec<&{integer}>`
|
||||
| --- - this argument has type `&{integer}`...
|
||||
| |
|
||||
| ... which causes `foo` to have type `Vec<&{integer}>`
|
||||
...
|
||||
LL | bar(foo);
|
||||
| --- ^^^ expected `Vec<i32>`, found `Vec<&{integer}>`
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ LL | primes.contains(3);
|
|||
| | expected `&_`, found integer
|
||||
| | help: consider borrowing here: `&3`
|
||||
| arguments to this method are incorrect
|
||||
| here the type of `primes` is inferred to be `[_]`
|
||||
|
|
||||
= note: expected reference `&_`
|
||||
found type `{integer}`
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/bad-type-in-vec-push.rs:11:17
|
||||
|
|
||||
LL | vector.sort();
|
||||
| ------ here the type of `vector` is inferred to be `Vec<_>`
|
||||
LL | result.push(vector);
|
||||
| ---- ^^^^^^ expected integer, found `Vec<_>`
|
||||
| |
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ error[E0308]: mismatched types
|
|||
--> $DIR/issue-107775.rs:35:16
|
||||
|
|
||||
LL | map.insert(1, Struct::do_something);
|
||||
| - -------------------- this is of type `fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}`, which causes `map` to be inferred as `HashMap<{integer}, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>`
|
||||
| |
|
||||
| this is of type `{integer}`, which causes `map` to be inferred as `HashMap<{integer}, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>`
|
||||
| --- -------------------- this argument has type `fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}`...
|
||||
| |
|
||||
| ... which causes `map` to have type `HashMap<{integer}, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>`
|
||||
LL | Self { map }
|
||||
| ^^^ expected `HashMap<u16, fn(u8) -> Pin<...>>`, found `HashMap<{integer}, ...>`
|
||||
|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue