Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 41301c3

Browse files
committedNov 17, 2021
Auto merge of #90966 - matthiaskrgr:rollup-4akzcrh, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #90733 (Build musl dist artifacts with debuginfo enabled) - #90787 (Add `#[inline]`s to `SortedIndexMultiMap`) - #90920 (:arrow_up: rust-analyzer) - #90933 (Fix await suggestion on non-future type) - #90935 (Alphabetize language features) - #90949 (update miri) - #90958 (Mark `<*const _>::align_offset` and `<*mut _>::align_offset` as `const fn`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d914f17 + 0c3a662 commit 41301c3

File tree

17 files changed

+885
-837
lines changed

17 files changed

+885
-837
lines changed
 

‎compiler/rustc_data_structures/src/sorted_map/index_map.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,47 @@ pub struct SortedIndexMultiMap<I: Idx, K, V> {
3434
}
3535

3636
impl<I: Idx, K: Ord, V> SortedIndexMultiMap<I, K, V> {
37+
#[inline]
3738
pub fn new() -> Self {
3839
SortedIndexMultiMap { items: IndexVec::new(), idx_sorted_by_item_key: Vec::new() }
3940
}
4041

42+
#[inline]
4143
pub fn len(&self) -> usize {
4244
self.items.len()
4345
}
4446

47+
#[inline]
4548
pub fn is_empty(&self) -> bool {
4649
self.items.is_empty()
4750
}
4851

4952
/// Returns an iterator over the items in the map in insertion order.
53+
#[inline]
5054
pub fn into_iter(self) -> impl DoubleEndedIterator<Item = (K, V)> {
5155
self.items.into_iter()
5256
}
5357

5458
/// Returns an iterator over the items in the map in insertion order along with their indices.
59+
#[inline]
5560
pub fn into_iter_enumerated(self) -> impl DoubleEndedIterator<Item = (I, (K, V))> {
5661
self.items.into_iter_enumerated()
5762
}
5863

5964
/// Returns an iterator over the items in the map in insertion order.
65+
#[inline]
6066
pub fn iter(&self) -> impl '_ + DoubleEndedIterator<Item = (&K, &V)> {
6167
self.items.iter().map(|(ref k, ref v)| (k, v))
6268
}
6369

6470
/// Returns an iterator over the items in the map in insertion order along with their indices.
71+
#[inline]
6572
pub fn iter_enumerated(&self) -> impl '_ + DoubleEndedIterator<Item = (I, (&K, &V))> {
6673
self.items.iter_enumerated().map(|(i, (ref k, ref v))| (i, (k, v)))
6774
}
6875

