Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #82263

Merged
merged 30 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dfa581f
Fix pretty printing of generic associated type constraints
matthewjasper Feb 11, 2021
9bbd3e0
Remove ProjectionTy::from_ref_and_name
matthewjasper Feb 11, 2021
0bf1d73
Don't go through TraitRef to relate projections
matthewjasper Feb 12, 2021
9526c0c
Avoid `trait_ref` when lowering ExistentialProjections
matthewjasper Feb 12, 2021
79f6f11
Remove some unnecessary `trait_ref` calls
matthewjasper Feb 12, 2021
dfee89f
Make ProjectionTy::trait_ref truncate substs again
matthewjasper Feb 12, 2021
d785c8c
Remove unnecessary function parameters project.rs
matthewjasper Feb 12, 2021
eeb82e4
Add more tests for generic associated type bounds
matthewjasper Feb 12, 2021
7e368e5
the environment round here is awfully empty
BoxyUwU Feb 15, 2021
0f04875
replace if-let and while-let with `if let` and `while let`
TaKO8Ki Feb 17, 2021
43aed74
[libtest] Run the test synchronously when hitting thread limit
Jan 29, 2021
2a66685
Make sure pdbs are copied along with exe and dlls when bootstrapping
rylev Feb 17, 2021
32c97da
In some limited cases, suggest `where` bounds for non-type params
estebank Feb 16, 2021
ec50a20
avoid converting types into themselves (clippy::useless_conversion)
matthiaskrgr Feb 17, 2021
5ae392f
Add long explanation for E0549
jesusprubio Feb 18, 2021
5112cf0
Update compiler/rustc_error_codes/src/error_codes/E0549.md
jesusprubio Feb 18, 2021
0e01c41
Update compiler/rustc_error_codes/src/error_codes/E0549.md
jesusprubio Feb 18, 2021
3c4fe1e
Update compiler/rustc_error_codes/src/error_codes/E0549.md
jesusprubio Feb 18, 2021
6165d1c
Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.
eddyb Feb 18, 2021
8a5c568
nhwn: optimize counting digits in line numbers
nhwn Feb 18, 2021
55ab2e3
Rollup merge of #81546 - hyd-dev:libtest-run-out-of-threads, r=Mark-S…
Dylan-DPC Feb 18, 2021
66211f6
Rollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726
Dylan-DPC Feb 18, 2021
928819a
Rollup merge of #82112 - BoxyUwU:tumbleweed, r=varkor
Dylan-DPC Feb 18, 2021
f01b339
Rollup merge of #82194 - estebank:arbitrary-bounds-suggestion, r=petr…
Dylan-DPC Feb 18, 2021
b3d3251
Rollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkor
Dylan-DPC Feb 18, 2021
01104b5
Rollup merge of #82218 - rylev:copy-pdbs, r=Mark-Simulacrum
Dylan-DPC Feb 18, 2021
04df75a
Rollup merge of #82236 - matthiaskrgr:useless_conv, r=jyn514
Dylan-DPC Feb 18, 2021
5ca94cd
Rollup merge of #82246 - jesusprubio:add-long-explanation-e0549, r=Gu…
Dylan-DPC Feb 18, 2021
555db2d
Rollup merge of #82248 - nhwn:optimize-counting-digits, r=varkor
Dylan-DPC Feb 18, 2021
efdcb43
Rollup merge of #82256 - eddyb:time-passes-stderr, r=varkor
Dylan-DPC Feb 18, 2021
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
Prev Previous commit
Next Next commit
replace if-let and while-let with if let and while let
  • Loading branch information
TaKO8Ki committed Feb 17, 2021
commit 0f04875d2e21919e5f716b9946407ba07de08840
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0162.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### Note: this error code is no longer emitted by the compiler.

An if-let pattern attempts to match the pattern, and enters the body if the
An `if let` pattern attempts to match the pattern, and enters the body if the
match was successful. If the match is irrefutable (when it cannot fail to
match), use a regular `let`-binding instead. For instance:

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0165.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### Note: this error code is no longer emitted by the compiler.

