Skip to content

Rollup of 7 pull requests #98669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jun 29, 2022
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
dcfe92e
add `fetch_not` method on `AtomicBool`
Jun 25, 2022
7d5f236
Add feature gate `#![atomic_bool_fetch_not]`
Jun 25, 2022
0df7364
temporarily remove tests because I'm not sure if we need them
Jun 25, 2022
3b117c4
library: fix uefi va_list type definition
dlrobertson Jun 26, 2022
9c5ae20
forgot about the feature flag in the doctest
Jun 26, 2022
6e32a16
fix box with custom allocator in miri
beepster4096 Jun 26, 2022
d317988
validate box's allocator
beepster4096 Jun 27, 2022
7533777
Remove `final_arg_types`, improve tuple wrapping suggestion
compiler-errors Jun 28, 2022
9f9c311
Validate all fields of box instead of validating allocator specifically
beepster4096 Jun 28, 2022
5fc1dd1
emit Retag for compound types with reference fields
RalfJung Jun 28, 2022
9039265
fix silly mistake
beepster4096 Jun 28, 2022
98af1bf
Migrate some rustc_borrowck diagnostics to SessionDiagnostic
compiler-errors Jun 23, 2022
23f3b0d
Don't point at another arg if we're already pointing at one
compiler-errors Jun 29, 2022
1e40200
Erase regions in new abstract consts
JulianKnodt Jun 25, 2022
d10497b
Rollup merge of #98415 - compiler-errors:rustc-borrowck-session-diagn…
Dylan-DPC Jun 29, 2022
3f2ba25
Rollup merge of #98479 - leocth:atomic-bool-fetch-not, r=joshtriplett
Dylan-DPC Jun 29, 2022
7b9a7ef
Rollup merge of #98499 - JulianKnodt:erase_lifetime, r=lcnr
Dylan-DPC Jun 29, 2022
375ab3e
Rollup merge of #98516 - dlrobertson:uefi_va_list, r=joshtriplett
Dylan-DPC Jun 29, 2022
b2836bd
Rollup merge of #98554 - DrMeepster:box_unsizing_is_not_special, r=Ra…
Dylan-DPC Jun 29, 2022
fcbb2e8
Rollup merge of #98607 - compiler-errors:tuple-wrap-suggestion, r=oli…
Dylan-DPC Jun 29, 2022
68228be
Rollup merge of #98625 - RalfJung:retag, r=oli-obk
Dylan-DPC Jun 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -3595,6 +3595,7 @@ dependencies = [
"rustc_index",
"rustc_infer",
"rustc_lexer",
"rustc_macros",
"rustc_middle",
"rustc_mir_dataflow",
"rustc_serialize",
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/Cargo.toml
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_infer = { path = "../rustc_infer" }
rustc_lexer = { path = "../rustc_lexer" }
rustc_macros = { path = "../rustc_macros" }
rustc_middle = { path = "../rustc_middle" }
rustc_const_eval = { path = "../rustc_const_eval" }
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
27 changes: 18 additions & 9 deletions compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs
Original file line number Diff line number Diff line change
@@ -19,6 +19,9 @@ use std::fmt;
use std::rc::Rc;

use crate::region_infer::values::RegionElement;
use crate::session_diagnostics::HigherRankedErrorCause;
use crate::session_diagnostics::HigherRankedLifetimeError;
use crate::session_diagnostics::HigherRankedSubtypeError;
use crate::MirBorrowckCtxt;

#[derive(Clone)]
@@ -69,7 +72,7 @@ impl<'tcx> UniverseInfo<'tcx> {
// up in the existing UI tests. Consider investigating this
// some more.
mbcx.buffer_error(
mbcx.infcx.tcx.sess.struct_span_err(cause.span, "higher-ranked subtype error"),
mbcx.infcx.tcx.sess.create_err(HigherRankedSubtypeError { span: cause.span }),
);
}
}
@@ -216,9 +219,12 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
tcx: TyCtxt<'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error");
err.note(&format!("could not prove {}", self.canonical_query.value.value.predicate));
err
tcx.sess.create_err(HigherRankedLifetimeError {
cause: Some(HigherRankedErrorCause::CouldNotProve {
predicate: self.canonical_query.value.value.predicate.to_string(),
}),
span,
})
}

