summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/region_name.rs10
-rw-r--r--compiler/rustc_borrowck/src/type_check/mod.rs2
-rw-r--r--compiler/rustc_codegen_cranelift/src/base.rs6
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/rvalue.rs2
-rw-r--r--compiler/rustc_const_eval/src/interpret/cast.rs6
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/check.rs2
-rw-r--r--compiler/rustc_const_eval/src/transform/promote_consts.rs2
-rw-r--r--compiler/rustc_error_messages/locales/en-US/parser.ftl18
-rw-r--r--compiler/rustc_errors/src/emitter.rs37
-rw-r--r--compiler/rustc_hir/src/def.rs5
-rw-r--r--compiler/rustc_hir/src/hir.rs11
-rw-r--r--compiler/rustc_hir/src/lib.rs1
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/mod.rs62
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs50
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs3
-rw-r--r--compiler/rustc_middle/src/mir/mod.rs9
-rw-r--r--compiler/rustc_middle/src/ty/print/pretty.rs71
-rw-r--r--compiler/rustc_mir_build/src/build/expr/as_rvalue.rs2
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs163
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs16
-rw-r--r--compiler/rustc_parse/src/parser/pat.rs16
-rw-r--r--compiler/rustc_parse/src/parser/stmt.rs2
-rw-r--r--compiler/rustc_parse/src/parser/ty.rs15
-rw-r--r--compiler/rustc_typeck/src/check/check.rs177
-rw-r--r--compiler/rustc_typeck/src/check/compare_method.rs20
-rw-r--r--library/alloc/src/boxed.rs23
-rw-r--r--library/alloc/src/sync.rs6
-rw-r--r--library/core/src/ptr/mut_ptr.rs119
-rw-r--r--library/std/src/sync/mpsc/cache_aligned.rs3
-rw-r--r--src/librustdoc/formats/mod.rs25
-rw-r--r--src/librustdoc/html/render/mod.rs4
-rw-r--r--src/librustdoc/html/render/print_item.rs5
-rw-r--r--src/librustdoc/passes/collect_trait_impls.rs31
-rw-r--r--src/test/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff2
-rw-r--r--src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff2
-rw-r--r--src/test/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff4
-rw-r--r--src/test/rustdoc/issue-75588.rs2
-rw-r--r--src/test/rustdoc/primitive-slice-auto-trait.rs14
-rw-r--r--src/test/ui/async-await/issue-76547.base.stderr12
-rw-r--r--src/test/ui/async-await/issue-76547.nll.stderr10
-rw-r--r--src/test/ui/async-await/issues/issue-63388-1.base.stderr10
-rw-r--r--src/test/ui/async-await/issues/issue-63388-1.nll.stderr9
-rw-r--r--src/test/ui/async-await/issues/issue-63388-1.rs4
-rw-r--r--src/test/ui/codemap_tests/two_files.stderr1
-rw-r--r--src/test/ui/const-generics/generic_const_exprs/issue-94287.stderr1
-rw-r--r--src/test/ui/editions/edition-keywords-2015-2018-expansion.stderr1
-rw-r--r--src/test/ui/editions/edition-keywords-2018-2018-expansion.stderr1
-rw-r--r--src/test/ui/error-codes/E0308-2.stderr2
-rw-r--r--src/test/ui/generic-associated-types/parameter_number_and_kind_impl.stderr6
-rw-r--r--src/test/ui/issues/issue-17905-2.stderr4
-rw-r--r--src/test/ui/issues/issue-65230.stderr2
-rw-r--r--src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr1
-rw-r--r--src/test/ui/methods/method-on-ambiguous-numeric-type.stderr1
-rw-r--r--src/test/ui/nll/issue-52742.base.stderr2
-rw-r--r--src/test/ui/nll/issue-52742.nll.stderr2
-rw-r--r--src/test/ui/nll/issue-55394.base.stderr2
-rw-r--r--src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr4
-rw-r--r--src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.base.stderr12
-rw-r--r--src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr10
-rw-r--r--src/test/ui/self/elision/lt-ref-self-async.base.stderr36
-rw-r--r--src/test/ui/self/elision/lt-ref-self-async.nll.stderr30
-rw-r--r--src/test/ui/self/elision/ref-mut-self-async.base.stderr36
-rw-r--r--src/test/ui/self/elision/ref-mut-self-async.nll.stderr30
-rw-r--r--src/test/ui/self/elision/ref-mut-struct-async.base.stderr30
-rw-r--r--src/test/ui/self/elision/ref-mut-struct-async.nll.stderr25
-rw-r--r--src/test/ui/self/elision/ref-self-async.base.stderr42
-rw-r--r--src/test/ui/self/elision/ref-self-async.nll.stderr35
-rw-r--r--src/test/ui/self/elision/ref-struct-async.base.stderr30
-rw-r--r--src/test/ui/self/elision/ref-struct-async.nll.stderr25
-rw-r--r--src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs2
70 files changed, 1039 insertions, 327 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs
index 4d2a16aa609..cb4b154d271 100644
--- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs
@@ -567,15 +567,17 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
let lifetime =
self.try_match_adt_and_generic_args(substs, needle_fr, args, search_stack)?;
match lifetime.name {
- hir::LifetimeName::Param(_)
+ hir::LifetimeName::Param(hir::ParamName::Plain(_) | hir::ParamName::Error)
| hir::LifetimeName::Error
- | hir::LifetimeName::Static
- | hir::LifetimeName::Underscore => {
+ | hir::LifetimeName::Static => {
let lifetime_span = lifetime.span;
Some(RegionNameHighlight::MatchedAdtAndSegment(lifetime_span))
}
- hir::LifetimeName::ImplicitObjectLifetimeDefault | hir::LifetimeName::Implicit => {
+ hir::LifetimeName::Param(hir::ParamName::Fresh(_))
+ | hir::LifetimeName::ImplicitObjectLifetimeDefault
+ | hir::LifetimeName::Implicit
+ | hir::LifetimeName::Underscore => {
// In this case, the user left off the lifetime; so
// they wrote something like:
//
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs
index d9d31ab2c89..abf77acb8c7 100644
--- a/compiler/rustc_borrowck/src/type_check/mod.rs
+++ b/compiler/rustc_borrowck/src/type_check/mod.rs
@@ -2147,7 +2147,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
}
- CastKind::PointerAddress => {
+ CastKind::PointerExposeAddress => {
let ty_from = op.ty(body, tcx);
let cast_ty_from = CastTy::from_ty(ty_from);
let cast_ty_to = CastTy::from_ty(*ty);
diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs
index 7c59ce354c0..58bec183c94 100644
--- a/compiler/rustc_codegen_cranelift/src/base.rs
+++ b/compiler/rustc_codegen_cranelift/src/base.rs
@@ -607,7 +607,11 @@ fn codegen_stmt<'tcx>(
let operand = codegen_operand(fx, operand);
lval.write_cvalue(fx, operand.cast_pointer_to(to_layout));
}
- Rvalue::Cast(CastKind::Misc | CastKind::PointerAddress, ref operand, to_ty) => {
+ Rvalue::Cast(
+ CastKind::Misc | CastKind::PointerExposeAddress,
+ ref operand,
+ to_ty,
+ ) => {
let operand = codegen_operand(fx, operand);
let from_ty = operand.layout().ty;
let to_ty = fx.monomorphize(to_ty);
diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
index bd88aa33372..6ff8d4aa442 100644
--- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
@@ -181,7 +181,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let cast = bx.cx().layout_of(self.monomorphize(mir_cast_ty));
let val = match *kind {
- mir::CastKind::PointerAddress => {
+ mir::CastKind::PointerExposeAddress => {
assert!(bx.cx().is_backend_immediate(cast));
let llptr = operand.immediate();
let llcast_ty = bx.cx().immediate_backend_type(cast);
diff --git a/compiler/rustc_const_eval/src/interpret/cast.rs b/compiler/rustc_const_eval/src/interpret/cast.rs
index af563c1450e..520ae409e6b 100644
--- a/compiler/rustc_const_eval/src/interpret/cast.rs
+++ b/compiler/rustc_const_eval/src/interpret/cast.rs
@@ -31,9 +31,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
self.unsize_into(src, cast_ty, dest)?;
}
- PointerAddress => {
+ PointerExposeAddress => {
let src = self.read_immediate(src)?;
- let res = self.pointer_address_cast(&src, cast_ty)?;
+ let res = self.pointer_expose_address_cast(&src, cast_ty)?;
self.write_immediate(res, dest)?;
}
@@ -184,7 +184,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Ok(self.cast_from_int_like(scalar, src.layout, cast_ty)?.into())
}
- pub fn pointer_address_cast(
+ pub fn pointer_expose_address_cast(
&mut self,
src: &ImmTy<'tcx, M::PointerTag>,
cast_ty: Ty<'tcx>,
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs
index 4ef33d62a6b..c07680515f4 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs
@@ -542,7 +542,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
// in the type of any local, which also excludes casts).
}
- Rvalue::Cast(CastKind::PointerAddress, _, _) => {
+ Rvalue::Cast(CastKind::PointerExposeAddress, _, _) => {
self.check_op(ops::RawPtrToIntCast);
}
diff --git a/compiler/rustc_const_eval/src/transform/promote_consts.rs b/compiler/rustc_const_eval/src/transform/promote_consts.rs
index ea23bd14d25..cf5d7b6c70a 100644
--- a/compiler/rustc_const_eval/src/transform/promote_consts.rs
+++ b/compiler/rustc_const_eval/src/transform/promote_consts.rs
@@ -502,7 +502,7 @@ impl<'tcx> Validator<'_, 'tcx> {
Rvalue::ThreadLocalRef(_) => return Err(Unpromotable),
// ptr-to-int casts are not possible in consts and thus not promotable
- Rvalue::Cast(CastKind::PointerAddress, _, _) => return Err(Unpromotable),
+ Rvalue::Cast(CastKind::PointerExposeAddress, _, _) => return Err(Unpromotable),
// int-to-ptr casts are fine, they just use the integer value at pointer type.
Rvalue::Cast(_, operand, _) => {
diff --git a/compiler/rustc_error_messages/locales/en-US/parser.ftl b/compiler/rustc_error_messages/locales/en-US/parser.ftl
index c98989b23c1..076b1b1caed 100644
--- a/compiler/rustc_error_messages/locales/en-US/parser.ftl
+++ b/compiler/rustc_error_messages/locales/en-US/parser.ftl
@@ -14,3 +14,21 @@ parser-add-paren = try adding parentheses
parser-forgot-paren = perhaps you forgot parentheses?
parser-expect-path = expected a path
+
+parser-maybe-recover-from-bad-qpath-stage-2 =
+ missing angle brackets in associated item path
+ .suggestion = try: `{$ty}`
+
+parser-incorrect-semicolon =
+ expected item, found `;`
+ .suggestion = remove this semicolon
+ .help = {$name} declarations are not followed by a semicolon
+
+parser-incorrect-use-of-await =
+ incorrect use of `await`
+ .parentheses-suggestion = `await` is not a method call, remove the parentheses
+ .postfix-suggestion = `await` is a postfix operation
+
+parser-in-in-typo =
+ expected iterable, found keyword `in`
+ .suggestion = remove the duplicated `in`
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index 3fdc8cf8ac2..e9e7065ec03 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -1715,6 +1715,7 @@ impl EmitterWriter {
fn emit_suggestion_default(
&mut self,
+ span: &MultiSpan,
suggestion: &CodeSuggestion,
args: &FluentArgs<'_>,
level: &Level,
@@ -1766,6 +1767,30 @@ impl EmitterWriter {
None,
}
+ if let Some(span) = span.primary_span() {
+ // Compare the primary span of the diagnostic with the span of the suggestion
+ // being emitted. If they belong to the same file, we don't *need* to show the
+ // file name, saving in verbosity, but if it *isn't* we do need it, otherwise we're
+ // telling users to make a change but not clarifying *where*.
+ let loc = sm.lookup_char_pos(parts[0].span.lo());
+ if loc.file.name != sm.span_to_filename(span) && loc.file.name.is_real() {
+ buffer.puts(row_num - 1, 0, "--> ", Style::LineNumber);
+ buffer.append(
+ row_num - 1,
+ &format!(
+ "{}:{}:{}",
+ sm.filename_for_diagnostics(&loc.file.name),
+ sm.doctest_offset_line(&loc.file.name, loc.line),
+ loc.col.0 + 1,
+ ),
+ Style::LineAndColumn,
+ );
+ for _ in 0..max_line_num_len {
+ buffer.prepend(row_num - 1, " ", Style::NoStyle);
+ }
+ row_num += 1;
+ }
+ }
let show_code_change = if has_deletion && !is_multiline {
DisplaySuggestion::Diff
} else if (parts.len() != 1 || parts[0].snippet.trim() != complete.trim())
@@ -1787,7 +1812,7 @@ impl EmitterWriter {
assert!(!file_lines.lines.is_empty() || parts[0].span.is_dummy());
let line_start = sm.lookup_char_pos(parts[0].span.lo()).line;
- draw_col_separator_no_space(&mut buffer, 1, max_line_num_len + 1);
+ draw_col_separator_no_space(&mut buffer, row_num - 1, max_line_num_len + 1);
let mut lines = complete.lines();
if lines.clone().next().is_none() {
// Account for a suggestion to completely remove a line(s) with whitespace (#94192).
@@ -2046,9 +2071,13 @@ impl EmitterWriter {
) {
panic!("failed to emit error: {}", e);
}
- } else if let Err(e) =
- self.emit_suggestion_default(sugg, args, &Level::Help, max_line_num_len)
- {
+ } else if let Err(e) = self.emit_suggestion_default(
+ span,
+ sugg,
+ args,
+ &Level::Help,
+ max_line_num_len,
+ ) {
panic!("failed to emit error: {}", e);
};
}
diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs
index 68876e89c4b..414f6272591 100644
--- a/compiler/rustc_hir/src/def.rs
+++ b/compiler/rustc_hir/src/def.rs
@@ -671,7 +671,10 @@ impl<Id> Res<Id> {
#[track_caller]
pub fn expect_non_local<OtherId>(self) -> Res<OtherId> {
- self.map_id(|_| panic!("unexpected `Res::Local`"))
+ self.map_id(
+ #[track_caller]
+ |_| panic!("unexpected `Res::Local`"),
+ )
}
pub fn macro_kind(self) -> Option<MacroKind> {
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs
index bda7affe529..dbe6fe6ea84 100644
--- a/compiler/rustc_hir/src/hir.rs
+++ b/compiler/rustc_hir/src/hir.rs
@@ -131,6 +131,17 @@ impl LifetimeName {
}
}
+ pub fn is_anonymous(&self) -> bool {
+ match *self {
+ LifetimeName::ImplicitObjectLifetimeDefault
+ | LifetimeName::Implicit
+ | LifetimeName::Underscore
+ | LifetimeName::Param(ParamName::Fresh(_))
+ | LifetimeName::Error => true,
+ LifetimeName::Static | LifetimeName::Param(_) => false,
+ }
+ }
+
pub fn is_elided(&self) -> bool {
match self {
LifetimeName::ImplicitObjectLifetimeDefault
diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs
index 7833571f88d..d845c433d8c 100644
--- a/compiler/rustc_hir/src/lib.rs
+++ b/compiler/rustc_hir/src/lib.rs
@@ -3,6 +3,7 @@
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
#![feature(associated_type_defaults)]
+#![feature(closure_track_caller)]
#![feature(const_btree_new)]
#![feature(let_else)]
#![feature(once_cell)]
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
index e156930cc89..579d7efb568 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
@@ -72,7 +72,7 @@ use rustc_middle::ty::{
subst::{GenericArgKind, Subst, SubstsRef},
Binder, EarlyBinder, List, Region, Ty, TyCtxt, TypeFoldable,
};
-use rustc_span::{sym, BytePos, DesugaringKind, Pos, Span};
+use rustc_span::{sym, symbol::kw, BytePos, DesugaringKind, Pos, Span};
use rustc_target::spec::abi;
use std::ops::ControlFlow;
use std::{cmp, fmt, iter};
@@ -161,35 +161,45 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>(
{
sp = param.span;
}
- (format!("the lifetime `{}` as defined here", br.name), sp)
+ let text = if br.has_name() {
+ format!("the lifetime `{}` as defined here", br.name)
+ } else {
+ format!("the anonymous lifetime as defined here")
+ };
+ (text, sp)
}
- ty::ReFree(ty::FreeRegion {
- bound_region: ty::BoundRegionKind::BrNamed(_, name), ..
- }) => {
- let mut sp = sm.guess_head_span(tcx.def_span(scope));
- if let Some(param) =
- tcx.hir().get_generics(scope).and_then(|generics| generics.get_named(name))
+ ty::ReFree(ref fr) => {
+ if !fr.bound_region.is_named()
+ && let Some((ty, _)) = find_anon_type(tcx, region, &fr.bound_region)
{
- sp = param.span;
- }
- (format!("the lifetime `{}` as defined here", name), sp)
- }
- ty::ReFree(ref fr) => match fr.bound_region {
- ty::BrAnon(idx) => {
- if let Some((ty, _)) = find_anon_type(tcx, region, &fr.bound_region) {
- ("the anonymous lifetime defined here".to_string(), ty.span)
- } else {
- (
+ ("the anonymous lifetime defined here".to_string(), ty.span)
+ } else {
+ match fr.bound_region {
+ ty::BoundRegionKind::BrNamed(_, name) => {
+ let mut sp = sm.guess_head_span(tcx.def_span(scope));
+ if let Some(param) =
+ tcx.hir().get_generics(scope).and_then(|generics| generics.get_named(name))
+ {
+ sp = param.span;
+ }
+ let text = if name == kw::UnderscoreLifetime {
+ format!("the anonymous lifetime as defined here")
+ } else {
+ format!("the lifetime `{}` as defined here", name)
+ };
+ (text, sp)
+ }
+ ty::BrAnon(idx) => (
format!("the anonymous lifetime #{} defined here", idx + 1),
- tcx.def_span(scope),
- )
+ tcx.def_span(scope)
+ ),
+ _ => (
+ format!("the lifetime `{}` as defined here", region),
+ sm.guess_head_span(tcx.def_span(scope)),
+ ),
}
}
- _ => (
- format!("the lifetime `{}` as defined here", region),
- sm.guess_head_span(tcx.def_span(scope)),
- ),
- },
+ }
_ => bug!(),
}
}
@@ -2552,7 +2562,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
ty::ReEarlyBound(ty::EarlyBoundRegion { name, .. })
| ty::ReFree(ty::FreeRegion { bound_region: ty::BrNamed(_, name), .. }),
_,
- ) => {
+ ) if name != kw::UnderscoreLifetime => {
// Does the required lifetime have a nice name we can print?
let mut err = struct_span_err!(
self.tcx.sess,
diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
index cb72cb41a7c..b744594ddb7 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
@@ -12,6 +12,7 @@ use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed};
use rustc_hir as hir;
use rustc_hir::{GenericParamKind, Ty};
use rustc_middle::ty::Region;
+use rustc_span::symbol::kw;
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// Print the error message for lifetime errors when both the concerned regions are anonymous.
@@ -169,7 +170,7 @@ pub fn suggest_adding_lifetime_params<'tcx>(
return false;
};
- if !lifetime_sub.name.is_elided() || !lifetime_sup.name.is_elided() {
+ if !lifetime_sub.name.is_anonymous() || !lifetime_sup.name.is_anonymous() {
return false;
};
@@ -188,32 +189,37 @@ pub fn suggest_adding_lifetime_params<'tcx>(
_ => return false,
};
- let (suggestion_param_name, introduce_new) = generics
+ let suggestion_param_name = generics
.params
.iter()
- .find(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }))
- .and_then(|p| tcx.sess.source_map().span_to_snippet(p.span).ok())
- .map(|name| (name, false))
- .unwrap_or_else(|| ("'a".to_string(), true));
-
- let mut suggestions = vec![
- if let hir::LifetimeName::Underscore = lifetime_sub.name {
- (lifetime_sub.span, suggestion_param_name.clone())
+ .filter(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }))
+ .map(|p| p.name.ident().name)
+ .find(|i| *i != kw::UnderscoreLifetime);
+ let introduce_new = suggestion_param_name.is_none();
+ let suggestion_param_name =
+ suggestion_param_name.map(|n| n.to_string()).unwrap_or_else(|| "'a".to_owned());
+
+ debug!(?lifetime_sup.span);
+ debug!(?lifetime_sub.span);
+ let make_suggestion = |span: rustc_span::Span| {
+ if span.is_empty() {
+ (span, format!("{}, ", suggestion_param_name))
+ } else if let Ok("&") = tcx.sess.source_map().span_to_snippet(span).as_deref() {
+ (span.shrink_to_hi(), format!("{} ", suggestion_param_name))
} else {
- (lifetime_sub.span.shrink_to_hi(), suggestion_param_name.clone() + " ")
- },
- if let hir::LifetimeName::Underscore = lifetime_sup.name {
- (lifetime_sup.span, suggestion_param_name.clone())
- } else {
- (lifetime_sup.span.shrink_to_hi(), suggestion_param_name.clone() + " ")
- },
- ];
+ (span, suggestion_param_name.clone())
+ }
+ };
+ let mut suggestions =
+ vec![make_suggestion(lifetime_sub.span), make_suggestion(lifetime_sup.span)];
if introduce_new {
- let new_param_suggestion = match &generics.params {
- [] => (generics.span, format!("<{}>", suggestion_param_name)),
- [first, ..] => (first.span.shrink_to_lo(), format!("{}, ", suggestion_param_name)),
- };
+ let new_param_suggestion =
+ if let Some(first) = generics.params.iter().find(|p| !p.name.ident().span.is_empty()) {
+ (first.span.shrink_to_lo(), format!("{}, ", suggestion_param_name))
+ } else {
+ (generics.span, format!("<{}>", suggestion_param_name))
+ };
suggestions.push(new_param_suggestion);
}
diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs
index 3de5273d8c7..375ad8d3736 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs
@@ -4,6 +4,7 @@ use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
use rustc_middle::ty;
+use rustc_span::symbol::kw;
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// When given a `ConcreteFailure` for a function with parameters containing a named region and
@@ -67,7 +68,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
let is_impl_item = region_info.is_impl_item;
match br {
- ty::BrAnon(_) => {}
+ ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon(_) => {}
_ => {
/* not an anonymous region */
debug!("try_report_named_anon_conflict: not an anonymous region");
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs
index 1b63c8d67ca..d9cdca8bcb5 100644
--- a/compiler/rustc_middle/src/mir/mod.rs
+++ b/compiler/rustc_middle/src/mir/mod.rs
@@ -2607,16 +2607,17 @@ static_assert_size!(Rvalue<'_>, 40);
impl<'tcx> Rvalue<'tcx> {
#[inline]
pub fn is_pointer_int_cast(&self) -> bool {
- matches!(self, Rvalue::Cast(CastKind::PointerAddress, _, _))
+ matches!(self, Rvalue::Cast(CastKind::PointerExposeAddress, _, _))
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
pub enum CastKind {
Misc,
- /// A pointer to address cast. A cast between a pointer and an integer type,
- /// or between a function pointer and an integer type.
- PointerAddress,
+ /// An exposing pointer to address cast. A cast between a pointer and an integer type, or
+ /// between a function pointer and an integer type.
+ /// See the docs on `expose_addr` for more details.
+ PointerExposeAddress,
Pointer(PointerCast),
}
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs
index 4c0bc2e4337..64c63e3d567 100644
--- a/compiler/rustc_middle/src/ty/print/pretty.rs
+++ b/compiler/rustc_middle/src/ty/print/pretty.rs
@@ -2177,61 +2177,47 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
define_scoped_cx!(self);
let mut region_index = self.region_index;
+ let mut next_name = |this: &Self| loop {
+ let name = name_by_region_index(region_index);
+ region_index += 1;
+ if !this.used_region_names.contains(&name) {
+ break name;
+ }
+ };
+
// If we want to print verbosely, then print *all* binders, even if they
// aren't named. Eventually, we might just want this as the default, but
// this is not *quite* right and changes the ordering of some output
// anyways.
let (new_value, map) = if self.tcx().sess.verbose() {
// anon index + 1 (BrEnv takes 0) -> name
- let mut region_map: BTreeMap<u32, Symbol> = BTreeMap::default();
+ let mut region_map: FxHashMap<_, _> = Default::default();
let bound_vars = value.bound_vars();
for var in bound_vars {
+ let ty::BoundVariableKind::Region(var) = var else { continue };
match var {
- ty::BoundVariableKind::Region(ty::BrNamed(_, name)) => {
+ ty::BrAnon(_) | ty::BrEnv => {
start_or_continue(&mut self, "for<", ", ");
+ let name = next_name(&self);
do_continue(&mut self, name);
+ region_map.insert(var, ty::BrNamed(CRATE_DEF_ID.to_def_id(), name));
}
- ty::BoundVariableKind::Region(ty::BrAnon(i)) => {
+ ty::BrNamed(def_id, kw::UnderscoreLifetime) => {
start_or_continue(&mut self, "for<", ", ");
- let name = loop {
- let name = name_by_region_index(region_index);
- region_index += 1;
- if !self.used_region_names.contains(&name) {
- break name;
- }
- };
+ let name = next_name(&self);
do_continue(&mut self, name);
- region_map.insert(i + 1, name);
+ region_map.insert(var, ty::BrNamed(def_id, name));
}
- ty::BoundVariableKind::Region(ty::BrEnv) => {
+ ty::BrNamed(_, name) => {
start_or_continue(&mut self, "for<", ", ");
- let name = loop {
- let name = name_by_region_index(region_index);
- region_index += 1;
- if !self.used_region_names.contains(&name) {
- break name;
- }
- };
do_continue(&mut self, name);
- region_map.insert(0, name);
}
- _ => continue,
}
}
start_or_continue(&mut self, "", "> ");
self.tcx.replace_late_bound_regions(value.clone(), |br| {
- let kind = match br.kind {
- ty::BrNamed(_, _) => br.kind,
- ty::BrAnon(i) => {
- let name = region_map[&(i + 1)];
- ty::BrNamed(CRATE_DEF_ID.to_def_id(), name)
- }
- ty::BrEnv => {
- let name = region_map[&0];
- ty::BrNamed(CRATE_DEF_ID.to_def_id(), name)
- }
- };
+ let kind = region_map[&br.kind];
self.tcx.mk_region(ty::ReLateBound(
ty::INNERMOST,
ty::BoundRegion { var: br.var, kind },
@@ -2242,21 +2228,20 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
let mut name = |br: ty::BoundRegion| {
start_or_continue(&mut self, "for<", ", ");
let kind = match br.kind {
- ty::BrNamed(_, name) => {
- do_continue(&mut self, name);
- br.kind
- }
ty::BrAnon(_) | ty::BrEnv => {
- let name = loop {
- let name = name_by_region_index(region_index);
- region_index += 1;
- if !self.used_region_names.contains(&name) {
- break name;
- }
- };
+ let name = next_name(&self);
do_continue(&mut self, name);
ty::BrNamed(CRATE_DEF_ID.to_def_id(), name)
}
+ ty::BrNamed(def_id, kw::UnderscoreLifetime) => {
+ let name = next_name(&self);
+ do_continue(&mut self, name);
+ ty::BrNamed(def_id, name)
+ }
+ ty::BrNamed(_, name) => {
+ do_continue(&mut self, name);
+ br.kind
+ }
};
tcx.mk_region(ty::ReLateBound(ty::INNERMOST, ty::BoundRegion { var: br.var, kind }))
};
diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
index 2b137046c7f..7d08b20631e 100644
--- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
+++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
@@ -194,7 +194,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let cast_ty = CastTy::from_ty(expr.ty);
let cast_kind = match (from_ty, cast_ty) {
(Some(CastTy::Ptr(_) | CastTy::FnPtr), Some(CastTy::Int(_))) => {
- CastKind::PointerAddress
+ CastKind::PointerExposeAddress
}
(_, _) => CastKind::Misc,
};
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index 12302315e90..a4cdfdf55f9 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -1,8 +1,7 @@
use super::pat::Expected;
-use super::ty::{AllowPlus, RecoverQuestionMark};
use super::{
- BlockMode, CommaRecoveryMode, Parser, PathStyle, RecoverColon, RecoverComma, Restrictions,
- SemiColonMode, SeqSep, TokenExpectType, TokenType,
+ BlockMode, CommaRecoveryMode, Parser, PathStyle, Restrictions, SemiColonMode, SeqSep,
+ TokenExpectType, TokenType,
};
use crate::lexer::UnmatchedBrace;
@@ -286,6 +285,54 @@ pub enum BadTypePlusSub {
},
}
+#[derive(SessionDiagnostic)]
+#[error(slug = "parser-maybe-recover-from-bad-qpath-stage-2")]
+struct BadQPathStage2 {
+ #[primary_span]
+ #[suggestion(applicability = "maybe-incorrect")]
+ span: Span,
+ ty: String,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(slug = "parser-incorrect-semicolon")]
+struct IncorrectSemicolon<'a> {
+ #[primary_span]
+ #[suggestion_short(applicability = "machine-applicable")]
+ span: Span,
+ #[help]
+ opt_help: Option<()>,
+ name: &'a str,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(slug = "parser-incorrect-use-of-await")]
+struct IncorrectUseOfAwait {
+ #[primary_span]
+ #[suggestion(message = "parentheses-suggestion", applicability = "machine-applicable")]
+ span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(slug = "parser-incorrect-use-of-await")]
+struct IncorrectAwait {
+ #[primary_span]
+ span: Span,
+ #[suggestion(message = "postfix-suggestion", code = "{expr}.await{question_mark}")]
+ sugg_span: (Span, Applicability),
+ expr: String,
+ question_mark: &'static str,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(slug = "parser-in-in-typo")]
+struct InInTypo {
+ #[primary_span]
+ span: Span,
+ #[suggestion(applicability = "machine-applicable")]
+ sugg_span: Span,
+}
+
// SnapshotParser is used to create a snapshot of the parser
// without causing duplicate errors being emitted when the `Parser`
// is dropped.
@@ -1233,26 +1280,14 @@ impl<'a> Parser<'a> {
}
}
- pub(super) fn maybe_report_ambiguous_plus(
- &mut self,
- allow_plus: AllowPlus,
- impl_dyn_multi: bool,
- ty: &Ty,
- ) {
- if matches!(allow_plus, AllowPlus::No) && impl_dyn_multi {
+ pub(super) fn maybe_report_ambiguous_plus(&mut self, impl_dyn_multi: bool, ty: &Ty) {
+ if impl_dyn_multi {
self.sess.emit_err(AmbiguousPlus { sum_ty: pprust::ty_to_string(&ty), span: ty.span });
}
}
/// Swift lets users write `Ty?` to mean `Option<Ty>`. Parse the construct and recover from it.
- pub(super) fn maybe_recover_from_question_mark(
- &mut self,
- ty: P<Ty>,
- recover_question_mark: RecoverQuestionMark,
- ) -> P<Ty> {
- if let RecoverQuestionMark::No = recover_question_mark {
- return ty;
- }
+ pub(super) fn maybe_recover_from_question_mark(&mut self, ty: P<Ty>) -> P<Ty> {
if self.token == token::Question {
self.bump();
self.struct_span_err(self.prev_token.span, "invalid `?` in type")
@@ -1272,13 +1307,9 @@ impl<'a> Parser<'a> {
}
}
- pub(super) fn maybe_recover_from_bad_type_plus(
- &mut self,
- allow_plus: AllowPlus,
- ty: &Ty,
- ) -> PResult<'a, ()> {
+ pub(super) fn maybe_recover_from_bad_type_plus(&mut self, ty: &Ty) -> PResult<'a, ()> {
// Do not add `+` to expected tokens.
- if matches!(allow_plus, AllowPlus::No) || !self.token.is_like_plus() {
+ if !self.token.is_like_plus() {
return Ok(());
}
@@ -1444,10 +1475,9 @@ impl<'a> Parser<'a> {
pub(super) fn maybe_recover_from_bad_qpath<T: RecoverQPath>(
&mut self,
base: P<T>,
- allow_recovery: bool,
) -> PResult<'a, P<T>> {
// Do not add `::` to expected tokens.
- if allow_recovery && self.token == token::ModSep {
+ if self.token == token::ModSep {
if let Some(ty) = base.to_ty() {
return self.maybe_recover_from_bad_qpath_stage_2(ty.span, ty);
}
@@ -1469,15 +1499,10 @@ impl<'a> Parser<'a> {
path.span = ty_span.to(self.prev_token.span);
let ty_str = self.span_to_snippet(ty_span).unwrap_or_else(|_| pprust::ty_to_string(&ty));
- self.struct_span_err(path.span, "missing angle brackets in associated item path")
- .span_suggestion(
- // This is a best-effort recovery.
- path.span,
- "try",
- format!("<{}>::{}", ty_str, pprust::path_to_string(&path)),
- Applicability::MaybeIncorrect,
- )
- .emit();
+ self.sess.emit_err(BadQPathStage2 {
+ span: path.span,
+ ty: format!("<{}>::{}", ty_str, pprust::path_to_string(&path)),
+ });
let path_span = ty_span.shrink_to_hi(); // Use an empty path since `position == 0`.
Ok(P(T::recovered(Some(QSelf { ty, path_span, position: 0 }), path)))
@@ -1486,13 +1511,10 @@ impl<'a> Parser<'a> {
pub fn maybe_consume_incorrect_semicolon(&mut self, items: &[P<Item>]) -> bool {
if self.token.kind == TokenKind::Semi {
self.bump();
- let mut err = self.struct_span_err(self.prev_token.span, "expected item, found `;`");
- err.span_suggestion_short(
- self.prev_token.span,
- "remove this semicolon",
- String::new(),
- Applicability::MachineApplicable,
- );
+
+ let mut err =
+ IncorrectSemicolon { span: self.prev_token.span, opt_help: None, name: "" };
+
if !items.is_empty() {
let previous_item = &items[items.len() - 1];
let previous_item_kind_name = match previous_item.kind {
@@ -1505,10 +1527,11 @@ impl<'a> Parser<'a> {
_ => None,
};
if let Some(name) = previous_item_kind_name {
- err.help(&format!("{name} declarations are not followed by a semicolon"));
+ err.opt_help = Some(());
+ err.name = name;
}
}
- err.emit();
+ self.sess.emit_err(err);
true
} else {
false
@@ -1593,7 +1616,7 @@ impl<'a> Parser<'a> {
_ => ExprKind::Await(expr),
};
let expr = self.mk_expr(lo.to(sp), kind, attrs);
- self.maybe_recover_from_bad_qpath(expr, true)
+ self.maybe_recover_from_bad_qpath(expr)
}
fn recover_await_macro(&mut self) -> PResult<'a, (Span, P<Expr>, bool)> {
@@ -1622,18 +1645,20 @@ impl<'a> Parser<'a> {
}
fn error_on_incorrect_await(&self, lo: Span, hi: Span, expr: &Expr, is_question: bool) -> Span {
- let expr_str =
- self.span_to_snippet(expr.span).unwrap_or_else(|_| pprust::expr_to_string(&expr));
- let suggestion = format!("{}.await{}", expr_str, if is_question { "?" } else { "" });
- let sp = lo.to(hi);
- let app = match expr.kind {
+ let span = lo.to(hi);
+ let applicability = match expr.kind {
ExprKind::Try(_) => Applicability::MaybeIncorrect, // `await <expr>?`
_ => Applicability::MachineApplicable,
};
- self.struct_span_err(sp, "incorrect use of `await`")
- .span_suggestion(sp, "`await` is a postfix operation", suggestion, app)
- .emit();
- sp
+
+ self.sess.emit_err(IncorrectAwait {
+ span,
+ sugg_span: (span, applicability),
+ expr: self.span_to_snippet(expr.span).unwrap_or_else(|_| pprust::expr_to_string(&expr)),
+ question_mark: if is_question { "?" } else { "" },
+ });
+
+ span
}
/// If encountering `future.await()`, consumes and emits an error.
@@ -1644,16 +1669,10 @@ impl<'a> Parser<'a> {
// future.await()
let lo = self.token.span;
self.bump(); // (
- let sp = lo.to(self.token.span);
+ let span = lo.to(self.token.span);
self.bump(); // )
- self.struct_span_err(sp, "incorrect use of `await`")
- .span_suggestion(
- sp,
- "`await` is not a method call, remove the parentheses",
- String::new(),
- Applicability::MachineApplicable,
- )
- .emit();
+
+ self.sess.emit_err(IncorrectUseOfAwait { span });
}
}
@@ -1925,14 +1944,10 @@ impl<'a> Parser<'a> {
pub(super) fn check_for_for_in_in_typo(&mut self, in_span: Span) {
if self.eat_keyword(kw::In) {
// a common typo: `for _ in in bar {}`
- self.struct_span_err(self.prev_token.span, "expected iterable, found keyword `in`")
- .span_suggestion_short(
- in_span.until(self.prev_token.span),
- "remove the duplicated `in`",
- String::new(),
- Applicability::MachineApplicable,
- )
- .emit();
+ self.sess.emit_err(InInTypo {
+ span: self.prev_token.span,
+ sugg_span: in_span.until(self.prev_token.span),
+ });
}
}
@@ -2457,10 +2472,9 @@ impl<'a> Parser<'a> {
pub(crate) fn maybe_recover_colon_colon_in_pat_typo(
&mut self,
mut first_pat: P<Pat>,
- ra: RecoverColon,
expected: Expected,
) -> P<Pat> {
- if RecoverColon::Yes != ra || token::Colon != self.token.kind {
+ if token::Colon != self.token.kind {
return first_pat;
}
if !matches!(first_pat.kind, PatKind::Ident(_, _, None) | PatKind::Path(..))
@@ -2594,10 +2608,9 @@ impl<'a> Parser<'a> {
pub(crate) fn maybe_recover_unexpected_comma(
&mut self,
lo: Span,
- rc: RecoverComma,
rt: CommaRecoveryMode,
) -> PResult<'a, ()> {
- if rc == RecoverComma::No || self.token != token::Comma {
+ if self.token != token::Comma {
return Ok(());
}
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index bb6d892138a..63c7decbb2f 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -1417,7 +1417,7 @@ impl<'a> Parser<'a> {
match self.parse_opt_lit() {
Some(literal) => {
let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(literal), attrs);
- self.maybe_recover_from_bad_qpath(expr, true)
+ self.maybe_recover_from_bad_qpath(expr)
}
None => self.try_macro_suggestion(),
}
@@ -1444,7 +1444,7 @@ impl<'a> Parser<'a> {
ExprKind::Tup(es)
};
let expr = self.mk_expr(lo.to(self.prev_token.span), kind, attrs);
- self.maybe_recover_from_bad_qpath(expr, true)
+ self.maybe_recover_from_bad_qpath(expr)
}
fn parse_array_or_repeat_expr(
@@ -1481,7 +1481,7 @@ impl<'a> Parser<'a> {
}
};
let expr = self.mk_expr(lo.to(self.prev_token.span), kind, attrs);
- self.maybe_recover_from_bad_qpath(expr, true)
+ self.maybe_recover_from_bad_qpath(expr)
}
fn parse_path_start_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
@@ -1519,7 +1519,7 @@ impl<'a> Parser<'a> {
};
let expr = self.mk_expr(lo.to(hi), kind, attrs);
- self.maybe_recover_from_bad_qpath(expr, true)
+ self.maybe_recover_from_bad_qpath(expr)
}
/// Parse `'label: $expr`. The label is already parsed.
@@ -1604,7 +1604,7 @@ impl<'a> Parser<'a> {
let lo = self.prev_token.span;
let kind = ExprKind::Ret(self.parse_expr_opt()?);
let expr = self.mk_expr(lo.to(self.prev_token.span), kind, attrs);
- self.maybe_recover_from_bad_qpath(expr, true)
+ self.maybe_recover_from_bad_qpath(expr)
}
/// Parse `"do" "yeet" expr?`.
@@ -1619,7 +1619,7 @@ impl<'a> Parser<'a> {
let span = lo.to(self.prev_token.span);
self.sess.gated_spans.gate(sym::yeet_expr, span);
let expr = self.mk_expr(span, kind, attrs);
- self.maybe_recover_from_bad_qpath(expr, true)
+ self.maybe_recover_from_bad_qpath(expr)
}
/// Parse `"break" (('label (:? expr)?) | expr?)` with `"break"` token already eaten.
@@ -1679,7 +1679,7 @@ impl<'a> Parser<'a> {
None
};
let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Break(label, kind), attrs);
- self.maybe_recover_from_bad_qpath(expr, true)
+ self.maybe_recover_from_bad_qpath(expr)
}
/// Parse `"yield" expr?`.
@@ -1689,7 +1689,7 @@ impl<'a> Parser<'a> {
let span = lo.to(self.prev_token.span);
self.sess.gated_spans.gate(sym::generators, span);
let expr = self.mk_expr(span, kind, attrs);
- self.maybe_recover_from_bad_qpath(expr, true)
+ self.maybe_recover_from_bad_qpath(expr)
}
/// Returns a string literal if the next token is a string literal.
diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs
index 8019c5fb67c..2ad3f3ec19d 100644
--- a/compiler/rustc_parse/src/parser/pat.rs
+++ b/compiler/rustc_parse/src/parser/pat.rs
@@ -100,8 +100,10 @@ impl<'a> Parser<'a> {
};
// Parse the first pattern (`p_0`).
- let first_pat = self.parse_pat_no_top_alt(expected)?;
- self.maybe_recover_unexpected_comma(first_pat.span, rc, rt)?;
+ let mut first_pat = self.parse_pat_no_top_alt(expected)?;
+ if rc == RecoverComma::Yes {
+ self.maybe_recover_unexpected_comma(first_pat.span, rt)?;
+ }
// If the next token is not a `|`,
// this is not an or-pattern and we should exit here.
@@ -111,7 +113,9 @@ impl<'a> Parser<'a> {
// This complicated procedure is done purely for diagnostics UX.
// Check if the user wrote `foo:bar` instead of `foo::bar`.
- let first_pat = self.maybe_recover_colon_colon_in_pat_typo(first_pat, ra, expected);
+ if ra == RecoverColon::Yes {
+ first_pat = self.maybe_recover_colon_colon_in_pat_typo(first_pat, expected);
+ }
if let Some(leading_vert_span) = leading_vert_span {
// If there was a leading vert, treat this as an or-pattern. This improves
@@ -139,7 +143,9 @@ impl<'a> Parser<'a> {
err.span_label(lo, WHILE_PARSING_OR_MSG);
err
})?;
- self.maybe_recover_unexpected_comma(pat.span, rc, rt)?;
+ if rc == RecoverComma::Yes {
+ self.maybe_recover_unexpected_comma(pat.span, rt)?;
+ }
pats.push(pat);
}
let or_pattern_span = lo.to(self.prev_token.span);
@@ -408,7 +414,7 @@ impl<'a> Parser<'a> {
};
let pat = self.mk_pat(lo.to(self.prev_token.span), pat);
- let pat = self.maybe_recover_from_bad_qpath(pat, true)?;
+ let pat = self.maybe_recover_from_bad_qpath(pat)?;
let pat = self.recover_intersection_pat(pat)?;
if !allow_range_pat {
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs
index 27a6a487474..7907ec44e98 100644
--- a/compiler/rustc_parse/src/parser/stmt.rs
+++ b/compiler/rustc_parse/src/parser/stmt.rs
@@ -180,7 +180,7 @@ impl<'a> Parser<'a> {
} else {
// Since none of the above applied, this is an expression statement macro.
let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac), AttrVec::new());
- let e = self.maybe_recover_from_bad_qpath(e, true)?;
+ let e = self.maybe_recover_from_bad_qpath(e)?;
let e = self.parse_dot_or_call_expr_with(e, lo, attrs.into())?;
let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?;
StmtKind::Expr(e)
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs
index fb3f5eb3f9f..dee025cfd3c 100644
--- a/compiler/rustc_parse/src/parser/ty.rs
+++ b/compiler/rustc_parse/src/parser/ty.rs
@@ -312,13 +312,18 @@ impl<'a> Parser<'a> {
};
let span = lo.to(self.prev_token.span);
- let ty = self.mk_ty(span, kind);
+ let mut ty = self.mk_ty(span, kind);
// Try to recover from use of `+` with incorrect priority.
- self.maybe_report_ambiguous_plus(allow_plus, impl_dyn_multi, &ty);
- self.maybe_recover_from_bad_type_plus(allow_plus, &ty)?;
- let ty = self.maybe_recover_from_question_mark(ty, recover_question_mark);
- self.maybe_recover_from_bad_qpath(ty, allow_qpath_recovery)
+ if matches!(allow_plus, AllowPlus::Yes) {
+ self.maybe_recover_from_bad_type_plus(&ty)?;
+ } else {
+ self.maybe_report_ambiguous_plus(impl_dyn_multi, &ty);
+ }
+ if let RecoverQuestionMark::Yes = recover_question_mark {
+ ty = self.maybe_recover_from_question_mark(ty);
+ }
+ if allow_qpath_recovery { self.maybe_recover_from_bad_qpath(ty) } else { Ok(ty) }
}
/// Parses either:
diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs
index 7499e5efdee..de5367ca27c 100644
--- a/compiler/rustc_typeck/src/check/check.rs
+++ b/compiler/rustc_typeck/src/check/check.rs
@@ -8,10 +8,11 @@ use super::*;
use rustc_attr as attr;
use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan};
use rustc_hir as hir;
+use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::Visitor;
use rustc_hir::lang_items::LangItem;
-use rustc_hir::{def::Res, ItemKind, Node, PathSegment};
+use rustc_hir::{ItemKind, Node, PathSegment};
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt};
use rustc_infer::traits::Obligation;
@@ -29,7 +30,6 @@ use rustc_trait_selection::traits;
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
use rustc_ty_utils::representability::{self, Representability};
-use rustc_hir::def::DefKind;
use std::iter;
use std::ops::ControlFlow;
@@ -93,7 +93,6 @@ pub(super) fn check_fn<'a, 'tcx>(
fcx.return_type_pre_known = return_type_pre_known;
let tcx = fcx.tcx;
- let sess = tcx.sess;
let hir = tcx.hir();
let declared_ret_ty = fn_sig.output();
@@ -259,85 +258,123 @@ pub(super) fn check_fn<'a, 'tcx>(
if let Some(panic_impl_did) = tcx.lang_items().panic_impl()
&& panic_impl_did == hir.local_def_id(fn_id).to_def_id()
{
- if let Some(panic_info_did) = tcx.lang_items().panic_info() {
- if *declared_ret_ty.kind() != ty::Never {
- sess.span_err(decl.output.span(), "return type should be `!`");
- }
-
- let inputs = fn_sig.inputs();
- let span = hir.span(fn_id);
- if inputs.len() == 1 {
- let arg_is_panic_info = match *inputs[0].kind() {
- ty::Ref(region, ty, mutbl) => match *ty.kind() {
- ty::Adt(ref adt, _) => {
- adt.did() == panic_info_did
- && mutbl == hir::Mutability::Not
- && !region.is_static()
- }
- _ => false,
- },
- _ => false,
- };
-
- if !arg_is_panic_info {
- sess.span_err(decl.inputs[0].span, "argument should be `&PanicInfo`");
- }
-
- if let Node::Item(item) = hir.get(fn_id)
- && let ItemKind::Fn(_, ref generics, _) = item.kind
- && !generics.params.is_empty()
- {
- sess.span_err(span, "should have no type parameters");
- }
- } else {
- let span = sess.source_map().guess_head_span(span);
- sess.span_err(span, "function should have one argument");
- }
- } else {
- sess.err("language item required, but not found: `panic_info`");
- }
+ check_panic_info_fn(tcx, panic_impl_did.expect_local(), fn_sig, decl, declared_ret_ty);
}
// Check that a function marked as `#[alloc_error_handler]` has signature `fn(Layout) -> !`
if let Some(alloc_error_handler_did) = tcx.lang_items().oom()
&& alloc_error_handler_did == hir.local_def_id(fn_id).to_def_id()
{
- if let Some(alloc_layout_did) = tcx.lang_items().alloc_layout() {
- if *declared_ret_ty.kind() != ty::Never {
- sess.span_err(decl.output.span(), "return type should be `!`");
- }
+ check_alloc_error_fn(tcx, alloc_error_handler_did.expect_local(), fn_sig, decl, declared_ret_ty);
+ }
- let inputs = fn_sig.inputs();
- let span = hir.span(fn_id);
- if inputs.len() == 1 {
- let arg_is_alloc_layout = match inputs[0].kind() {
- ty::Adt(ref adt, _) => adt.did() == alloc_layout_did,
- _ => false,
- };
+ (fcx, gen_ty)
+}
- if !arg_is_alloc_layout {
- sess.span_err(decl.inputs[0].span, "argument should be `Layout`");
- }
+fn check_panic_info_fn(
+ tcx: TyCtxt<'_>,
+ fn_id: LocalDefId,
+ fn_sig: ty::FnSig<'_>,
+ decl: &hir::FnDecl<'_>,
+ declared_ret_ty: Ty<'_>,
+) {
+ let Some(panic_info_did) = tcx.lang_items().panic_info() else {
+ tcx.sess.err("language item required, but not found: `panic_info`");
+ return;
+ };
- if let Node::Item(item) = hir.get(fn_id)
- && let ItemKind::Fn(_, ref generics, _) = item.kind
- && !generics.params.is_empty()
- {
- sess.span_err(
- span,
- "`#[alloc_error_handler]` function should have no type parameters",
- );
- }
- } else {
- let span = sess.source_map().guess_head_span(span);
- sess.span_err(span, "function should have one argument");
+ if *declared_ret_ty.kind() != ty::Never {
+ tcx.sess.span_err(decl.output.span(), "return type should be `!`");
+ }
+
+ let span = tcx.def_span(fn_id);
+ let inputs = fn_sig.inputs();
+ if inputs.len() != 1 {
+ let span = tcx.sess.source_map().guess_head_span(span);
+ tcx.sess.span_err(span, "function should have one argument");
+ return;
+ }
+
+ let arg_is_panic_info = match *inputs[0].kind() {
+ ty::Ref(region, ty, mutbl) => match *ty.kind() {
+ ty::Adt(ref adt, _) => {
+ adt.did() == panic_info_did && mutbl == hir::Mutability::Not && !region.is_static()
}
- } else {
- sess.err("language item required, but not found: `alloc_layout`");
- }
+ _ => false,
+ },
+ _ => false,
+ };
+
+ if !arg_is_panic_info {
+ tcx.sess.span_err(decl.inputs[0].span, "argument should be `&PanicInfo`");
}
- (fcx, gen_ty)
+ let DefKind::Fn = tcx.def_kind(fn_id) else {
+ let span = tcx.def_span(fn_id);
+ tcx.sess.span_err(span, "should be a function");
+ return;
+ };
+
+ let generic_counts = tcx.generics_of(fn_id).own_counts();
+ if generic_counts.types != 0 {
+ let span = tcx.def_span(fn_id);
+ tcx.sess.span_err(span, "should have no type parameters");
+ }
+ if generic_counts.consts != 0 {
+ let span = tcx.def_span(fn_id);
+ tcx.sess.span_err(span, "should have no const parameters");
+ }
+}
+
+fn check_alloc_error_fn(
+ tcx: TyCtxt<'_>,
+ fn_id: LocalDefId,
+ fn_sig: ty::FnSig<'_>,
+ decl: &hir::FnDecl<'_>,
+ declared_ret_ty: Ty<'_>,
+) {
+ let Some(alloc_layout_did) = tcx.lang_items().alloc_layout() else {
+ tcx.sess.err("language item required, but not found: `alloc_layout`");
+ return;
+ };
+
+ if *declared_ret_ty.kind() != ty::Never {
+ tcx.sess.span_err(decl.output.span(), "return type should be `!`");
+ }
+
+ let inputs = fn_sig.inputs();
+ if inputs.len() != 1 {
+ let span = tcx.def_span(fn_id);
+ let span = tcx.sess.source_map().guess_head_span(span);
+ tcx.sess.span_err(span, "function should have one argument");
+ return;
+ }
+
+ let arg_is_alloc_layout = match inputs[0].kind() {
+ ty::Adt(ref adt, _) => adt.did() == alloc_layout_did,
+ _ => false,
+ };
+
+ if !arg_is_alloc_layout {
+ tcx.sess.span_err(decl.inputs[0].span, "argument should be `Layout`");
+ }
+
+ let DefKind::Fn = tcx.def_kind(fn_id) else {
+ let span = tcx.def_span(fn_id);
+ tcx.sess.span_err(span, "`#[alloc_error_handler]` should be a function");
+ return;
+ };
+
+ let generic_counts = tcx.generics_of(fn_id).own_counts();
+ if generic_counts.types != 0 {
+ let span = tcx.def_span(fn_id);
+ tcx.sess.span_err(span, "`#[alloc_error_handler]` function should have no type parameters");
+ }
+ if generic_counts.consts != 0 {
+ let span = tcx.def_span(fn_id);
+ tcx.sess
+ .span_err(span, "`#[alloc_error_handler]` function should have no const parameters");
+ }
}
fn check_struct(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) {
diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs
index 277bc1cf0f0..4d17307ddb9 100644
--- a/compiler/rustc_typeck/src/check/compare_method.rs
+++ b/compiler/rustc_typeck/src/check/compare_method.rs
@@ -660,8 +660,24 @@ fn compare_number_of_generics<'tcx>(
_ => None,
})
.collect();
- let spans = impl_item.generics.spans();
- let span = spans.primary_span();
+ let spans = if impl_item.generics.params.is_empty() {
+ vec![impl_item.generics.span]
+ } else {
+ impl_item
+ .generics
+ .params
+ .iter()
+ .filter(|p| {
+ matches!(
+ p.kind,
+ hir::GenericParamKind::Type { .. }
+ | hir::GenericParamKind::Const { .. }
+ )
+ })
+ .map(|p| p.span)
+ .collect::<Vec<Span>>()
+ };
+ let span = spans.first().copied();
let mut err = tcx.sess.struct_span_err_with_code(
spans,
diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs
index 41f3b1fa3dd..e2c692b5299 100644
--- a/library/alloc/src/boxed.rs
+++ b/library/alloc/src/boxed.rs
@@ -1175,14 +1175,33 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
/// This conversion does not allocate on the heap and happens in place.
///
/// This is also available via [`From`].
- #[unstable(feature = "box_into_pin", issue = "62370")]
+ ///
+ /// # Notes
+ ///
+ /// It's not recommended that crates add an impl like `From<Box<T>> for Pin<T>`,
+ /// as it'll introduce an ambiguity when calling `Pin::from`.
+ /// A demonstration of such a poor impl is shown below.
+ ///
+ /// ```compile_fail
+ /// # use std::pin::Pin;
+ /// struct Foo; // A type defined in this crate.
+ /// impl From<Box<()>> for Pin<Foo> {
+ /// fn from(_: Box<()>) -> Pin<Foo> {
+ /// Pin::new(Foo)
+ /// }
+ /// }
+ ///
+ /// let foo = Box::new(());
+ /// let bar = Pin::from(foo);
+ /// ```
+ #[stable(feature = "box_into_pin", since = "1.63.0")]
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
pub const fn into_pin(boxed: Self) -> Pin<Self>
where
A: 'static,
{
// It's not possible to move or replace the insides of a `Pin<Box<T>>`
- // when `T: !Unpin`, so it's safe to pin it directly without any
+ // when `T: !Unpin`, so it's safe to pin it directly without any
// additional requirements.
unsafe { Pin::new_unchecked(boxed) }
}
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs
index d5ed3fd18c3..55d51e0a3c4 100644
--- a/library/alloc/src/sync.rs
+++ b/library/alloc/src/sync.rs
@@ -1393,11 +1393,11 @@ impl<T: Clone> Arc<T> {
/// referred to as clone-on-write.
///
/// However, if there are no other `Arc` pointers to this allocation, but some [`Weak`]
- /// pointers, then the [`Weak`] pointers will be disassociated and the inner value will not
+ /// pointers, then the [`Weak`] pointers will be dissociated and the inner value will not
/// be cloned.
///
/// See also [`get_mut`], which will fail rather than cloning the inner value
- /// or diassociating [`Weak`] pointers.
+ /// or dissociating [`Weak`] pointers.
///
/// [`clone`]: Clone::clone
/// [`get_mut`]: Arc::get_mut
@@ -1420,7 +1420,7 @@ impl<T: Clone> Arc<T> {
/// assert_eq!(*other_data, 12);
/// ```
///
- /// [`Weak`] pointers will be disassociated:
+ /// [`Weak`] pointers will be dissociated:
///
/// ```
/// use std::sync::Arc;
diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs
index 1aaa274a054..1fbf592c232 100644
--- a/library/core/src/ptr/mut_ptr.rs
+++ b/library/core/src/ptr/mut_ptr.rs
@@ -1622,6 +1622,122 @@ impl<T> *mut [T] {
metadata(self)
}
+ /// Returns `true` if the raw slice has a length of 0.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(slice_ptr_len)]
+ ///
+ /// let mut a = [1, 2, 3];
+ /// let ptr = &mut a as *mut [_];
+ /// assert!(!ptr.is_empty());
+ /// ```
+ #[inline(always)]
+ #[unstable(feature = "slice_ptr_len", issue = "71146")]
+ #[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")]
+ pub const fn is_empty(self) -> bool {
+ self.len() == 0
+ }
+
+ /// Divides one mutable raw slice into two at an index.
+ ///
+ /// The first will contain all indices from `[0, mid)` (excluding
+ /// the index `mid` itself) and the second will contain all
+ /// indices from `[mid, len)` (excluding the index `len` itself).
+ ///
+ /// # Panics
+ ///
+ /// Panics if `mid > len`.
+ ///
+ /// # Safety
+ ///
+ /// `mid` must be [in-bounds] of the underlying [allocated object].
+ /// Which means `self` must be dereferenceable and span a single allocation
+ /// that is at least `mid * size_of::<T>()` bytes long. Not upholding these
+ /// requirements is *[undefined behavior]* even if the resulting pointers are not used.
+ ///
+ /// Since `len` being in-bounds it is not a safety invariant of `*mut [T]` the
+ /// safety requirements of this method are the same as for [`split_at_mut_unchecked`].
+ /// The explicit bounds check is only as useful as `len` is correct.
+ ///
+ /// [`split_at_mut_unchecked`]: #method.split_at_mut_unchecked
+ /// [in-bounds]: #method.add
+ /// [allocated object]: crate::ptr#allocated-object
+ /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(raw_slice_split)]
+ /// #![feature(slice_ptr_get)]
+ ///
+ /// let mut v = [1, 0, 3, 0, 5, 6];
+ /// let ptr = &mut v as *mut [_];
+ /// unsafe {
+ /// let (left, right) = ptr.split_at_mut(2);
+ /// assert_eq!(&*left, [1, 0]);
+ /// assert_eq!(&*right, [3, 0, 5, 6]);
+ /// }
+ /// ```
+ #[inline(always)]
+ #[track_caller]
+ #[unstable(feature = "raw_slice_split", issue = "95595")]
+ pub unsafe fn split_at_mut(self, mid: usize) -> (*mut [T], *mut [T]) {
+ assert!(mid <= self.len());
+ // SAFETY: The assert above is only a safety-net as long as `self.len()` is correct
+ // The actual safety requirements of this function are the same as for `split_at_mut_unchecked`
+ unsafe { self.split_at_mut_unchecked(mid) }
+ }
+
+ /// Divides one mutable raw slice into two at an index, without doing bounds checking.
+ ///
+ /// The first will contain all indices from `[0, mid)` (excluding
+ /// the index `mid` itself) and the second will contain all
+ /// indices from `[mid, len)` (excluding the index `len` itself).
+ ///
+ /// # Safety
+ ///
+ /// `mid` must be [in-bounds] of the underlying [allocated object].
+ /// Which means `self` must be dereferenceable and span a single allocation
+ /// that is at least `mid * size_of::<T>()` bytes long. Not upholding these
+ /// requirements is *[undefined behavior]* even if the resulting pointers are not used.
+ ///
+ /// [in-bounds]: #method.add
+ /// [out-of-bounds index]: #method.add
+ /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(raw_slice_split)]
+ ///
+ /// let mut v = [1, 0, 3, 0, 5, 6];
+ /// // scoped to restrict the lifetime of the borrows
+ /// unsafe {
+ /// let ptr = &mut v as *mut [_];
+ /// let (left, right) = ptr.split_at_mut_unchecked(2);
+ /// assert_eq!(&*left, [1, 0]);
+ /// assert_eq!(&*right, [3, 0, 5, 6]);
+ /// (&mut *left)[1] = 2;
+ /// (&mut *right)[1] = 4;
+ /// }
+ /// assert_eq!(v, [1, 2, 3, 4, 5, 6]);
+ /// ```
+ #[inline(always)]
+ #[unstable(feature = "raw_slice_split", issue = "95595")]
+ pub unsafe fn split_at_mut_unchecked(self, mid: usize) -> (*mut [T], *mut [T]) {
+ let len = self.len();
+ let ptr = self.as_mut_ptr();
+
+ // SAFETY: Caller must pass a valid pointer and an index that is in-bounds.
+ let tail = unsafe { ptr.add(mid) };
+ (
+ crate::ptr::slice_from_raw_parts_mut(ptr, mid),
+ crate::ptr::slice_from_raw_parts_mut(tail, len - mid),
+ )
+ }
+
/// Returns a raw pointer to the slice's buffer.
///
/// This is equivalent to casting `self` to `*mut T`, but more type-safe.
@@ -1645,9 +1761,10 @@ impl<T> *mut [T] {
/// Returns a raw pointer to an element or subslice, without doing bounds
/// checking.
///
- /// Calling this method with an out-of-bounds index or when `self` is not dereferenceable
+ /// Calling this method with an [out-of-bounds index] or when `self` is not dereferenceable
/// is *[undefined behavior]* even if the resulting pointer is not used.
///
+ /// [out-of-bounds index]: #method.add
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
///
/// # Examples
diff --git a/library/std/src/sync/mpsc/cache_aligned.rs b/library/std/src/sync/mpsc/cache_aligned.rs
index f95b0ddd589..9197f0d6e6c 100644
--- a/library/std/src/sync/mpsc/cache_aligned.rs
+++ b/library/std/src/sync/mpsc/cache_aligned.rs
@@ -1,7 +1,8 @@
use crate::ops::{Deref, DerefMut};
#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(align(64))]
+#[cfg_attr(target_arch = "aarch64", repr(align(128)))]
+#[cfg_attr(not(target_arch = "aarch64"), repr(align(64)))]
pub(super) struct CacheAligned<T>(pub T);
impl<T> Deref for CacheAligned<T> {
diff --git a/src/librustdoc/formats/mod.rs b/src/librustdoc/formats/mod.rs
index 2367bde0167..9f26ccc74d1 100644
--- a/src/librustdoc/formats/mod.rs
+++ b/src/librustdoc/formats/mod.rs
@@ -7,6 +7,7 @@ use rustc_hir::def_id::DefId;
pub(crate) use renderer::{run_format, FormatRenderer};
use crate::clean::{self, ItemId};
+use cache::Cache;
/// Specifies whether rendering directly implemented trait items or ones from a certain Deref
/// impl.
@@ -60,4 +61,28 @@ impl Impl {
}
}
}
+
+ // Returns true if this is an implementation on a "local" type, meaning:
+ // the type is in the current crate, or the type and the trait are both
+ // re-exported by the current crate.
+ pub(crate) fn is_on_local_type(&self, cache: &Cache) -> bool {
+ let for_type = &self.inner_impl().for_;
+ if let Some(for_type_did) = for_type.def_id(cache) {
+ // The "for" type is local if it's in the paths for the current crate.
+ if cache.paths.contains_key(&for_type_did) {
+ return true;
+ }
+ if let Some(trait_did) = self.trait_did() {
+ // The "for" type and the trait are from the same crate. That could
+ // be different from the current crate, for instance when both were
+ // re-exported from some other crate. But they are local with respect to
+ // each other.
+ if for_type_did.krate == trait_did.krate {
+ return true;
+ }
+ }
+ return false;
+ };
+ true
+ }
}
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index b8d6b340b14..0b801a20995 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -2285,9 +2285,7 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean
if let Some(implementors) = cache.implementors.get(&it.item_id.expect_def_id()) {
let mut res = implementors
.iter()
- .filter(|i| {
- i.inner_impl().for_.def_id(cache).map_or(false, |d| !cache.paths.contains_key(&d))
- })
+ .filter(|i| !i.is_on_local_type(cache))
.filter_map(|i| extract_for_impl_name(&i.impl_item, cx))
.collect::<Vec<_>>();
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index dcf36b5e865..8683e6dfcd9 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -822,9 +822,8 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
}
}
- let (local, foreign) = implementors.iter().partition::<Vec<_>, _>(|i| {
- i.inner_impl().for_.def_id(cache).map_or(true, |d| cache.paths.contains_key(&d))
- });
+ let (local, foreign) =
+ implementors.iter().partition::<Vec<_>, _>(|i| i.is_on_local_type(cache));
let (mut synthetic, mut concrete): (Vec<&&Impl>, Vec<&&Impl>) =
local.iter().partition(|i| i.inner_impl().kind.is_auto());
diff --git a/src/librustdoc/passes/collect_trait_impls.rs b/src/librustdoc/passes/collect_trait_impls.rs
index aa7028247be..6ea33d763b1 100644
--- a/src/librustdoc/passes/collect_trait_impls.rs
+++ b/src/librustdoc/passes/collect_trait_impls.rs
@@ -9,7 +9,7 @@ use crate::visit::DocVisitor;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir::def_id::DefId;
-use rustc_middle::ty::DefIdTree;
+use rustc_middle::ty::{self, DefIdTree};
use rustc_span::symbol::sym;
pub(crate) const COLLECT_TRAIT_IMPLS: Pass = Pass {
@@ -81,8 +81,35 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) ->
// Do not calculate blanket impl list for docs that are not going to be rendered.
// While the `impl` blocks themselves are only in `libcore`, the module with `doc`
// attached is directly included in `libstd` as well.
+ let tcx = cx.tcx;
if did.is_local() {
- for def_id in prim.impls(cx.tcx) {
+ for def_id in prim.impls(tcx).filter(|def_id| {
+ // Avoid including impl blocks with filled-in generics.
+ // https://github.com/rust-lang/rust/issues/94937
+ //
+ // FIXME(notriddle): https://github.com/rust-lang/rust/issues/97129
+ //
+ // This tactic of using inherent impl blocks for getting
+ // auto traits and blanket impls is a hack. What we really
+ // want is to check if `[T]` impls `Send`, which has
+ // nothing to do with the inherent impl.
+ //
+ // Rustdoc currently uses these `impl` block as a source of
+ // the `Ty`, as well as the `ParamEnv`, `SubstsRef`, and
+ // `Generics`. To avoid relying on the `impl` block, these
+ // things would need to be created from wholecloth, in a
+ // form that is valid for use in type inference.
+ let ty = tcx.type_of(def_id);
+ match ty.kind() {
+ ty::Slice(ty)
+ | ty::Ref(_, ty, _)
+ | ty::RawPtr(ty::TypeAndMut { ty, .. }) => {
+ matches!(ty.kind(), ty::Param(..))
+ }
+ ty::Tuple(tys) => tys.iter().all(|ty| matches!(ty.kind(), ty::Param(..))),
+ _ => true,
+ }
+ }) {
let impls = get_auto_trait_and_blanket_impls(cx, def_id);
new_items_external.extend(impls.filter(|i| cx.inlined.insert(i.item_id)));
}
diff --git a/src/test/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff b/src/test/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff
index 4fdd4b2b4bb..84d72202d52 100644
--- a/src/test/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff
+++ b/src/test/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff
@@ -21,7 +21,7 @@
// + span: $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
// + literal: Const { ty: &i32, val: Unevaluated(FOO, [], None) }
_2 = &raw const (*_3); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
- _1 = move _2 as usize (PointerAddress); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:39
+ _1 = move _2 as usize (PointerExposeAddress); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:39
StorageDead(_2); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:38: 7:39
StorageDead(_3); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:39: 7:40
StorageLive(_4); // scope 1 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12
diff --git a/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff b/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff
index 7eb34ed5469..04724b13ca6 100644
--- a/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff
+++ b/src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff
@@ -17,7 +17,7 @@
// mir::Constant
// + span: $DIR/reify_fn_ptr.rs:4:13: 4:17
// + literal: Const { ty: fn() {main}, val: Value(Scalar(<ZST>)) }
- _2 = move _3 as usize (PointerAddress); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26
+ _2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26
StorageDead(_3); // scope 0 at $DIR/reify_fn_ptr.rs:4:25: 4:26
_1 = move _2 as *const fn() (Misc); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41
StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:4:40: 4:41
diff --git a/src/test/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff b/src/test/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff
index bf32245e300..2331f63ecdd 100644
--- a/src/test/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff
+++ b/src/test/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff
@@ -19,12 +19,12 @@
StorageLive(_2); // scope 0 at $DIR/provenance_soundness.rs:8:9: 8:11
StorageLive(_3); // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:15
_3 = _1; // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:15
- _2 = move _3 as usize (PointerAddress); // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:24
+ _2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/provenance_soundness.rs:8:14: 8:24
StorageDead(_3); // scope 0 at $DIR/provenance_soundness.rs:8:23: 8:24
StorageLive(_4); // scope 1 at $DIR/provenance_soundness.rs:9:9: 9:11
StorageLive(_5); // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:15
_5 = _1; // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:15
- _4 = move _5 as isize (PointerAddress); // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:24
+ _4 = move _5 as isize (PointerExposeAddress); // scope 1 at $DIR/provenance_soundness.rs:9:14: 9:24
StorageDead(_5); // scope 1 at $DIR/provenance_soundness.rs:9:23: 9:24
_0 = const (); // scope 0 at $DIR/provenance_soundness.rs:7:32: 10:2
StorageDead(_4); // scope 1 at $DIR/provenance_soundness.rs:10:1: 10:2
diff --git a/src/test/rustdoc/issue-75588.rs b/src/test/rustdoc/issue-75588.rs
index ac97b94fb35..a8cb16ec34c 100644
--- a/src/test/rustdoc/issue-75588.rs
+++ b/src/test/rustdoc/issue-75588.rs
@@ -13,5 +13,5 @@ extern crate real_gimli;
// @!has foo/trait.Deref.html '//*[@id="impl-Deref-for-EndianSlice"]//h3[@class="code-header in-band"]' 'impl Deref for EndianSlice'
pub use realcore::Deref;
-// @has foo/trait.Join.html '//*[@id="impl-Join-for-Foo"]//h3[@class="code-header in-band"]' 'impl Join for Foo'
+// @has foo/trait.Join.html '//*[@id="impl-Join"]//h3[@class="code-header in-band"]' 'impl Join for Foo'
pub use realcore::Join;
diff --git a/src/test/rustdoc/primitive-slice-auto-trait.rs b/src/test/rustdoc/primitive-slice-auto-trait.rs
new file mode 100644
index 00000000000..b3f511bc1f1
--- /dev/null
+++ b/src/test/rustdoc/primitive-slice-auto-trait.rs
@@ -0,0 +1,14 @@
+// compile-flags: --crate-type lib --edition 2018
+
+#![crate_name = "foo"]
+#![feature(rustdoc_internals)]
+
+// @has foo/primitive.slice.html '//a[@class="primitive"]' 'slice'
+// @has - '//span[@class="in-band"]' 'Primitive Type slice'
+// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!'
+// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations'
+// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Send for [T] where T: Send'
+// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Sync for [T] where T: Sync'
+#[doc(primitive = "slice")]
+/// this is a test!
+mod slice_prim {}
diff --git a/src/test/ui/async-await/issue-76547.base.stderr b/src/test/ui/async-await/issue-76547.base.stderr
index 34705d4838e..109883fbeb7 100644
--- a/src/test/ui/async-await/issue-76547.base.stderr
+++ b/src/test/ui/async-await/issue-76547.base.stderr
@@ -5,6 +5,12 @@ LL | async fn fut(bufs: &mut [&mut [u8]]) {
| ---------------- these two types are declared with different lifetimes...
LL | ListFut(bufs).await
| ^^^^ ...but data from `bufs` flows into `bufs` here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter
+ |
+LL | async fn fut<'a>(bufs: &'a mut [&'a mut [u8]]) {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/issue-76547.rs:39:14
@@ -13,6 +19,12 @@ LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 {
| ---------------- these two types are declared with different lifetimes...
LL | ListFut2(bufs).await
| ^^^^ ...but data from `bufs` flows into `bufs` here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter
+ |
+LL | async fn fut2<'a>(bufs: &'a mut [&'a mut [u8]]) -> i32 {
+ | ++++ ++ ++
error: aborting due to 2 previous errors
diff --git a/src/test/ui/async-await/issue-76547.nll.stderr b/src/test/ui/async-await/issue-76547.nll.stderr
index bc30da1e389..0a5a52cb79e 100644
--- a/src/test/ui/async-await/issue-76547.nll.stderr
+++ b/src/test/ui/async-await/issue-76547.nll.stderr
@@ -7,6 +7,11 @@ LL | async fn fut(bufs: &mut [&mut [u8]]) {
| let's call the lifetime of this reference `'1`
LL | ListFut(bufs).await
| ^^^^ this usage requires that `'1` must outlive `'2`
+ |
+help: consider introducing a named lifetime parameter
+ |
+LL | async fn fut<'a>(bufs: &'a mut [&'a mut [u8]]) {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/issue-76547.rs:39:14
@@ -17,6 +22,11 @@ LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 {
| let's call the lifetime of this reference `'1`
LL | ListFut2(bufs).await
| ^^^^ this usage requires that `'1` must outlive `'2`
+ |
+help: consider introducing a named lifetime parameter
+ |
+LL | async fn fut2<'a>(bufs: &'a mut [&'a mut [u8]]) -> i32 {
+ | ++++ ++ ++
error: aborting due to 2 previous errors
diff --git a/src/test/ui/async-await/issues/issue-63388-1.base.stderr b/src/test/ui/async-await/issues/issue-63388-1.base.stderr
index 2ff85a27a46..f5409a7ca5d 100644
--- a/src/test/ui/async-await/issues/issue-63388-1.base.stderr
+++ b/src/test/ui/async-await/issues/issue-63388-1.base.stderr
@@ -1,14 +1,12 @@
-error[E0623]: lifetime mismatch
+error[E0621]: explicit lifetime required in the type of `foo`
--> $DIR/issue-63388-1.rs:19:9
|
LL | &'a self, foo: &dyn Foo
- | -------- this parameter and the return type are declared with different lifetimes...
-LL | ) -> &dyn Foo
- | --------
+ | -------- help: add explicit lifetime `'a` to the type of `foo`: `&'a (dyn Foo + 'a)`
...
LL | foo
- | ^^^ ...but data from `foo` is returned here
+ | ^^^ lifetime `'a` required
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
+For more information about this error, try `rustc --explain E0621`.
diff --git a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr
index eee0cee278b..9263a81bb6a 100644
--- a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr
+++ b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr
@@ -1,17 +1,16 @@
-error: lifetime may not live long enough
+error[E0621]: explicit lifetime required in the type of `foo`
--> $DIR/issue-63388-1.rs:17:5
|
-LL | async fn do_sth<'a>(
- | -- lifetime `'a` defined here
LL | &'a self, foo: &dyn Foo
- | - let's call the lifetime of this reference `'1`
+ | -------- help: add explicit lifetime `'a` to the type of `foo`: `&'a (dyn Foo + 'a)`
LL | ) -> &dyn Foo
LL | / {
LL | |
LL | | foo
LL | |
LL | | }
- | |_____^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`
+ | |_____^ lifetime `'a` required
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0621`.
diff --git a/src/test/ui/async-await/issues/issue-63388-1.rs b/src/test/ui/async-await/issues/issue-63388-1.rs
index c45d2a42177..f00f9295406 100644
--- a/src/test/ui/async-await/issues/issue-63388-1.rs
+++ b/src/test/ui/async-await/issues/issue-63388-1.rs
@@ -15,9 +15,9 @@ impl Xyz {
&'a self, foo: &dyn Foo
) -> &dyn Foo
{
- //[nll]~^ ERROR lifetime may not live long enough
+ //[nll]~^ ERROR explicit lifetime required in the type of `foo` [E0621]
foo
- //[base]~^ ERROR lifetime mismatch
+ //[base]~^ ERROR explicit lifetime required in the type of `foo` [E0621]
}
}
diff --git a/src/test/ui/codemap_tests/two_files.stderr b/src/test/ui/codemap_tests/two_files.stderr
index aff51ee9e2f..2eb3fd56783 100644
--- a/src/test/ui/codemap_tests/two_files.stderr
+++ b/src/test/ui/codemap_tests/two_files.stderr
@@ -5,6 +5,7 @@ LL | impl Bar for Baz { }
| ^^^ type aliases cannot be used as traits
|
help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias
+ --> $DIR/two_files_data.rs:5:1
|
LL | trait Bar = dyn Foo;
|
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-94287.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-94287.stderr
index c918651ba62..7390a007742 100644
--- a/src/test/ui/const-generics/generic_const_exprs/issue-94287.stderr
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-94287.stderr
@@ -6,6 +6,7 @@ LL | If<{ FRAC <= 32 }>: True,
|
= note: the crate this constant originates from uses `#![feature(generic_const_exprs)]`
help: consider enabling this feature
+ --> $DIR/issue-94287.rs:1:1
|
LL | #![feature(generic_const_exprs)]
|
diff --git a/src/test/ui/editions/edition-keywords-2015-2018-expansion.stderr b/src/test/ui/editions/edition-keywords-2015-2018-expansion.stderr
index 23dad2c16b2..570bbac2b21 100644
--- a/src/test/ui/editions/edition-keywords-2015-2018-expansion.stderr
+++ b/src/test/ui/editions/edition-keywords-2015-2018-expansion.stderr
@@ -6,6 +6,7 @@ LL | produces_async! {}
|
= note: this error originates in the macro `produces_async` (in Nightly builds, run with -Z macro-backtrace for more info)
help: escape `async` to use it as an identifier
+ --> $DIR/auxiliary/edition-kw-macro-2018.rs:7:19
|
LL | () => (pub fn r#async() {})
| ++
diff --git a/src/test/ui/editions/edition-keywords-2018-2018-expansion.stderr b/src/test/ui/editions/edition-keywords-2018-2018-expansion.stderr
index 67f9aa60413..69f275746bd 100644
--- a/src/test/ui/editions/edition-keywords-2018-2018-expansion.stderr
+++ b/src/test/ui/editions/edition-keywords-2018-2018-expansion.stderr
@@ -6,6 +6,7 @@ LL | produces_async! {}
|
= note: this error originates in the macro `produces_async` (in Nightly builds, run with -Z macro-backtrace for more info)
help: escape `async` to use it as an identifier
+ --> $DIR/auxiliary/edition-kw-macro-2018.rs:7:19
|
LL | () => (pub fn r#async() {})
| ++
diff --git a/src/test/ui/error-codes/E0308-2.stderr b/src/test/ui/error-codes/E0308-2.stderr
index 5c1dcb4d4f9..de54a417253 100644
--- a/src/test/ui/error-codes/E0308-2.stderr
+++ b/src/test/ui/error-codes/E0308-2.stderr
@@ -6,7 +6,7 @@ LL | impl Eq for &dyn DynEq {}
|
= note: expected trait `<&dyn DynEq as PartialEq>`
found trait `<&(dyn DynEq + 'static) as PartialEq>`
-note: the lifetime `'_` as defined here...
+note: the anonymous lifetime as defined here...
--> $DIR/E0308-2.rs:9:13
|
LL | impl Eq for &dyn DynEq {}
diff --git a/src/test/ui/generic-associated-types/parameter_number_and_kind_impl.stderr b/src/test/ui/generic-associated-types/parameter_number_and_kind_impl.stderr
index 1458bf0c4a4..76d39c88b61 100644
--- a/src/test/ui/generic-associated-types/parameter_number_and_kind_impl.stderr
+++ b/src/test/ui/generic-associated-types/parameter_number_and_kind_impl.stderr
@@ -8,7 +8,7 @@ LL | type A = u32;
| ^ lifetimes do not match type in trait
error[E0049]: type `B` has 1 type parameter but its trait declaration has 0 type parameters
- --> $DIR/parameter_number_and_kind_impl.rs:17:12
+ --> $DIR/parameter_number_and_kind_impl.rs:17:16
|
LL | type B<'a, 'b>;
| -- --
@@ -16,9 +16,7 @@ LL | type B<'a, 'b>;
| expected 0 type parameters
...
LL | type B<'a, T> = Vec<T>;
- | ^^ ^
- | |
- | found 1 type parameter
+ | ^ found 1 type parameter
error[E0195]: lifetime parameters or bounds on type `C` do not match the trait declaration
--> $DIR/parameter_number_and_kind_impl.rs:19:11
diff --git a/src/test/ui/issues/issue-17905-2.stderr b/src/test/ui/issues/issue-17905-2.stderr
index c68265f71f2..88b5fbec6cf 100644
--- a/src/test/ui/issues/issue-17905-2.stderr
+++ b/src/test/ui/issues/issue-17905-2.stderr
@@ -11,7 +11,7 @@ note: the anonymous lifetime defined here...
|
LL | fn say(self: &Pair<&str, isize>) {
| ^^^^
-note: ...does not necessarily outlive the lifetime `'_` as defined here
+note: ...does not necessarily outlive the anonymous lifetime as defined here
--> $DIR/issue-17905-2.rs:5:5
|
LL | &str,
@@ -25,7 +25,7 @@ LL | fn say(self: &Pair<&str, isize>) {
|
= note: expected struct `Pair<&str, _>`
found struct `Pair<&str, _>`
-note: the lifetime `'_` as defined here...
+note: the anonymous lifetime as defined here...
--> $DIR/issue-17905-2.rs:5:5
|
LL | &str,
diff --git a/src/test/ui/issues/issue-65230.stderr b/src/test/ui/issues/issue-65230.stderr
index bfeb38d6471..fcabcdea74f 100644
--- a/src/test/ui/issues/issue-65230.stderr
+++ b/src/test/ui/issues/issue-65230.stderr
@@ -6,7 +6,7 @@ LL | impl T1 for &dyn T2 {}
|
= note: expected trait `<&dyn T2 as T0>`
found trait `<&(dyn T2 + 'static) as T0>`
-note: the lifetime `'_` as defined here...
+note: the anonymous lifetime as defined here...
--> $DIR/issue-65230.rs:8:13
|
LL | impl T1 for &dyn T2 {}
diff --git a/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr b/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr
index 4c11f354494..c6e6ea1e096 100644
--- a/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr
+++ b/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr
@@ -9,6 +9,7 @@ LL | assert_eq!(a, 0);
|
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might have forgotten to call this function
+ --> $SRC_DIR/core/src/macros/mod.rs:LL:COL
|
LL | if !(*left_val() == *right_val) {
| ++
diff --git a/src/test/ui/methods/method-on-ambiguous-numeric-type.stderr b/src/test/ui/methods/method-on-ambiguous-numeric-type.stderr
index 09978b35f7e..0af58bc61f4 100644
--- a/src/test/ui/methods/method-on-ambiguous-numeric-type.stderr
+++ b/src/test/ui/methods/method-on-ambiguous-numeric-type.stderr
@@ -46,6 +46,7 @@ LL | bar.pow(2);
| ^^^
|
help: you must specify a type for this binding, like `i32`
+ --> $DIR/auxiliary/macro-in-other-crate.rs:3:29
|
LL | ($ident:ident) => { let $ident: i32 = 42; }
| ~~~~~~~~~~~
diff --git a/src/test/ui/nll/issue-52742.base.stderr b/src/test/ui/nll/issue-52742.base.stderr
index 259f378f70b..7b1fac082e4 100644
--- a/src/test/ui/nll/issue-52742.base.stderr
+++ b/src/test/ui/nll/issue-52742.base.stderr
@@ -4,7 +4,7 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content...
LL | self.y = b.z
| ^^^
|
-note: ...the reference is valid for the lifetime `'_` as defined here...
+note: ...the reference is valid for the anonymous lifetime as defined here...
--> $DIR/issue-52742.rs:15:10
|
LL | impl Foo<'_, '_> {
diff --git a/src/test/ui/nll/issue-52742.nll.stderr b/src/test/ui/nll/issue-52742.nll.stderr
index 6828418a78e..1a2165e0a9d 100644
--- a/src/test/ui/nll/issue-52742.nll.stderr
+++ b/src/test/ui/nll/issue-52742.nll.stderr
@@ -2,7 +2,7 @@ error: lifetime may not live long enough
--> $DIR/issue-52742.rs:17:9
|
LL | fn take_bar(&mut self, b: Bar<'_>) {
- | --------- -- let's call this `'1`
+ | --------- - has type `Bar<'1>`
| |
| has type `&mut Foo<'_, '2>`
LL | self.y = b.z
diff --git a/src/test/ui/nll/issue-55394.base.stderr b/src/test/ui/nll/issue-55394.base.stderr
index cc87954732c..2ec6a7af3f2 100644
--- a/src/test/ui/nll/issue-55394.base.stderr
+++ b/src/test/ui/nll/issue-55394.base.stderr
@@ -14,7 +14,7 @@ note: ...so that reference does not outlive borrowed content
|
LL | Foo { bar }
| ^^^
-note: but, the lifetime must be valid for the lifetime `'_` as defined here...
+note: but, the lifetime must be valid for the anonymous lifetime as defined here...
--> $DIR/issue-55394.rs:11:10
|
LL | impl Foo<'_> {
diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr
index 570a08cb587..5b8b9bb68ad 100644
--- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr
+++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr
@@ -2,9 +2,9 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:48
|
LL | async fn f(self: Pin<&Self>) -> impl Clone { self }
- | - ^^^^^^^^
+ | ----- ^^^^^^^^
| |
- | hidden type `Pin<&Foo>` captures the lifetime `'_` as defined here
+ | hidden type `Pin<&Foo>` captures the anonymous lifetime defined here
|
help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'_` lifetime bound
|
diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.base.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.base.stderr
index 7985bf266d8..d2106630dfe 100644
--- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.base.stderr
+++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.base.stderr
@@ -5,6 +5,12 @@ LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
| ---- ---- ^ ...but data from `f` is returned here
| |
| this parameter and the return type are declared with different lifetimes...
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &Foo { f }
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:82
@@ -13,6 +19,12 @@ LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (
| ---- ----------------- ^ ...but data from `f` is returned here
| |
| this parameter and the return type are declared with different lifetimes...
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:22:64
diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr
index 8a55a7c34d7..3fd58725d02 100644
--- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr
+++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr
@@ -6,6 +6,11 @@ LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
| | |
| | let's call the lifetime of this reference `'1`
| let's call the lifetime of this reference `'2`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &Foo { f }
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:75
@@ -15,6 +20,11 @@ LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (
| | |
| | let's call the lifetime of this reference `'1`
| let's call the lifetime of this reference `'2`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:22:64
diff --git a/src/test/ui/self/elision/lt-ref-self-async.base.stderr b/src/test/ui/self/elision/lt-ref-self-async.base.stderr
index b4385490614..0e2bbcc3c04 100644
--- a/src/test/ui/self/elision/lt-ref-self-async.base.stderr
+++ b/src/test/ui/self/elision/lt-ref-self-async.base.stderr
@@ -7,6 +7,12 @@ LL | async fn ref_self(&self, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/lt-ref-self-async.rs:24:9
@@ -17,6 +23,12 @@ LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/lt-ref-self-async.rs:30:9
@@ -27,6 +39,12 @@ LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/lt-ref-self-async.rs:36:9
@@ -37,6 +55,12 @@ LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/lt-ref-self-async.rs:42:9
@@ -47,6 +71,12 @@ LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_box_ref_Self<'a>(self: Box<Box<&'a Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/lt-ref-self-async.rs:48:9
@@ -57,6 +87,12 @@ LL | async fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_pin_Self<'a>(self: Box<Pin<&'a Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: aborting due to 6 previous errors
diff --git a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr
index 2ba9a6596f6..1c889838e70 100644
--- a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr
+++ b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr
@@ -7,6 +7,11 @@ LL | async fn ref_self(&self, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self-async.rs:24:9
@@ -17,6 +22,11 @@ LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self-async.rs:30:9
@@ -27,6 +37,11 @@ LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self-async.rs:36:9
@@ -37,6 +52,11 @@ LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self-async.rs:42:9
@@ -47,6 +67,11 @@ LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_box_ref_Self<'a>(self: Box<Box<&'a Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self-async.rs:48:9
@@ -57,6 +82,11 @@ LL | async fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_pin_Self<'a>(self: Box<Pin<&'a Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: aborting due to 6 previous errors
diff --git a/src/test/ui/self/elision/ref-mut-self-async.base.stderr b/src/test/ui/self/elision/ref-mut-self-async.base.stderr
index 851337552c9..8ffc0d62242 100644
--- a/src/test/ui/self/elision/ref-mut-self-async.base.stderr
+++ b/src/test/ui/self/elision/ref-mut-self-async.base.stderr
@@ -7,6 +7,12 @@ LL | async fn ref_self(&mut self, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_self<'a>(&'a mut self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self-async.rs:24:9
@@ -17,6 +23,12 @@ LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self-async.rs:30:9
@@ -27,6 +39,12 @@ LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self-async.rs:36:9
@@ -37,6 +55,12 @@ LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self-async.rs:42:9
@@ -47,6 +71,12 @@ LL | async fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_box_ref_Self<'a>(self: Box<Box<&'a mut Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self-async.rs:48:9
@@ -57,6 +87,12 @@ LL | async fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_pin_ref_Self<'a>(self: Box<Pin<&'a mut Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: aborting due to 6 previous errors
diff --git a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr
index cdd464039cd..9beafcd4ff9 100644
--- a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr
+++ b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr
@@ -7,6 +7,11 @@ LL | async fn ref_self(&mut self, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_self<'a>(&'a mut self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-mut-self-async.rs:24:9
@@ -17,6 +22,11 @@ LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-mut-self-async.rs:30:9
@@ -27,6 +37,11 @@ LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-mut-self-async.rs:36:9
@@ -37,6 +52,11 @@ LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-mut-self-async.rs:42:9
@@ -47,6 +67,11 @@ LL | async fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_box_ref_Self<'a>(self: Box<Box<&'a mut Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-mut-self-async.rs:48:9
@@ -57,6 +82,11 @@ LL | async fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_pin_ref_Self<'a>(self: Box<Pin<&'a mut Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: aborting due to 6 previous errors
diff --git a/src/test/ui/self/elision/ref-mut-struct-async.base.stderr b/src/test/ui/self/elision/ref-mut-struct-async.base.stderr
index 0de11c24875..fefb3fc1944 100644
--- a/src/test/ui/self/elision/ref-mut-struct-async.base.stderr
+++ b/src/test/ui/self/elision/ref-mut-struct-async.base.stderr
@@ -7,6 +7,12 @@ LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct-async.rs:22:9
@@ -17,6 +23,12 @@ LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct-async.rs:28:9
@@ -27,6 +39,12 @@ LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct-async.rs:34:9
@@ -37,6 +55,12 @@ LL | async fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_box_ref_Struct<'a>(self: Box<Box<&'a mut Struct>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct-async.rs:40:9
@@ -47,6 +71,12 @@ LL | async fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_pin_ref_Struct<'a>(self: Box<Pin<&'a mut Struct>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: aborting due to 5 previous errors
diff --git a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr
index 0ef410c8df1..7fbecbe76a5 100644
--- a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr
+++ b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr
@@ -7,6 +7,11 @@ LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-mut-struct-async.rs:22:9
@@ -17,6 +22,11 @@ LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-mut-struct-async.rs:28:9
@@ -27,6 +37,11 @@ LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-mut-struct-async.rs:34:9
@@ -37,6 +52,11 @@ LL | async fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_box_ref_Struct<'a>(self: Box<Box<&'a mut Struct>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-mut-struct-async.rs:40:9
@@ -47,6 +67,11 @@ LL | async fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_pin_ref_Struct<'a>(self: Box<Pin<&'a mut Struct>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: aborting due to 5 previous errors
diff --git a/src/test/ui/self/elision/ref-self-async.base.stderr b/src/test/ui/self/elision/ref-self-async.base.stderr
index fa13b69bb21..2b142b089d5 100644
--- a/src/test/ui/self/elision/ref-self-async.base.stderr
+++ b/src/test/ui/self/elision/ref-self-async.base.stderr
@@ -7,6 +7,12 @@ LL | async fn ref_self(&self, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:34:9
@@ -17,6 +23,12 @@ LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:40:9
@@ -27,6 +39,12 @@ LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:46:9
@@ -37,6 +55,12 @@ LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:52:9
@@ -47,6 +71,12 @@ LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_box_ref_Self<'a>(self: Box<Box<&'a Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:58:9
@@ -57,6 +87,12 @@ LL | async fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_pin_ref_Self<'a>(self: Box<Pin<&'a Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-self-async.rs:64:9
@@ -67,6 +103,12 @@ LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &u8 {
+ | ++++ ++ ++
error: aborting due to 7 previous errors
diff --git a/src/test/ui/self/elision/ref-self-async.nll.stderr b/src/test/ui/self/elision/ref-self-async.nll.stderr
index 77faaa86650..f4e531a817c 100644
--- a/src/test/ui/self/elision/ref-self-async.nll.stderr
+++ b/src/test/ui/self/elision/ref-self-async.nll.stderr
@@ -7,6 +7,11 @@ LL | async fn ref_self(&self, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self-async.rs:34:9
@@ -17,6 +22,11 @@ LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self-async.rs:40:9
@@ -27,6 +37,11 @@ LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self-async.rs:46:9
@@ -37,6 +52,11 @@ LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self-async.rs:52:9
@@ -47,6 +67,11 @@ LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_box_ref_Self<'a>(self: Box<Box<&'a Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self-async.rs:58:9
@@ -57,6 +82,11 @@ LL | async fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_pin_ref_Self<'a>(self: Box<Pin<&'a Self>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self-async.rs:64:9
@@ -67,6 +97,11 @@ LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &u8 {
+ | ++++ ++ ++
error: aborting due to 7 previous errors
diff --git a/src/test/ui/self/elision/ref-struct-async.base.stderr b/src/test/ui/self/elision/ref-struct-async.base.stderr
index 8da673d4435..88ddca89804 100644
--- a/src/test/ui/self/elision/ref-struct-async.base.stderr
+++ b/src/test/ui/self/elision/ref-struct-async.base.stderr
@@ -7,6 +7,12 @@ LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-struct-async.rs:22:9
@@ -17,6 +23,12 @@ LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-struct-async.rs:28:9
@@ -27,6 +39,12 @@ LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-struct-async.rs:34:9
@@ -37,6 +55,12 @@ LL | async fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_box_ref_Struct<'a>(self: Box<Box<&'a Struct>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error[E0623]: lifetime mismatch
--> $DIR/ref-struct-async.rs:40:9
@@ -47,6 +71,12 @@ LL | async fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 {
| this parameter and the return type are declared with different lifetimes...
LL | f
| ^ ...but data from `f` is returned here
+ |
+ = note: each elided lifetime in input position becomes a distinct lifetime
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_pin_Struct<'a>(self: Box<Pin<&'a Struct>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: aborting due to 5 previous errors
diff --git a/src/test/ui/self/elision/ref-struct-async.nll.stderr b/src/test/ui/self/elision/ref-struct-async.nll.stderr
index ad07c70df87..83c20329c3d 100644
--- a/src/test/ui/self/elision/ref-struct-async.nll.stderr
+++ b/src/test/ui/self/elision/ref-struct-async.nll.stderr
@@ -7,6 +7,11 @@ LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-struct-async.rs:22:9
@@ -17,6 +22,11 @@ LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-struct-async.rs:28:9
@@ -27,6 +37,11 @@ LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-struct-async.rs:34:9
@@ -37,6 +52,11 @@ LL | async fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_box_ref_Struct<'a>(self: Box<Box<&'a Struct>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-struct-async.rs:40:9
@@ -47,6 +67,11 @@ LL | async fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 {
| let's call the lifetime of this reference `'2`
LL | f
| ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
+ |
+help: consider introducing a named lifetime parameter and update trait if needed
+ |
+LL | async fn box_pin_Struct<'a>(self: Box<Pin<&'a Struct>>, f: &'a u32) -> &u32 {
+ | ++++ ++ ++
error: aborting due to 5 previous errors
diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs
index 283b20fc24d..b1c82ac76e8 100644
--- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs
+++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs
@@ -125,7 +125,7 @@ fn check_rvalue<'tcx>(
Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
check_place(tcx, *place, span, body)
},
- Rvalue::Cast(CastKind::PointerAddress, _, _) => {
+ Rvalue::Cast(CastKind::PointerExposeAddress, _, _) => {
Err((span, "casting pointers to ints is unstable in const fn".into()))
},
Rvalue::Cast(CastKind::Misc, operand, _) => {