6976
/// Returns the item in the map with the given index.
77+
#[inline]
7078
pub fn get(&self, idx: I) -> Option<&(K, V)> {
7179
self.items.get(idx)
7280
}
@@ -75,6 +83,7 @@ impl<I: Idx, K: Ord, V> SortedIndexMultiMap<I, K, V> {
7583
///
7684
/// If there are multiple items that are equivalent to `key`, they will be yielded in
7785
/// insertion order.
86+
#[inline]
7887
pub fn get_by_key(&'a self, key: K) -> impl 'a + Iterator<Item = &'a V> {
7988
self.get_by_key_enumerated(key).map(|(_, v)| v)
8089
}
@@ -84,6 +93,7 @@ impl<I: Idx, K: Ord, V> SortedIndexMultiMap<I, K, V> {
8493
///
8594
/// If there are multiple items that are equivalent to `key`, they will be yielded in
8695
/// insertion order.
96+
#[inline]
8797
pub fn get_by_key_enumerated(&'a self, key: K) -> impl '_ + Iterator<Item = (I, &V)> {
8898
let lower_bound = self.idx_sorted_by_item_key.partition_point(|&i| self.items[i].0 < key);
8999
self.idx_sorted_by_item_key[lower_bound..].iter().map_while(move |&i| {

‎compiler/rustc_feature/src/accepted.rs

Lines changed: 226 additions & 220 deletions
Large diffs are not rendered by default.

‎compiler/rustc_feature/src/active.rs

Lines changed: 330 additions & 485 deletions
Large diffs are not rendered by default.

‎compiler/rustc_feature/src/removed.rs

Lines changed: 94 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -45,132 +45,130 @@ declare_features! (
4545
// feature-group-start: removed features
4646
// -------------------------------------------------------------------------
4747

48-
(removed, import_shadowing, "1.0.0", None, None, None),
49-
(removed, managed_boxes, "1.0.0", None, None, None),
50-
/// Allows use of unary negate on unsigned integers, e.g., -e for e: u8
51-
(removed, negate_unsigned, "1.0.0", Some(29645), None, None),
52-
(removed, reflect, "1.0.0", Some(27749), None, None),
53-
/// A way to temporarily opt out of opt in copy. This will *never* be accepted.
54-
(removed, opt_out_copy, "1.0.0", None, None, None),
55-
(removed, quad_precision_float, "1.0.0", None, None, None),
56-
(removed, struct_inherit, "1.0.0", None, None, None),
57-
(removed, test_removed_feature, "1.0.0", None, None, None),
58-
(removed, visible_private_types, "1.0.0", None, None, None),
59-
(removed, unsafe_no_drop_flag, "1.0.0", None, None, None),
60-
/// Allows using items which are missing stability attributes
61-
(removed, unmarked_api, "1.0.0", None, None, None),
62-
(removed, allocator, "1.0.0", None, None, None),
63-
(removed, simd, "1.0.0", Some(27731), None,
64-
Some("removed in favor of `#[repr(simd)]`")),
6548
(removed, advanced_slice_patterns, "1.0.0", Some(62254), None,
6649
Some("merged into `#![feature(slice_patterns)]`")),
67-
(removed, macro_reexport, "1.0.0", Some(29638), None,
68-
Some("subsumed by `pub use`")),
50+
(removed, allocator, "1.0.0", None, None, None),
51+
(removed, await_macro, "1.38.0", Some(50547), None,
52+
Some("subsumed by `.await` syntax")),
53+
/// Allows comparing raw pointers during const eval.
54+
(removed, const_compare_raw_pointers, "1.46.0", Some(53020), None,
55+
Some("cannot be allowed in const eval in any meaningful way")),
56+
/// Allows non-trivial generic constants which have to be manually propagated upwards.
57+
(removed, const_evaluatable_checked, "1.48.0", Some(76560), None, Some("renamed to `generic_const_exprs`")),
58+
/// Allows the definition of `const` functions with some advanced features.
59+
(removed, const_fn, "1.54.0", Some(57563), None,
60+
Some("split into finer-grained feature gates")),
61+
/// Allows const generic types (e.g. `struct Foo<const N: usize>(...);`).
62+
(removed, const_generics, "1.34.0", Some(44580), None,
63+
Some("removed in favor of `#![feature(adt_const_params)]` and `#![feature(generic_const_exprs)]`")),
64+
/// Allows `[x; N]` where `x` is a constant (RFC 2203).
65+
(removed, const_in_array_repeat_expressions, "1.37.0", Some(49147), None,
66+
Some("removed due to causing promotable bugs")),
67+
/// Allows casting raw pointers to `usize` during const eval.
68+
(removed, const_raw_ptr_to_usize_cast, "1.55.0", Some(51910), None,
69+
Some("at compile-time, pointers do not have an integer value, so these casts cannot be properly supported")),
70+
/// Allows `T: ?const Trait` syntax in bounds.
71+
(removed, const_trait_bound_opt_out, "1.42.0", Some(67794), None,
72+
Some("Removed in favor of `~const` bound in #![feature(const_trait_impl)]")),
6973
/// Allows using custom attributes (RFC 572).
7074
(removed, custom_attribute, "1.0.0", Some(29642), None,
7175
Some("removed in favor of `#![register_tool]` and `#![register_attr]`")),
72-
/// Allows features specific to OIBIT (now called auto traits).
73-
/// Renamed to `auto_traits`.
74-
(removed, optin_builtin_traits, "1.0.0", Some(13231), None,
75-
Some("renamed to `auto_traits`")),
76-
(removed, pushpop_unsafe, "1.2.0", None, None, None),
77-
(removed, needs_allocator, "1.4.0", Some(27389), None,
78-
Some("subsumed by `#![feature(allocator_internals)]`")),
79-
/// Allows identifying crates that contain sanitizer runtimes.
80-
(removed, sanitizer_runtime, "1.17.0", None, None, None),
76+
/// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
77+
(removed, custom_derive, "1.32.0", Some(29644), None,
78+
Some("subsumed by `#[proc_macro_derive]`")),
8179
/// Allows `#[doc(spotlight)]`.
8280
/// The attribute was renamed to `#[doc(notable_trait)]`
8381
/// and the feature to `doc_notable_trait`.
8482
(removed, doc_spotlight, "1.22.0", Some(45040), None,
8583
Some("renamed to `doc_notable_trait`")),
86-
(removed, proc_macro_mod, "1.27.0", Some(54727), None,
87-
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
88-
(removed, proc_macro_expr, "1.27.0", Some(54727), None,
89-
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
90-
(removed, proc_macro_non_items, "1.27.0", Some(54727), None,
91-
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
92-
(removed, proc_macro_gen, "1.27.0", Some(54727), None,
93-
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
94-
(removed, panic_implementation, "1.28.0", Some(44489), None,
95-
Some("subsumed by `#[panic_handler]`")),
96-
/// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
97-
(removed, custom_derive, "1.32.0", Some(29644), None,
98-
Some("subsumed by `#[proc_macro_derive]`")),
99-
/// Paths of the form: `extern::foo::bar`
100-
(removed, extern_in_paths, "1.33.0", Some(55600), None,
101-
Some("subsumed by `::foo::bar` paths")),
102-
(removed, quote, "1.33.0", Some(29601), None, None),
103-
/// Allows const generic types (e.g. `struct Foo<const N: usize>(...);`).
104-
(removed, const_generics, "1.34.0", Some(44580), None,
105-
Some("removed in favor of `#![feature(adt_const_params)]` and `#![feature(generic_const_exprs)]`")),
106-
/// Allows `[x; N]` where `x` is a constant (RFC 2203).
107-
(removed, const_in_array_repeat_expressions, "1.37.0", Some(49147), None,
108-
Some("removed due to causing promotable bugs")),
10984
/// Allows using `#[unsafe_destructor_blind_to_params]` (RFC 1238).
11085
(removed, dropck_parametricity, "1.38.0", Some(28498), None, None),
111-
(removed, await_macro, "1.38.0", Some(50547), None,
112-
Some("subsumed by `.await` syntax")),
11386
/// Allows defining `existential type`s.
11487
(removed, existential_type, "1.38.0", Some(63063), None,
11588
Some("removed in favor of `#![feature(type_alias_impl_trait)]`")),
116-
/// Allows using the macros:
117-
/// + `__diagnostic_used`
118-
/// + `__register_diagnostic`
119-
/// +`__build_diagnostic_array`
120-
(removed, rustc_diagnostic_macros, "1.38.0", None, None, None),
121-
/// Allows using `#[on_unimplemented(..)]` on traits.
122-
/// (Moved to `rustc_attrs`.)
123-
(removed, on_unimplemented, "1.40.0", None, None, None),
124-
/// Allows overlapping impls of marker traits.
125-
(removed, overlapping_marker_traits, "1.42.0", Some(29864), None,
126-
Some("removed in favor of `#![feature(marker_trait_attr)]`")),
127-
/// Allows `T: ?const Trait` syntax in bounds.
128-
(removed, const_trait_bound_opt_out, "1.42.0", Some(67794), None,
129-
Some("Removed in favor of `~const` bound in #![feature(const_trait_impl)]")),
130-
/// Allows `#[no_debug]`.
131-
(removed, no_debug, "1.43.0", Some(29721), None, Some("removed due to lack of demand")),
89+
/// Paths of the form: `extern::foo::bar`
90+
(removed, extern_in_paths, "1.33.0", Some(55600), None,
91+
Some("subsumed by `::foo::bar` paths")),
92+
/// Allows `#[doc(include = "some-file")]`.
93+
(removed, external_doc, "1.54.0", Some(44732), None,
94+
Some("use #[doc = include_str!(\"filename\")] instead, which handles macro invocations")),
95+
/// Allows `impl Trait` in bindings (`let`, `const`, `static`).
96+
(removed, impl_trait_in_bindings, "1.55.0", Some(63065), None,
97+
Some("the implementation was not maintainable, the feature may get reintroduced once the current refactorings are done")),
98+
(removed, import_shadowing, "1.0.0", None, None, None),
13299
/// Lazily evaluate constants. This allows constants to depend on type parameters.
133100
(removed, lazy_normalization_consts, "1.46.0", Some(72219), None, Some("superseded by `generic_const_exprs`")),
134-
/// Allows comparing raw pointers during const eval.
135-
(removed, const_compare_raw_pointers, "1.46.0", Some(53020), None,
136-
Some("cannot be allowed in const eval in any meaningful way")),
137-
/// Allows non-trivial generic constants which have to be manually propagated upwards.
138-
(removed, const_evaluatable_checked, "1.48.0", Some(76560), None, Some("renamed to `generic_const_exprs`")),
139101
/// Allows using the `#[link_args]` attribute.
140102
(removed, link_args, "1.53.0", Some(29596), None,
141103
Some("removed in favor of using `-C link-arg=ARG` on command line, \
142104
which is available from cargo build scripts with `cargo:rustc-link-arg` now")),
105+
(removed, macro_reexport, "1.0.0", Some(29638), None,
106+
Some("subsumed by `pub use`")),
143107
/// Allows using `#[main]` to replace the entrypoint `#[lang = "start"]` calls.
144108
(removed, main, "1.53.0", Some(29634), None, None),
145-
(removed, pub_macro_rules, "1.53.0", Some(78855), None,
146-
Some("removed due to being incomplete, in particular it does not work across crates")),
147-
/// Allows the definition of `const` functions with some advanced features.
148-
(removed, const_fn, "1.54.0", Some(57563), None,
149-
Some("split into finer-grained feature gates")),
150-
/// Allows using `#[plugin_registrar]` on functions.
151-
(removed, plugin_registrar, "1.54.0", Some(29597), None,
152-
Some("a __rustc_plugin_registrar symbol must now be defined instead")),
153-
154-
/// Allows `#[doc(include = "some-file")]`.
155-
(removed, external_doc, "1.54.0", Some(44732), None,
156-
Some("use #[doc = include_str!(\"filename\")] instead, which handles macro invocations")),
157-
158-
/// Allows casting raw pointers to `usize` during const eval.
159-
(removed, const_raw_ptr_to_usize_cast, "1.55.0", Some(51910), None,
160-
Some("at compile-time, pointers do not have an integer value, so these casts cannot be properly supported")),
161-
162-
/// Allows `impl Trait` in bindings (`let`, `const`, `static`).
163-
(removed, impl_trait_in_bindings, "1.55.0", Some(63065), None,
164-
Some("the implementation was not maintainable, the feature may get reintroduced once the current refactorings are done")),
165-
109+
(removed, managed_boxes, "1.0.0", None, None, None),
166110
/// Allows the use of type alias impl trait in function return positions
167111
(removed, min_type_alias_impl_trait, "1.56.0", Some(63063), None,
168112
Some("removed in favor of full type_alias_impl_trait")),
169-
113+
(removed, needs_allocator, "1.4.0", Some(27389), None,
114+
Some("subsumed by `#![feature(allocator_internals)]`")),
115+
/// Allows use of unary negate on unsigned integers, e.g., -e for e: u8
116+
(removed, negate_unsigned, "1.0.0", Some(29645), None, None),
117+
/// Allows `#[no_debug]`.
118+
(removed, no_debug, "1.43.0", Some(29721), None, Some("removed due to lack of demand")),
119+
/// Allows using `#[on_unimplemented(..)]` on traits.
120+
/// (Moved to `rustc_attrs`.)
121+
(removed, on_unimplemented, "1.40.0", None, None, None),
122+
/// A way to temporarily opt out of opt in copy. This will *never* be accepted.
123+
(removed, opt_out_copy, "1.0.0", None, None, None),
124+
/// Allows features specific to OIBIT (now called auto traits).
125+
/// Renamed to `auto_traits`.
126+
(removed, optin_builtin_traits, "1.0.0", Some(13231), None,
127+
Some("renamed to `auto_traits`")),
128+
/// Allows overlapping impls of marker traits.
129+
(removed, overlapping_marker_traits, "1.42.0", Some(29864), None,
130+
Some("removed in favor of `#![feature(marker_trait_attr)]`")),
131+
(removed, panic_implementation, "1.28.0", Some(44489), None,
132+
Some("subsumed by `#[panic_handler]`")),
133+
/// Allows using `#[plugin_registrar]` on functions.
134+
(removed, plugin_registrar, "1.54.0", Some(29597), None,
135+
Some("a __rustc_plugin_registrar symbol must now be defined instead")),
136+
(removed, proc_macro_expr, "1.27.0", Some(54727), None,
137+
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
138+
(removed, proc_macro_gen, "1.27.0", Some(54727), None,
139+
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
140+
(removed, proc_macro_mod, "1.27.0", Some(54727), None,
141+
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
142+
(removed, proc_macro_non_items, "1.27.0", Some(54727), None,
143+
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
144+
(removed, pub_macro_rules, "1.53.0", Some(78855), None,
145+
Some("removed due to being incomplete, in particular it does not work across crates")),
146+
(removed, pushpop_unsafe, "1.2.0", None, None, None),
147+
(removed, quad_precision_float, "1.0.0", None, None, None),
148+
(removed, quote, "1.33.0", Some(29601), None, None),
149+
(removed, reflect, "1.0.0", Some(27749), None, None),
150+
/// Allows using the macros:
151+
/// + `__diagnostic_used`
152+
/// + `__register_diagnostic`
153+
/// +`__build_diagnostic_array`
154+
(removed, rustc_diagnostic_macros, "1.38.0", None, None, None),
155+
/// Allows identifying crates that contain sanitizer runtimes.
156+
(removed, sanitizer_runtime, "1.17.0", None, None, None),
157+
(removed, simd, "1.0.0", Some(27731), None,
158+
Some("removed in favor of `#[repr(simd)]`")),
159+
(removed, struct_inherit, "1.0.0", None, None, None),
160+
(removed, test_removed_feature, "1.0.0", None, None, None),
161+
/// Allows using items which are missing stability attributes
162+
(removed, unmarked_api, "1.0.0", None, None, None),
163+
(removed, unsafe_no_drop_flag, "1.0.0", None, None, None),
170164
/// Allows `#[unwind(..)]`.
171165
///
172166
/// Permits specifying whether a function should permit unwinding or abort on unwind.
173167
(removed, unwind_attributes, "1.56.0", Some(58760), None, Some("use the C-unwind ABI instead")),
168+
(removed, visible_private_types, "1.0.0", None, None, None),
169+
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!
170+
// Features are listed in alphabetical order. Tidy will fail if you don't keep it this way.
171+
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!
174172

175173
// -------------------------------------------------------------------------
176174
// feature-group-end: removed features

‎compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,31 +1794,38 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17941794
}
17951795
},
17961796
(_, Some(ty)) if ty::TyS::same_type(exp_found.expected, ty) => {
1797-
let span = match cause.code {
1798-
// scrutinee's span
1799-
ObligationCauseCode::Pattern { span: Some(span), .. } => span,
1800-
_ => exp_span,
1801-
};
1802-
diag.span_suggestion_verbose(
1803-
span.shrink_to_hi(),
1804-
"consider `await`ing on the `Future`",
1805-
".await".to_string(),
1806-
Applicability::MaybeIncorrect,
1807-
);
1808-
}
1809-
(Some(ty), _) if ty::TyS::same_type(ty, exp_found.found) => {
1810-
let span = match cause.code {
1811-
// scrutinee's span
1812-
ObligationCauseCode::Pattern { span: Some(span), .. } => span,
1813-
_ => exp_span,
1814-
};
18151797
diag.span_suggestion_verbose(
1816-
span.shrink_to_hi(),
1798+
exp_span.shrink_to_hi(),
18171799
"consider `await`ing on the `Future`",
18181800
".await".to_string(),
18191801
Applicability::MaybeIncorrect,
18201802
);
18211803
}
1804+
(Some(ty), _) if ty::TyS::same_type(ty, exp_found.found) => match cause.code {
1805+
ObligationCauseCode::Pattern { span: Some(span), .. }
1806+
| ObligationCauseCode::IfExpression(box IfExpressionCause { then: span, .. }) => {
1807+
diag.span_suggestion_verbose(
1808+
span.shrink_to_hi(),
1809+
"consider `await`ing on the `Future`",
1810+
".await".to_string(),
1811+
Applicability::MaybeIncorrect,
1812+
);
1813+
}
1814+
ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause {
1815+
ref prior_arms,
1816+
..
1817+
}) => {
1818+
diag.multipart_suggestion_verbose(
1819+
"consider `await`ing on the `Future`",
1820+
prior_arms
1821+
.iter()
1822+
.map(|arm| (arm.shrink_to_hi(), ".await".to_string()))
1823+
.collect(),
1824+
Applicability::MaybeIncorrect,
1825+
);
1826+
}
1827+
_ => {}
1828+
},
18221829
_ => {}
18231830
}
18241831
}

‎library/core/src/ptr/const_ptr.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -879,15 +879,30 @@ impl<T: ?Sized> *const T {
879879
/// # } }
880880
/// ```
881881
#[stable(feature = "align_offset", since = "1.36.0")]
882-
pub fn align_offset(self, align: usize) -> usize
882+
#[rustc_const_unstable(feature = "const_align_offset", issue = "90962")]
883+
pub const fn align_offset(self, align: usize) -> usize
883884
where
884885
T: Sized,
885886
{
886887
if !align.is_power_of_two() {
887888
panic!("align_offset: align is not a power-of-two");
888889
}
889-
// SAFETY: `align` has been checked to be a power of 2 above
890-
unsafe { align_offset(self, align) }
890+
891+
fn rt_impl<T>(p: *const T, align: usize) -> usize {
892+
// SAFETY: `align` has been checked to be a power of 2 above
893+
unsafe { align_offset(p, align) }
894+
}
895+
896+
const fn ctfe_impl<T>(_: *const T, _: usize) -> usize {
897+
usize::MAX
898+
}
899+
900+
// SAFETY:
901+
// It is permisseble for `align_offset` to always return `usize::MAX`,
902+
// algorithm correctness can not depend on `align_offset` returning non-max values.
903+
//
904+
// As such the behaviour can't change after replacing `align_offset` with `usize::MAX`, only performance can.
905+
unsafe { intrinsics::const_eval_select((self, align), ctfe_impl, rt_impl) }
891906
}
892907
}
893908

‎library/core/src/ptr/mut_ptr.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,15 +1142,30 @@ impl<T: ?Sized> *mut T {
11421142
/// # } }
11431143
/// ```
11441144
#[stable(feature = "align_offset", since = "1.36.0")]
1145-
pub fn align_offset(self, align: usize) -> usize
1145+
#[rustc_const_unstable(feature = "const_align_offset", issue = "90962")]
1146+
pub const fn align_offset(self, align: usize) -> usize
11461147
where
11471148
T: Sized,
11481149
{
11491150
if !align.is_power_of_two() {
11501151
panic!("align_offset: align is not a power-of-two");
11511152
}
1152-
// SAFETY: `align` has been checked to be a power of 2 above
1153-
unsafe { align_offset(self, align) }
1153+
1154+
fn rt_impl<T>(p: *mut T, align: usize) -> usize {
1155+
// SAFETY: `align` has been checked to be a power of 2 above
1156+
unsafe { align_offset(p, align) }
1157+
}
1158+
1159+
const fn ctfe_impl<T>(_: *mut T, _: usize) -> usize {
1160+
usize::MAX
1161+
}
1162+
1163+
// SAFETY:
1164+
// It is permisseble for `align_offset` to always return `usize::MAX`,
1165+
// algorithm correctness can not depend on `align_offset` returning non-max values.
1166+
//
1167+
// As such the behaviour can't change after replacing `align_offset` with `usize::MAX`, only performance can.
1168+
unsafe { intrinsics::const_eval_select((self, align), ctfe_impl, rt_impl) }
11541169
}
11551170
}
11561171

‎src/ci/docker/host-x86_64/dist-arm-linux/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ RUN sh /scripts/crosstool-ng-1.24.sh
88

99
WORKDIR /build
1010

11+
COPY scripts/musl-patch-configure.diff /build/
1112
COPY scripts/musl-toolchain.sh /build/
1213
# We need to mitigate rust-lang/rust#34978 when compiling musl itself as well
1314
RUN CFLAGS="-Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" \

‎src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ WORKDIR /build/
2424
COPY scripts/cmake.sh /scripts/
2525
RUN /scripts/cmake.sh
2626

27+
COPY scripts/musl-patch-configure.diff /build/
2728
COPY scripts/musl-toolchain.sh /build/
2829
# We need to mitigate rust-lang/rust#34978 when compiling musl itself as well
2930
RUN CFLAGS="-Wa,-mrelax-relocations=no -Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" \

‎src/ci/docker/host-x86_64/test-various/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ RUN curl -sL https://nodejs.org/dist/v15.14.0/node-v15.14.0-linux-x64.tar.xz | \
2222
tar -xJ
2323

2424
WORKDIR /build/
25+
COPY scripts/musl-patch-configure.diff /build/
2526
COPY scripts/musl-toolchain.sh /build/
2627
RUN bash musl-toolchain.sh x86_64 && rm -rf build
2728
WORKDIR /
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/configure b/configure
2+
index 86801281..ed2f7998 100755
3+
--- a/configure
4+
+++ b/configure
5+
@@ -398,7 +398,7 @@ test "$debug" = yes && CFLAGS_AUTO=-g
6+
#
7+
printf "checking whether we should preprocess assembly to add debugging information... "
8+
if fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS" &&
9+
- test -f "tools/add-cfi.$ARCH.awk" &&
10+
+ test -f "$srcdir/tools/add-cfi.$ARCH.awk" &&
11+
printf ".file 1 \"srcfile.s\"\n.line 1\n.cfi_startproc\n.cfi_endproc" | $CC -g -x assembler -c -o /dev/null 2>/dev/null -
12+
then
13+
ADD_CFI=yes

‎src/ci/docker/scripts/musl-toolchain.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,20 @@ shift
3838

3939
# Ancient binutils versions don't understand debug symbols produced by more recent tools.
4040
# Apparently applying `-fPIC` everywhere allows them to link successfully.
41-
export CFLAGS="-fPIC $CFLAGS"
41+
# Enable debug info. If we don't do so, users can't debug into musl code,
42+
# debuggers can't walk the stack, etc. Fixes #90103.
43+
export CFLAGS="-fPIC -g1 $CFLAGS"
4244

4345
git clone https://github.com/richfelker/musl-cross-make # -b v0.9.9
4446
cd musl-cross-make
4547
# A few commits ahead of v0.9.9 to include the cowpatch fix:
4648
git checkout a54eb56f33f255dfca60be045f12a5cfaf5a72a9
4749

50+
# Fix the cfi detection script in musl's configure so cfi is generated
51+
# when debug info is asked for.
52+
mkdir patches/musl-1.1.24
53+
cp ../musl-patch-configure.diff patches/musl-1.1.24/0001-fix-cfi-detection.diff
54+
4855
hide_output make -j$(nproc) TARGET=$TARGET MUSL_VER=1.1.24 LINUX_HEADERS_SITE=$LINUX_HEADERS_SITE
4956
hide_output make install TARGET=$TARGET MUSL_VER=1.1.24 LINUX_HEADERS_SITE=$LINUX_HEADERS_SITE OUTPUT=$OUTPUT
5057

‎src/test/ui/async-await/suggest-missing-await.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,32 @@ async fn suggest_await_in_async_fn_return() {
2626
//~| SUGGESTION .await
2727
}
2828

29+
#[allow(unused)]
30+
async fn suggest_await_on_if() {
31+
let _x = if true {
32+
dummy()
33+
//~^ HELP consider `await`ing on the `Future`
34+
} else {
35+
dummy().await
36+
//~^ ERROR `if` and `else` have incompatible types [E0308]
37+
};
38+
}
39+
40+
#[allow(unused)]
41+
async fn suggest_await_on_previous_match_arms() {
42+
let _x = match 0usize {
43+
0 => dummy(), //~ HELP consider `await`ing on the `Future`
44+
1 => dummy(),
45+
2 => dummy().await,
46+
//~^ `match` arms have incompatible types [E0308]
47+
};
48+
}
49+
50+
#[allow(unused)]
51+
async fn suggest_await_on_match_expr() {
52+
let _x = match dummy() { //~ HELP consider `await`ing on the `Future`
53+
() => {} //~ ERROR mismatched types [E0308]
54+
};
55+
}
56+
2957
fn main() {}

‎src/test/ui/async-await/suggest-missing-await.stderr

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,74 @@ help: consider using a semicolon here
3838
LL | dummy();
3939
| +
4040

41-
error: aborting due to 2 previous errors
41+
error[E0308]: `if` and `else` have incompatible types
42+
--> $DIR/suggest-missing-await.rs:35:9
43+
|
44+
LL | let _x = if true {
45+
| ______________-
46+
LL | | dummy()
47+
| | ------- expected because of this
48+
LL | |
49+
LL | | } else {
50+
LL | | dummy().await
51+
| | ^^^^^^^^^^^^^ expected opaque type, found `()`
52+
LL | |
53+
LL | | };
54+
| |_____- `if` and `else` have incompatible types
55+
|
56+
= note: expected type `impl Future`
57+
found unit type `()`
58+
help: consider `await`ing on the `Future`
59+
|
60+
LL | dummy().await
61+
| ++++++
62+
63+
error[E0308]: `match` arms have incompatible types
64+
--> $DIR/suggest-missing-await.rs:45:14
65+
|
66+
LL | let _x = match 0usize {
67+
| ______________-
68+
LL | | 0 => dummy(),
69+
| | ------- this is found to be of type `impl Future`
70+
LL | | 1 => dummy(),
71+
| | ------- this is found to be of type `impl Future`
72+
LL | | 2 => dummy().await,
73+
| | ^^^^^^^^^^^^^ expected opaque type, found `()`
74+
LL | |
75+
LL | | };
76+
| |_____- `match` arms have incompatible types
77+
|
78+
note: while checking the return type of the `async fn`
79+
--> $DIR/suggest-missing-await.rs:18:18
80+
|
81+
LL | async fn dummy() {}
82+
| ^ checked the `Output` of this `async fn`, expected opaque type
83+
= note: expected opaque type `impl Future`
84+
found unit type `()`
85+
help: consider `await`ing on the `Future`
86+
|
87+
LL ~ 0 => dummy().await,
88+
LL ~ 1 => dummy().await,
89+
|
90+
91+
error[E0308]: mismatched types
92+
--> $DIR/suggest-missing-await.rs:53:9
93+
|
94+
LL | () => {}
95+
| ^^ expected opaque type, found `()`
96+
|
97+
note: while checking the return type of the `async fn`
98+
--> $DIR/suggest-missing-await.rs:18:18
99+
|
100+
LL | async fn dummy() {}
101+
| ^ checked the `Output` of this `async fn`, expected opaque type
102+
= note: expected opaque type `impl Future`
103+
found unit type `()`
104+
help: consider `await`ing on the `Future`
105+
|
106+
LL | let _x = match dummy().await {
107+
| ++++++
108+
109+
error: aborting due to 5 previous errors
42110

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

‎src/tools/rust-analyzer

‎src/tools/tidy/src/features.rs

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! * Library features have at most one stability level.
88
//! * Library features have at most one `since` value.
99
//! * All unstable lang features have tests to ensure they are actually unstable.
10-
//! * Language features in a group are sorted by `since` value.
10+
//! * Language features in a group are sorted by feature name.
1111
1212
use std::collections::HashMap;
1313
use std::fmt;
@@ -258,7 +258,7 @@ fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features
258258
let mut next_feature_omits_tracking_issue = false;
259259

260260
let mut in_feature_group = false;
261-
let mut prev_since = None;
261+
let mut prev_names = vec![];
262262

263263
contents
264264
.lines()
@@ -291,11 +291,11 @@ fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features
291291
}
292292

293293
in_feature_group = true;
294-
prev_since = None;
294+
prev_names = vec![];
295295
return None;
296296
} else if line.starts_with(FEATURE_GROUP_END_PREFIX) {
297297
in_feature_group = false;
298-
prev_since = None;
298+
prev_names = vec![];
299299
return None;
300300
}
301301

@@ -325,16 +325,49 @@ fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features
325325
}
326326
};
327327
if in_feature_group {
328-
if prev_since > since {
328+
if prev_names.last() > Some(&name) {
329+
// This assumes the user adds the feature name at the end of the list, as we're
330+
// not looking ahead.
331+
let correct_index = match prev_names.binary_search(&name) {
332+
Ok(_) => {
333+
// This only occurs when the feature name has already been declared.
334+
tidy_error!(
335+
bad,
336+
"{}:{}: duplicate feature {}",
337+
path.display(),
338+
line_number,
339+
name,
340+
);
341+
// skip any additional checks for this line
342+
return None;
343+
}
344+
Err(index) => index,
345+
};
346+
347+
let correct_placement = if correct_index == 0 {
348+
"at the beginning of the feature group".to_owned()
349+
} else if correct_index == prev_names.len() {
350+
// I don't believe this is reachable given the above assumption, but it
351+
// doesn't hurt to be safe.
352+
"at the end of the feature group".to_owned()
353+
} else {
354+
format!(
355+
"between {} and {}",
356+
prev_names[correct_index - 1],
357+
prev_names[correct_index],
358+
)
359+
};
360+
329361
tidy_error!(
330362
bad,
331-
"{}:{}: feature {} is not sorted by \"since\" (version number)",
363+
"{}:{}: feature {} is not sorted by feature name (should be {})",
332364
path.display(),
333365
line_number,
334366
name,
367+
correct_placement,
335368
);
336369
}
337-
prev_since = since;
370+
prev_names.push(name);
338371
}
339372

340373
let issue_str = parts.next().unwrap().trim();

0 commit comments

Comments
 (0)
Please sign in to comment.