A while-let pattern attempts to match the pattern, and enters the body if the
A `while let` pattern attempts to match the pattern, and enters the body if the
match was successful. If the match is irrefutable (when it cannot fail to
match), use a regular `let`-binding inside a `loop` instead. For instance:

Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ declare_lint! {

declare_lint! {
/// The `irrefutable_let_patterns` lint detects detects [irrefutable
/// patterns] in [if-let] and [while-let] statements.
/// patterns] in [`if let`] and [`while let`] statements.
///
///
///
Expand All @@ -1832,7 +1832,7 @@ declare_lint! {
/// ### Explanation
///
/// There usually isn't a reason to have an irrefutable pattern in an
/// if-let or while-let statement, because the pattern will always match
/// `if let` or `while let` statement, because the pattern will always match
/// successfully. A [`let`] or [`loop`] statement will suffice. However,
/// when generating code with a macro, forbidding irrefutable patterns
/// would require awkward workarounds in situations where the macro
Expand All @@ -1843,14 +1843,14 @@ declare_lint! {
/// See [RFC 2086] for more details.
///
/// [irrefutable patterns]: https://doc.rust-lang.org/reference/patterns.html#refutability
/// [if-let]: https://doc.rust-lang.org/reference/expressions/if-expr.html#if-let-expressions
/// [while-let]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-pattern-loops
/// [`if let`]: https://doc.rust-lang.org/reference/expressions/if-expr.html#if-let-expressions
/// [`while let`]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-pattern-loops
/// [`let`]: https://doc.rust-lang.org/reference/statements.html#let-statements
/// [`loop`]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#infinite-loops
/// [RFC 2086]: https://github.com/rust-lang/rfcs/blob/master/text/2086-allow-if-let-irrefutables.md
pub IRREFUTABLE_LET_PATTERNS,
Warn,
"detects irrefutable patterns in if-let and while-let statements"
"detects irrefutable patterns in `if let` and `while let` statements"
}

declare_lint! {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ fn unreachable_pattern(tcx: TyCtxt<'_>, span: Span, id: HirId, catchall: Option<
fn irrefutable_let_pattern(tcx: TyCtxt<'_>, span: Span, id: HirId, source: hir::MatchSource) {
tcx.struct_span_lint_hir(IRREFUTABLE_LET_PATTERNS, id, span, |lint| {
let msg = match source {
hir::MatchSource::IfLetDesugar { .. } => "irrefutable if-let pattern",
hir::MatchSource::WhileLetDesugar => "irrefutable while-let pattern",
hir::MatchSource::IfLetGuardDesugar => "irrefutable if-let guard",
hir::MatchSource::IfLetDesugar { .. } => "irrefutable `if let` pattern",
hir::MatchSource::WhileLetDesugar => "irrefutable `while let` pattern",
hir::MatchSource::IfLetGuardDesugar => "irrefutable `if let` guard",
_ => bug!(),
};
lint.build(msg).emit()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl NonConstExpr {
return None;
}

Self::Match(IfLetGuardDesugar) => bug!("if-let guard outside a `match` expression"),
Self::Match(IfLetGuardDesugar) => bug!("`if let` guard outside a `match` expression"),

// All other expressions are allowed.
Self::Loop(Loop | While | WhileLet)
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/binding/if-let.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub fn main() {
if let Some(y) = x {
assert_eq!(y, 3);
} else {
panic!("if-let panicked");
panic!("`if let` panicked");
}
let mut worked = false;
if let Some(_) = x {
Expand Down Expand Up @@ -54,7 +54,7 @@ pub fn main() {
if let Foo::Two(b) = a {
assert_eq!(b, 42_usize);
} else {
panic!("panic in nested if-let");
panic!("panic in nested `if let`");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() {
// FIXME(project-rfc-2229#24): Change this to be a destructure pattern
// once this is fixed, to remove the warning.
if let SingleVariant::Point(ref mut x, _) = point {
//~^ WARNING: irrefutable if-let pattern
//~^ WARNING: irrefutable `if let` pattern
*x += 1;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information

warning: irrefutable if-let pattern
warning: irrefutable `if let` pattern
--> $DIR/closure-origin-single-variant-diagnostics.rs:18:9
|
LL | / if let SingleVariant::Point(ref mut x, _) = point {
Expand Down
16 changes: 8 additions & 8 deletions src/test/ui/expr/if/if-let.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ fn macros() {
macro_rules! foo{
($p:pat, $e:expr, $b:block) => {{
if let $p = $e $b
//~^ WARN irrefutable if-let
//~| WARN irrefutable if-let
//~^ WARN irrefutable `if let`
//~| WARN irrefutable `if let`
}}
}
macro_rules! bar{
Expand All @@ -23,27 +23,27 @@ fn macros() {
}

pub fn main() {
if let a = 1 { //~ WARN irrefutable if-let
if let a = 1 { //~ WARN irrefutable `if let`
println!("irrefutable pattern");
}

if let a = 1 { //~ WARN irrefutable if-let
if let a = 1 { //~ WARN irrefutable `if let`
println!("irrefutable pattern");
} else if true {
println!("else-if in irrefutable if-let");
println!("else-if in irrefutable `if let`");
} else {
println!("else in irrefutable if-let");
println!("else in irrefutable `if let`");
}

if let 1 = 2 {
println!("refutable pattern");
} else if let a = 1 { //~ WARN irrefutable if-let
} else if let a = 1 { //~ WARN irrefutable `if let`
println!("irrefutable pattern");
}

if true {
println!("if");
} else if let a = 1 { //~ WARN irrefutable if-let
} else if let a = 1 { //~ WARN irrefutable `if let`
println!("irrefutable pattern");
}
}
16 changes: 8 additions & 8 deletions src/test/ui/expr/if/if-let.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: irrefutable if-let pattern
warning: irrefutable `if let` pattern
--> $DIR/if-let.rs:6:13
|
LL | if let $p = $e $b
Expand All @@ -12,7 +12,7 @@ LL | | });
= note: `#[warn(irrefutable_let_patterns)]` on by default
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: irrefutable if-let pattern
warning: irrefutable `if let` pattern
--> $DIR/if-let.rs:6:13
|
LL | if let $p = $e $b
Expand All @@ -25,27 +25,27 @@ LL | | });
|
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: irrefutable if-let pattern
warning: irrefutable `if let` pattern
--> $DIR/if-let.rs:26:5
|
LL | / if let a = 1 {
LL | | println!("irrefutable pattern");
LL | | }
| |_____^

warning: irrefutable if-let pattern
warning: irrefutable `if let` pattern
--> $DIR/if-let.rs:30:5
|
LL | / if let a = 1 {
LL | | println!("irrefutable pattern");
LL | | } else if true {
LL | | println!("else-if in irrefutable if-let");
LL | | println!("else-if in irrefutable `if let`");
LL | | } else {
LL | | println!("else in irrefutable if-let");
LL | | println!("else in irrefutable `if let`");
LL | | }
| |_____^

warning: irrefutable if-let pattern
warning: irrefutable `if let` pattern
--> $DIR/if-let.rs:40:12
|
LL | } else if let a = 1 {
Expand All @@ -54,7 +54,7 @@ LL | | println!("irrefutable pattern");
LL | | }
| |_____^

warning: irrefutable if-let pattern
warning: irrefutable `if let` pattern
--> $DIR/if-let.rs:46:12
|
LL | } else if let a = 1 {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-19991.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Test if the sugared if-let construct correctly prints "missing an else clause" when an else
// Test if the sugared `if let` construct correctly prints "missing an else clause" when an else
// clause does not exist, instead of the unsympathetic "`match` arms have incompatible types"

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![deny(irrefutable_let_patterns)]

fn main() {
if let _ = 5 {} //~ ERROR irrefutable if-let pattern
if let _ = 5 {} //~ ERROR irrefutable `if let` pattern

while let _ = 5 { //~ ERROR irrefutable while-let pattern
while let _ = 5 { //~ ERROR irrefutable `while let` pattern
break;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: irrefutable if-let pattern
error: irrefutable `if let` pattern
--> $DIR/deny-irrefutable-let-patterns.rs:4:5
|
LL | if let _ = 5 {}
Expand All @@ -10,7 +10,7 @@ note: the lint level is defined here
LL | #![deny(irrefutable_let_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^

error: irrefutable while-let pattern
error: irrefutable `while let` pattern
--> $DIR/deny-irrefutable-let-patterns.rs:6:5
|
LL | / while let _ = 5 {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rfc-2294-if-let-guard/warns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
fn irrefutable_let_guard() {
match Some(()) {
Some(x) if let () = x => {}
//~^ ERROR irrefutable if-let guard
//~^ ERROR irrefutable `if let` guard
_ => {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rfc-2294-if-let-guard/warns.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: irrefutable if-let guard
error: irrefutable `if let` guard
--> $DIR/warns.rs:7:24
|
LL | Some(x) if let () = x => {}
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/while-let.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ fn macros() {
macro_rules! foo{
($p:pat, $e:expr, $b:block) => {{
while let $p = $e $b
//~^ WARN irrefutable while-let
//~| WARN irrefutable while-let
//~^ WARN irrefutable `while let`
//~| WARN irrefutable `while let`
}}
}
macro_rules! bar{
Expand All @@ -24,7 +24,7 @@ fn macros() {
}

pub fn main() {
while let _a = 1 { //~ WARN irrefutable while-let
while let _a = 1 { //~ WARN irrefutable `while let`
println!("irrefutable pattern");
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/while-let.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: irrefutable while-let pattern
warning: irrefutable `while let` pattern
--> $DIR/while-let.rs:7:13
|
LL | while let $p = $e $b
Expand All @@ -12,7 +12,7 @@ LL | | });
= note: `#[warn(irrefutable_let_patterns)]` on by default
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: irrefutable while-let pattern
warning: irrefutable `while let` pattern
--> $DIR/while-let.rs:7:13
|
LL | while let $p = $e $b
Expand All @@ -25,7 +25,7 @@ LL | | });
|
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: irrefutable while-let pattern
warning: irrefutable `while let` pattern
--> $DIR/while-let.rs:27:5
|
LL | / while let _a = 1 {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ declare_clippy_lint! {
/// ```
pub WHILE_LET_ON_ITERATOR,
style,
"using a while-let loop instead of a for loop on an iterator"
"using a `while let` loop instead of a for loop on an iterator"
}

declare_clippy_lint! {
Expand Down