Skip to content

Commit 734233d

Browse files
committed
Auto merge of #74569 - Manishearth:rollup-hkn5ex9, r=Manishearth
Rollup of 13 pull requests Successful merges: - #72714 (Fix debug assertion in typeck) - #73197 (Impl Default for ranges) - #73323 (wf: check foreign fn decls for well-formedness) - #74051 (disallow non-static lifetimes in const generics) - #74376 (test caching opt_const_param_of on disc) - #74501 (Ayu theme: Use different background color for Run button) - #74505 (Fix search input focus in ayu theme) - #74522 (Update sanitizer docs) - #74546 (Fix duplicate maybe_uninit_extra attribute) - #74552 (Stabilize TAU constant.) - #74555 (Improve "important traits" popup display on mobile) - #74557 (Fix an ICE on an invalid `binding @ ...` in a tuple struct pattern) - #74561 (update backtrace-rs) Failed merges: r? @ghost
2 parents f9a3086 + df8d169 commit 734233d

File tree

28 files changed

+305
-81
lines changed

28 files changed

+305
-81
lines changed

src/doc/unstable-book/src/compiler-flags/sanitizer.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ of bugs:
2626
* Double-free, invalid free
2727
* Memory leaks
2828

29+
The memory leak detection is enabled by default on Linux, and can be enabled
30+
with runtime flag `ASAN_OPTIONS=detect_leaks=1` on macOS.
31+
2932
AddressSanitizer is supported on the following targets:
3033

