authorbors <bors@rust-lang.org> 2026-02-23 02:39:01 UTC
committerbors <bors@rust-lang.org> 2026-02-23 02:39:01 UTC
logd3e8bd94cc042c65e30a6c60146a8a00531d1292
tree4ab77e891f59003c330107a5c81f93c24a3b0709
parentc78a29473a68f07012904af11c92ecffa68fcc75
parent8c96521c992d7567d689823edc1c88cf9607429f

Auto merge of #153000 - Zalathar:rollup-68jDIBK, r=Zalathar

Rollup of 9 pull requests Successful merges: - rust-lang/rust#152229 (Remove deterministic picking from query cycle handling) - rust-lang/rust#152970 (extend unpin noalias tests to cover mutable references) - rust-lang/rust#149783 (stabilize `cfg_select!`) - rust-lang/rust#151744 (fix refining_impl_trait suggestion with return_type_notation) - rust-lang/rust#152366 (Add try_shrink_to and try_shrink_to_fit to Vec) - rust-lang/rust#152640 (Add direct link to rustc-dev-guide in README) - rust-lang/rust#152963 (Revert "Stabilize `str_as_str`") - rust-lang/rust#152984 (Remove redundant call to `check_codegen_attributes_extra` in Inliner) - rust-lang/rust#152987 (Use `HashStable` derive in more places)

64 files changed, 329 insertions(+), 286 deletions(-)