fn base_universe(&self) -> ty::UniverseIndex {
@@ -263,9 +269,12 @@ where
tcx: TyCtxt<'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error");
err.note(&format!("could not normalize `{}`", self.canonical_query.value.value.value));
err
tcx.sess.create_err(HigherRankedLifetimeError {
cause: Some(HigherRankedErrorCause::CouldNotNormalize {
value: self.canonical_query.value.value.value.to_string(),
}),
span,
})
}

fn base_universe(&self) -> ty::UniverseIndex {
@@ -326,7 +335,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
// FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
// and is only the fallback when the nice error fails. Consider improving this some more.
tcx.sess.struct_span_err(span, "higher-ranked lifetime error")
tcx.sess.create_err(HigherRankedLifetimeError { cause: None, span })
}

fn base_universe(&self) -> ty::UniverseIndex {
@@ -366,7 +375,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
// FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
// and is only the fallback when the nice error fails. Consider improving this some more.
tcx.sess.struct_span_err(span, "higher-ranked lifetime error for opaque type!")
tcx.sess.create_err(HigherRankedLifetimeError { cause: None, span })
}

fn base_universe(&self) -> ty::UniverseIndex {
9 changes: 6 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ use rustc_span::symbol::Ident;
use rustc_span::Span;

use crate::borrowck_errors;
use crate::session_diagnostics::GenericDoesNotLiveLongEnough;

use super::{OutlivesSuggestionBuilder, RegionName};
use crate::region_infer::BlameConstraint;
@@ -196,9 +197,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
// to report it; we could probably handle it by
// iterating over the universal regions and reporting
// an error that multiple bounds are required.
self.buffer_error(self.infcx.tcx.sess.struct_span_err(
type_test_span,
&format!("`{}` does not live long enough", type_test.generic_kind),
self.buffer_error(self.infcx.tcx.sess.create_err(
GenericDoesNotLiveLongEnough {
kind: type_test.generic_kind.to_string(),
span: type_test_span,
},
));
}
}
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
@@ -76,6 +76,7 @@ mod places_conflict;
mod prefixes;
mod region_infer;
mod renumber;
mod session_diagnostics;
mod type_check;
mod universal_regions;
mod used_muts;
44 changes: 44 additions & 0 deletions compiler/rustc_borrowck/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
use rustc_middle::ty::Ty;
use rustc_span::Span;

#[derive(SessionDiagnostic)]
#[error(borrowck::move_unsized, code = "E0161")]
pub(crate) struct MoveUnsized<'tcx> {
pub ty: Ty<'tcx>,
#[primary_span]
#[label]
pub span: Span,
}

#[derive(SessionDiagnostic)]
#[error(borrowck::higher_ranked_lifetime_error)]
pub(crate) struct HigherRankedLifetimeError {
#[subdiagnostic]
pub cause: Option<HigherRankedErrorCause>,
#[primary_span]
pub span: Span,
}

#[derive(SessionSubdiagnostic)]
pub(crate) enum HigherRankedErrorCause {
#[note(borrowck::could_not_prove)]
CouldNotProve { predicate: String },
#[note(borrowck::could_not_normalize)]
CouldNotNormalize { value: String },
}

#[derive(SessionDiagnostic)]
#[error(borrowck::higher_ranked_subtype_error)]
pub(crate) struct HigherRankedSubtypeError {
#[primary_span]
pub span: Span,
}

#[derive(SessionDiagnostic)]
#[error(borrowck::generic_does_not_live_long_enough)]
pub(crate) struct GenericDoesNotLiveLongEnough {
pub kind: String,
#[primary_span]
pub span: Span,
}
13 changes: 2 additions & 11 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ use hir::OpaqueTyOrigin;
use rustc_data_structures::frozen::Frozen;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::vec_map::VecMap;
use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalDefId;
@@ -48,6 +47,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::ResultsCursor;

