Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6d569f7
stabilize if_let_rescope
dingxiangfei2009 Oct 20, 2024
ad76564
Ensure that resume arg outlives region bound for coroutines
compiler-errors Oct 25, 2024
6ab87f8
Collect item bounds for RPITITs from trait where clauses just like as…
compiler-errors Oct 26, 2024
e4f793a
riscv-soft-abi-with-float-features.rs: adapt for LLVM 20
krasimirgg Oct 28, 2024
0bff994
split clippy task for library and compiler, so different lints can be…
klensy Oct 7, 2024
746b675
fix clippy::clone_on_ref_ptr for compiler
klensy Oct 7, 2024
a946721
clarified doc for `std::fs::OpenOptions.truncate()`
yakiimoninja Oct 28, 2024
2cc9d58
Updating Fuchsia platform-support documentation
claywilkinson Oct 28, 2024
c50bc62
Inline obligation_for_method
compiler-errors Oct 28, 2024
f202abd
Inline construct_obligation_for_trait
compiler-errors Oct 28, 2024
5910a4f
clarified std::fs truncate doc
yakiimoninja Oct 28, 2024
d4774ff
Remove my ping for rustdoc/clean/types.rs
camelid Oct 28, 2024
b2f335e
Split `boxed.rs` into a few modules
WaffleLapkin Oct 27, 2024
f0744ca
Bless a miri test
WaffleLapkin Oct 28, 2024
3240fe2
Remove some goofy slice logic from the operator path
compiler-errors Oct 28, 2024
5ae5323
Remove myself from mentions inside `tests/ui/check-cfg` directory
Urgau Oct 28, 2024
8b7b8e5
Hack out effects support for old solver
compiler-errors Oct 22, 2024
1763637
correct LLVMRustCreateThinLTOData arg types
klensy Oct 27, 2024
2b326e3
correct LLVMRustDIBuilderCreateOpLLVMFragment return type
klensy Oct 27, 2024
1a51a60
Rollup merge of #131375 - klensy:clone_on_ref_ptr, r=cjgillot
workingjubilee Oct 29, 2024
1bb0628
Rollup merge of #131984 - dingxiangfei2009:stabilize-if-let-rescope, …
workingjubilee Oct 29, 2024
1139e4d
Rollup merge of #132119 - compiler-errors:effects-old-solver, r=lcnr
workingjubilee Oct 29, 2024
3779738
Rollup merge of #132151 - compiler-errors:coroutine-resume-outlives, …
workingjubilee Oct 29, 2024
2d07afa
Rollup merge of #132194 - compiler-errors:rpitit-super-wc, r=spastorino
workingjubilee Oct 29, 2024
a90055a
Rollup merge of #132216 - klensy:c_uint, r=cuviper
workingjubilee Oct 29, 2024
707c614
Rollup merge of #132233 - WaffleLapkin:box-module-split, r=workingjub…
workingjubilee Oct 29, 2024
2b3d256
Rollup merge of #132266 - krasimirgg:llvm-20-testfix, r=hanna-kruppe,…
workingjubilee Oct 29, 2024
e13e1de
Rollup merge of #132270 - yakiimoninja:fs-truncate-docs, r=Noratrieb
workingjubilee Oct 29, 2024
27d37d3
Rollup merge of #132271 - claywilkinson:master, r=tmandry
workingjubilee Oct 29, 2024
a620e2f
Rollup merge of #132274 - compiler-errors:cleanup-op-lookup, r=nnethe…
workingjubilee Oct 29, 2024
07f055f
Rollup merge of #132284 - camelid:rm-ping, r=workingjubilee
workingjubilee Oct 29, 2024
6ab4120
Rollup merge of #132293 - Urgau:tests-check-cfg-out-triagebot, r=lqd
workingjubilee Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
stabilize if_let_rescope
  • Loading branch information
