Auto merge of #129915 - matthiaskrgr:rollup-56h2xp2, r=matthiaskrgr
Rollup of 12 pull requests Successful merges: - #129748 (Box validity: update for new zero-sized rules) - #129829 (Make decoding non-optional `LazyArray` panic if not set) - #129856 (compiler_fence documentation: emphasize synchronization, not reordering) - #129868 (Remove kobzol vacation status) - #129875 (chore: Fix typos in 'compiler' (batch 1)) - #129877 (chore: Fix typos in 'compiler' (batch 2)) - #129878 (chore: Fix typos in 'compiler' (batch 3)) - #129890 (Remove stray word in a comment) - #129892 (Clarify language around ptrs in slice::raw) - #129905 (mailmap: add new email for davidtwco) - #129906 (mailmapper?) - #129907 (Fix compile error in solid's remove_dir_all) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
2251572086
2
.mailmap
2
.mailmap
@ -81,6 +81,7 @@ boolean_coercion <booleancoercion@gmail.com>
|
||||
Boris Egorov <jightuse@gmail.com> <egorov@linux.com>
|
||||
bors <bors@rust-lang.org> bors[bot] <26634292+bors[bot]@users.noreply.github.com>
|
||||
bors <bors@rust-lang.org> bors[bot] <bors[bot]@users.noreply.github.com>
|
||||
Boxy <rust@boxyuwu.dev> <supbscripter@gmail.com>
|
||||
Braden Nelson <moonheart08@users.noreply.github.com>
|
||||
Brandon Sanderson <singingboyo@gmail.com> Brandon Sanderson <singingboyo@hotmail.com>
|
||||
Brett Cannon <brett@python.org> Brett Cannon <brettcannon@users.noreply.github.com>
|
||||
@ -146,6 +147,7 @@ David Klein <david.klein@baesystemsdetica.com>
|
||||
David Manescu <david.manescu@gmail.com> <dman2626@uni.sydney.edu.au>
|
||||
David Ross <daboross@daboross.net>
|
||||
David Wood <david@davidtw.co> <david.wood@huawei.com>
|
||||
David Wood <david@davidtw.co> <david.wood2@arm.com>
|
||||
Deadbeef <ent3rm4n@gmail.com>
|
||||
Deadbeef <ent3rm4n@gmail.com> <fee1-dead-beef@protonmail.com>
|
||||
dependabot[bot] <dependabot[bot]@users.noreply.github.com> <27856297+dependabot-preview[bot]@users.noreply.github.com>
|
||||
|
@ -72,7 +72,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
fn has_self(&self, def_id: DefId, span: Span) -> bool {
|
||||
if let Some(local_sig_id) = def_id.as_local() {
|
||||
// The value may be missing due to recursive delegation.
|
||||
// Error will be emmited later during HIR ty lowering.
|
||||
// Error will be emitted later during HIR ty lowering.
|
||||
self.resolver.delegation_fn_sigs.get(&local_sig_id).map_or(false, |sig| sig.has_self)
|
||||
} else {
|
||||
match self.tcx.def_kind(def_id) {
|
||||
@ -139,7 +139,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
fn param_count(&self, sig_id: DefId) -> (usize, bool /*c_variadic*/) {
|
||||
if let Some(local_sig_id) = sig_id.as_local() {
|
||||
// Map may be filled incorrectly due to recursive delegation.
|
||||
// Error will be emmited later during HIR ty lowering.
|
||||
// Error will be emitted later during HIR ty lowering.
|
||||
match self.resolver.delegation_fn_sigs.get(&local_sig_id) {
|
||||
Some(sig) => (sig.param_count, sig.c_variadic),
|
||||
None => (0, false),
|
||||
|
@ -1179,7 +1179,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
|
||||
for field in &variant.fields {
|
||||
// In practice unless there are more than one field with the same type, we'll be
|
||||
// suggesting a single field at a type, because we don't aggregate multiple borrow
|
||||
// checker errors involving the functional record update sytnax into a single one.
|
||||
// checker errors involving the functional record update syntax into a single one.
|
||||
let field_ty = field.ty(self.infcx.tcx, args);
|
||||
let ident = field.ident(self.infcx.tcx);
|
||||
if field_ty == ty && fields.iter().all(|field| field.ident.name != ident.name) {
|
||||
|
@ -218,7 +218,7 @@ impl<'a, 'me, 'typeck, 'flow, 'tcx> LivenessResults<'a, 'me, 'typeck, 'flow, 'tc
|
||||
// This collect is more necessary than immediately apparent
|
||||
// because these facts go into `add_drop_live_facts_for()`,
|
||||
// which also writes to `all_facts`, and so this is genuinely
|
||||
// a simulatneous overlapping mutable borrow.
|
||||
// a simultaneous overlapping mutable borrow.
|
||||
// FIXME for future hackers: investigate whether this is
|
||||
// actually necessary; these facts come from Polonius
|
||||
// and probably maybe plausibly does not need to go back in.
|
||||
|
@ -422,7 +422,7 @@ fn prepare_usage_sets<'tcx>(tcx: TyCtxt<'tcx>) -> UsageSets<'tcx> {
|
||||
(instance.def_id(), body)
|
||||
});
|
||||
|
||||
// Functions whose coverage statments were found inlined into other functions.
|
||||
// Functions whose coverage statements were found inlined into other functions.
|
||||
let mut used_via_inlining = FxHashSet::default();
|
||||
// Functions that were instrumented, but had all of their coverage statements
|
||||
// removed by later MIR transforms (e.g. UnreachablePropagation).
|
||||
|
@ -701,7 +701,7 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
|
||||
match ty.kind() {
|
||||
ty::Int(ity) => {
|
||||
// FIXME: directly extract the bits from a valtree instead of evaluating an
|
||||
// alreay evaluated `Const` in order to get the bits.
|
||||
// already evaluated `Const` in order to get the bits.
|
||||
let bits = ct.eval_bits(tcx, ty::ParamEnv::reveal_all());
|
||||
let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128;
|
||||
write!(output, "{val}")
|
||||
|
@ -20,7 +20,7 @@ use super::{
|
||||
};
|
||||
use crate::fluent_generated as fluent;
|
||||
|
||||
/// An argment passed to a function.
|
||||
/// An argument passed to a function.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum FnArg<'tcx, Prov: Provenance = CtfeProvenance> {
|
||||
/// Pass a copy of the given operand.
|
||||
@ -123,7 +123,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
self.tcx.has_attr(def.did(), sym::rustc_nonnull_optimization_guaranteed)
|
||||
};
|
||||
let inner = self.unfold_transparent(inner, /* may_unfold */ |def| {
|
||||
// Stop at NPO tpyes so that we don't miss that attribute in the check below!
|
||||
// Stop at NPO types so that we don't miss that attribute in the check below!
|
||||
def.is_struct() && !is_npo(def)
|
||||
});
|
||||
Ok(match inner.ty.kind() {
|
||||
|
@ -574,7 +574,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
// be computed as the type references non-existing names.
|
||||
// See <https://github.com/rust-lang/rust/issues/124348>.
|
||||
} else {
|
||||
// Looks like the const is not captued by `required_consts`, that's bad.
|
||||
// Looks like the const is not captured by `required_consts`, that's bad.
|
||||
span_bug!(span, "interpret const eval failure of {val:?} which is not in required_consts");
|
||||
}
|
||||
}
|
||||
|
@ -827,7 +827,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
|
||||
let (size, align) = if nested {
|
||||
// Nested anonymous statics are untyped, so let's get their
|
||||
// size and alignment from the allocaiton itself. This always
|
||||
// size and alignment from the allocation itself. This always
|
||||
// succeeds, as the query is fed at DefId creation time, so no
|
||||
// evaluation actually occurs.
|
||||
let alloc = self.tcx.eval_static_initializer(def_id).unwrap();
|
||||
|
@ -186,7 +186,7 @@ pub(super) enum Place<Prov: Provenance = CtfeProvenance> {
|
||||
/// `Local` places always refer to the current stack frame, so they are unstable under
|
||||
/// function calls/returns and switching betweens stacks of different threads!
|
||||
/// We carry around the address of the `locals` buffer of the correct stack frame as a sanity
|
||||
/// chec to be able to catch some cases of using a dangling `Place`.
|
||||
/// check to be able to catch some cases of using a dangling `Place`.
|
||||
///
|
||||
/// This variant shall not be used for unsized types -- those must always live in memory.
|
||||
Local { local: mir::Local, offset: Option<Size>, locals_addr: usize },
|
||||
|
@ -1,5 +1,5 @@
|
||||
//! Manages the low-level pushing and popping of stack frames and the (de)allocation of local variables.
|
||||
//! For hadling of argument passing and return values, see the `call` module.
|
||||
//! For handling of argument passing and return values, see the `call` module.
|
||||
use std::cell::Cell;
|
||||
use std::{fmt, mem};
|
||||
|
||||
|
@ -42,7 +42,7 @@ impl fmt::Display for BaseNString {
|
||||
}
|
||||
|
||||
// This trait just lets us reserve the exact right amount of space when doing fixed-length
|
||||
// case-insensitve encoding. Add any impls you need.
|
||||
// case-insensitive encoding. Add any impls you need.
|
||||
pub trait ToBaseN: Into<u128> {
|
||||
fn encoded_len(base: usize) -> usize;
|
||||
|
||||
|
@ -477,7 +477,7 @@ where
|
||||
// will know when we hit the state where previous_node == node.
|
||||
loop {
|
||||
// Back at the beginning, we can return. Note that we return the root state.
|
||||
// This is becuse for components being explored, we would otherwise get a
|
||||
// This is because for components being explored, we would otherwise get a
|
||||
// `node_state[n] = InCycleWith{ parent: n }` and that's wrong.
|
||||
if previous_node == node {
|
||||
return root_state;
|
||||
|
@ -3,11 +3,11 @@
|
||||
//! or 16 bytes of the hash.
|
||||
//!
|
||||
//! The types in this module represent 64-bit or 128-bit hashes produced by a `StableHasher`.
|
||||
//! `Hash64` and `Hash128` expose some utilty functions to encourage users to not extract the inner
|
||||
//! `Hash64` and `Hash128` expose some utility functions to encourage users to not extract the inner
|
||||
//! hash value as an integer type and accidentally apply varint encoding to it.
|
||||
//!
|
||||
//! In contrast with `Fingerprint`, users of these types cannot and should not attempt to construct
|
||||
//! and decompose these types into constitutent pieces. The point of these types is only to
|
||||
//! and decompose these types into constituent pieces. The point of these types is only to
|
||||
//! connect the fact that they can only be produced by a `StableHasher` to their
|
||||
//! `Encode`/`Decode` impls.
|
||||
|
||||
|
@ -19,7 +19,7 @@ impl RegistryId {
|
||||
/// index within the registry. This panics if the current thread is not associated with this
|
||||
/// registry.
|
||||
///
|
||||
/// Note that there's a race possible where the identifer in `THREAD_DATA` could be reused
|
||||
/// Note that there's a race possible where the identifier in `THREAD_DATA` could be reused
|
||||
/// so this can succeed from a different registry.
|
||||
#[cfg(parallel_compiler)]
|
||||
fn verify(self) -> usize {
|
||||
@ -50,7 +50,7 @@ struct ThreadData {
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
/// A thread local which contains the identifer of `REGISTRY` but allows for faster access.
|
||||
/// A thread local which contains the identifier of `REGISTRY` but allows for faster access.
|
||||
/// It also holds the index of the current thread.
|
||||
static THREAD_DATA: ThreadData = const { ThreadData {
|
||||
registry_id: Cell::new(RegistryId(ptr::null())),
|
||||
@ -66,7 +66,7 @@ impl Registry {
|
||||
|
||||
/// Gets the registry associated with the current thread. Panics if there's no such registry.
|
||||
pub fn current() -> Self {
|
||||
REGISTRY.with(|registry| registry.get().cloned().expect("No assocated registry"))
|
||||
REGISTRY.with(|registry| registry.get().cloned().expect("No associated registry"))
|
||||
}
|
||||
|
||||
/// Registers the current thread with the registry so worker locals can be used on it.
|
||||
@ -92,7 +92,7 @@ impl Registry {
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets the identifer of this registry.
|
||||
/// Gets the identifier of this registry.
|
||||
fn id(&self) -> RegistryId {
|
||||
RegistryId(&*self.0)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ where
|
||||
```
|
||||
The latter scenario encounters this error because `Foo::Assoc<'a>` could be
|
||||
implemented by a type that does not use the `'a` parameter, so there is no
|
||||
guarentee that `X::Assoc<'a>` actually uses `'a`.
|
||||
guarantee that `X::Assoc<'a>` actually uses `'a`.
|
||||
|
||||
To fix this we can pass a dummy parameter:
|
||||
```
|
||||
|
@ -479,7 +479,7 @@ pub struct Subdiag {
|
||||
/// - The `EmissionGuarantee`, which determines the type returned from `emit`.
|
||||
///
|
||||
/// Each constructed `Diag` must be consumed by a function such as `emit`,
|
||||
/// `cancel`, `delay_as_bug`, or `into_diag`. A panic occurrs if a `Diag`
|
||||
/// `cancel`, `delay_as_bug`, or `into_diag`. A panic occurs if a `Diag`
|
||||
/// is dropped without being consumed by one of these functions.
|
||||
///
|
||||
/// If there is some state in a downstream crate you would like to access in
|
||||
|
@ -2300,7 +2300,7 @@ impl HumanEmitter {
|
||||
// For example, for the following:
|
||||
// |
|
||||
// 2 - .await
|
||||
// 2 + (note the left over whitepsace)
|
||||
// 2 + (note the left over whitespace)
|
||||
// |
|
||||
// We really want
|
||||
// |
|
||||
|
@ -817,7 +817,7 @@ impl<'a> DiagCtxtHandle<'a> {
|
||||
);
|
||||
}
|
||||
// We delay a bug here so that `-Ztreat-err-as-bug -Zeagerly-emit-delayed-bugs`
|
||||
// can be used to create a backtrace at the stashing site insted of whenever the
|
||||
// can be used to create a backtrace at the stashing site instead of whenever the
|
||||
// diagnostic context is dropped and thus delayed bugs are emitted.
|
||||
Error => Some(self.span_delayed_bug(span, format!("stashing {key:?}"))),
|
||||
DelayedBug => {
|
||||
|
@ -487,7 +487,7 @@ fn is_break_ty(val: &MdTree<'_>) -> bool {
|
||||
|| matches!(val, MdTree::PlainText(txt) if txt.trim().is_empty())
|
||||
}
|
||||
|
||||
/// Perform tranformations to text. This splits paragraphs, replaces patterns,
|
||||
/// Perform transformations to text. This splits paragraphs, replaces patterns,
|
||||
/// and corrects newlines.
|
||||
///
|
||||
/// To avoid allocating strings (and using a different heavier tt type), our
|
||||
|
@ -585,7 +585,7 @@ declare_features! (
|
||||
(unstable, rust_cold_cc, "1.63.0", Some(97544)),
|
||||
/// Allows use of x86 SHA512, SM3 and SM4 target-features and intrinsics
|
||||
(unstable, sha512_sm_x86, "CURRENT_RUSTC_VERSION", Some(126624)),
|
||||
/// Shortern the tail expression lifetime
|
||||
/// Shorten the tail expression lifetime
|
||||
(unstable, shorter_tail_lifetimes, "1.79.0", Some(123739)),
|
||||
/// Allows the use of SIMD types in functions declared in `extern` blocks.
|
||||
(unstable, simd_ffi, "1.0.0", Some(27731)),
|
||||
|
@ -1016,7 +1016,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
|
||||
sym::adt_const_params,
|
||||
)])
|
||||
}
|
||||
// Implments `ConstParamTy`, suggest adding the feature to enable.
|
||||
// Implements `ConstParamTy`, suggest adding the feature to enable.
|
||||
Ok(..) => Some(vec![(adt_const_params_feature_string, sym::adt_const_params)]),
|
||||
};
|
||||
if let Some(features) = may_suggest_feature {
|
||||
|
@ -219,7 +219,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
|
||||
// Later parts of the compiler rely on all DispatchFromDyn types to be ABI-compatible with raw
|
||||
// pointers. This is enforced here: we only allow impls for references, raw pointers, and things
|
||||
// that are effectively repr(transparent) newtypes around types that already hav a
|
||||
// DispatchedFromDyn impl. We cannot literally use repr(transparent) on those tpyes since some
|
||||
// DispatchedFromDyn impl. We cannot literally use repr(transparent) on those types since some
|
||||
// of them support an allocator, but we ensure that for the cases where the type implements this
|
||||
// trait, they *do* satisfy the repr(transparent) rules, and then we assume that everything else
|
||||
// in the compiler (in particular, all the call ABI logic) will treat them as repr(transparent)
|
||||
|
@ -1037,7 +1037,7 @@ impl<'tcx> FieldUniquenessCheckContext<'tcx> {
|
||||
|
||||
/// Check the uniqueness of fields in a struct variant, and recursively
|
||||
/// check the nested fields if it is an unnamed field with type of an
|
||||
/// annoymous adt.
|
||||
/// anonymous adt.
|
||||
fn check_field(&mut self, field: &hir::FieldDef<'_>) {
|
||||
if field.ident.name != kw::Underscore {
|
||||
self.check_field_decl(field.ident, field.span.into());
|
||||
@ -1491,7 +1491,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
|
||||
Some(ty) => {
|
||||
let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id];
|
||||
// Typeck doesn't expect erased regions to be returned from `type_of`.
|
||||
// This is a heuristic approach. If the scope has region paramters,
|
||||
// This is a heuristic approach. If the scope has region parameters,
|
||||
// we should change fn_sig's lifetime from `ReErased` to `ReError`,
|
||||
// otherwise to `ReStatic`.
|
||||
let has_region_params = generics.params.iter().any(|param| match param.kind {
|
||||
|
@ -529,7 +529,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
|
||||
/// Detect and reject early-bound & escaping late-bound generic params in the type of assoc const bindings.
|
||||
///
|
||||
/// FIXME(const_generics): This is a temporary and semi-artifical restriction until the
|
||||
/// FIXME(const_generics): This is a temporary and semi-artificial restriction until the
|
||||
/// arrival of *generic const generics*[^1].
|
||||
///
|
||||
/// It might actually be possible that we can already support early-bound generic params
|
||||
|
@ -986,7 +986,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
/// We **don't** support paths whose self type is an arbitrary type like `Struct::Ty` where
|
||||
/// struct `Struct` impls an in-scope trait that defines an associated type called `Ty`.
|
||||
/// For the latter case, we report ambiguity.
|
||||
/// While desirable to support, the implemention would be non-trivial. Tracked in [#22519].
|
||||
/// While desirable to support, the implementation would be non-trivial. Tracked in [#22519].
|
||||
///
|
||||
/// At the time of writing, *inherent associated types* are also resolved here. This however
|
||||
/// is [problematic][iat]. A proper implementation would be as non-trivial as the one
|
||||
|
@ -650,7 +650,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
// cannot distinguish. This would cause us to erroneously discard a cast which will
|
||||
// lead to a borrowck error like #113257.
|
||||
// We still did a coercion above to unify inference variables for `ptr as _` casts.
|
||||
// This does cause us to miss some trivial casts in the trival cast lint.
|
||||
// This does cause us to miss some trivial casts in the trivial cast lint.
|
||||
debug!(" -> PointerCast");
|
||||
} else {
|
||||
self.trivial_cast_lint(fcx);
|
||||
|
@ -249,7 +249,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
/// Returns a set of generic parameters for the method *receiver* where all type and region
|
||||
/// parameters are instantiated with fresh variables. This generic paramters does not include any
|
||||
/// parameters are instantiated with fresh variables. This generic parameters does not include any
|
||||
/// parameters declared on the method itself.
|
||||
///
|
||||
/// Note that this generic parameters may include late-bound regions from the impl level. If so,
|
||||
@ -375,7 +375,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
||||
IsMethodCall::Yes,
|
||||
);
|
||||
|
||||
// Create generic paramters for early-bound lifetime parameters,
|
||||
// Create generic parameters for early-bound lifetime parameters,
|
||||
// combining parameters from the type and those from the method.
|
||||
assert_eq!(generics.parent_count, parent_args.len());
|
||||
|
||||
@ -546,7 +546,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
||||
debug!("instantiate_method_sig(pick={:?}, all_args={:?})", pick, all_args);
|
||||
|
||||
// Instantiate the bounds on the method with the
|
||||
// type/early-bound-regions instatiations performed. There can
|
||||
// type/early-bound-regions instantiations performed. There can
|
||||
// be no late-bound regions appearing here.
|
||||
let def_id = pick.item.def_id;
|
||||
let method_predicates = self.tcx.predicates_of(def_id).instantiate(self.tcx, all_args);
|
||||
|
@ -228,7 +228,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// coroutine bodies can't borrow from their parent closure. To fix this,
|
||||
// we force the inner coroutine to also be `move`. This only matters for
|
||||
// coroutine-closures that are `move` since otherwise they themselves will
|
||||
// be borrowing from the outer environment, so there's no self-borrows occuring.
|
||||
// be borrowing from the outer environment, so there's no self-borrows occurring.
|
||||
if let UpvarArgs::Coroutine(..) = args
|
||||
&& let hir::CoroutineKind::Desugared(_, hir::CoroutineSource::Closure) =
|
||||
self.tcx.coroutine_kind(closure_def_id).expect("coroutine should have kind")
|
||||
|
@ -51,7 +51,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
query_state,
|
||||
|tcx, param_env, query_state| {
|
||||
// FIXME(#118965): We don't canonicalize the static lifetimes that appear in the
|
||||
// `param_env` beacause they are treated differently by trait selection.
|
||||
// `param_env` because they are treated differently by trait selection.
|
||||
Canonicalizer::canonicalize(
|
||||
param_env,
|
||||
None,
|
||||
|
@ -213,7 +213,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
/// ```
|
||||
///
|
||||
/// As indicating in the comments above, each of those references
|
||||
/// is (in the compiler) basically generic paramters (`args`)
|
||||
/// is (in the compiler) basically generic parameters (`args`)
|
||||
/// applied to the type of a suitable `def_id` (which identifies
|
||||
/// `Foo1` or `Foo2`).
|
||||
///
|
||||
|
@ -153,7 +153,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
|
||||
// During coherence, opaque types should be treated as *possibly*
|
||||
// equal to any other type (except for possibly itself). This is an
|
||||
// extremely heavy hammer, but can be relaxed in a fowards-compatible
|
||||
// extremely heavy hammer, but can be relaxed in a forwards-compatible
|
||||
// way later.
|
||||
(&ty::Alias(ty::Opaque, _), _) | (_, &ty::Alias(ty::Opaque, _)) if self.intercrate => {
|
||||
relation.register_predicates([ty::Binder::dummy(ty::PredicateKind::Ambiguous)]);
|
||||
|
@ -120,7 +120,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
} else {
|
||||
// NOTE: The `instantiation_variance` is not the same variance as
|
||||
// used by the relation. When instantiating `b`, `target_is_expected`
|
||||
// is flipped and the `instantion_variance` is also flipped. To
|
||||
// is flipped and the `instantiation_variance` is also flipped. To
|
||||
// constrain the `generalized_ty` while using the original relation,
|
||||
// we therefore only have to flip the arguments.
|
||||
//
|
||||
|
@ -435,7 +435,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
|
||||
escape_dep_filename(&file.prefer_local().to_string())
|
||||
};
|
||||
|
||||
// The entries will be used to declare dependencies beween files in a
|
||||
// The entries will be used to declare dependencies between files in a
|
||||
// Makefile-like output, so the iteration order does not matter.
|
||||
#[allow(rustc::potential_query_instability)]
|
||||
let extra_tracked_files =
|
||||
|
@ -267,7 +267,7 @@ pub(super) fn unexpected_cfg_value(
|
||||
// encouraged to do so.
|
||||
let can_suggest_adding_value = !sess.psess.check_config.well_known_names.contains(&name)
|
||||
// Except when working on rustc or the standard library itself, in which case we want to
|
||||
// suggest adding these cfgs to the "normal" place because of bootstraping reasons. As a
|
||||
// suggest adding these cfgs to the "normal" place because of bootstrapping reasons. As a
|
||||
// basic heuristic, we use the "cheat" unstable feature enable method and the
|
||||
// non-ui-testing enabled option.
|
||||
|| (matches!(sess.psess.unstable_features, rustc_feature::UnstableFeatures::Cheat)
|
||||
|
@ -126,7 +126,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
|
||||
// > same expression-containing item.
|
||||
//
|
||||
// To achieve this we get try to get the paths of the _Trait_ and
|
||||
// _Type_, and we look inside thoses paths to try a find in one
|
||||
// _Type_, and we look inside those paths to try a find in one
|
||||
// of them a type whose parent is the same as the impl definition.
|
||||
//
|
||||
// If that's the case this means that this impl block declaration
|
||||
|
@ -734,7 +734,7 @@ trait UnusedDelimLint {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if we need parens for `match &( Struct { feild: }) {}`.
|
||||
// Check if we need parens for `match &( Struct { field: }) {}`.
|
||||
{
|
||||
let mut innermost = inner;
|
||||
loop {
|
||||
|
@ -71,8 +71,8 @@ impl<'a, 'tcx, T: Copy + Decodable<DecodeContext<'a, 'tcx>>> ProcessQueryValue<'
|
||||
for Option<DecodeIterator<'a, 'tcx, T>>
|
||||
{
|
||||
#[inline(always)]
|
||||
fn process_decoded(self, tcx: TyCtxt<'tcx>, _err: impl Fn() -> !) -> &'tcx [T] {
|
||||
if let Some(iter) = self { tcx.arena.alloc_from_iter(iter) } else { &[] }
|
||||
fn process_decoded(self, tcx: TyCtxt<'tcx>, err: impl Fn() -> !) -> &'tcx [T] {
|
||||
if let Some(iter) = self { tcx.arena.alloc_from_iter(iter) } else { err() }
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,12 +84,12 @@ impl<'a, 'tcx, T: Copy + Decodable<DecodeContext<'a, 'tcx>>>
|
||||
fn process_decoded(
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
_err: impl Fn() -> !,
|
||||
err: impl Fn() -> !,
|
||||
) -> ty::EarlyBinder<'tcx, &'tcx [T]> {
|
||||
ty::EarlyBinder::bind(if let Some(iter) = self {
|
||||
tcx.arena.alloc_from_iter(iter)
|
||||
} else {
|
||||
&[]
|
||||
err()
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -300,7 +300,20 @@ provide! { tcx, def_id, other, cdata,
|
||||
.unwrap_or_else(|| panic!("{def_id:?} does not have eval_static_initializer")))
|
||||
}
|
||||
trait_def => { table }
|
||||
deduced_param_attrs => { table }
|
||||
deduced_param_attrs => {
|
||||
// FIXME: `deduced_param_attrs` has some sketchy encoding settings,
|
||||
// where we don't encode unless we're optimizing, doing codegen,
|
||||
// and not incremental (see `encoder.rs`). I don't think this is right!
|
||||
cdata
|
||||
.root
|
||||
.tables
|
||||
.deduced_param_attrs
|
||||
.get(cdata, def_id.index)
|
||||
.map(|lazy| {
|
||||
&*tcx.arena.alloc_from_iter(lazy.decode((cdata, tcx)))
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
is_type_alias_impl_trait => {
|
||||
debug_assert_eq!(tcx.def_kind(def_id), DefKind::OpaqueTy);
|
||||
cdata.root.tables.is_type_alias_impl_trait.get(cdata, def_id.index)
|
||||
|
@ -240,7 +240,7 @@ impl<'tcx> Const<'tcx> {
|
||||
match self {
|
||||
Const::Ty(ty, ct) => {
|
||||
match ct.kind() {
|
||||
// Dont use the outter ty as on invalid code we can wind up with them not being the same.
|
||||
// Dont use the outer ty as on invalid code we can wind up with them not being the same.
|
||||
// this then results in allowing const eval to add `1_i64 + 1_usize` in cases where the mir
|
||||
// was originally `({N: usize} + 1_usize)` under `generic_const_exprs`.
|
||||
ty::ConstKind::Value(ty, _) => ty,
|
||||
|
@ -91,9 +91,9 @@ pub type EvalToAllocationRawResult<'tcx> = Result<ConstAlloc<'tcx>, ErrorHandled
|
||||
pub type EvalStaticInitializerRawResult<'tcx> = Result<ConstAllocation<'tcx>, ErrorHandled>;
|
||||
pub type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;
|
||||
/// `Ok(Err(ty))` indicates the constant was fine, but the valtree couldn't be constructed
|
||||
/// because the value containts something of type `ty` that is not valtree-compatible.
|
||||
/// because the value contains something of type `ty` that is not valtree-compatible.
|
||||
/// The caller can then show an appropriate error; the query does not have the
|
||||
/// necssary context to give good user-facing errors for this case.
|
||||
/// necessary context to give good user-facing errors for this case.
|
||||
pub type EvalToValTreeResult<'tcx> = Result<Result<ValTree<'tcx>, Ty<'tcx>>, ErrorHandled>;
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
@ -231,7 +231,7 @@ pub enum CheckInAllocMsg {
|
||||
pub enum CheckAlignMsg {
|
||||
/// The accessed pointer did not have proper alignment.
|
||||
AccessedPtr,
|
||||
/// The access ocurred with a place that was based on a misaligned pointer.
|
||||
/// The access occurred with a place that was based on a misaligned pointer.
|
||||
BasedOn,
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ rustc_queries! {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the list of bounds that are required to be satsified
|
||||
/// Returns the list of bounds that are required to be satisfied
|
||||
/// by a implementation or definition. For associated types, these
|
||||
/// must be satisfied for an implementation to be well-formed,
|
||||
/// and for opaque types, these are required to be satisfied by
|
||||
|
@ -1475,7 +1475,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
/// provides a `TyCtxt`.
|
||||
///
|
||||
/// By only providing the `TyCtxt` inside of the closure we enforce that the type
|
||||
/// context and any interned alue (types, args, etc.) can only be used while `ty::tls`
|
||||
/// context and any interned value (types, args, etc.) can only be used while `ty::tls`
|
||||
/// has a valid reference to the context, to allow formatting values that need it.
|
||||
pub fn create_global_ctxt(
|
||||
s: &'tcx Session,
|
||||
|
@ -38,7 +38,7 @@ pub struct Instance<'tcx> {
|
||||
pub args: GenericArgsRef<'tcx>,
|
||||
}
|
||||
|
||||
/// Describes why a `ReifyShim` was created. This is needed to distingish a ReifyShim created to
|
||||
/// Describes why a `ReifyShim` was created. This is needed to distinguish a ReifyShim created to
|
||||
/// adjust for things like `#[track_caller]` in a vtable from a `ReifyShim` created to produce a
|
||||
/// function pointer from a vtable entry.
|
||||
/// Currently, this is only used when KCFI is enabled, as only KCFI needs to treat those two
|
||||
|
@ -1819,7 +1819,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
self.get_attrs(did, attr).next().is_some()
|
||||
}
|
||||
|
||||
/// Determines whether an item is annotated with a multi-segement attribute
|
||||
/// Determines whether an item is annotated with a multi-segment attribute
|
||||
pub fn has_attrs_with_path(self, did: impl Into<DefId>, attrs: &[Symbol]) -> bool {
|
||||
self.get_attrs_by_path(did.into(), attrs).next().is_some()
|
||||
}
|
||||
|
@ -1930,7 +1930,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
|
||||
/// Returns `true` when the outermost type cannot be further normalized,
|
||||
/// resolved, or instantiated. This includes all primitive types, but also
|
||||
/// things like ADTs and trait objects, sice even if their arguments or
|
||||
/// things like ADTs and trait objects, since even if their arguments or
|
||||
/// nested types may be further simplified, the outermost [`TyKind`] or
|
||||
/// type constructor remains the same.
|
||||
pub fn is_known_rigid(self) -> bool {
|
||||
|
@ -32,7 +32,7 @@ pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
let borrowed_locals = borrowed_locals(body);
|
||||
|
||||
// If the user requests complete debuginfo, mark the locals that appear in it as live, so
|
||||
// we don't remove assignements to them.
|
||||
// we don't remove assignments to them.
|
||||
let mut always_live = debuginfo_locals(body);
|
||||
always_live.union(&borrowed_locals);
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
//! not contain any indirection through a pointer or any indexing projections.
|
||||
//!
|
||||
//! * `p` and `q` must have the **same type**. If we replace a local with a subtype or supertype,
|
||||
//! we may end up with a differnet vtable for that local. See the `subtyping-impacts-selection`
|
||||
//! we may end up with a different vtable for that local. See the `subtyping-impacts-selection`
|
||||
//! tests for an example where that causes issues.
|
||||
//!
|
||||
//! * We need to make sure that the goal of "merging the memory" is actually structurally possible
|
||||
|
@ -914,7 +914,7 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
|
||||
fn visit_place(&mut self, place: &Place<'tcx>, mut context: PlaceContext, loc: Location) {
|
||||
use rustc_middle::mir::visit::PlaceContext::*;
|
||||
|
||||
// Dereferencing just read the addess of `place.local`.
|
||||
// Dereferencing just read the address of `place.local`.
|
||||
if place.projection.first() == Some(&PlaceElem::Deref) {
|
||||
context = NonMutatingUse(NonMutatingUseContext::Copy);
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ fn can_cast(
|
||||
|
||||
#[derive(Default)]
|
||||
struct SimplifyToExp {
|
||||
transfrom_kinds: Vec<TransfromKind>,
|
||||
transform_kinds: Vec<TransformKind>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
@ -302,17 +302,17 @@ enum ExpectedTransformKind<'tcx, 'a> {
|
||||
Cast { place: &'a Place<'tcx>, ty: Ty<'tcx> },
|
||||
}
|
||||
|
||||
enum TransfromKind {
|
||||
enum TransformKind {
|
||||
Same,
|
||||
Cast,
|
||||
}
|
||||
|
||||
impl From<ExpectedTransformKind<'_, '_>> for TransfromKind {
|
||||
impl From<ExpectedTransformKind<'_, '_>> for TransformKind {
|
||||
fn from(compare_type: ExpectedTransformKind<'_, '_>) -> Self {
|
||||
match compare_type {
|
||||
ExpectedTransformKind::Same(_) => TransfromKind::Same,
|
||||
ExpectedTransformKind::SameByEq { .. } => TransfromKind::Same,
|
||||
ExpectedTransformKind::Cast { .. } => TransfromKind::Cast,
|
||||
ExpectedTransformKind::Same(_) => TransformKind::Same,
|
||||
ExpectedTransformKind::SameByEq { .. } => TransformKind::Same,
|
||||
ExpectedTransformKind::Cast { .. } => TransformKind::Cast,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -475,7 +475,7 @@ impl<'tcx> SimplifyMatch<'tcx> for SimplifyToExp {
|
||||
}
|
||||
}
|
||||
}
|
||||
self.transfrom_kinds = expected_transform_kinds.into_iter().map(|c| c.into()).collect();
|
||||
self.transform_kinds = expected_transform_kinds.into_iter().map(|c| c.into()).collect();
|
||||
Some(())
|
||||
}
|
||||
|
||||
@ -493,13 +493,13 @@ impl<'tcx> SimplifyMatch<'tcx> for SimplifyToExp {
|
||||
let (_, first) = targets.iter().next().unwrap();
|
||||
let first = &bbs[first];
|
||||
|
||||
for (t, s) in iter::zip(&self.transfrom_kinds, &first.statements) {
|
||||
for (t, s) in iter::zip(&self.transform_kinds, &first.statements) {
|
||||
match (t, &s.kind) {
|
||||
(TransfromKind::Same, _) => {
|
||||
(TransformKind::Same, _) => {
|
||||
patch.add_statement(parent_end, s.kind.clone());
|
||||
}
|
||||
(
|
||||
TransfromKind::Cast,
|
||||
TransformKind::Cast,
|
||||
StatementKind::Assign(box (lhs, Rvalue::Use(Operand::Constant(f_c)))),
|
||||
) => {
|
||||
let operand = Operand::Copy(Place::from(discr_local));
|
||||
|
@ -498,7 +498,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
||||
Some(x) if x != 0 => {} // okay
|
||||
_ => return Err(Unpromotable), // value not known or 0 -- not okay
|
||||
}
|
||||
// Furthermore, for signed divison, we also have to exclude `int::MIN / -1`.
|
||||
// Furthermore, for signed division, we also have to exclude `int::MIN / -1`.
|
||||
if lhs_ty.is_signed() {
|
||||
match rhs_val.map(|x| x.to_int(sz)) {
|
||||
Some(-1) | None => {
|
||||
|
@ -345,7 +345,7 @@ fn fully_replacable_locals(ssa: &SsaLocals) -> BitSet<Local> {
|
||||
replacable
|
||||
}
|
||||
|
||||
/// Utility to help performing subtitution of `*pattern` by `target`.
|
||||
/// Utility to help performing substitution of `*pattern` by `target`.
|
||||
struct Replacer<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
targets: IndexVec<Local, Value<'tcx>>,
|
||||
|
@ -397,7 +397,7 @@ fn collect_items_rec<'tcx>(
|
||||
MonoItem::Static(def_id) => {
|
||||
recursion_depth_reset = None;
|
||||
|
||||
// Statics always get evaluted (which is possible because they can't be generic), so for
|
||||
// Statics always get evaluated (which is possible because they can't be generic), so for
|
||||
// `MentionedItems` collection there's nothing to do here.
|
||||
if mode == CollectionMode::UsedItems {
|
||||
let instance = Instance::mono(tcx, def_id);
|
||||
|
@ -238,7 +238,7 @@ where
|
||||
(normalization_nested_goals.clone(), certainty)
|
||||
}
|
||||
|
||||
/// This returns the canoncial variable values to instantiate the bound variables of
|
||||
/// This returns the canonical variable values to instantiate the bound variables of
|
||||
/// the canonical response. This depends on the `original_values` for the
|
||||
/// bound variables.
|
||||
fn compute_query_response_instantiation_values<T: ResponseT<I>>(
|
||||
|
@ -164,7 +164,7 @@ where
|
||||
// - `Bound` cannot exist as we don't have a binder around the self Type
|
||||
// - `Expr` is part of `feature(generic_const_exprs)` and is not implemented yet
|
||||
ty::ConstKind::Param(_) | ty::ConstKind::Bound(_, _) | ty::ConstKind::Expr(_) => {
|
||||
panic!("unexpect const kind: {:?}", ct)
|
||||
panic!("unexpected const kind: {:?}", ct)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -628,7 +628,7 @@ where
|
||||
}
|
||||
|
||||
// FIXME: This actually should destructure the `Result` we get from transmutability and
|
||||
// register candiates. We probably need to register >1 since we may have an OR of ANDs.
|
||||
// register candidates. We probably need to register >1 since we may have an OR of ANDs.
|
||||
ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| {
|
||||
let certainty = ecx.is_transmutable(
|
||||
goal.param_env,
|
||||
|
@ -402,7 +402,7 @@ impl<'a> Parser<'a> {
|
||||
let non_assoc_span = expr.span;
|
||||
|
||||
// Parse an associative expression such as `+ expr`, `% expr`, ...
|
||||
// Assignements, ranges and `|` are disabled by [`Restrictions::IS_PAT`].
|
||||
// Assignments, ranges and `|` are disabled by [`Restrictions::IS_PAT`].
|
||||
if let Ok((expr, _)) =
|
||||
snapshot.parse_expr_assoc_rest_with(0, false, expr).map_err(|err| err.cancel())
|
||||
{
|
||||
|
@ -439,7 +439,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
||||
_ => intravisit::walk_item(self, item),
|
||||
},
|
||||
Node::TraitItem(trait_item) => {
|
||||
// mark corresponing ImplTerm live
|
||||
// mark corresponding ImplTerm live
|
||||
let trait_item_id = trait_item.owner_id.to_def_id();
|
||||
if let Some(trait_id) = self.tcx.trait_of_item(trait_item_id) {
|
||||
// mark the trait live
|
||||
@ -1035,7 +1035,7 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||
};
|
||||
|
||||
let encl_def_id = parent_item.unwrap_or(first_item.def_id);
|
||||
// If parent of encl_def_id is an enum, use the parent ID intead.
|
||||
// If parent of encl_def_id is an enum, use the parent ID instead.
|
||||
let encl_def_id = get_parent_if_enum_variant(tcx, encl_def_id);
|
||||
|
||||
let ignored_derived_impls =
|
||||
|
@ -288,7 +288,7 @@ impl IntRange {
|
||||
/// Best effort; will not know that e.g. `255u8..` is a singleton.
|
||||
pub fn is_singleton(&self) -> bool {
|
||||
// Since `lo` and `hi` can't be the same `Infinity` and `plus_one` never changes from finite
|
||||
// to infinite, this correctly only detects ranges that contain exacly one `Finite(x)`.
|
||||
// to infinite, this correctly only detects ranges that contain exactly one `Finite(x)`.
|
||||
self.lo.plus_one() == Some(self.hi)
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ fn check(patterns: Vec<DeconstructedPat<Cx>>) -> Vec<WitnessPat<Cx>> {
|
||||
fn assert_exhaustive(patterns: Vec<DeconstructedPat<Cx>>) {
|
||||
let witnesses = check(patterns);
|
||||
if !witnesses.is_empty() {
|
||||
panic!("non-exaustive match: missing {witnesses:?}");
|
||||
panic!("non-exhaustive match: missing {witnesses:?}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1405,7 +1405,7 @@ fn panic_on_forbidden_read<D: Deps>(data: &DepGraphData<D>, dep_node_index: DepN
|
||||
"Error: trying to record dependency on DepNode {dep_node} in a \
|
||||
context that does not allow it (e.g. during query deserialization). \
|
||||
The most common case of recording a dependency on a DepNode `foo` is \
|
||||
when the correspondng query `foo` is invoked. Invoking queries is not \
|
||||
when the corresponding query `foo` is invoked. Invoking queries is not \
|
||||
allowed as part of loading something from the incremental on-disk cache. \
|
||||
See <https://github.com/rust-lang/rust/pull/91919>."
|
||||
)
|
||||
|
@ -11,7 +11,7 @@ resolve_added_macro_use =
|
||||
resolve_ancestor_only =
|
||||
visibilities can only be restricted to ancestor modules
|
||||
|
||||
resolve_anonymous_livetime_non_gat_report_error =
|
||||
resolve_anonymous_lifetime_non_gat_report_error =
|
||||
in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
|
||||
.label = this lifetime must come from the implemented type
|
||||
|
||||
|
@ -894,7 +894,7 @@ pub(crate) struct LendingIteratorReportError {
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(resolve_anonymous_livetime_non_gat_report_error)]
|
||||
#[diag(resolve_anonymous_lifetime_non_gat_report_error)]
|
||||
pub(crate) struct AnonymousLivetimeNonGatReportError {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
|
@ -445,7 +445,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
Scope::DeriveHelpersCompat => {
|
||||
// FIXME: Try running this logic eariler, to allocate name bindings for
|
||||
// FIXME: Try running this logic earlier, to allocate name bindings for
|
||||
// legacy derive helpers when creating an attribute invocation with
|
||||
// following derives. Legacy derive helpers are not common, so it shouldn't
|
||||
// affect performance. It should also allow to remove the `derives`
|
||||
|
@ -133,7 +133,7 @@ pub(crate) enum NoConstantGenericsReason {
|
||||
/// Const arguments are only allowed to use generic parameters when:
|
||||
/// - `feature(generic_const_exprs)` is enabled
|
||||
/// or
|
||||
/// - the const argument is a sole const generic paramater, i.e. `foo::<{ N }>()`
|
||||
/// - the const argument is a sole const generic parameter, i.e. `foo::<{ N }>()`
|
||||
///
|
||||
/// If neither of the above are true then this is used as the cause.
|
||||
NonTrivialConstArg,
|
||||
@ -4486,7 +4486,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||
|
||||
/// There are a few places that we need to resolve an anon const but we did not parse an
|
||||
/// anon const so cannot provide an `&'ast AnonConst`. Right now this is just unbraced
|
||||
/// const arguments that were parsed as type arguments, and `legact_const_generics` which
|
||||
/// const arguments that were parsed as type arguments, and `legacy_const_generics` which
|
||||
/// parse as normal function argument expressions. To avoid duplicating the code for resolving
|
||||
/// an anon const we have this function which lets the caller manually call `resolve_expr` or
|
||||
/// `smart_resolve_path`.
|
||||
|
@ -417,7 +417,7 @@ pub(crate) fn attrs_to_preprocessed_links(attrs: &[ast::Attribute]) -> Vec<Box<s
|
||||
parse_links(&doc)
|
||||
}
|
||||
|
||||
/// Similiar version of `markdown_links` from rustdoc.
|
||||
/// Similar version of `markdown_links` from rustdoc.
|
||||
/// This will collect destination links and display text if exists.
|
||||
fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> {
|
||||
let mut broken_link_callback = |link: BrokenLink<'md>| Some((link.reference, "".into()));
|
||||
|
@ -262,7 +262,7 @@ fn trait_object_ty<'tcx>(tcx: TyCtxt<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tc
|
||||
/// mangling.
|
||||
///
|
||||
/// typeid_for_instance is called at two locations, initially when declaring/defining functions and
|
||||
/// methods, and later during code generation at call sites, after type erasure might have ocurred.
|
||||
/// methods, and later during code generation at call sites, after type erasure might have occurred.
|
||||
///
|
||||
/// In the first call (i.e., when declaring/defining functions and methods), it encodes type ids for
|
||||
/// an FnAbi or Instance, and these type ids are attached to functions and methods. (These type ids
|
||||
@ -270,7 +270,7 @@ fn trait_object_ty<'tcx>(tcx: TyCtxt<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tc
|
||||
/// these type ids.)
|
||||
///
|
||||
/// In the second call (i.e., during code generation at call sites), it encodes a type id for an
|
||||
/// FnAbi or Instance, after type erasure might have occured, and this type id is used for testing
|
||||
/// FnAbi or Instance, after type erasure might have occurred, and this type id is used for testing
|
||||
/// if a function is member of the group derived from this type id. Therefore, in the first call to
|
||||
/// typeid_for_fnabi (when type ids are attached to functions and methods), it can only include at
|
||||
/// most as much information that would be available in the second call (i.e., during code
|
||||
@ -365,7 +365,7 @@ pub fn transform_instance<'tcx>(
|
||||
// of the trait that defines the method.
|
||||
if let Some((trait_ref, method_id, ancestor)) = implemented_method(tcx, instance) {
|
||||
// Trait methods will have a Self polymorphic parameter, where the concreteized
|
||||
// implementatation will not. We need to walk back to the more general trait method
|
||||
// implementation will not. We need to walk back to the more general trait method
|
||||
let trait_ref = tcx.instantiate_and_normalize_erasing_regions(
|
||||
instance.args,
|
||||
ty::ParamEnv::reveal_all(),
|
||||
|
@ -159,7 +159,7 @@ impl FileEncoder {
|
||||
// We produce a post-mono error if N > BUF_SIZE.
|
||||
let buf = unsafe { self.buffer_empty().first_chunk_mut::<N>().unwrap_unchecked() };
|
||||
let written = visitor(buf);
|
||||
// We have to ensure that an errant visitor cannot cause self.buffered to exeed BUF_SIZE.
|
||||
// We have to ensure that an errant visitor cannot cause self.buffered to exceed BUF_SIZE.
|
||||
if written > N {
|
||||
Self::panic_invalid_write::<N>(written);
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ pub struct LinkSelfContained {
|
||||
pub explicitly_set: Option<bool>,
|
||||
|
||||
/// The components that are enabled on the CLI, using the `+component` syntax or one of the
|
||||
/// `true` shorcuts.
|
||||
/// `true` shortcuts.
|
||||
enabled_components: LinkSelfContainedComponents,
|
||||
|
||||
/// The components that are disabled on the CLI, using the `-component` syntax or one of the
|
||||
@ -313,13 +313,13 @@ impl LinkSelfContained {
|
||||
}
|
||||
|
||||
/// Returns whether the self-contained linker component was enabled on the CLI, using the
|
||||
/// `-C link-self-contained=+linker` syntax, or one of the `true` shorcuts.
|
||||
/// `-C link-self-contained=+linker` syntax, or one of the `true` shortcuts.
|
||||
pub fn is_linker_enabled(&self) -> bool {
|
||||
self.enabled_components.contains(LinkSelfContainedComponents::LINKER)
|
||||
}
|
||||
|
||||
/// Returns whether the self-contained linker component was disabled on the CLI, using the
|
||||
/// `-C link-self-contained=-linker` syntax, or one of the `false` shorcuts.
|
||||
/// `-C link-self-contained=-linker` syntax, or one of the `false` shortcuts.
|
||||
pub fn is_linker_disabled(&self) -> bool {
|
||||
self.disabled_components.contains(LinkSelfContainedComponents::LINKER)
|
||||
}
|
||||
@ -360,7 +360,7 @@ impl LinkerFeaturesCli {
|
||||
// Duplicate flags are reduced as we go, the last occurrence wins:
|
||||
// `+feature,-feature,+feature` only enables the feature, and does not record it as both
|
||||
// enabled and disabled on the CLI.
|
||||
// We also only expose `+/-lld` at the moment, as it's currenty the only implemented linker
|
||||
// We also only expose `+/-lld` at the moment, as it's currently the only implemented linker
|
||||
// feature and toggling `LinkerFeatures::CC` would be a noop.
|
||||
match feature {
|
||||
"+lld" => {
|
||||
@ -1102,7 +1102,7 @@ bitflags::bitflags! {
|
||||
const MACRO = 1 << 0;
|
||||
/// Apply remappings to printed compiler diagnostics
|
||||
const DIAGNOSTICS = 1 << 1;
|
||||
/// Apply remappings to debug informations
|
||||
/// Apply remappings to debug information
|
||||
const DEBUGINFO = 1 << 3;
|
||||
|
||||
/// An alias for `macro` and `debuginfo`. This ensures all paths in compiled
|
||||
|
@ -397,7 +397,7 @@ macro_rules! run_driver {
|
||||
}};
|
||||
}
|
||||
|
||||
/// Simmilar to rustc's `FxIndexMap`, `IndexMap` with extra
|
||||
/// Similar to rustc's `FxIndexMap`, `IndexMap` with extra
|
||||
/// safety features added.
|
||||
pub struct IndexMap<K, V> {
|
||||
index_map: fx::FxIndexMap<K, V>,
|
||||
|
@ -1358,7 +1358,7 @@ pub fn decode_syntax_context<D: Decoder, F: FnOnce(&mut D, u32) -> SyntaxContext
|
||||
let mut inner = context.inner.lock();
|
||||
|
||||
if let Some(ctxt) = inner.remapped_ctxts.get(raw_id as usize).copied().flatten() {
|
||||
// This has already beeen decoded.
|
||||
// This has already been decoded.
|
||||
return ctxt;
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ impl RealFileName {
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the path remmapped or not depending on the [`FileNameDisplayPreference`].
|
||||
/// Return the path remapped or not depending on the [`FileNameDisplayPreference`].
|
||||
///
|
||||
/// For the purpose of this function, local and short preference are equal.
|
||||
pub fn to_path(&self, display_pref: FileNameDisplayPreference) -> &Path {
|
||||
@ -1683,7 +1683,7 @@ impl fmt::Debug for SourceFile {
|
||||
/// is because SourceFiles for the local crate are allocated very early in the
|
||||
/// compilation process when the `StableCrateId` is not yet known. If, due to
|
||||
/// some refactoring of the compiler, the `StableCrateId` of the local crate
|
||||
/// were to become available, it would be better to uniformely make this a
|
||||
/// were to become available, it would be better to uniformly make this a
|
||||
/// hash of `(filename, stable_crate_id)`.
|
||||
///
|
||||
/// When `SourceFile`s are exported in crate metadata, the `StableSourceFileId`
|
||||
|
@ -14,7 +14,7 @@ pub(super) fn mangle<'tcx>(
|
||||
) -> String {
|
||||
// The symbol of a generic function may be scattered in multiple downstream dylibs.
|
||||
// If the symbol of a generic function still contains `crate name`, hash conflicts between the
|
||||
// generic funcion and other symbols of the same `crate` cannot be detected in time during
|
||||
// generic function and other symbols of the same `crate` cannot be detected in time during
|
||||
// construction. This symbol conflict is left over until it occurs during run time.
|
||||
// In this case, `instantiating-crate name` is used to replace `crate name` can completely
|
||||
// eliminate the risk of the preceding potential hash conflict.
|
||||
|
@ -26,7 +26,7 @@ where
|
||||
// so defer to `classify_arg_ty`.
|
||||
let mut arg_gprs_left = NUM_RET_GPRS;
|
||||
classify_arg_ty(arg, &mut arg_gprs_left, MAX_RET_IN_REGS_SIZE);
|
||||
// Ret args cannot be passed via stack, we lower to indirect and let the backend handle the invisble reference
|
||||
// Ret args cannot be passed via stack, we lower to indirect and let the backend handle the invisible reference
|
||||
match arg.mode {
|
||||
super::PassMode::Indirect { attrs: _, meta_attrs: _, ref mut on_stack } => {
|
||||
*on_stack = false;
|
||||
|
@ -29,7 +29,7 @@ pub fn opts() -> TargetOptions {
|
||||
// they bring in.
|
||||
//
|
||||
// See also https://learn.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=msvc-170#lib
|
||||
// for documention on including library dependencies in C/C++ code.
|
||||
// for documentation on including library dependencies in C/C++ code.
|
||||
no_default_libraries: false,
|
||||
has_thread_local: true,
|
||||
|
||||
|
@ -2149,7 +2149,7 @@ pub struct TargetOptions {
|
||||
pub is_like_aix: bool,
|
||||
/// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
|
||||
/// in particular running dsymutil and some other stuff like `-dead_strip`. Defaults to false.
|
||||
/// Also indiates whether to use Apple-specific ABI changes, such as extending function
|
||||
/// Also indicates whether to use Apple-specific ABI changes, such as extending function
|
||||
/// parameters to 32-bits.
|
||||
pub is_like_osx: bool,
|
||||
/// Whether the target toolchain is like Solaris's.
|
||||
|
@ -53,7 +53,7 @@ pub fn target() -> Target {
|
||||
options.entry_name = "__main_void".into();
|
||||
|
||||
// Default to PIC unlike base wasm. This makes precompiled objects such as
|
||||
// the standard library more suitable to be used with shared libaries a la
|
||||
// the standard library more suitable to be used with shared libraries a la
|
||||
// emscripten's dynamic linking convention.
|
||||
options.relocation_model = RelocModel::Pic;
|
||||
|
||||
|
@ -170,7 +170,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
{
|
||||
return guar;
|
||||
}
|
||||
// Silence redundant errors on binding acccess that are already
|
||||
// Silence redundant errors on binding access that are already
|
||||
// reported on the binding definition (#56607).
|
||||
if let Err(guar) = self.fn_arg_obligation(&obligation) {
|
||||
return guar;
|
||||
@ -898,7 +898,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
let mut suggested = false;
|
||||
let mut chain = vec![];
|
||||
|
||||
// The following logic is simlar to `point_at_chain`, but that's focused on associated types
|
||||
// The following logic is similar to `point_at_chain`, but that's focused on associated types
|
||||
let mut expr = expr;
|
||||
while let hir::ExprKind::MethodCall(path_segment, rcvr_expr, args, span) = expr.kind {
|
||||
// Point at every method call in the chain with the `Result` type.
|
||||
|
@ -878,7 +878,7 @@ impl<'tcx> OnUnimplementedFormatString {
|
||||
}
|
||||
}
|
||||
// we cannot return errors from processing the format string as hard error here
|
||||
// as the diagnostic namespace gurantees that malformed input cannot cause an error
|
||||
// as the diagnostic namespace guarantees that malformed input cannot cause an error
|
||||
//
|
||||
// if we encounter any error while processing we nevertheless want to show it as warning
|
||||
// so that users are aware that something is not correct
|
||||
@ -986,10 +986,10 @@ impl<'tcx> OnUnimplementedFormatString {
|
||||
})
|
||||
.collect();
|
||||
// we cannot return errors from processing the format string as hard error here
|
||||
// as the diagnostic namespace gurantees that malformed input cannot cause an error
|
||||
// as the diagnostic namespace guarantees that malformed input cannot cause an error
|
||||
//
|
||||
// if we encounter any error while processing the format string
|
||||
// we don't want to show the potentially half assembled formated string,
|
||||
// we don't want to show the potentially half assembled formatted string,
|
||||
// therefore we fall back to just showing the input string in this case
|
||||
//
|
||||
// The actual parser errors are emitted earlier
|
||||
|
@ -4663,7 +4663,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
// because this suggest adding both return type in
|
||||
// the `FnSig` and a default return value in the body, so it
|
||||
// is not suitable for foreign function without a local body,
|
||||
// and neighter for trait method which may be also implemented
|
||||
// and neither for trait method which may be also implemented
|
||||
// in other place, so shouldn't change it's FnSig.
|
||||
fn choose_suggest_items<'tcx, 'hir>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -723,7 +723,7 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a, 'tcx> {
|
||||
// FIXME: While this matches the behavior of the
|
||||
// old solver, it is not the only way in which the unknowable
|
||||
// candidates *weaken* coherence, they can also force otherwise
|
||||
// sucessful normalization to be ambiguous.
|
||||
// successful normalization to be ambiguous.
|
||||
Ok(Certainty::Maybe(_) | Certainty::Yes) => {
|
||||
ambiguity_cause = None;
|
||||
break;
|
||||
|
@ -472,7 +472,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||
};
|
||||
|
||||
match infcx.at(&obligation.cause, obligation.param_env).eq(
|
||||
// Only really excercised by generic_const_exprs
|
||||
// Only really exercised by generic_const_exprs
|
||||
DefineOpaqueTypes::Yes,
|
||||
ct_ty,
|
||||
ty,
|
||||
|
@ -991,7 +991,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
};
|
||||
|
||||
match self.infcx.at(&obligation.cause, obligation.param_env).eq(
|
||||
// Only really excercised by generic_const_exprs
|
||||
// Only really exercised by generic_const_exprs
|
||||
DefineOpaqueTypes::Yes,
|
||||
ct_ty,
|
||||
ty,
|
||||
|
@ -242,7 +242,7 @@ where
|
||||
// }
|
||||
// ...if `refs_answer` was computed lazily. The below early
|
||||
// returns can be deleted without impacting the correctness of
|
||||
// the algoritm; only its performance.
|
||||
// the algorithm; only its performance.
|
||||
debug!(?bytes_answer);
|
||||
match bytes_answer {
|
||||
Answer::No(_) if !self.assume.validity => return bytes_answer,
|
||||
|
@ -776,7 +776,7 @@ impl<'a, I: Interner> ArgFolder<'a, I> {
|
||||
}
|
||||
|
||||
/// It is sometimes necessary to adjust the De Bruijn indices during instantiation. This occurs
|
||||
/// when we are instantating a type with escaping bound vars into a context where we have
|
||||
/// when we are instantiating a type with escaping bound vars into a context where we have
|
||||
/// passed through binders. That's quite a mouthful. Let's see an example:
|
||||
///
|
||||
/// ```
|
||||
|
@ -162,7 +162,7 @@ pub trait Ty<I: Interner<Ty = Self>>:
|
||||
|
||||
/// Returns `true` when the outermost type cannot be further normalized,
|
||||
/// resolved, or instantiated. This includes all primitive types, but also
|
||||
/// things like ADTs and trait objects, sice even if their arguments or
|
||||
/// things like ADTs and trait objects, since even if their arguments or
|
||||
/// nested types may be further simplified, the outermost [`ty::TyKind`] or
|
||||
/// type constructor remains the same.
|
||||
fn is_known_rigid(self) -> bool {
|
||||
|
@ -550,7 +550,7 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
|
||||
/// Any semantic equality, e.g. of unevaluated consts, and inference variables have
|
||||
/// to be handled by the caller.
|
||||
///
|
||||
/// FIXME: This is not totally structual, which probably should be fixed.
|
||||
/// FIXME: This is not totally structural, which probably should be fixed.
|
||||
/// See the HACKs below.
|
||||
pub fn structurally_relate_consts<I: Interner, R: TypeRelation<I>>(
|
||||
relation: &mut R,
|
||||
|
@ -132,7 +132,7 @@ pub enum GoalSource {
|
||||
/// results in better error messages by avoiding spurious errors.
|
||||
/// We do not erase overflow constraints in `normalizes-to` goals unless
|
||||
/// they are from an impl where-clause. This is necessary due to
|
||||
/// backwards compatability, cc trait-system-refactor-initiatitive#70.
|
||||
/// backwards compatibility, cc trait-system-refactor-initiatitive#70.
|
||||
ImplWhereBound,
|
||||
/// Instantiating a higher-ranked goal and re-proving it.
|
||||
InstantiateHigherRanked,
|
||||
|
@ -70,7 +70,7 @@ pub struct TyAndLayout {
|
||||
/// The layout of a type in memory.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
|
||||
pub struct LayoutShape {
|
||||
/// The fields location withing the layout
|
||||
/// The fields location within the layout
|
||||
pub fields: FieldsShape,
|
||||
|
||||
/// Encodes information about multi-variant layouts.
|
||||
|
@ -267,7 +267,7 @@ impl Span {
|
||||
with(|c| c.get_filename(self))
|
||||
}
|
||||
|
||||
/// Return lines that corespond to this `Span`
|
||||
/// Return lines that correspond to this `Span`
|
||||
pub fn get_lines(&self) -> LineInfo {
|
||||
with(|c| c.get_lines(self))
|
||||
}
|
||||
|
@ -53,22 +53,20 @@
|
||||
//!
|
||||
//! # Memory layout
|
||||
//!
|
||||
//! For non-zero-sized values, a [`Box`] will use the [`Global`] allocator for
|
||||
//! its allocation. It is valid to convert both ways between a [`Box`] and a
|
||||
//! raw pointer allocated with the [`Global`] allocator, given that the
|
||||
//! [`Layout`] used with the allocator is correct for the type. More precisely,
|
||||
//! a `value: *mut T` that has been allocated with the [`Global`] allocator
|
||||
//! with `Layout::for_value(&*value)` may be converted into a box using
|
||||
//! [`Box::<T>::from_raw(value)`]. Conversely, the memory backing a `value: *mut
|
||||
//! T` obtained from [`Box::<T>::into_raw`] may be deallocated using the
|
||||
//! [`Global`] allocator with [`Layout::for_value(&*value)`].
|
||||
//! For non-zero-sized values, a [`Box`] will use the [`Global`] allocator for its allocation. It is
|
||||
//! valid to convert both ways between a [`Box`] and a raw pointer allocated with the [`Global`]
|
||||
//! allocator, given that the [`Layout`] used with the allocator is correct for the type and the raw
|
||||
//! pointer points to a valid value of the right type. More precisely, a `value: *mut T` that has
|
||||
//! been allocated with the [`Global`] allocator with `Layout::for_value(&*value)` may be converted
|
||||
//! into a box using [`Box::<T>::from_raw(value)`]. Conversely, the memory backing a `value: *mut T`
|
||||
//! obtained from [`Box::<T>::into_raw`] may be deallocated using the [`Global`] allocator with
|
||||
//! [`Layout::for_value(&*value)`].
|
||||
//!
|
||||
//! For zero-sized values, the `Box` pointer still has to be [valid] for reads
|
||||
//! and writes and sufficiently aligned. In particular, casting any aligned
|
||||
//! non-zero integer literal to a raw pointer produces a valid pointer, but a
|
||||
//! pointer pointing into previously allocated memory that since got freed is
|
||||
//! not valid. The recommended way to build a Box to a ZST if `Box::new` cannot
|
||||
//! be used is to use [`ptr::NonNull::dangling`].
|
||||
//! For zero-sized values, the `Box` pointer has to be non-null and sufficiently aligned. The
|
||||
//! recommended way to build a Box to a ZST if `Box::new` cannot be used is to use
|
||||
//! [`ptr::NonNull::dangling`].
|
||||
//!
|
||||
//! On top of these basic layout requirements, a `Box<T>` must point to a valid value of `T`.
|
||||
//!
|
||||
//! So long as `T: Sized`, a `Box<T>` is guaranteed to be represented
|
||||
//! as a single pointer and is also ABI-compatible with C pointers
|
||||
|
@ -11,13 +11,13 @@ use crate::{array, ptr, ub_checks};
|
||||
///
|
||||
/// Behavior is undefined if any of the following conditions are violated:
|
||||
///
|
||||
/// * `data` must be [valid] for reads for `len * mem::size_of::<T>()` many bytes,
|
||||
/// * `data` must be non-null, [valid] for reads for `len * mem::size_of::<T>()` many bytes,
|
||||
/// and it must be properly aligned. This means in particular:
|
||||
///
|
||||
/// * The entire memory range of this slice must be contained within a single allocated object!
|
||||
/// Slices can never span across multiple allocated objects. See [below](#incorrect-usage)
|
||||
/// for an example incorrectly not taking this into account.
|
||||
/// * `data` must be non-null and aligned even for zero-length slices. One
|
||||
/// * `data` must be non-null and aligned even for zero-length slices or slices of ZSTs. One
|
||||
/// reason for this is that enum layout optimizations may rely on references
|
||||
/// (including slices of any length) being aligned and non-null to distinguish
|
||||
/// them from other data. You can obtain a pointer that is usable as `data`
|
||||
@ -146,12 +146,12 @@ pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T]
|
||||
///
|
||||
/// Behavior is undefined if any of the following conditions are violated:
|
||||
///
|
||||
/// * `data` must be [valid] for both reads and writes for `len * mem::size_of::<T>()` many bytes,
|
||||
/// * `data` must be non-null, [valid] for both reads and writes for `len * mem::size_of::<T>()` many bytes,
|
||||
/// and it must be properly aligned. This means in particular:
|
||||
///
|
||||
/// * The entire memory range of this slice must be contained within a single allocated object!
|
||||
/// Slices can never span across multiple allocated objects.
|
||||
/// * `data` must be non-null and aligned even for zero-length slices. One
|
||||
/// * `data` must be non-null and aligned even for zero-length slices or slices of ZSTs. One
|
||||
/// reason for this is that enum layout optimizations may rely on references
|
||||
/// (including slices of any length) being aligned and non-null to distinguish
|
||||
/// them from other data. You can obtain a pointer that is usable as `data`
|
||||
@ -219,7 +219,7 @@ pub const fn from_mut<T>(s: &mut T) -> &mut [T] {
|
||||
///
|
||||
/// Behavior is undefined if any of the following conditions are violated:
|
||||
///
|
||||
/// * The `start` pointer of the range must be a [valid] and properly aligned pointer
|
||||
/// * The `start` pointer of the range must be a non-null, [valid] and properly aligned pointer
|
||||
/// to the first element of a slice.
|
||||
///
|
||||
/// * The `end` pointer must be a [valid] and properly aligned pointer to *one past*
|
||||
@ -235,7 +235,7 @@ pub const fn from_mut<T>(s: &mut T) -> &mut [T] {
|
||||
/// of lifetime `'a`, except inside an `UnsafeCell`.
|
||||
///
|
||||
/// * The total length of the range must be no larger than `isize::MAX`,
|
||||
/// and adding that size to `data` must not "wrap around" the address space.
|
||||
/// and adding that size to `start` must not "wrap around" the address space.
|
||||
/// See the safety documentation of [`pointer::offset`].
|
||||
///
|
||||
/// Note that a range created from [`slice::as_ptr_range`] fulfills these requirements.
|
||||
@ -288,7 +288,7 @@ pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] {
|
||||
///
|
||||
/// Behavior is undefined if any of the following conditions are violated:
|
||||
///
|
||||
/// * The `start` pointer of the range must be a [valid] and properly aligned pointer
|
||||
/// * The `start` pointer of the range must be a non-null, [valid] and properly aligned pointer
|
||||
/// to the first element of a slice.
|
||||
///
|
||||
/// * The `end` pointer must be a [valid] and properly aligned pointer to *one past*
|
||||
@ -305,7 +305,7 @@ pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] {
|
||||
/// Both read and write accesses are forbidden.
|
||||
///
|
||||
/// * The total length of the range must be no larger than `isize::MAX`,
|
||||
/// and adding that size to `data` must not "wrap around" the address space.
|
||||
/// and adding that size to `start` must not "wrap around" the address space.
|
||||
/// See the safety documentation of [`pointer::offset`].
|
||||
///
|
||||
/// Note that a range created from [`slice::as_mut_ptr_range`] fulfills these requirements.
|
||||
|
@ -3570,10 +3570,9 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
|
||||
/// An atomic fence.
|
||||
///
|
||||
/// Depending on the specified order, a fence prevents the compiler and CPU from
|
||||
/// reordering certain types of memory operations around it.
|
||||
/// That creates synchronizes-with relationships between it and atomic operations
|
||||
/// or fences in other threads.
|
||||
/// Fences create synchronization between themselves and atomic operations or fences in other
|
||||
/// threads. To achieve this, a fence prevents the compiler and CPU from reordering certain types of
|
||||
/// memory operations around it.
|
||||
///
|
||||
/// A fence 'A' which has (at least) [`Release`] ordering semantics, synchronizes
|
||||
/// with a fence 'B' with (at least) [`Acquire`] semantics, if and only if there
|
||||
@ -3594,6 +3593,12 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Note that in the example above, it is crucial that the accesses to `x` are atomic. Fences cannot
|
||||
/// be used to establish synchronization among non-atomic accesses in different threads. However,
|
||||
/// thanks to the happens-before relationship between A and B, any non-atomic accesses that
|
||||
/// happen-before A are now also properly synchronized with any non-atomic accesses that
|
||||
/// happen-after B.
|
||||
///
|
||||
/// Atomic operations with [`Release`] or [`Acquire`] semantics can also synchronize
|
||||
/// with a fence.
|
||||
///
|
||||
@ -3659,33 +3664,30 @@ pub fn fence(order: Ordering) {
|
||||
}
|
||||
}
|
||||
|
||||
/// A compiler memory fence.
|
||||
/// A "compiler-only" atomic fence.
|
||||
///
|
||||
/// `compiler_fence` does not emit any machine code, but restricts the kinds
|
||||
/// of memory re-ordering the compiler is allowed to do. Specifically, depending on
|
||||
/// the given [`Ordering`] semantics, the compiler may be disallowed from moving reads
|
||||
/// or writes from before or after the call to the other side of the call to
|
||||
/// `compiler_fence`. Note that it does **not** prevent the *hardware*
|
||||
/// from doing such re-ordering. This is not a problem in a single-threaded,
|
||||
/// execution context, but when other threads may modify memory at the same
|
||||
/// time, stronger synchronization primitives such as [`fence`] are required.
|
||||
/// Like [`fence`], this function establishes synchronization with other atomic operations and
|
||||
/// fences. However, unlike [`fence`], `compiler_fence` only establishes synchronization with
|
||||
/// operations *in the same thread*. This may at first sound rather useless, since code within a
|
||||
/// thread is typically already totally ordered and does not need any further synchronization.
|
||||
/// However, there are cases where code can run on the same thread without being ordered:
|
||||
/// - The most common case is that of a *signal handler*: a signal handler runs in the same thread
|
||||
/// as the code it interrupted, but it is not ordered with respect to that code. `compiler_fence`
|
||||
/// can be used to establish synchronization between a thread and its signal handler, the same way
|
||||
/// that `fence` can be used to establish synchronization across threads.
|
||||
/// - Similar situations can arise in embedded programming with interrupt handlers, or in custom
|
||||
/// implementations of preemptive green threads. In general, `compiler_fence` can establish
|
||||
/// synchronization with code that is guaranteed to run on the same hardware CPU.
|
||||
///
|
||||
/// The re-ordering prevented by the different ordering semantics are:
|
||||
/// See [`fence`] for how a fence can be used to achieve synchronization. Note that just like
|
||||
/// [`fence`], synchronization still requires atomic operations to be used in both threads -- it is
|
||||
/// not possible to perform synchronization entirely with fences and non-atomic operations.
|
||||
///
|
||||
/// - with [`SeqCst`], no re-ordering of reads and writes across this point is allowed.
|
||||
/// - with [`Release`], preceding reads and writes cannot be moved past subsequent writes.
|
||||
/// - with [`Acquire`], subsequent reads and writes cannot be moved ahead of preceding reads.
|
||||
/// - with [`AcqRel`], both of the above rules are enforced.
|
||||
/// `compiler_fence` does not emit any machine code, but restricts the kinds of memory re-ordering
|
||||
/// the compiler is allowed to do. `compiler_fence` corresponds to [`atomic_signal_fence`] in C and
|
||||
/// C++.
|
||||
///
|
||||
/// `compiler_fence` is generally only useful for preventing a thread from
|
||||
/// racing *with itself*. That is, if a given thread is executing one piece
|
||||
/// of code, and is then interrupted, and starts executing code elsewhere
|
||||
/// (while still in the same thread, and conceptually still on the same
|
||||
/// core). In traditional programs, this can only occur when a signal
|
||||
/// handler is registered. In more low-level code, such situations can also
|
||||
/// arise when handling interrupts, when implementing green threads with
|
||||
/// pre-emption, etc. Curious readers are encouraged to read the Linux kernel's
|
||||
/// discussion of [memory barriers].
|
||||
/// [`atomic_signal_fence`]: https://en.cppreference.com/w/cpp/atomic/atomic_signal_fence
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
@ -3723,8 +3725,6 @@ pub fn fence(order: Ordering) {
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// [memory barriers]: https://www.kernel.org/doc/Documentation/memory-barriers.txt
|
||||
#[inline]
|
||||
#[stable(feature = "compiler_fences", since = "1.21.0")]
|
||||
#[rustc_diagnostic_item = "compiler_fence"]
|
||||
|
@ -517,7 +517,7 @@ impl<T> OnceLock<T> {
|
||||
res = Err(e);
|
||||
|
||||
// Treat the underlying `Once` as poisoned since we
|
||||
// failed to initialize our value. Calls
|
||||
// failed to initialize our value.
|
||||
p.poison();
|
||||
}
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ pub fn remove_dir_all(path: &Path) -> io::Result<()> {
|
||||
}
|
||||
};
|
||||
// ignore internal NotFound errors
|
||||
if let Err(err) = result
|
||||
if let Err(err) = &result
|
||||
&& err.kind() != io::ErrorKind::NotFound
|
||||
{
|
||||
return result;
|
||||
|
@ -917,7 +917,6 @@ users_on_vacation = [
|
||||
"jhpratt",
|
||||
"joboet",
|
||||
"jyn514",
|
||||
"kobzol",
|
||||
"oli-obk",
|
||||
"tgross35",
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user