use crate::session_diagnostics::MoveUnsized;
use crate::{
borrow_set::BorrowSet,
constraints::{OutlivesConstraint, OutlivesConstraintSet},
@@ -1780,19 +1780,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
// slot or local, so to find all unsized rvalues it is enough
// to check all temps, return slots and locals.
if self.reported_errors.replace((ty, span)).is_none() {
let mut diag = struct_span_err!(
self.tcx().sess,
span,
E0161,
"cannot move a value of type {0}: the size of {0} \
cannot be statically determined",
ty
);

// While this is located in `nll::typeck` this error is not
// an NLL error, it's a required check to prevent creation
// of unsized rvalues in a call expression.
diag.emit();
self.tcx().sess.emit_err(MoveUnsized { ty, span });
}
}
}
16 changes: 0 additions & 16 deletions compiler/rustc_const_eval/src/interpret/cast.rs
Original file line number Diff line number Diff line change
@@ -366,22 +366,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
assert_eq!(def_a, def_b);
if def_a.is_box() || def_b.is_box() {
if !def_a.is_box() || !def_b.is_box() {
span_bug!(
self.cur_span(),
"invalid unsizing between {:?} -> {:?}",
src.layout.ty,
cast_ty.ty
);
}
return self.unsize_into_ptr(
src,
dest,
src.layout.ty.boxed_ty(),
cast_ty.ty.boxed_ty(),
);
}

// unsizing of generic struct with pointer fields
// Example: `Arc<T>` -> `Arc<Trait>`
8 changes: 7 additions & 1 deletion compiler/rustc_const_eval/src/interpret/validity.rs
Original file line number Diff line number Diff line change
@@ -594,7 +594,13 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
Ok(true)
}
ty::Adt(def, ..) if def.is_box() => {
self.check_safe_pointer(value, "box")?;
let unique = self.ecx.operand_field(value, 0)?;
let nonnull = self.ecx.operand_field(&unique, 0)?;
let ptr = self.ecx.operand_field(&nonnull, 0)?;
self.check_safe_pointer(&ptr, "box")?;

// Check other fields of Box
self.walk_value(value)?;
Ok(true)
}
ty::FnPtr(_sig) => {
18 changes: 18 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/borrowck.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
borrowck-move-unsized =
cannot move a value of type `{$ty}`
.label = the size of `{$ty}` cannot be statically determined

borrowck-higher-ranked-lifetime-error =
higher-ranked lifetime error

borrowck-could-not-prove =
could not prove `{$predicate}`

borrowck-could-not-normalize =
could not normalize `{$value}`

borrowck-higher-ranked-subtype-error =
higher-ranked subtype error

generic-does-not-live-long-enough =
`{$kind}` does not live long enough
1 change: 1 addition & 0 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ fluent_messages! {
privacy => "../locales/en-US/privacy.ftl",
typeck => "../locales/en-US/typeck.ftl",
builtin_macros => "../locales/en-US/builtin_macros.ftl",
borrowck => "../locales/en-US/borrowck.ftl",
}

pub use fluent_generated::{self as fluent, DEFAULT_LOCALE_RESOURCES};
14 changes: 12 additions & 2 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
@@ -281,9 +281,19 @@ pub trait Emitter {
let message = bundle.get_message(&identifier).expect("missing diagnostic in fluent bundle");
let value = match attr {
Some(attr) => {
message.get_attribute(attr).expect("missing attribute in fluent message").value()
if let Some(attr) = message.get_attribute(attr) {
attr.value()
} else {
panic!("missing attribute `{attr}` in fluent message `{identifier}`")
}
}
None => {
if let Some(value) = message.value() {
value
} else {
panic!("missing value in fluent message `{identifier}`")
}
}
None => message.value().expect("missing value in fluent message"),
};

let mut err = vec![];
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
@@ -342,8 +342,8 @@ pub fn same_type_modulo_infer<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
)
| (&ty::Infer(ty::InferTy::TyVar(_)), _)
| (_, &ty::Infer(ty::InferTy::TyVar(_))) => true,
(&ty::Ref(reg_a, ty_a, mut_a), &ty::Ref(reg_b, ty_b, mut_b)) => {
reg_a == reg_b && mut_a == mut_b && same_type_modulo_infer(*ty_a, *ty_b)
(&ty::Ref(_, ty_a, mut_a), &ty::Ref(_, ty_b, mut_b)) => {
mut_a == mut_b && same_type_modulo_infer(*ty_a, *ty_b)
}
_ => a == b,
}
23 changes: 18 additions & 5 deletions compiler/rustc_mir_transform/src/add_retag.rs
Original file line number Diff line number Diff line change
@@ -33,8 +33,9 @@ fn is_stable(place: PlaceRef<'_>) -> bool {
})
}