Cargo.lock-1
......@@ -4492,7 +4492,6 @@ dependencies = [
44924492 "rustc_abi",
44934493 "rustc_data_structures",
44944494 "rustc_errors",
4495 "rustc_hashes",
44964495 "rustc_hir",
44974496 "rustc_index",
44984497 "rustc_macros",
README.md+2
......@@ -52,6 +52,8 @@ See https://www.rust-lang.org/community for a list of chat platforms and forums.
5252
5353See [CONTRIBUTING.md](CONTRIBUTING.md).
5454
55For a detailed explanation of the compiler's architecture and how to begin contributing, see the [rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/).
56
5557## License
5658
5759Rust is primarily distributed under the terms of both the MIT license and the
compiler/rustc_attr_parsing/src/attributes/cfg_select.rs+8-14
......@@ -128,20 +128,14 @@ pub fn parse_cfg_select(
128128 }
129129 }
130130
131 if let Some(features) = features
132 && features.enabled(sym::cfg_select)
133 {
134 let it = branches
135 .reachable
136 .iter()
137 .map(|(entry, _, _)| CfgSelectPredicate::Cfg(entry.clone()))
138 .chain(branches.wildcard.as_ref().map(|(t, _, _)| CfgSelectPredicate::Wildcard(*t)))
139 .chain(
140 branches.unreachable.iter().map(|(entry, _, _)| CfgSelectPredicate::clone(entry)),
141 );
142
143 lint_unreachable(p, it, lint_node_id);
144 }
131 let it = branches
132 .reachable
133 .iter()
134 .map(|(entry, _, _)| CfgSelectPredicate::Cfg(entry.clone()))
135 .chain(branches.wildcard.as_ref().map(|(t, _, _)| CfgSelectPredicate::Wildcard(*t)))
136 .chain(branches.unreachable.iter().map(|(entry, _, _)| CfgSelectPredicate::clone(entry)));
137
138 lint_unreachable(p, it, lint_node_id);
145139
146140 Ok(branches)
147141}
compiler/rustc_codegen_cranelift/patches/0027-sysroot_tests-128bit-atomic-operations.patch+1-1
......@@ -17,8 +17,8 @@ index 1e336bf..35e6f54 100644
1717@@ -2,4 +2,3 @@
1818 // tidy-alphabetical-start
1919-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
20 #![cfg_attr(test, feature(cfg_select))]
2120 #![feature(array_ptr_get)]
21 #![feature(array_try_from_fn)]
2222diff --git a/coretests/tests/atomic.rs b/coretests/tests/atomic.rs
2323index b735957..ea728b6 100644
2424--- a/coretests/tests/atomic.rs
compiler/rustc_data_structures/src/lib.rs+4-1
......@@ -11,6 +11,7 @@
1111#![allow(rustc::default_hash_types)]
1212#![allow(rustc::potential_query_instability)]
1313#![cfg_attr(bootstrap, feature(assert_matches))]
14#![cfg_attr(bootstrap, feature(cfg_select))]
1415#![cfg_attr(bootstrap, feature(cold_path))]
1516#![cfg_attr(test, feature(test))]
1617#![deny(unsafe_op_in_unsafe_fn)]
......@@ -18,7 +19,6 @@
1819#![feature(ascii_char)]
1920#![feature(ascii_char_variants)]
2021#![feature(auto_traits)]
21#![feature(cfg_select)]
2222#![feature(const_default)]
2323#![feature(const_trait_impl)]
2424#![feature(dropck_eyepatch)]
......@@ -47,6 +47,9 @@ use std::fmt;
4747#[cfg(not(bootstrap))]
4848pub use std::{assert_matches, debug_assert_matches};
4949
50// This allows derive macros to reference this crate
51extern crate self as rustc_data_structures;
52
5053pub use atomic_ref::AtomicRef;
5154pub use ena::{snapshot_vec, undo_log, unify};
5255// Re-export `hashbrown::hash_table`, because it's part of our API
compiler/rustc_data_structures/src/sorted_map/index_map.rs+4-19
......@@ -3,8 +3,7 @@
33use std::hash::{Hash, Hasher};
44
55use rustc_index::{Idx, IndexVec};
6
7use crate::stable_hasher::{HashStable, StableHasher};
6use rustc_macros::HashStable_NoContext;
87
98/// An indexed multi-map that preserves insertion order while permitting both *O*(log *n*) lookup of
109/// an item by key and *O*(1) lookup by index.
......@@ -24,11 +23,13 @@ use crate::stable_hasher::{HashStable, StableHasher};
2423/// in-place.
2524///
2625/// [`SortedMap`]: super::SortedMap
27#[derive(Clone, Debug)]
26#[derive(Clone, Debug, HashStable_NoContext)]
2827pub struct SortedIndexMultiMap<I: Idx, K, V> {
2928 /// The elements of the map in insertion order.
3029 items: IndexVec<I, (K, V)>,
3130
31 // We can ignore this field because it is not observable from the outside.
32 #[stable_hasher(ignore)]
3233 /// Indices of the items in the set, sorted by the item's key.
3334 idx_sorted_by_item_key: Vec<I>,
3435}
......@@ -126,22 +127,6 @@ where
126127 }
127128}
128129
129impl<I: Idx, K, V, C> HashStable<C> for SortedIndexMultiMap<I, K, V>
130where
131 K: HashStable<C>,
132 V: HashStable<C>,
133{
134 fn hash_stable(&self, ctx: &mut C, hasher: &mut StableHasher) {
135 let SortedIndexMultiMap {
136 items,
137 // We can ignore this field because it is not observable from the outside.
138 idx_sorted_by_item_key: _,
139 } = self;
140
141 items.hash_stable(ctx, hasher)
142 }
143}
144
145130impl<I: Idx, K: Ord, V> FromIterator<(K, V)> for SortedIndexMultiMap<I, K, V> {
146131 fn from_iter<J>(iter: J) -> Self
147132 where
compiler/rustc_data_structures/src/svh.rs+12-11
......@@ -7,12 +7,21 @@
77
88use std::fmt;
99
10use rustc_macros::{Decodable_NoContext, Encodable_NoContext};
10use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
1111
1212use crate::fingerprint::Fingerprint;
13use crate::stable_hasher;
1413
15#[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable_NoContext, Decodable_NoContext, Hash)]
14#[derive(
15 Copy,
16 Clone,
17 PartialEq,
18 Eq,
19 Debug,
20 Encodable_NoContext,
21 Decodable_NoContext,
22 Hash,
23 HashStable_NoContext
24)]
1625pub struct Svh {
1726 hash: Fingerprint,
1827}
......@@ -39,11 +48,3 @@ impl fmt::Display for Svh {
3948 f.pad(&self.to_hex())
4049 }
4150}
42
43impl<T> stable_hasher::HashStable<T> for Svh {
44 #[inline]
45 fn hash_stable(&self, ctx: &mut T, hasher: &mut stable_hasher::StableHasher) {
46 let Svh { hash } = *self;
47 hash.hash_stable(ctx, hasher);
48 }
49}
compiler/rustc_feature/src/accepted.rs+2
......@@ -102,6 +102,8 @@ declare_features! (
102102 (accepted, cfg_doctest, "1.40.0", Some(62210)),
103103 /// Enables `#[cfg(panic = "...")]` config key.
104104 (accepted, cfg_panic, "1.60.0", Some(77443)),
105 /// Provides a native way to easily manage multiple conditional flags without having to rewrite each clause multiple times.
106 (accepted, cfg_select, "CURRENT_RUSTC_VERSION", Some(115585)),
105107 /// Allows `cfg(target_abi = "...")`.
106108 (accepted, cfg_target_abi, "1.78.0", Some(80970)),
107109 /// Allows `cfg(target_feature = "...")`.
compiler/rustc_feature/src/unstable.rs-2
......@@ -388,8 +388,6 @@ declare_features! (
388388 (unstable, cfg_sanitize, "1.41.0", Some(39699)),
389389 /// Allows `cfg(sanitizer_cfi_generalize_pointers)` and `cfg(sanitizer_cfi_normalize_integers)`.
390390 (unstable, cfg_sanitizer_cfi, "1.77.0", Some(89653)),
391 /// Provides a native way to easily manage multiple conditional flags without having to rewrite each clause multiple times.
392 (unstable, cfg_select, "CURRENT_RUSTC_VERSION", Some(115585)),
393391 /// Allows `cfg(target(abi = "..."))`.
394392 (unstable, cfg_target_compact, "1.63.0", Some(96901)),
395393 /// Allows `cfg(target_has_atomic_load_store = "...")`.
compiler/rustc_hir/src/diagnostic_items.rs+3-9
......@@ -1,19 +1,13 @@
11use rustc_data_structures::fx::FxIndexMap;
2use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2use rustc_macros::HashStable_Generic;
33use rustc_span::Symbol;
44use rustc_span::def_id::DefIdMap;
55
66use crate::def_id::DefId;
77
8#[derive(Debug, Default)]
8#[derive(Debug, Default, HashStable_Generic)]
99pub struct DiagnosticItems {
10 #[stable_hasher(ignore)]
1011 pub id_to_name: DefIdMap<Symbol>,
1112 pub name_to_id: FxIndexMap<Symbol, DefId>,
1213}
13
14impl<CTX: crate::HashStableContext> HashStable<CTX> for DiagnosticItems {
15 #[inline]
16 fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
17 self.name_to_id.hash_stable(ctx, hasher);
18 }
19}
compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs+13-1
......@@ -6,6 +6,7 @@ use rustc_infer::infer::TyCtxtInferExt;
66use rustc_lint_defs::builtin::{REFINING_IMPL_TRAIT_INTERNAL, REFINING_IMPL_TRAIT_REACHABLE};
77use rustc_middle::span_bug;
88use rustc_middle::traits::ObligationCause;
9use rustc_middle::ty::print::{with_no_trimmed_paths, with_types_for_signature};
910use rustc_middle::ty::{
1011 self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperVisitable, TypeVisitable,
1112 TypeVisitableExt, TypeVisitor, TypingMode,
......@@ -332,6 +333,17 @@ fn report_mismatched_rpitit_signature<'tcx>(
332333 hir::FnRetTy::Return(ty) => ty.span,
333334 });
334335
336 // Use ForSignature mode to ensure RPITITs are printed as `impl Trait` rather than
337 // `impl Trait { T::method(..) }` when RTN is enabled.
338 //
339 // We use `with_no_trimmed_paths!` to avoid triggering the `trimmed_def_paths` query,
340 // which requires diagnostic context (via `must_produce_diag`). Since we're formatting
341 // the type before creating the diagnostic, we need to avoid this query. This is the
342 // standard approach used elsewhere in the compiler for formatting types in suggestions
343 // (e.g., see `rustc_hir_typeck/src/demand.rs`).
344 let return_ty_suggestion =
345 with_no_trimmed_paths!(with_types_for_signature!(format!("{return_ty}")));
346
335347 let span = unmatched_bound.unwrap_or(span);
336348 tcx.emit_node_span_lint(
337349 if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE },
......@@ -342,7 +354,7 @@ fn report_mismatched_rpitit_signature<'tcx>(
342354 trait_return_span,
343355 pre,
344356 post,
345 return_ty,
357 return_ty: return_ty_suggestion,
346358 unmatched_bound,
347359 },
348360 );
compiler/rustc_hir_analysis/src/errors.rs+2-2
......@@ -1132,7 +1132,7 @@ pub(crate) struct UnusedAssociatedTypeBounds {
11321132#[note(
11331133 "we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information"
11341134)]
1135pub(crate) struct ReturnPositionImplTraitInTraitRefined<'tcx> {
1135pub(crate) struct ReturnPositionImplTraitInTraitRefined {
11361136 #[suggestion(
11371137 "replace the return type so that it matches the trait",
11381138 applicability = "maybe-incorrect",
......@@ -1146,7 +1146,7 @@ pub(crate) struct ReturnPositionImplTraitInTraitRefined<'tcx> {
11461146
11471147 pub pre: &'static str,
11481148 pub post: &'static str,
1149 pub return_ty: Ty<'tcx>,
1149 pub return_ty: String,
11501150}
11511151
11521152#[derive(LintDiagnostic)]
compiler/rustc_lint_defs/src/builtin.rs+1-2
......@@ -864,7 +864,7 @@ declare_lint! {
864864 /// ### Example
865865 ///
866866 /// ```rust
867 /// #![feature(cfg_select)]
867 /// # #![cfg_attr(bootstrap, feature(cfg_select))]
868868 /// cfg_select! {
869869 /// _ => (),
870870 /// windows => (),
......@@ -882,7 +882,6 @@ declare_lint! {
882882 pub UNREACHABLE_CFG_SELECT_PREDICATES,
883883 Warn,
884884 "detects unreachable configuration predicates in the cfg_select macro",
885 @feature_gate = cfg_select;
886885}
887886
888887declare_lint! {
compiler/rustc_macros/src/lib.rs+1-1
......@@ -64,7 +64,7 @@ decl_derive!(
6464 hash_stable::hash_stable_generic_derive
6565);
6666decl_derive!(
67 [HashStable_NoContext] =>
67 [HashStable_NoContext, attributes(stable_hasher)] =>
6868 /// `HashStable` implementation that has no `HashStableContext` bound and
6969 /// which adds `where` bounds for `HashStable` based off of fields and not
7070 /// generics. This is suitable for use in crates like `rustc_type_ir`.
compiler/rustc_middle/src/dep_graph/dep_node.rs+4-9
......@@ -54,7 +54,7 @@ use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
5454use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey};
5555use rustc_hir::def_id::DefId;
5656use rustc_hir::definitions::DefPathHash;
57use rustc_macros::{Decodable, Encodable};
57use rustc_macros::{Decodable, Encodable, HashStable};
5858use rustc_span::Symbol;
5959
6060use super::{KeyFingerprintStyle, SerializedDepNodeIndex};
......@@ -290,7 +290,9 @@ pub struct DepKindVTable<'tcx> {
290290/// some independent path or string that persists between runs without
291291/// the need to be mapped or unmapped. (This ensures we can serialize
292292/// them even in the absence of a tcx.)
293#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
293#[derive(
294 Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable, HashStable
295)]
294296pub struct WorkProductId {
295297 hash: Fingerprint,
296298}
......@@ -302,13 +304,6 @@ impl WorkProductId {
302304 WorkProductId { hash: hasher.finish() }
303305 }
304306}
305
306impl<HCX> HashStable<HCX> for WorkProductId {
307 #[inline]
308 fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
309 self.hash.hash_stable(hcx, hasher)
310 }
311}
312307impl<HCX> ToStableHashKey<HCX> for WorkProductId {
313308 type KeyType = Fingerprint;
314309 #[inline]
compiler/rustc_middle/src/mir/mod.rs+1-20
......@@ -891,7 +891,7 @@ pub struct VarBindingForm<'tcx> {
891891 pub introductions: Vec<VarBindingIntroduction>,
892892}
893893
894#[derive(Clone, Debug, TyEncodable, TyDecodable)]
894#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]
895895pub enum BindingForm<'tcx> {
896896 /// This is a binding for a non-`self` binding, or a `self` that has an explicit type.
897897 Var(VarBindingForm<'tcx>),
......@@ -909,25 +909,6 @@ pub struct VarBindingIntroduction {
909909 pub is_shorthand: bool,
910910}
911911
912mod binding_form_impl {
913 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
914
915 use crate::ich::StableHashingContext;
916
917 impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for super::BindingForm<'tcx> {
918 fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
919 use super::BindingForm::*;
920 std::mem::discriminant(self).hash_stable(hcx, hasher);
921
922 match self {
923 Var(binding) => binding.hash_stable(hcx, hasher),
924 ImplicitSelf(kind) => kind.hash_stable(hcx, hasher),
925 RefForGuard(local) => local.hash_stable(hcx, hasher),
926 }
927 }
928 }
929}
930
931912/// `BlockTailInfo` is attached to the `LocalDecl` for temporaries
932913/// created during evaluation of expressions in a block tail
933914/// expression; that is, a block like `{ STMT_1; STMT_2; EXPR }`.
compiler/rustc_middle/src/query/stack.rs+1-7
......@@ -4,7 +4,6 @@ use std::mem::transmute;
44use std::sync::Arc;
55
66use rustc_data_structures::sync::{DynSend, DynSync};
7use rustc_hashes::Hash64;
87use rustc_hir::def::DefKind;
98use rustc_span::Span;
109use rustc_span::def_id::DefId;
......@@ -23,9 +22,6 @@ pub struct QueryStackFrame<I> {
2322 pub info: I,
2423
2524 pub dep_kind: DepKind,
26 /// This hash is used to deterministically pick
27 /// a query to remove cycles in the parallel compiler.
28 pub hash: Hash64,
2925 pub def_id: Option<DefId>,
3026 /// A def-id that is extracted from a `Ty` in a query key
3127 pub def_id_for_ty_in_cycle: Option<DefId>,
......@@ -36,18 +32,16 @@ impl<'tcx> QueryStackFrame<QueryStackDeferred<'tcx>> {
3632 pub fn new(
3733 info: QueryStackDeferred<'tcx>,
3834 dep_kind: DepKind,
39 hash: Hash64,
4035 def_id: Option<DefId>,
4136 def_id_for_ty_in_cycle: Option<DefId>,
4237 ) -> Self {
43 Self { info, def_id, dep_kind, hash, def_id_for_ty_in_cycle }
38 Self { info, def_id, dep_kind, def_id_for_ty_in_cycle }
4439 }
4540
4641 pub fn lift(&self) -> QueryStackFrame<QueryStackFrameExtra> {
4742 QueryStackFrame {
4843 info: self.info.extract(),
4944 dep_kind: self.dep_kind,
50 hash: self.hash,
5145 def_id: self.def_id,
5246 def_id_for_ty_in_cycle: self.def_id_for_ty_in_cycle,
5347 }
compiler/rustc_mir_transform/src/inline.rs-1
......@@ -607,7 +607,6 @@ fn try_inlining<'tcx, I: Inliner<'tcx>>(
607607 let callee_attrs = callee_attrs.as_ref();
608608 check_inline::is_inline_valid_on_fn(tcx, callsite.callee.def_id())?;
609609 check_codegen_attributes(inliner, callsite, callee_attrs)?;
610 inliner.check_codegen_attributes_extra(callee_attrs)?;
611610
612611 let terminator = caller_body[callsite.block].terminator.as_ref().unwrap();
613612 let TerminatorKind::Call { args, destination, .. } = &terminator.kind else { bug!() };
compiler/rustc_query_impl/Cargo.toml-1
......@@ -9,7 +9,6 @@ measureme = "12.0.1"
99rustc_abi = { path = "../rustc_abi" }
1010rustc_data_structures = { path = "../rustc_data_structures" }
1111rustc_errors = { path = "../rustc_errors" }
12rustc_hashes = { path = "../rustc_hashes" }
1312rustc_hir = { path = "../rustc_hir" }
1413rustc_index = { path = "../rustc_index" }
1514rustc_macros = { path = "../rustc_macros" }
compiler/rustc_query_impl/src/job.rs+29-42
......@@ -209,27 +209,6 @@ fn connected_to_root<'tcx>(
209209 visit_waiters(job_map, query, |_, successor| connected_to_root(job_map, successor, visited))
210210}
211211
212// Deterministically pick an query from a list
213fn pick_query<'a, 'tcx, T, F>(job_map: &QueryJobMap<'tcx>, queries: &'a [T], f: F) -> &'a T
214where
215 F: Fn(&T) -> (Span, QueryJobId),
216{
217 // Deterministically pick an entry point
218 // FIXME: Sort this instead
219 queries
220 .iter()
221 .min_by_key(|v| {
222 let (span, query) = f(v);
223 let hash = job_map.frame_of(query).hash;
224 // Prefer entry points which have valid spans for nicer error messages
225 // We add an integer to the tuple ensuring that entry points
226 // with valid spans are picked first
227 let span_cmp = if span == DUMMY_SP { 1 } else { 0 };
228 (span_cmp, hash)
229 })
230 .unwrap()
231}
232
233212/// Looks for query cycles starting from the last query in `jobs`.
234213/// If a cycle is found, all queries in the cycle is removed from `jobs` and
235214/// the function return true.
......@@ -263,48 +242,56 @@ fn remove_cycle<'tcx>(
263242 }
264243 }
265244
245 struct EntryPoint {
246 query_in_cycle: QueryJobId,
247 waiter: Option<(Span, QueryJobId)>,
248 }
249
266250 // Find the queries in the cycle which are
267251 // connected to queries outside the cycle
268252 let entry_points = stack
269253 .iter()
270 .filter_map(|&(span, query)| {
271 if job_map.parent_of(query).is_none() {
254 .filter_map(|&(_, query_in_cycle)| {
255 if job_map.parent_of(query_in_cycle).is_none() {
272256 // This query is connected to the root (it has no query parent)
273 Some((span, query, None))
257 Some(EntryPoint { query_in_cycle, waiter: None })
274258 } else {
275 let mut waiters = Vec::new();
276 // Find all the direct waiters who lead to the root
277 let _ = visit_waiters(job_map, query, |span, waiter| {
259 let mut waiter_on_cycle = None;
260 // Find a direct waiter who leads to the root
261 let _ = visit_waiters(job_map, query_in_cycle, |span, waiter| {
278262 // Mark all the other queries in the cycle as already visited
279263 let mut visited = FxHashSet::from_iter(stack.iter().map(|q| q.1));
280264
281265 if connected_to_root(job_map, waiter, &mut visited).is_break() {
282 waiters.push((span, waiter));
266 waiter_on_cycle = Some((span, waiter));
267 ControlFlow::Break(None)
268 } else {
269 ControlFlow::Continue(())
283270 }
284
285 ControlFlow::Continue(())
286271 });
287 if waiters.is_empty() {
288 None
289 } else {
290 // Deterministically pick one of the waiters to show to the user
291 let waiter = *pick_query(job_map, &waiters, |s| *s);
292 Some((span, query, Some(waiter)))
293 }
272
273 waiter_on_cycle.map(|waiter_on_cycle| EntryPoint {
274 query_in_cycle,
275 waiter: Some(waiter_on_cycle),
276 })
294277 }
295278 })
296 .collect::<Vec<(Span, QueryJobId, Option<(Span, QueryJobId)>)>>();
279 .collect::<Vec<EntryPoint>>();
297280
298 // Deterministically pick an entry point
299 let (_, entry_point, usage) = pick_query(job_map, &entry_points, |e| (e.0, e.1));
281 // Pick an entry point, preferring ones with waiters
282 let entry_point = entry_points
283 .iter()
284 .find(|entry_point| entry_point.waiter.is_some())
285 .unwrap_or(&entry_points[0]);
300286
301287 // Shift the stack so that our entry point is first
302 let entry_point_pos = stack.iter().position(|(_, query)| query == entry_point);
288 let entry_point_pos =
289 stack.iter().position(|(_, query)| *query == entry_point.query_in_cycle);
303290 if let Some(pos) = entry_point_pos {
304291 stack.rotate_left(pos);
305292 }
306293
307 let usage = usage.map(|(span, job)| (span, job_map.frame_of(job).clone()));
294 let usage = entry_point.waiter.map(|(span, job)| (span, job_map.frame_of(job).clone()));
308295
309296 // Create the cycle error
310297 let error = CycleError {
compiler/rustc_query_impl/src/plumbing.rs+1-10
......@@ -4,10 +4,8 @@
44
55use std::num::NonZero;
66
7use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
87use rustc_data_structures::sync::{DynSend, DynSync};
98use rustc_data_structures::unord::UnordMap;
10use rustc_hashes::Hash64;
119use rustc_hir::def_id::DefId;
1210use rustc_hir::limit::Limit;
1311use rustc_index::Idx;
......@@ -319,18 +317,11 @@ where
319317{
320318 let kind = vtable.dep_kind;
321319
322 let hash = tcx.with_stable_hashing_context(|mut hcx| {
323 let mut hasher = StableHasher::new();
324 kind.as_usize().hash_stable(&mut hcx, &mut hasher);
325 key.hash_stable(&mut hcx, &mut hasher);
326 hasher.finish::<Hash64>()
327 });
328
329320 let def_id: Option<DefId> = key.key_as_def_id();
330321 let def_id_for_ty_in_cycle: Option<DefId> = key.def_id_for_ty_in_cycle();
331322
332323 let info = QueryStackDeferred::new((tcx, vtable, key), mk_query_stack_frame_extra);
333 QueryStackFrame::new(info, kind, hash, def_id, def_id_for_ty_in_cycle)
324 QueryStackFrame::new(info, kind, def_id, def_id_for_ty_in_cycle)
334325}
335326
336327pub(crate) fn encode_query_results<'a, 'tcx, Q, C: QueryCache, const FLAGS: QueryFlags>(
compiler/rustc_span/src/lib.rs+2-8
......@@ -17,9 +17,9 @@
1717
1818// tidy-alphabetical-start
1919#![allow(internal_features)]
20#![cfg_attr(bootstrap, feature(cfg_select))]
2021#![cfg_attr(bootstrap, feature(if_let_guard))]
2122#![cfg_attr(target_arch = "loongarch64", feature(stdarch_loongarch))]
22#![feature(cfg_select)]
2323#![feature(core_io_borrowed_buf)]
2424#![feature(map_try_insert)]
2525#![feature(negative_impls)]
......@@ -2653,7 +2653,7 @@ impl_pos! {
26532653 pub struct BytePos(pub u32);
26542654
26552655 /// A byte offset relative to file beginning.
2656 #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
2656 #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, HashStable_Generic)]
26572657 pub struct RelativeBytePos(pub u32);
26582658
26592659 /// A character offset.
......@@ -2677,12 +2677,6 @@ impl<D: Decoder> Decodable<D> for BytePos {
26772677 }
26782678}
26792679
2680impl<H: HashStableContext> HashStable<H> for RelativeBytePos {
2681 fn hash_stable(&self, hcx: &mut H, hasher: &mut StableHasher) {
2682 self.0.hash_stable(hcx, hasher);
2683 }
2684}
2685
26862680impl<S: Encoder> Encodable<S> for RelativeBytePos {
26872681 fn encode(&self, s: &mut S) {
26882682 s.emit_u32(self.0);
compiler/rustc_target/src/target_features.rs+2-18
......@@ -2,7 +2,7 @@
22//! Note that these are similar to but not always identical to LLVM's feature names,
33//! and Rust adds some features that do not correspond to LLVM features at all.
44use rustc_data_structures::fx::{FxHashMap, FxHashSet};
5use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5use rustc_macros::HashStable_Generic;
66use rustc_span::{Symbol, sym};
77
88use crate::spec::{Abi, Arch, FloatAbi, RustcAbi, Target};
......@@ -12,7 +12,7 @@ use crate::spec::{Abi, Arch, FloatAbi, RustcAbi, Target};
1212pub const RUSTC_SPECIFIC_FEATURES: &[&str] = &["crt-static"];
1313
1414/// Stability information for target features.
15#[derive(Debug, Copy, Clone)]
15#[derive(Debug, Copy, Clone, HashStable_Generic)]
1616pub enum Stability {
1717 /// This target feature is stable, it can be used in `#[target_feature]` and
1818 /// `#[cfg(target_feature)]`.
......@@ -32,22 +32,6 @@ pub enum Stability {
3232}
3333use Stability::*;
3434
35impl<CTX> HashStable<CTX> for Stability {
36 #[inline]
37 fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
38 std::mem::discriminant(self).hash_stable(hcx, hasher);
39 match self {
40 Stability::Stable => {}
41 Stability::Unstable(nightly_feature) => {
42 nightly_feature.hash_stable(hcx, hasher);
43 }
44 Stability::Forbidden { reason } => {
45 reason.hash_stable(hcx, hasher);
46 }
47 }
48 }
49}
50
5135impl Stability {
5236 /// Returns whether the feature can be used in `cfg(target_feature)` ever.
5337 /// (It might still be nightly-only even if this returns `true`, so make sure to also check
library/alloc/src/raw_vec/mod.rs+29-2
......@@ -399,6 +399,21 @@ impl<T, A: Allocator> RawVec<T, A> {
399399 // SAFETY: All calls on self.inner pass T::LAYOUT as the elem_layout
400400 unsafe { self.inner.shrink_to_fit(cap, T::LAYOUT) }
401401 }
402
403 /// Shrinks the buffer down to the specified capacity. If the given amount
404 /// is 0, actually completely deallocates.
405 ///
406 /// # Errors
407 ///
408 /// This function returns an error if the allocator cannot shrink the allocation.
409 ///
410 /// # Panics
411 ///
412 /// Panics if the given amount is *larger* than the current capacity.
413 #[inline]
414 pub(crate) fn try_shrink_to_fit(&mut self, cap: usize) -> Result<(), TryReserveError> {
415 unsafe { self.inner.try_shrink_to_fit(cap, T::LAYOUT) }
416 }
402417}
403418
404419unsafe impl<#[may_dangle] T, A: Allocator> Drop for RawVec<T, A> {
......@@ -731,6 +746,20 @@ impl<A: Allocator> RawVecInner<A> {
731746 }
732747 }
733748
749 /// # Safety
750 ///
751 /// - `elem_layout` must be valid for `self`, i.e. it must be the same `elem_layout` used to
752 /// initially construct `self`
753 /// - `elem_layout`'s size must be a multiple of its alignment
754 /// - `cap` must be less than or equal to `self.capacity(elem_layout.size())`
755 unsafe fn try_shrink_to_fit(
756 &mut self,
757 cap: usize,
758 elem_layout: Layout,
759 ) -> Result<(), TryReserveError> {
760 unsafe { self.shrink(cap, elem_layout) }
761 }
762
734763 #[inline]
735764 const fn needs_to_grow(&self, len: usize, additional: usize, elem_layout: Layout) -> bool {
736765 additional > self.capacity(elem_layout.size()).wrapping_sub(len)
......@@ -778,7 +807,6 @@ impl<A: Allocator> RawVecInner<A> {
778807 /// initially construct `self`
779808 /// - `elem_layout`'s size must be a multiple of its alignment
780809 /// - `cap` must be less than or equal to `self.capacity(elem_layout.size())`
781 #[cfg(not(no_global_oom_handling))]
782810 #[inline]
783811 unsafe fn shrink(&mut self, cap: usize, elem_layout: Layout) -> Result<(), TryReserveError> {
784812 assert!(cap <= self.capacity(elem_layout.size()), "Tried to shrink to a larger capacity");
......@@ -796,7 +824,6 @@ impl<A: Allocator> RawVecInner<A> {
796824 ///
797825 /// # Safety
798826 /// `cap <= self.capacity()`
799 #[cfg(not(no_global_oom_handling))]
800827 unsafe fn shrink_unchecked(
801828 &mut self,
802829 cap: usize,
library/alloc/src/vec/mod.rs+68-3
......@@ -75,8 +75,6 @@
7575
7676#[cfg(not(no_global_oom_handling))]
7777use core::clone::TrivialClone;
78#[cfg(not(no_global_oom_handling))]
79use core::cmp;
8078use core::cmp::Ordering;
8179use core::hash::{Hash, Hasher};
8280#[cfg(not(no_global_oom_handling))]
......@@ -88,7 +86,7 @@ use core::mem::{self, Assume, ManuallyDrop, MaybeUninit, SizedTypeProperties, Tr
8886use core::ops::{self, Index, IndexMut, Range, RangeBounds};
8987use core::ptr::{self, NonNull};
9088use core::slice::{self, SliceIndex};
91use core::{fmt, hint, intrinsics, ub_checks};
89use core::{cmp, fmt, hint, intrinsics, ub_checks};
9290
9391#[stable(feature = "extract_if", since = "1.87.0")]
9492pub use self::extract_if::ExtractIf;
......@@ -1613,6 +1611,73 @@ impl<T, A: Allocator> Vec<T, A> {
16131611 }
16141612 }
16151613
1614 /// Tries to shrink the capacity of the vector as much as possible
1615 ///
1616 /// The behavior of this method depends on the allocator, which may either shrink the vector
1617 /// in-place or reallocate. The resulting vector might still have some excess capacity, just as
1618 /// is the case for [`with_capacity`]. See [`Allocator::shrink`] for more details.
1619 ///
1620 /// [`with_capacity`]: Vec::with_capacity
1621 ///
1622 /// # Errors
1623 ///
1624 /// This function returns an error if the allocator fails to shrink the allocation,
1625 /// the vector thereafter is still safe to use, the capacity remains unchanged
1626 /// however. See [`Allocator::shrink`].
1627 ///
1628 /// # Examples
1629 ///
1630 /// ```
1631 /// #![feature(vec_fallible_shrink)]
1632 ///
1633 /// let mut vec = Vec::with_capacity(10);
1634 /// vec.extend([1, 2, 3]);
1635 /// assert!(vec.capacity() >= 10);
1636 /// vec.try_shrink_to_fit().expect("why is the test harness failing to shrink to 12 bytes");
1637 /// assert!(vec.capacity() >= 3);
1638 /// ```
1639 #[unstable(feature = "vec_fallible_shrink", issue = "152350")]
1640 #[inline]
1641 pub fn try_shrink_to_fit(&mut self) -> Result<(), TryReserveError> {
1642 if self.capacity() > self.len { self.buf.try_shrink_to_fit(self.len) } else { Ok(()) }
1643 }
1644
1645 /// Shrinks the capacity of the vector with a lower bound.
1646 ///
1647 /// The capacity will remain at least as large as both the length
1648 /// and the supplied value.
1649 ///
1650 /// If the current capacity is less than the lower limit, this is a no-op.
1651 ///
1652 /// # Errors
1653 ///
1654 /// This function returns an error if the allocator fails to shrink the allocation,
1655 /// the vector thereafter is still safe to use, the capacity remains unchanged
1656 /// however. See [`Allocator::shrink`].
1657 ///
1658 /// # Examples
1659 ///
1660 /// ```
1661 /// #![feature(vec_fallible_shrink)]
1662 ///
1663 /// let mut vec = Vec::with_capacity(10);
1664 /// vec.extend([1, 2, 3]);
1665 /// assert!(vec.capacity() >= 10);
1666 /// vec.try_shrink_to(4).expect("why is the test harness failing to shrink to 12 bytes");
1667 /// assert!(vec.capacity() >= 4);
1668 /// vec.try_shrink_to(0).expect("this is a no-op and thus the allocator isn't involved.");
1669 /// assert!(vec.capacity() >= 3);
1670 /// ```
1671 #[unstable(feature = "vec_fallible_shrink", issue = "152350")]
1672 #[inline]
1673 pub fn try_shrink_to(&mut self, min_capacity: usize) -> Result<(), TryReserveError> {
1674 if self.capacity() > min_capacity {
1675 self.buf.try_shrink_to_fit(cmp::max(self.len, min_capacity))
1676 } else {
1677 Ok(())
1678 }
1679 }
1680
16161681 /// Converts the vector into [`Box<[T]>`][owned slice].
16171682 ///
16181683 /// Before doing the conversion, this method discards excess capacity like [`shrink_to_fit`].
library/alloctests/tests/lib.rs+1
......@@ -33,6 +33,7 @@
3333#![feature(thin_box)]
3434#![feature(drain_keep_rest)]
3535#![feature(local_waker)]
36#![feature(str_as_str)]
3637#![feature(strict_provenance_lints)]
3738#![feature(string_replace_in_place)]
3839#![feature(vec_deque_truncate_front)]
library/core/src/bstr/mod.rs+2
......@@ -74,6 +74,7 @@ impl ByteStr {
7474 /// it helps dereferencing other "container" types,
7575 /// for example `Box<ByteStr>` or `Arc<ByteStr>`.
7676 #[inline]
77 // #[unstable(feature = "str_as_str", issue = "130366")]
7778 #[unstable(feature = "bstr", issue = "134915")]
7879 pub const fn as_byte_str(&self) -> &ByteStr {
7980 self
......@@ -85,6 +86,7 @@ impl ByteStr {
8586 /// it helps dereferencing other "container" types,
8687 /// for example `Box<ByteStr>` or `MutexGuard<ByteStr>`.
8788 #[inline]
89 // #[unstable(feature = "str_as_str", issue = "130366")]
8890 #[unstable(feature = "bstr", issue = "134915")]
8991 pub const fn as_mut_byte_str(&mut self) -> &mut ByteStr {
9092 self
library/core/src/ffi/c_str.rs+1-2
......@@ -655,8 +655,7 @@ impl CStr {
655655 /// it helps dereferencing other string-like types to string slices,
656656 /// for example references to `Box<CStr>` or `Arc<CStr>`.
657657 #[inline]
658 #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
659 #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
658 #[unstable(feature = "str_as_str", issue = "130366")]
660659 pub const fn as_c_str(&self) -> &CStr {
661660 self
662661 }
library/core/src/lib.rs+1-2
......@@ -98,7 +98,6 @@
9898// tidy-alphabetical-start
9999#![feature(asm_experimental_arch)]
100100#![feature(bstr_internals)]
101#![feature(cfg_select)]
102101#![feature(cfg_target_has_reliable_f16_f128)]
103102#![feature(const_carrying_mul_add)]
104103#![feature(const_cmp)]
......@@ -227,7 +226,7 @@ pub mod autodiff {
227226#[unstable(feature = "contracts", issue = "128044")]
228227pub mod contracts;
229228
230#[unstable(feature = "cfg_select", issue = "115585")]
229#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")]
231230pub use crate::macros::cfg_select;
232231
233232#[macro_use]
library/core/src/macros/mod.rs+1-5
......@@ -206,8 +206,6 @@ pub macro assert_matches {
206206/// # Example
207207///
208208/// ```
209/// #![feature(cfg_select)]
210///
211209/// cfg_select! {
212210/// unix => {
213211/// fn foo() { /* unix specific functionality */ }
......@@ -225,14 +223,12 @@ pub macro assert_matches {
225223/// right-hand side:
226224///
227225/// ```
228/// #![feature(cfg_select)]
229///
230226/// let _some_string = cfg_select! {
231227/// unix => "With great power comes great electricity bills",
232228/// _ => { "Behind every successful diet is an unwatched pizza" }
233229/// };
234230/// ```
235#[unstable(feature = "cfg_select", issue = "115585")]
231#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")]
236232#[rustc_diagnostic_item = "cfg_select"]
237233#[rustc_builtin_macro]
238234pub macro cfg_select($($tt:tt)*) {
library/core/src/prelude/v1.rs+1-1
......@@ -80,7 +80,7 @@ mod ambiguous_macros_only {
8080#[doc(no_inline)]
8181pub use self::ambiguous_macros_only::{env, panic};
8282
83#[unstable(feature = "cfg_select", issue = "115585")]
83#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")]
8484#[doc(no_inline)]
8585pub use crate::cfg_select;
8686
library/core/src/slice/mod.rs+2-4
......@@ -5337,8 +5337,7 @@ impl<T> [T] {
53375337 /// it helps dereferencing other "container" types to slices,
53385338 /// for example `Box<[T]>` or `Arc<[T]>`.
53395339 #[inline]
5340 #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
5341 #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
5340 #[unstable(feature = "str_as_str", issue = "130366")]
53425341 pub const fn as_slice(&self) -> &[T] {
53435342 self
53445343 }
......@@ -5349,8 +5348,7 @@ impl<T> [T] {
53495348 /// it helps dereferencing other "container" types to slices,
53505349 /// for example `Box<[T]>` or `MutexGuard<[T]>`.
53515350 #[inline]
5352 #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
5353 #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
5351 #[unstable(feature = "str_as_str", issue = "130366")]
53545352 pub const fn as_mut_slice(&mut self) -> &mut [T] {
53555353 self
53565354 }
library/core/src/str/mod.rs+1-2
......@@ -3137,8 +3137,7 @@ impl str {
31373137 /// it helps dereferencing other string-like types to string slices,
31383138 /// for example references to `Box<str>` or `Arc<str>`.
31393139 #[inline]
3140 #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
3141 #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
3140 #[unstable(feature = "str_as_str", issue = "130366")]
31423141 pub const fn as_str(&self) -> &str {
31433142 self
31443143 }
library/coretests/tests/lib.rs-1
......@@ -1,6 +1,5 @@
11// tidy-alphabetical-start
22#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
3#![cfg_attr(test, feature(cfg_select))]
43#![feature(array_ptr_get)]
54#![feature(array_try_from_fn)]
65#![feature(array_try_map)]
library/panic_unwind/src/lib.rs-1
......@@ -15,7 +15,6 @@
1515#![unstable(feature = "panic_unwind", issue = "32837")]
1616#![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
1717#![feature(cfg_emscripten_wasm_eh)]
18#![feature(cfg_select)]
1918#![feature(core_intrinsics)]
2019#![feature(panic_unwind)]
2120#![feature(staged_api)]
library/std/src/ffi/os_str.rs+1-2
......@@ -1285,8 +1285,7 @@ impl OsStr {
12851285 /// it helps dereferencing other string-like types to string slices,
12861286 /// for example references to `Box<OsStr>` or `Arc<OsStr>`.
12871287 #[inline]
1288 #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
1289 #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
1288 #[unstable(feature = "str_as_str", issue = "130366")]
12901289 pub const fn as_os_str(&self) -> &OsStr {
12911290 self
12921291 }
library/std/src/lib.rs+1-2
......@@ -322,7 +322,6 @@
322322#![feature(bstr)]
323323#![feature(bstr_internals)]
324324#![feature(cast_maybe_uninit)]
325#![feature(cfg_select)]
326325#![feature(char_internals)]
327326#![feature(clone_to_uninit)]
328327#![feature(const_convert)]
......@@ -695,7 +694,7 @@ mod panicking;
695694#[allow(dead_code, unused_attributes, fuzzy_provenance_casts, unsafe_op_in_unsafe_fn)]
696695mod backtrace_rs;
697696
698#[unstable(feature = "cfg_select", issue = "115585")]
697#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")]
699698pub use core::cfg_select;
700699#[unstable(
701700 feature = "concat_bytes",
library/std/src/path.rs+1-2
......@@ -3235,8 +3235,7 @@ impl Path {
32353235 /// it helps dereferencing other `PathBuf`-like types to `Path`s,
32363236 /// for example references to `Box<Path>` or `Arc<Path>`.
32373237 #[inline]
3238 #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
3239 #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")]
3238 #[unstable(feature = "str_as_str", issue = "130366")]
32403239 pub const fn as_path(&self) -> &Path {
32413240 self
32423241 }
library/std/src/prelude/v1.rs+1-1
......@@ -79,7 +79,7 @@ mod ambiguous_macros_only {
7979#[doc(no_inline)]
8080pub use self::ambiguous_macros_only::{vec, panic};
8181
82#[unstable(feature = "cfg_select", issue = "115585")]
82#[stable(feature = "cfg_select", since = "CURRENT_RUSTC_VERSION")]
8383#[doc(no_inline)]
8484pub use core::prelude::v1::cfg_select;
8585
library/std/tests/env_modify.rs-1
......@@ -1,6 +1,5 @@
11// These tests are in a separate integration test as they modify the environment,
22// and would otherwise cause some other tests to fail.
3#![feature(cfg_select)]
43
54use std::env::*;
65use std::ffi::{OsStr, OsString};
library/std_detect/src/lib.rs+1-1
......@@ -15,7 +15,7 @@
1515//! * `s390x`: [`is_s390x_feature_detected`]
1616
1717#![unstable(feature = "stdarch_internal", issue = "none")]
18#![feature(staged_api, cfg_select, doc_cfg, allow_internal_unstable)]
18#![feature(staged_api, doc_cfg, allow_internal_unstable)]
1919#![deny(rust_2018_idioms)]
2020#![allow(clippy::shadow_reuse)]
2121#![cfg_attr(test, allow(unused_imports))]
library/unwind/src/lib.rs-1
......@@ -1,7 +1,6 @@
11#![no_std]
22#![unstable(feature = "panic_unwind", issue = "32837")]
33#![feature(cfg_emscripten_wasm_eh)]
4#![feature(cfg_select)]
54#![feature(link_cfg)]
65#![feature(staged_api)]
76#![cfg_attr(
src/tools/miri/src/lib.rs+1-1
......@@ -1,6 +1,5 @@
11#![cfg_attr(bootstrap, feature(if_let_guard))]
22#![feature(abort_unwind)]
3#![feature(cfg_select)]
43#![feature(rustc_private)]
54#![feature(float_gamma)]
65#![feature(float_erf)]
......@@ -17,6 +16,7 @@
1716#![feature(derive_coerce_pointee)]
1817#![feature(arbitrary_self_types)]
1918#![feature(iter_advance_by)]
19#![cfg_attr(bootstrap, feature(cfg_select))]
2020// Configure clippy and other lints
2121#![allow(
2222 clippy::collapsible_else_if,
src/tools/miri/tests/pass/float_extra_rounding_error.rs-1
......@@ -2,7 +2,6 @@
22//@revisions: random max none
33//@[max]compile-flags: -Zmiri-max-extra-rounding-error
44//@[none]compile-flags: -Zmiri-no-extra-rounding-error
5#![feature(cfg_select)]
65
76use std::collections::HashSet;
87use std::hint::black_box;
tests/codegen-llvm/function-arguments.rs+14-2
......@@ -257,11 +257,11 @@ pub fn option_trait_borrow_mut(x: Option<&mut dyn Drop>) {}
257257#[no_mangle]
258258pub fn trait_raw(_: *const dyn Drop) {}
259259
260// Ensure that `Box` gets `noalias` when the right traits are present, but removing *either* `Unpin`
261// or `UnsafeUnpin` is enough to lose the attribute.
260262// CHECK: @trait_box(ptr noalias noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}})
261263#[no_mangle]
262264pub fn trait_box(_: Box<dyn Drop + Unpin + UnsafeUnpin>) {}
263
264// Ensure that removing *either* `Unpin` or `UnsafeUnpin` is enough to lose the attribute.
265265// CHECK: @trait_box_pin1(ptr noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}})
266266#[no_mangle]
267267pub fn trait_box_pin1(_: Box<dyn Drop + Unpin>) {}
......@@ -269,6 +269,18 @@ pub fn trait_box_pin1(_: Box<dyn Drop + Unpin>) {}
269269#[no_mangle]
270270pub fn trait_box_pin2(_: Box<dyn Drop + UnsafeUnpin>) {}
271271
272// Same for mutable references (with a non-zero minimal size so that we also see the
273// `dereferenceable` disappear).
274// CHECK: @trait_mutref(ptr noalias noundef align 4 dereferenceable(4){{( %_1.0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %_1.1)?}})
275#[no_mangle]
276pub fn trait_mutref(_: &mut (i32, dyn Drop + Unpin + UnsafeUnpin)) {}
277// CHECK: @trait_mutref_pin1(ptr noundef nonnull align 4{{( %_1.0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %_1.1)?}})
278#[no_mangle]
279pub fn trait_mutref_pin1(_: &mut (i32, dyn Drop + Unpin)) {}
280// CHECK: @trait_mutref_pin2(ptr noundef nonnull align 4{{( %_1.0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %_1.1)?}})
281#[no_mangle]
282pub fn trait_mutref_pin2(_: &mut (i32, dyn Drop + UnsafeUnpin)) {}
283
272284// CHECK: { ptr, ptr } @trait_option(ptr noalias noundef align 1 %x.0, ptr %x.1)
273285#[no_mangle]
274286pub fn trait_option(
tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs-1
......@@ -1,6 +1,5 @@
11#![crate_type = "staticlib"]
22#![feature(c_variadic)]
3#![feature(cfg_select)]
43
54use std::ffi::{CStr, CString, VaList, c_char, c_double, c_int, c_long, c_longlong};
65
tests/ui/asm/cfg.rs-1
......@@ -3,7 +3,6 @@
33//@ revisions: reva revb
44//@ only-x86_64
55//@ run-pass
6#![feature(cfg_select)]
76
87use std::arch::{asm, naked_asm};
98
tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr+1-1
......@@ -18,7 +18,7 @@ LL | #[warn(refining_impl_trait)]
1818help: replace the return type so that it matches the trait
1919 |
2020LL - fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>> {
21LL + fn foo(&self) -> impl Future<Output = i32> {
21LL + fn foo(&self) -> impl std::future::Future<Output = i32> {
2222 |
2323
2424warning: 1 warning emitted
tests/ui/async-await/in-trait/async-example-desugared-manual.stderr+1-1
......@@ -18,7 +18,7 @@ LL | #[warn(refining_impl_trait)]
1818help: replace the return type so that it matches the trait
1919 |
2020LL - fn foo(&self) -> MyFuture {
21LL + fn foo(&self) -> impl Future<Output = i32> {
21LL + fn foo(&self) -> impl std::future::Future<Output = i32> {
2222 |
2323
2424warning: 1 warning emitted
tests/ui/check-cfg/cfg-select.rs-1
......@@ -1,6 +1,5 @@
11//@ check-pass
22
3#![feature(cfg_select)]
43#![crate_type = "lib"]
54
65cfg_select! {
tests/ui/check-cfg/cfg-select.stderr+2-2
......@@ -1,5 +1,5 @@
11warning: unexpected `cfg` condition name: `invalid_cfg1`
2 --> $DIR/cfg-select.rs:8:5
2 --> $DIR/cfg-select.rs:7:5
33 |
44LL | invalid_cfg1 => {}
55 | ^^^^^^^^^^^^
......@@ -10,7 +10,7 @@ LL | invalid_cfg1 => {}
1010 = note: `#[warn(unexpected_cfgs)]` on by default
1111
1212warning: unexpected `cfg` condition name: `invalid_cfg2`
13 --> $DIR/cfg-select.rs:14:5
13 --> $DIR/cfg-select.rs:13:5
1414 |
1515LL | invalid_cfg2 => {}
1616 | ^^^^^^^^^^^^
tests/ui/feature-gates/feature-gate-cfg-select.rs deleted-11
......@@ -1,11 +0,0 @@
1#![warn(unreachable_cfg_select_predicates)]
2//~^ WARN unknown lint: `unreachable_cfg_select_predicates`
3
4cfg_select! {
5 //~^ ERROR use of unstable library feature `cfg_select`
6 _ => {}
7 // With the feature enabled, this branch would trip the unreachable_cfg_select_predicate lint.
8 true => {}
9}
10
11fn main() {}
tests/ui/feature-gates/feature-gate-cfg-select.stderr deleted-25
......@@ -1,25 +0,0 @@
1error[E0658]: use of unstable library feature `cfg_select`
2 --> $DIR/feature-gate-cfg-select.rs:4:1
3 |
4LL | cfg_select! {
5 | ^^^^^^^^^^
6 |
7 = note: see issue #115585 <https://github.com/rust-lang/rust/issues/115585> for more information
8 = help: add `#![feature(cfg_select)]` to the crate attributes to enable
9 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10
11warning: unknown lint: `unreachable_cfg_select_predicates`
12 --> $DIR/feature-gate-cfg-select.rs:1:9
13 |
14LL | #![warn(unreachable_cfg_select_predicates)]
15 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16 |
17 = note: the `unreachable_cfg_select_predicates` lint is unstable
18 = note: see issue #115585 <https://github.com/rust-lang/rust/issues/115585> for more information
19 = help: add `#![feature(cfg_select)]` to the crate attributes to enable
20 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
21 = note: `#[warn(unknown_lints)]` on by default
22
23error: aborting due to 1 previous error; 1 warning emitted
24
25For more information about this error, try `rustc --explain E0658`.
tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr+1-1
......@@ -29,7 +29,7 @@ LL | fn iter(&self) -> impl 'a + Iterator<Item = I::Item<'a>> {
2929help: replace the return type so that it matches the trait
3030 |
3131LL - fn iter(&self) -> impl 'a + Iterator<Item = I::Item<'a>> {
32LL + fn iter(&self) -> impl Iterator<Item = <Self as Iterable>::Item<'_>> + '_ {
32LL + fn iter(&self) -> impl std::iter::Iterator<Item = <Self as Iterable>::Item<'_>> + '_ {
3333 |
3434
3535error: aborting due to 1 previous error; 1 warning emitted
tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.stderr+3-2
......@@ -12,8 +12,9 @@ LL | fn bar(&self) -> impl Iterator + '_ {
1212 = note: `#[warn(refining_impl_trait_internal)]` (part of `#[warn(refining_impl_trait)]`) on by default
1313help: replace the return type so that it matches the trait
1414 |
15LL | fn bar(&self) -> impl Iterator<Item = impl Sized> + '_ {
16 | +++++++++++++++++++
15LL - fn bar(&self) -> impl Iterator + '_ {
16LL + fn bar(&self) -> impl std::iter::Iterator<Item = impl Sized> + '_ {
17 |
1718
1819warning: 1 warning emitted
1920
tests/ui/impl-trait/in-trait/foreign.stderr+2-2
......@@ -15,7 +15,7 @@ LL | #[warn(refining_impl_trait)]
1515help: replace the return type so that it matches the trait
1616 |
1717LL - fn bar(self) -> Arc<String> {
18LL + fn bar(self) -> impl Deref<Target = impl Sized> {
18LL + fn bar(self) -> impl std::ops::Deref<Target = impl Sized> {
1919 |
2020
2121warning: impl trait in impl method signature does not match trait method signature
......@@ -34,7 +34,7 @@ LL | #[warn(refining_impl_trait)]
3434help: replace the return type so that it matches the trait
3535 |
3636LL - fn bar(self) -> Arc<String> {
37LL + fn bar(self) -> impl Deref<Target = impl Sized> {
37LL + fn bar(self) -> impl std::ops::Deref<Target = impl Sized> {
3838 |
3939
4040warning: 2 warnings emitted
tests/ui/impl-trait/in-trait/refine-return-type-notation.rs created+13
......@@ -0,0 +1,13 @@
1#![feature(return_type_notation)]
2#![deny(refining_impl_trait)]
3
4trait Trait {
5 fn f() -> impl Sized;
6}
7
8impl Trait for () {
9 fn f() {}
10 //~^ ERROR impl trait in impl method signature does not match trait method signature
11}
12
13fn main() {}
tests/ui/impl-trait/in-trait/refine-return-type-notation.stderr created+24
......@@ -0,0 +1,24 @@
1error: impl trait in impl method signature does not match trait method signature
2 --> $DIR/refine-return-type-notation.rs:9:5
3 |
4LL | fn f() -> impl Sized;
5 | ---------- return type from trait method defined here
6...
7LL | fn f() {}
8 | ^^^^^^
9 |
10 = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
11 = note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
12note: the lint level is defined here
13 --> $DIR/refine-return-type-notation.rs:2:9
14 |
15LL | #![deny(refining_impl_trait)]
16 | ^^^^^^^^^^^^^^^^^^^
17 = note: `#[deny(refining_impl_trait_internal)]` implied by `#[deny(refining_impl_trait)]`
18help: replace the return type so that it matches the trait
19 |
20LL | fn f()-> impl Sized {}
21 | +++++++++++++
22
23error: aborting due to 1 previous error
24
tests/ui/macros/cfg_select.rs-1
......@@ -1,4 +1,3 @@
1#![feature(cfg_select)]
21#![crate_type = "lib"]
32#![warn(unreachable_cfg_select_predicates)] // Unused warnings are disabled by default in UI tests.
43
tests/ui/macros/cfg_select.stderr+17-17
......@@ -1,5 +1,5 @@
11error: none of the predicates in this `cfg_select` evaluated to true
2 --> $DIR/cfg_select.rs:162:1
2 --> $DIR/cfg_select.rs:161:1
33 |
44LL | / cfg_select! {
55LL | |
......@@ -8,55 +8,55 @@ LL | | }
88 | |_^
99
1010error: none of the predicates in this `cfg_select` evaluated to true
11 --> $DIR/cfg_select.rs:167:1
11 --> $DIR/cfg_select.rs:166:1
1212 |
1313LL | cfg_select! {}
1414 | ^^^^^^^^^^^^^^
1515
1616error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `=>`
17 --> $DIR/cfg_select.rs:171:5
17 --> $DIR/cfg_select.rs:170:5
1818 |
1919LL | => {}
2020 | ^^
2121
2222error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found expression
23 --> $DIR/cfg_select.rs:176:5
23 --> $DIR/cfg_select.rs:175:5
2424 |
2525LL | () => {}
2626 | ^^ expressions are not allowed here
2727
2828error[E0539]: malformed `cfg_select` macro input
29 --> $DIR/cfg_select.rs:181:5
29 --> $DIR/cfg_select.rs:180:5
3030 |
3131LL | "str" => {}
3232 | ^^^^^ expected a valid identifier here
3333
3434error[E0539]: malformed `cfg_select` macro input
35 --> $DIR/cfg_select.rs:186:5
35 --> $DIR/cfg_select.rs:185:5
3636 |
3737LL | a::b => {}
3838 | ^^^^ expected a valid identifier here
3939
4040error[E0537]: invalid predicate `a`
41 --> $DIR/cfg_select.rs:191:5
41 --> $DIR/cfg_select.rs:190:5
4242 |
4343LL | a() => {}
4444 | ^^^
4545
4646error: expected one of `(`, `::`, `=>`, or `=`, found `+`
47 --> $DIR/cfg_select.rs:196:7
47 --> $DIR/cfg_select.rs:195:7
4848 |
4949LL | a + 1 => {}
5050 | ^ expected one of `(`, `::`, `=>`, or `=`
5151
5252error: expected one of `(`, `::`, `=>`, or `=`, found `!`
53 --> $DIR/cfg_select.rs:202:8
53 --> $DIR/cfg_select.rs:201:8
5454 |
5555LL | cfg!() => {}
5656 | ^ expected one of `(`, `::`, `=>`, or `=`
5757
5858warning: unreachable configuration predicate
59 --> $DIR/cfg_select.rs:137:5
59 --> $DIR/cfg_select.rs:136:5
6060 |
6161LL | _ => {}
6262 | - always matches
......@@ -64,13 +64,13 @@ LL | true => {}
6464 | ^^^^ this configuration predicate is never reached
6565 |
6666note: the lint level is defined here
67 --> $DIR/cfg_select.rs:3:9
67 --> $DIR/cfg_select.rs:2:9
6868 |
6969LL | #![warn(unreachable_cfg_select_predicates)] // Unused warnings are disabled by default in UI tests.
7070 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7171
7272warning: unreachable configuration predicate
73 --> $DIR/cfg_select.rs:143:5
73 --> $DIR/cfg_select.rs:142:5
7474 |
7575LL | true => {}
7676 | ---- always matches
......@@ -78,25 +78,25 @@ LL | _ => {}
7878 | ^ this configuration predicate is never reached
7979
8080warning: unreachable configuration predicate
81 --> $DIR/cfg_select.rs:150:5
81 --> $DIR/cfg_select.rs:149:5
8282 |
8383LL | _ => {}
8484 | ^ this configuration predicate is never reached
8585
8686warning: unreachable configuration predicate
87 --> $DIR/cfg_select.rs:156:5
87 --> $DIR/cfg_select.rs:155:5
8888 |
8989LL | test => {}
9090 | ^^^^ this configuration predicate is never reached
9191
9292warning: unreachable configuration predicate
93 --> $DIR/cfg_select.rs:158:5
93 --> $DIR/cfg_select.rs:157:5
9494 |
9595LL | _ => {}
9696 | ^ this configuration predicate is never reached
9797
9898warning: unexpected `cfg` condition name: `a`
99 --> $DIR/cfg_select.rs:196:5
99 --> $DIR/cfg_select.rs:195:5
100100 |
101101LL | a + 1 => {}
102102 | ^ help: found config with similar value: `target_feature = "a"`
......@@ -107,7 +107,7 @@ LL | a + 1 => {}
107107 = note: `#[warn(unexpected_cfgs)]` on by default
108108
109109warning: unexpected `cfg` condition name: `cfg`
110 --> $DIR/cfg_select.rs:202:5
110 --> $DIR/cfg_select.rs:201:5
111111 |
112112LL | cfg!() => {}
113113 | ^^^
tests/ui/macros/cfg_select_parse_error.rs-1
......@@ -1,4 +1,3 @@
1#![feature(cfg_select)]
21#![crate_type = "lib"]
32
43// Check that parse errors in arms that are not selected are still reported.
tests/ui/macros/cfg_select_parse_error.stderr+2-2
......@@ -1,5 +1,5 @@
11error: Rust has no postfix increment operator
2 --> $DIR/cfg_select_parse_error.rs:8:22
2 --> $DIR/cfg_select_parse_error.rs:7:22
33 |
44LL | false => { 1 ++ 2 }
55 | ^^ not a valid postfix operator
......@@ -11,7 +11,7 @@ LL + false => { { let tmp = 1 ; 1 += 1; tmp } 2 }
1111 |
1212
1313error: Rust has no postfix increment operator
14 --> $DIR/cfg_select_parse_error.rs:15:29
14 --> $DIR/cfg_select_parse_error.rs:14:29
1515 |
1616LL | false => { fn foo() { 1 +++ 2 } }
1717 | ^^ not a valid postfix operator
tests/ui/resolve/slice-as-slice.rs created+26
......@@ -0,0 +1,26 @@
1//@ check-pass
2// This is a regression test for github.com/rust-lang/rust/issues/152961
3// This broke when a method `as_slice` was added on slices
4// This pattern is used in the `rgb` crate
5
6struct Meow;
7
8trait ComponentSlice<T> {
9 fn as_slice(&self) -> &[T];
10}
11
12impl ComponentSlice<u8> for [Meow] {
13 fn as_slice(&self) -> &[u8] {
14 todo!()
15 }
16}
17
18fn a(data: &[Meow]) {
19 b(data.as_slice());
20 //~^ WARN a method with this name may be added to the standard library in the future
21 //~| WARN once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
22}
23
24fn b(_b: &[u8]) { }
25
26fn main() {}
tests/ui/resolve/slice-as-slice.stderr created+17
......@@ -0,0 +1,17 @@
1warning: a method with this name may be added to the standard library in the future
2 --> $DIR/slice-as-slice.rs:19:12
3 |
4LL | b(data.as_slice());
5 | ^^^^^^^^
6 |
7 = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
8 = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
9 = help: call with fully qualified syntax `ComponentSlice::as_slice(...)` to keep using the current method
10 = note: `#[warn(unstable_name_collisions)]` (part of `#[warn(future_incompatible)]`) on by default
11help: add `#![feature(str_as_str)]` to the crate attributes to enable `core::slice::<impl [T]>::as_slice`
12 |
13LL + #![feature(str_as_str)]
14 |
15
16warning: 1 warning emitted
17