3134
* `x86_64-apple-darwin`
@@ -196,10 +199,6 @@ fn main() {
196199
197200
```shell
198201
$ export \
199-
CC=clang \
200-
CXX=clang++ \
201-
CFLAGS='-fsanitize=memory -fsanitize-memory-track-origins' \
202-
CXXFLAGS='-fsanitize=memory -fsanitize-memory-track-origins' \
203202
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins' \
204203
RUSTDOCFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins'
205204
$ cargo clean

src/libcore/num/f32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub mod consts {
242242
/// The full circle constant (τ)
243243
///
244244
/// Equal to 2π.
245-
#[unstable(feature = "tau_constant", issue = "66770")]
245+
#[stable(feature = "tau_constant", since = "1.47.0")]
246246
pub const TAU: f32 = 6.28318530717958647692528676655900577_f32;
247247

248248
/// π/2

src/libcore/num/f64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub mod consts {
242242
/// The full circle constant (τ)
243243
///
244244
/// Equal to 2π.
245-
#[unstable(feature = "tau_constant", issue = "66770")]
245+
#[stable(feature = "tau_constant", since = "1.47.0")]
246246
pub const TAU: f64 = 6.28318530717958647692528676655900577_f64;
247247

248248
/// π/2

src/libcore/ops/range.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::hash::Hash;
3939
/// [`Iterator`]: ../iter/trait.IntoIterator.html
4040
/// [slicing index]: ../slice/trait.SliceIndex.html
4141
#[doc(alias = "..")]
42-
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
42+
#[derive(Copy, Clone, Default, PartialEq, Eq, Hash)]
4343
#[stable(feature = "rust1", since = "1.0.0")]
4444
pub struct RangeFull;
4545

@@ -71,7 +71,7 @@ impl fmt::Debug for RangeFull {
7171
/// assert_eq!(arr[1..=3], [ 1,2,3 ]);
7272
/// ```
7373
#[doc(alias = "..")]
74-
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
74+
#[derive(Clone, Default, PartialEq, Eq, Hash)] // not Copy -- see #27186
7575
#[stable(feature = "rust1", since = "1.0.0")]
7676
pub struct Range<Idx> {
7777
/// The lower bound of the range (inclusive).

src/librustc_error_codes/error_codes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ E0767: include_str!("./error_codes/E0767.md"),
453453
E0768: include_str!("./error_codes/E0768.md"),
454454
E0769: include_str!("./error_codes/E0769.md"),
455455
E0770: include_str!("./error_codes/E0770.md"),
456+
E0771: include_str!("./error_codes/E0771.md"),
456457
;
457458
// E0006, // merged with E0005
458459
// E0008, // cannot bind by-move into a pattern guard
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
A non-`'static` lifetime was used in a const generic. This is currently not
2+
allowed.
3+
4+
Erroneous code example:
5+
6+
```compile_fail,E0771
7+
#![feature(const_generics)]
8+
9+
fn function_with_str<'a, const STRING: &'a str>() {} // error!
10+
```
11+
12+
To fix this issue, the lifetime in the const generic need to be changed to
13+
`'static`:
14+
15+
```
16+
#![feature(const_generics)]
17+
18+
fn function_with_str<const STRING: &'static str>() {} // ok!
19+
```
20+
21+
For more information, see [GitHub issue #74052].
22+
23+
[GitHub issue #74052]: https://github.com/rust-lang/rust/issues/74052

src/librustc_middle/query/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,13 @@ rustc_queries! {
103103
/// // ^ While calling `opt_const_param_of` for other bodies returns `None`.
104104
/// }
105105
/// ```
106+
// It looks like caching this query on disk actually slightly
107+
// worsened performance in #74376.
108+
//
109+
// Once const generics are more prevalently used, we might want to
110+
// consider only caching calls returning `Some`.
106111
query opt_const_param_of(key: LocalDefId) -> Option<DefId> {
107112
desc { |tcx| "computing the optional const parameter of `{}`", tcx.def_path_str(key.to_def_id()) }
108-
// FIXME(#74113): consider storing this query on disk.
109113
}
110114

111115
/// Records the type of every item.

src/librustc_resolve/late.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,11 +1500,17 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
15001500
pat_src: PatternSource,
15011501
bindings: &mut SmallVec<[(PatBoundCtx, FxHashSet<Ident>); 1]>,
15021502
) {
1503+
let is_tuple_struct_pat = matches!(pat.kind, PatKind::TupleStruct(_, _));
1504+
15031505
// Visit all direct subpatterns of this pattern.
15041506
pat.walk(&mut |pat| {
15051507
debug!("resolve_pattern pat={:?} node={:?}", pat, pat.kind);
15061508
match pat.kind {
1507-
PatKind::Ident(bmode, ident, ref sub) => {
1509+
// In tuple struct patterns ignore the invalid `ident @ ...`.
1510+
// It will be handled as an error by the AST lowering.
1511+
PatKind::Ident(bmode, ident, ref sub)
1512+
if !(is_tuple_struct_pat && sub.as_ref().filter(|p| p.is_rest()).is_some()) =>
1513+
{
15081514
// First try to resolve the identifier as some existing entity,
15091515
// then fall back to a fresh binding.
15101516
let has_sub = sub.is_some();

src/librustc_resolve/late/diagnostics.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,24 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
11411141
err.emit();
11421142
}
11431143

1144+
// FIXME(const_generics): This patches over a ICE caused by non-'static lifetimes in const
1145+
// generics. We are disallowing this until we can decide on how we want to handle non-'static
1146+
// lifetimes in const generics. See issue #74052 for discussion.
1147+
crate fn emit_non_static_lt_in_const_generic_error(&self, lifetime_ref: &hir::Lifetime) {
1148+
let mut err = struct_span_err!(
1149+
self.tcx.sess,
1150+
lifetime_ref.span,
1151+
E0771,
1152+
"use of non-static lifetime `{}` in const generic",
1153+
lifetime_ref
1154+
);
1155+
err.note(
1156+
"for more information, see issue #74052 \
1157+
<https://github.com/rust-lang/rust/issues/74052>",
1158+
);
1159+
err.emit();
1160+
}
1161+
11441162
crate fn is_trait_ref_fn_scope(&mut self, trait_ref: &'tcx hir::PolyTraitRef<'tcx>) -> bool {
11451163
if let def::Res::Def(_, did) = trait_ref.trait_ref.path.res {
11461164
if [

0 commit comments

Comments
 (0)