/// Determine whether this type may be a reference (or box), and thus needs retagging.
fn may_be_reference(ty: Ty<'_>) -> bool {
/// Determine whether this type may contain a reference (or box), and thus needs retagging.
/// We will only recurse `depth` times into Tuples/ADTs to bound the cost of this.
fn may_contain_reference<'tcx>(ty: Ty<'tcx>, depth: u32, tcx: TyCtxt<'tcx>) -> bool {
match ty.kind() {
// Primitive types that are not references
ty::Bool
@@ -50,8 +51,20 @@ fn may_be_reference(ty: Ty<'_>) -> bool {
// References
ty::Ref(..) => true,
ty::Adt(..) if ty.is_box() => true,
// Compound types are not references
ty::Array(..) | ty::Slice(..) | ty::Tuple(..) | ty::Adt(..) => false,
// Compound types: recurse
ty::Array(ty, _) | ty::Slice(ty) => {
// This does not branch so we keep the depth the same.
may_contain_reference(*ty, depth, tcx)
}
ty::Tuple(tys) => {
depth == 0 || tys.iter().any(|ty| may_contain_reference(ty, depth - 1, tcx))
}
ty::Adt(adt, subst) => {
depth == 0
|| adt.variants().iter().any(|v| {
v.fields.iter().any(|f| may_contain_reference(f.ty(tcx, subst), depth - 1, tcx))
})
}
// Conservative fallback
_ => true,
}
@@ -83,7 +96,7 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
// FIXME: Instead of giving up for unstable places, we should introduce
// a temporary and retag on that.
is_stable(place.as_ref())
&& may_be_reference(place.ty(&*local_decls, tcx).ty)
&& may_contain_reference(place.ty(&*local_decls, tcx).ty, /*depth*/ 3, tcx)
&& is_not_temp(&local_decls[place.local])
};
let place_base_raw = |place: &Place<'tcx>| {
Original file line number Diff line number Diff line change
@@ -236,7 +236,7 @@ impl<'tcx> AbstractConst<'tcx> {
) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> {
let inner = tcx.thir_abstract_const_opt_const_arg(uv.def)?;
debug!("AbstractConst::new({:?}) = {:?}", uv, inner);
Ok(inner.map(|inner| AbstractConst { inner, substs: uv.substs }))
Ok(inner.map(|inner| AbstractConst { inner, substs: tcx.erase_regions(uv.substs) }))
}

pub fn from_const(
@@ -416,6 +416,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
// `AbstractConst`s should not contain any promoteds as they require references which
// are not allowed.
assert_eq!(ct.promoted, None);
assert_eq!(ct, self.tcx.erase_regions(ct));
}
}
}
346 changes: 169 additions & 177 deletions compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions library/core/src/ffi/mod.rs
Original file line number Diff line number Diff line change
@@ -231,7 +231,8 @@ impl fmt::Debug for c_void {
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_family = "wasm",
target_arch = "asmjs",
windows
target_os = "uefi",
windows,
))]
#[repr(transparent)]
#[unstable(
@@ -254,7 +255,8 @@ pub struct VaListImpl<'f> {
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_family = "wasm",
target_arch = "asmjs",
windows
target_os = "uefi",
windows,
))]
#[unstable(
feature = "c_variadic",
@@ -276,7 +278,8 @@ impl<'f> fmt::Debug for VaListImpl<'f> {
#[cfg(all(
target_arch = "aarch64",
not(any(target_os = "macos", target_os = "ios")),
not(windows)
not(target_os = "uefi"),
not(windows),
))]
#[repr(C)]
#[derive(Debug)]
@@ -297,7 +300,7 @@ pub struct VaListImpl<'f> {
}

/// PowerPC ABI implementation of a `va_list`.
#[cfg(all(target_arch = "powerpc", not(windows)))]
#[cfg(all(target_arch = "powerpc", not(target_os = "uefi"), not(windows)))]
#[repr(C)]
#[derive(Debug)]
#[unstable(
@@ -317,7 +320,7 @@ pub struct VaListImpl<'f> {
}