dingxiangfei2009 committed Oct 23, 2024
commit 6d569f769c3d7becbd566b4fec5baf9f11e098e1
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ declare_features! (
(accepted, i128_type, "1.26.0", Some(35118)),
/// Allows the use of `if let` expressions.
(accepted, if_let, "1.0.0", None),
/// Rescoping temporaries in `if let` to align with Rust 2024.
(accepted, if_let_rescope, "CURRENT_RUSTC_VERSION", Some(124085)),
/// Allows top level or-patterns (`p | q`) in `if let` and `while let`.
(accepted, if_while_or_patterns, "1.33.0", Some(48215)),
/// Allows lifetime elision in `impl` headers. For example:
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,6 @@ declare_features! (
(unstable, half_open_range_patterns_in_slices, "1.66.0", Some(67264)),
/// Allows `if let` guard in match arms.
(unstable, if_let_guard, "1.47.0", Some(51114)),
/// Rescoping temporaries in `if let` to align with Rust 2024.
(unstable, if_let_rescope, "1.83.0", Some(124085)),
/// Allows `impl Trait` to be used inside associated types (RFC 2515).
(unstable, impl_trait_in_assoc_type, "1.70.0", Some(63063)),
/// Allows `impl Trait` as output type in `Fn` traits in return position of functions.
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_hir_analysis/src/check/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h

hir::ExprKind::If(cond, then, Some(otherwise)) => {
let expr_cx = visitor.cx;
let data = if expr.span.at_least_rust_2024() && visitor.tcx.features().if_let_rescope()
{
let data = if expr.span.at_least_rust_2024() {
ScopeData::IfThenRescope
} else {
ScopeData::IfThen
Expand All @@ -482,8 +481,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h

hir::ExprKind::If(cond, then, None) => {
let expr_cx = visitor.cx;
let data = if expr.span.at_least_rust_2024() && visitor.tcx.features().if_let_rescope()
{
let data = if expr.span.at_least_rust_2024() {
ScopeData::IfThenRescope
} else {
ScopeData::IfThen
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_lint/src/if_let_rescope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ declare_lint! {
/// ### Example
///
/// ```rust,edition2021
/// #![feature(if_let_rescope)]
/// #![warn(if_let_rescope)]
/// #![allow(unused_variables)]
///
Expand Down Expand Up @@ -243,7 +242,7 @@ impl_lint_pass!(

impl<'tcx> LateLintPass<'tcx> for IfLetRescope {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
if expr.span.edition().at_least_rust_2024() || !cx.tcx.features().if_let_rescope() {
if expr.span.edition().at_least_rust_2024() {
return;
}
if let (Level::Allow, _) = cx.tcx.lint_level_at_node(IF_LET_RESCOPE, expr.hir_id) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/thir/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ impl<'tcx> Cx<'tcx> {
if_then_scope: region::Scope {
id: then.hir_id.local_id,
data: {
if expr.span.at_least_rust_2024() && tcx.features().if_let_rescope() {
if expr.span.at_least_rust_2024() {
region::ScopeData::IfThenRescope
} else {
region::ScopeData::IfThen
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/drop/drop_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//@ [edition2021] edition: 2021
//@ [edition2024] compile-flags: -Z unstable-options
//@ [edition2024] edition: 2024

#![feature(let_chains)]
#![cfg_attr(edition2024, feature(if_let_rescope))]

use std::cell::RefCell;
use std::convert::TryInto;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/drop/drop_order_if_let_rescope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//@ compile-flags: -Z validate-mir -Zunstable-options

#![feature(let_chains)]
#![feature(if_let_rescope)]

use std::cell::RefCell;
use std::convert::TryInto;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/drop/if-let-rescope-borrowck-suggestions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ edition: 2024
//@ compile-flags: -Z validate-mir -Zunstable-options

#![feature(if_let_rescope)]
#![deny(if_let_rescope)]

struct Droppy;
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/drop/if-let-rescope-borrowck-suggestions.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error[E0716]: temporary value dropped while borrowed
--> $DIR/if-let-rescope-borrowck-suggestions.rs:22:39
--> $DIR/if-let-rescope-borrowck-suggestions.rs:21:39
|
LL | do_something(if let Some(value) = Droppy.get_ref() { value } else { &0 });
| ^^^^^^ - temporary value is freed at the end of this statement
| |
| creates a temporary value which is freed while still in use
|
note: lifetimes for temporaries generated in `if let`s have been shortened in Edition 2024 so that they are dropped here instead
--> $DIR/if-let-rescope-borrowck-suggestions.rs:22:64
--> $DIR/if-let-rescope-borrowck-suggestions.rs:21:64
|
LL | do_something(if let Some(value) = Droppy.get_ref() { value } else { &0 });
| ^
Expand All @@ -22,7 +22,7 @@ LL | do_something({ match Droppy.get_ref() { Some(value) => { value } _ =>
| ~~~~~~~ ++++++++++++++++ ~~~~ ++

error[E0716]: temporary value dropped while borrowed
--> $DIR/if-let-rescope-borrowck-suggestions.rs:24:39
--> $DIR/if-let-rescope-borrowck-suggestions.rs:23:39
|
LL | do_something(if let Some(value) = Droppy.get_ref() {
| ^^^^^^ creates a temporary value which is freed while still in use
Expand All @@ -31,7 +31,7 @@ LL | } else if let Some(value) = Droppy.get_ref() {
| - temporary value is freed at the end of this statement
|
note: lifetimes for temporaries generated in `if let`s have been shortened in Edition 2024 so that they are dropped here instead
--> $DIR/if-let-rescope-borrowck-suggestions.rs:27:5
--> $DIR/if-let-rescope-borrowck-suggestions.rs:26:5
|
LL | } else if let Some(value) = Droppy.get_ref() {
| ^
Expand All @@ -53,7 +53,7 @@ LL ~ }}});
|

error[E0716]: temporary value dropped while borrowed
--> $DIR/if-let-rescope-borrowck-suggestions.rs:27:33
--> $DIR/if-let-rescope-borrowck-suggestions.rs:26:33
|
LL | } else if let Some(value) = Droppy.get_ref() {
| ^^^^^^ creates a temporary value which is freed while still in use
Expand All @@ -62,7 +62,7 @@ LL | } else {
| - temporary value is freed at the end of this statement
|
note: lifetimes for temporaries generated in `if let`s have been shortened in Edition 2024 so that they are dropped here instead
--> $DIR/if-let-rescope-borrowck-suggestions.rs:30:5
--> $DIR/if-let-rescope-borrowck-suggestions.rs:29:5
|
LL | } else {
| ^
Expand Down
22 changes: 11 additions & 11 deletions tests/ui/drop/lint-if-let-rescope-gated.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// This test checks that the lint `if_let_rescope` only actions
// when the feature gate is enabled.
// Edition 2021 is used here because the lint should work especially
// when edition migration towards 2024 is run.
// when Edition 2021 or prior is targeted here because the lint should work especially
// when edition migration towards 2024 is executed.

//@ revisions: with_feature_gate without_feature_gate
//@ [without_feature_gate] check-pass
//@ edition: 2021
//@ revisions: edition2021 edition2024
//@ [edition2021] edition: 2021
//@ [edition2024] edition: 2024
//@ [edition2024] compile-flags: -Zunstable-options
//@ [edition2024] check-pass

#![cfg_attr(with_feature_gate, feature(if_let_rescope))]
#![deny(if_let_rescope)]
#![allow(irrefutable_let_patterns)]

Expand All @@ -25,10 +25,10 @@ impl Droppy {

fn main() {
if let Some(_value) = Droppy.get() {
//[with_feature_gate]~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
//[with_feature_gate]~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
//[with_feature_gate]~| WARN: this changes meaning in Rust 2024
//[edition2021]~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
//[edition2021]~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
//[edition2021]~| WARN: this changes meaning in Rust 2024
} else {
//[with_feature_gate]~^ HELP: the value is now dropped here in Edition 2024
//[edition2021]~^ HELP: the value is now dropped here in Edition 2024
}
}
1 change: 0 additions & 1 deletion tests/ui/drop/lint-if-let-rescope-with-macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//@ edition:2021
//@ compile-flags: -Z unstable-options

#![feature(if_let_rescope)]
#![deny(if_let_rescope)]
#![allow(irrefutable_let_patterns)]

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/drop/lint-if-let-rescope-with-macro.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `if let` assigns a shorter lifetime since Edition 2024
--> $DIR/lint-if-let-rescope-with-macro.rs:13:12
--> $DIR/lint-if-let-rescope-with-macro.rs:12:12
|
LL | if let $p = $e { $($conseq)* } else { $($alt)* }
| ^^^
Expand All @@ -16,7 +16,7 @@ LL | | };
= warning: this changes meaning in Rust 2024
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
help: the value is now dropped here in Edition 2024
--> $DIR/lint-if-let-rescope-with-macro.rs:13:38
--> $DIR/lint-if-let-rescope-with-macro.rs:12:38
|
LL | if let $p = $e { $($conseq)* } else { $($alt)* }
| ^
Expand All @@ -29,7 +29,7 @@ LL | | {}
LL | | };
| |_____- in this macro invocation
note: the lint level is defined here
--> $DIR/lint-if-let-rescope-with-macro.rs:8:9
--> $DIR/lint-if-let-rescope-with-macro.rs:7:9
|
LL | #![deny(if_let_rescope)]
| ^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/drop/lint-if-let-rescope.fixed
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ run-rustfix

#![deny(if_let_rescope)]
#![feature(if_let_rescope, stmt_expr_attributes)]
#![feature(stmt_expr_attributes)]
#![allow(irrefutable_let_patterns, unused_parens)]

fn droppy() -> Droppy {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/drop/lint-if-let-rescope.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ run-rustfix

#![deny(if_let_rescope)]
#![feature(if_let_rescope, stmt_expr_attributes)]
#![feature(stmt_expr_attributes)]
#![allow(irrefutable_let_patterns, unused_parens)]

fn droppy() -> Droppy {
Expand Down
27 changes: 0 additions & 27 deletions tests/ui/feature-gates/feature-gate-if-let-rescope.rs

This file was deleted.

18 changes: 0 additions & 18 deletions tests/ui/feature-gates/feature-gate-if-let-rescope.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui/mir/mir_let_chains_drop_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// See `mir_drop_order.rs` for more information

#![feature(let_chains)]
#![cfg_attr(edition2024, feature(if_let_rescope))]
#![allow(irrefutable_let_patterns)]

use std::cell::RefCell;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/nll/issue-54556-niconii.edition2021.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0597]: `counter` does not live long enough
--> $DIR/issue-54556-niconii.rs:30:20
--> $DIR/issue-54556-niconii.rs:28:20
|
LL | let counter = Mutex;
| ------- binding `counter` declared here
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/nll/issue-54556-niconii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//@ [edition2024] compile-flags: -Z unstable-options
//@ [edition2024] check-pass

#![cfg_attr(edition2024, feature(if_let_rescope))]

struct Mutex;
struct MutexGuard<'a>(&'a Mutex);

Expand Down
Loading