/// x86_64 ABI implementation of a `va_list`.
#[cfg(all(target_arch = "x86_64", not(windows)))]
#[cfg(all(target_arch = "x86_64", not(target_os = "uefi"), not(windows)))]
#[repr(C)]
#[derive(Debug)]
#[unstable(
@@ -354,7 +357,8 @@ pub struct VaList<'a, 'f: 'a> {
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_family = "wasm",
target_arch = "asmjs",
windows
target_os = "uefi",
windows,
))]
inner: VaListImpl<'f>,

@@ -363,7 +367,8 @@ pub struct VaList<'a, 'f: 'a> {
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
not(target_family = "wasm"),
not(target_arch = "asmjs"),
not(windows)
not(target_os = "uefi"),
not(windows),
))]
inner: &'a mut VaListImpl<'f>,

@@ -375,7 +380,8 @@ pub struct VaList<'a, 'f: 'a> {
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_family = "wasm",
target_arch = "asmjs",
windows
target_os = "uefi",
windows,
))]
#[unstable(
feature = "c_variadic",
@@ -396,7 +402,8 @@ impl<'f> VaListImpl<'f> {
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
not(target_family = "wasm"),
not(target_arch = "asmjs"),
not(windows)
not(target_os = "uefi"),
not(windows),
))]
#[unstable(
feature = "c_variadic",
36 changes: 36 additions & 0 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
@@ -854,6 +854,42 @@ impl AtomicBool {
unsafe { atomic_xor(self.v.get(), val as u8, order) != 0 }
}

/// Logical "not" with a boolean value.
///
/// Performs a logical "not" operation on the current value, and sets
/// the new value to the result.
///
/// Returns the previous value.
///
/// `fetch_not` takes an [`Ordering`] argument which describes the memory ordering
/// of this operation. All ordering modes are possible. Note that using
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and
/// using [`Release`] makes the load part [`Relaxed`].
///
/// **Note:** This method is only available on platforms that support atomic
/// operations on `u8`.
///
/// # Examples
///
/// ```
/// #![feature(atomic_bool_fetch_not)]
/// use std::sync::atomic::{AtomicBool, Ordering};
///
/// let foo = AtomicBool::new(true);
/// assert_eq!(foo.fetch_not(Ordering::SeqCst), true);
/// assert_eq!(foo.load(Ordering::SeqCst), false);
///
/// let foo = AtomicBool::new(false);
/// assert_eq!(foo.fetch_not(Ordering::SeqCst), false);
/// assert_eq!(foo.load(Ordering::SeqCst), true);
/// ```
#[inline]
#[unstable(feature = "atomic_bool_fetch_not", issue = "98485")]
#[cfg(target_has_atomic = "8")]
pub fn fetch_not(&self, order: Ordering) -> bool {
self.fetch_xor(true, order)
}

/// Returns a mutable pointer to the underlying [`bool`].
///
/// Doing non-atomic reads and writes on the resulting integer can be a data race.
Original file line number Diff line number Diff line change
@@ -129,6 +129,7 @@ fn array_casts() -> () {
_18 = &(*_35); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
Retag(_18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_13 = (move _14, move _18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
Retag(_13); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageDead(_18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageDead(_14); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageLive(_20); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
@@ -171,6 +172,7 @@ fn array_casts() -> () {
Retag(_32); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageLive(_34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_34 = Option::<Arguments>::None; // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
Retag(_34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_28 = core::panicking::assert_failed::<usize, usize>(move _29, move _30, move _32, move _34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
// mir::Constant
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
33 changes: 33 additions & 0 deletions src/test/ui/const-generics/try_unify_ignore_lifetimes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// check-pass
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

struct Num<const N: usize>;

trait NumT {
const VALUE: usize;
}

impl<const N: usize> NumT for Num<N> {
const VALUE: usize = N;
}

struct Foo<'a, N: NumT>(&'a [u32; N::VALUE]) where [(); N::VALUE]:;

trait Bar {
type Size: NumT;

fn bar<'a>(foo: &Foo<'a, Self::Size>) where [(); Self::Size::VALUE]: {
todo!();
}
}

trait Baz<'a> {
type Size: NumT;

fn baz(foo: &Foo<'a, Self::Size>) where [(); Self::Size::VALUE]: {
todo!();
}
}

fn main() {}
8 changes: 4 additions & 4 deletions src/test/ui/dst/dst-index.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
error[E0161]: cannot move a value of type str: the size of str cannot be statically determined
error[E0161]: cannot move a value of type `str`
--> $DIR/dst-index.rs:31:5
|
LL | S[0];
| ^^^^
| ^^^^ the size of `str` cannot be statically determined

error[E0161]: cannot move a value of type dyn Debug: the size of dyn Debug cannot be statically determined
error[E0161]: cannot move a value of type `dyn Debug`
--> $DIR/dst-index.rs:34:5
|
LL | T[0];
| ^^^^
| ^^^^ the size of `dyn Debug` cannot be statically determined

error[E0507]: cannot move out of index of `S`
--> $DIR/dst-index.rs:31:5
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0161.base.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined
error[E0161]: cannot move a value of type `dyn Bar`
--> $DIR/E0161.rs:16:5
|
LL | x.f();
| ^^^^^
| ^^^^^ the size of `dyn Bar` cannot be statically determined

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/higher-rank-trait-bounds/issue-59311.stderr
Original file line number Diff line number Diff line change
@@ -4,15 +4,15 @@ error: higher-ranked lifetime error
LL | v.t(|| {});
| ^^^^^^^^^^
|
= note: could not prove [closure@$DIR/issue-59311.rs:17:9: 17:14] well-formed
= note: could not prove `[closure@$DIR/issue-59311.rs:17:9: 17:14] well-formed`

error: higher-ranked lifetime error
--> $DIR/issue-59311.rs:17:9
|
LL | v.t(|| {});
| ^^^^^
|
= note: could not prove for<'a> &'a V: 'static
= note: could not prove `for<'a> &'a V: 'static`

error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/lifetimes/re-empty-in-error.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ error: higher-ranked lifetime error
LL | foo(&10);
| ^^^^^^^^
|
= note: could not prove for<'b, 'r> &'b (): 'r
= note: could not prove `for<'b, 'r> &'b (): 'r`

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/mir/issue-67947.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct Bug {
A: [(); { *"" }.len()],
//~^ ERROR: cannot move a value of type str
//~^ ERROR: cannot move a value of type `str`
//~| ERROR: cannot move out of a shared reference
}

4 changes: 2 additions & 2 deletions src/test/ui/mir/issue-67947.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0161]: cannot move a value of type str: the size of str cannot be statically determined
error[E0161]: cannot move a value of type `str`
--> $DIR/issue-67947.rs:2:13
|
LL | A: [(); { *"" }.len()],
| ^^^^^^^
| ^^^^^^^ the size of `str` cannot be statically determined

error[E0507]: cannot move out of a shared reference
--> $DIR/issue-67947.rs:2:15
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ trait Baz {
}

fn use_bar(t: Box<dyn Bar>) {
t.bar() //~ ERROR cannot move a value of type dyn Bar
t.bar() //~ ERROR cannot move a value of type `dyn Bar`
}

fn main() { }
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined
error[E0161]: cannot move a value of type `dyn Bar`
--> $DIR/object-safety-by-value-self-use.rs:15:5
|
LL | t.bar()
| ^^^^^^^
| ^^^^^^^ the size of `dyn Bar` cannot be statically determined

error: aborting due to previous error

5 changes: 1 addition & 4 deletions src/test/ui/proc-macro/signature.stderr
Original file line number Diff line number Diff line change
@@ -5,10 +5,7 @@ LL | / pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 {
LL | |
LL | | loop {}
LL | | }
| | ^
| | |
| |_call the function in a closure: `|| unsafe { /* code */ }`
| required by a bound introduced by this call
| |_^ call the function in a closure: `|| unsafe { /* code */ }`
|
= help: the trait `Fn<(proc_macro::TokenStream,)>` is not implemented for `unsafe extern "C" fn(i32, u32) -> u32 {foo}`
= note: unsafe function cannot be called generically without an unsafe block
10 changes: 5 additions & 5 deletions src/test/ui/suggestions/args-instead-of-tuple.stderr
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ note: tuple variant defined here
|
LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
| ^^
help: use parentheses to construct a tuple
help: wrap these arguments in parentheses to construct a tuple
|
LL | let _: Result<(i32, i8), ()> = Ok((1, 2));
| + +
@@ -25,7 +25,7 @@ note: tuple variant defined here
|
LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T),
| ^^^^
help: use parentheses to construct a tuple
help: wrap these arguments in parentheses to construct a tuple
|
LL | let _: Option<(i32, i8, &'static str)> = Some((1, 2, "hi"));
| + +
@@ -97,7 +97,7 @@ note: function defined here
|
LL | fn two_ints(_: (i32, i32)) {
| ^^^^^^^^ -------------
help: use parentheses to construct a tuple
help: wrap these arguments in parentheses to construct a tuple
|
LL | two_ints((1, 2));
| + +
@@ -113,7 +113,7 @@ note: function defined here
|
LL | fn with_generic<T: Copy + Send>((a, b): (i32, T)) {
| ^^^^^^^^^^^^ ----------------
help: use parentheses to construct a tuple
help: wrap these arguments in parentheses to construct a tuple
|
LL | with_generic((3, 4));
| + +
@@ -129,7 +129,7 @@ note: function defined here
|
LL | fn with_generic<T: Copy + Send>((a, b): (i32, T)) {
| ^^^^^^^^^^^^ ----------------
help: use parentheses to construct a tuple
help: wrap these arguments in parentheses to construct a tuple
|
LL | with_generic((a, b));
| + +
10 changes: 10 additions & 0 deletions src/test/ui/tuple/add-tuple-within-arguments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn foo(s: &str, a: (i32, i32), s2: &str) {}

fn bar(s: &str, a: (&str,), s2: &str) {}

fn main() {
foo("hi", 1, 2, "hi");
//~^ ERROR this function takes 3 arguments but 4 arguments were supplied
bar("hi", "hi", "hi");
//~^ ERROR mismatched types
}
40 changes: 40 additions & 0 deletions src/test/ui/tuple/add-tuple-within-arguments.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
error[E0061]: this function takes 3 arguments but 4 arguments were supplied
--> $DIR/add-tuple-within-arguments.rs:6:5
|
LL | foo("hi", 1, 2, "hi");
| ^^^
|
note: function defined here
--> $DIR/add-tuple-within-arguments.rs:1:4
|
LL | fn foo(s: &str, a: (i32, i32), s2: &str) {}
| ^^^ ------- ------------- --------
help: wrap these arguments in parentheses to construct a tuple
|
LL | foo("hi", (1, 2), "hi");
| + +

error[E0308]: mismatched types
--> $DIR/add-tuple-within-arguments.rs:8:15
|
LL | bar("hi", "hi", "hi");
| --- ^^^^ expected tuple, found `&str`
| |
| arguments to this function are incorrect
|
= note: expected tuple `(&str,)`
found reference `&'static str`
note: function defined here
--> $DIR/add-tuple-within-arguments.rs:3:4
|
LL | fn bar(s: &str, a: (&str,), s2: &str) {}
| ^^^ ------- ---------- --------
help: use a trailing comma to create a tuple with one element
|
LL | bar("hi", ("hi",), "hi");
| + ++

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0061, E0308.
For more information about an error, try `rustc --explain E0061`.
2 changes: 1 addition & 1 deletion src/test/ui/tuple/wrong_argument_ice-2.stderr
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ note: function defined here
|
LL | fn test(t: (i32, i32)) {}
| ^^^^ -------------
help: use parentheses to construct a tuple
help: wrap these arguments in parentheses to construct a tuple
|
LL | test((x.qux(), x.qux()));
| + +
2 changes: 1 addition & 1 deletion src/test/ui/tuple/wrong_argument_ice.stderr
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ note: associated function defined here
|
LL | pub fn push_back(&mut self, value: T) {
| ^^^^^^^^^
help: use parentheses to construct a tuple
help: wrap these arguments in parentheses to construct a tuple
|
LL | self.acc.push_back((self.current_provides, self.current_requires));
| + +
2 changes: 1 addition & 1 deletion src/test/ui/unsized/return-unsized-from-trait-method.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ trait Foo {
fn foo(f: Option<&dyn Foo>) {
if let Some(f) = f {
let _ = f.foo();
//~^ ERROR cannot move a value of type [u8]: the size of [u8] cannot be statically determined
//~^ ERROR cannot move a value of type `[u8]`
}
}

4 changes: 2 additions & 2 deletions src/test/ui/unsized/return-unsized-from-trait-method.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0161]: cannot move a value of type [u8]: the size of [u8] cannot be statically determined
error[E0161]: cannot move a value of type `[u8]`
--> $DIR/return-unsized-from-trait-method.rs:9:17
|
LL | let _ = f.foo();
| ^^^^^^^
| ^^^^^^^ the size of `[u8]` cannot be statically determined

error: aborting due to previous error

16 changes: 12 additions & 4 deletions src/test/ui/unsized/unsized-fn-param.stderr
Original file line number Diff line number Diff line change
@@ -2,7 +2,9 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t
--> $DIR/unsized-fn-param.rs:11:11
|
LL | foo11("bar", &"baz");
| ^^^^^ doesn't have a size known at compile-time
| ----- ^^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `str`
= note: required for the cast from `str` to the object type `dyn AsRef<Path>`
@@ -15,7 +17,9 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t
--> $DIR/unsized-fn-param.rs:13:19
|
LL | foo12(&"bar", "baz");
| ^^^^^ doesn't have a size known at compile-time
| ----- ^^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `str`
= note: required for the cast from `str` to the object type `dyn AsRef<Path>`
@@ -28,7 +32,9 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t
--> $DIR/unsized-fn-param.rs:16:11
|
LL | foo21("bar", &"baz");
| ^^^^^ doesn't have a size known at compile-time
| ----- ^^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `str`
= note: required for the cast from `str` to the object type `dyn AsRef<str>`
@@ -41,7 +47,9 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t
--> $DIR/unsized-fn-param.rs:18:19
|
LL | foo22(&"bar", "baz");
| ^^^^^ doesn't have a size known at compile-time
| ----- ^^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `str`
= note: required for the cast from `str` to the object type `dyn AsRef<str>`
1 change: 1 addition & 0 deletions src/test/ui/unsized/unsized3.rs
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ fn f9<X: ?Sized>(x1: Box<S<X>>) {
fn f10<X: ?Sized>(x1: Box<S<X>>) {
f5(&(32, *x1));
//~^ ERROR the size for values of type
//~| ERROR the size for values of type
}

pub fn main() {}
35 changes: 33 additions & 2 deletions src/test/ui/unsized/unsized3.stderr
Original file line number Diff line number Diff line change
@@ -100,6 +100,29 @@ LL - fn f9<X: ?Sized>(x1: Box<S<X>>) {
LL + fn f9<X>(x1: Box<S<X>>) {
|

error[E0277]: the size for values of type `X` cannot be known at compilation time
--> $DIR/unsized3.rs:45:9
|
LL | fn f10<X: ?Sized>(x1: Box<S<X>>) {
| - this type parameter needs to be `std::marker::Sized`
LL | f5(&(32, *x1));
| -- ^^^^^^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
|
note: required because it appears within the type `S<X>`
--> $DIR/unsized3.rs:28:8
|
LL | struct S<X: ?Sized> {
| ^
= note: required because it appears within the type `({integer}, S<X>)`
= note: tuples must have a statically known size to be initialized
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
LL - fn f10<X: ?Sized>(x1: Box<S<X>>) {
LL + fn f10<X>(x1: Box<S<X>>) {
|

error[E0277]: the size for values of type `X` cannot be known at compilation time
--> $DIR/unsized3.rs:45:8
|
@@ -116,13 +139,21 @@ note: required because it appears within the type `S<X>`
LL | struct S<X: ?Sized> {
| ^
= note: required because it appears within the type `({integer}, S<X>)`
= note: tuples must have a statically known size to be initialized
note: required by a bound in `f5`
--> $DIR/unsized3.rs:24:7
|
LL | fn f5<Y>(x: &Y) {}
| ^ required by this bound in `f5`
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
LL - fn f10<X: ?Sized>(x1: Box<S<X>>) {
LL + fn f10<X>(x1: Box<S<X>>) {
|
help: consider relaxing the implicit `Sized` restriction
|
LL | fn f5<Y: ?Sized>(x: &Y) {}
| ++++++++

error: aborting due to 5 previous errors
error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0277`.