From 6288aada6de5c593a3d37bf51bbfda297d1b150b Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 8 Jun 2021 16:45:54 +0200 Subject: [PATCH 01/16] Stabilize span_open() and span_close(). --- library/proc_macro/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 3990826ce42e0..32fe0ad83d9cb 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -707,7 +707,7 @@ impl Group { /// pub fn span_open(&self) -> Span { /// ^ /// ``` - #[unstable(feature = "proc_macro_span", issue = "54725")] + #[stable(feature = "proc_macro_group_span", since = "1.55.0")] pub fn span_open(&self) -> Span { Span(self.0.span_open()) } @@ -718,7 +718,7 @@ impl Group { /// pub fn span_close(&self) -> Span { /// ^ /// ``` - #[unstable(feature = "proc_macro_span", issue = "54725")] + #[stable(feature = "proc_macro_group_span", since = "1.55.0")] pub fn span_close(&self) -> Span { Span(self.0.span_close()) } From e4b3131584bab1b4a5bf3480e79e305945762479 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 17 Jun 2021 03:23:17 +0800 Subject: [PATCH 02/16] Use as_secs_f64 in JunitFormatter --- library/test/src/formatters/junit.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/test/src/formatters/junit.rs b/library/test/src/formatters/junit.rs index ec66fc1219ff7..c4b0e1e5c2339 100644 --- a/library/test/src/formatters/junit.rs +++ b/library/test/src/formatters/junit.rs @@ -79,7 +79,7 @@ impl OutputFormatter for JunitFormatter { name=\"{}\" time=\"{}\">", class_name, test_name, - duration.as_secs() + duration.as_secs_f64() ))?; self.write_message("")?; self.write_message("")?; @@ -91,7 +91,7 @@ impl OutputFormatter for JunitFormatter { name=\"{}\" time=\"{}\">", class_name, test_name, - duration.as_secs() + duration.as_secs_f64() ))?; self.write_message(&*format!("", m))?; self.write_message("")?; @@ -103,7 +103,7 @@ impl OutputFormatter for JunitFormatter { name=\"{}\" time=\"{}\">", class_name, test_name, - duration.as_secs() + duration.as_secs_f64() ))?; self.write_message("")?; self.write_message("")?; @@ -123,7 +123,7 @@ impl OutputFormatter for JunitFormatter { name=\"{}\" time=\"{}\"/>", class_name, test_name, - duration.as_secs() + duration.as_secs_f64() ))?; } } From 210e46bf24a8cef7f513f0116909d57d76304086 Mon Sep 17 00:00:00 2001 From: Smitty Date: Wed, 16 Jun 2021 16:36:43 -0400 Subject: [PATCH 03/16] Add pattern walking support to THIR walker --- compiler/rustc_mir_build/src/thir/visit.rs | 53 ++++++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/visit.rs b/compiler/rustc_mir_build/src/thir/visit.rs index 1a60b1de7fd98..0f3276a1b0576 100644 --- a/compiler/rustc_mir_build/src/thir/visit.rs +++ b/compiler/rustc_mir_build/src/thir/visit.rs @@ -20,6 +20,10 @@ pub trait Visitor<'a, 'tcx: 'a>: Sized { walk_arm(self, arm); } + fn visit_pat(&mut self, pat: &Pat<'tcx>) { + walk_pat(self, pat); + } + fn visit_const(&mut self, _cnst: &'tcx Const<'tcx>) {} } @@ -142,18 +146,19 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp } pub fn walk_stmt<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, stmt: &Stmt<'tcx>) { - match stmt.kind { - StmtKind::Expr { expr, scope: _ } => visitor.visit_expr(&visitor.thir()[expr]), + match &stmt.kind { + StmtKind::Expr { expr, scope: _ } => visitor.visit_expr(&visitor.thir()[*expr]), StmtKind::Let { initializer, remainder_scope: _, init_scope: _, - pattern: _, + pattern, lint_level: _, } => { if let Some(init) = initializer { - visitor.visit_expr(&visitor.thir()[init]); + visitor.visit_expr(&visitor.thir()[*init]); } + visitor.visit_pat(&pattern); } } } @@ -170,10 +175,48 @@ pub fn walk_block<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, block: &B pub fn walk_arm<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, arm: &Arm<'tcx>) { match arm.guard { Some(Guard::If(expr)) => visitor.visit_expr(&visitor.thir()[expr]), - Some(Guard::IfLet(ref _pat, expr)) => { + Some(Guard::IfLet(ref pat, expr)) => { + visitor.visit_pat(pat); visitor.visit_expr(&visitor.thir()[expr]); } None => {} } + visitor.visit_pat(&arm.pattern); visitor.visit_expr(&visitor.thir()[arm.body]); } + +pub fn walk_pat<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, pat: &Pat<'tcx>) { + use PatKind::*; + match pat.kind.as_ref() { + AscribeUserType { subpattern, .. } + | Deref { subpattern, .. } + | Binding { subpattern: Some(subpattern), .. } => visitor.visit_pat(&subpattern), + Binding { .. } | Wild => {} + Variant { subpatterns, .. } | Leaf { subpatterns } => { + for subpattern in subpatterns { + visitor.visit_pat(&subpattern.pattern); + } + } + Constant { value } => visitor.visit_const(value), + Range(range) => { + visitor.visit_const(range.lo); + visitor.visit_const(range.hi); + } + Slice { prefix, slice, suffix } | Array { prefix, slice, suffix } => { + for subpattern in prefix { + visitor.visit_pat(&subpattern); + } + if let Some(pat) = slice { + visitor.visit_pat(pat); + } + for subpattern in suffix { + visitor.visit_pat(&subpattern); + } + } + Or { pats } => { + for pat in pats { + visitor.visit_pat(&pat); + } + } + }; +} From 68f9172fc136ab0b5cbc082eb7a51a725c108a7d Mon Sep 17 00:00:00 2001 From: Matteo Briani Date: Thu, 17 Jun 2021 09:57:48 +0200 Subject: [PATCH 04/16] Fix rustdoc stabilized versions layout --- src/librustdoc/html/render/print_item.rs | 5 +++-- src/librustdoc/html/static/rustdoc.css | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 04464b622d7a3..a606d0d01efb2 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -979,7 +979,9 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum } w.write_str(")"); } - w.write_str(""); + w.write_str(""); + render_stability_since(w, variant, it, cx.tcx()); + w.write_str(""); document(w, cx, variant, Some(it)); document_non_exhaustive(w, variant); @@ -1021,7 +1023,6 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum w.write_str(""); toggle_close(w); } - render_stability_since(w, variant, it, cx.tcx()); } } let def_id = it.def_id.expect_real(); diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 7535145caa5c8..51bd6a79f9427 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -654,6 +654,12 @@ a { background: transparent; } +.small-section-header { + display: flex; + justify-content: space-between; + position: relative; +} + .small-section-header:hover > .anchor { display: initial; } From 7cadf7bc0167d254d564ec81361db257e7ed2e82 Mon Sep 17 00:00:00 2001 From: Rupert Rutledge <1982481+Eosis@users.noreply.github.com> Date: Thu, 17 Jun 2021 11:02:16 +0100 Subject: [PATCH 05/16] Alter std::cell::Cell::get_mut documentation I find this more consistent with RefCell's equivalent method. --- library/core/src/cell.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index f88a6e418c7c8..6fd4936158589 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -488,6 +488,13 @@ impl Cell { /// This call borrows `Cell` mutably (at compile-time) which guarantees /// that we possess the only reference. /// + /// However be cautious: this method expects `self` to be mutable, which is + /// generally not the case when using a `Cell`. If you require interior + /// mutability by reference, consider using `RefCell` which provides + /// run-time checked mutable borrows through its [`borrow_mut`] method. + /// + /// [`borrow_mut`]: RefCell::borrow_mut() + /// /// # Examples /// /// ``` From 1d5accabf1ae1d546f03e8776f0b0c36e14c70a7 Mon Sep 17 00:00:00 2001 From: Smitty Date: Thu, 17 Jun 2021 10:15:02 -0400 Subject: [PATCH 06/16] simplify borrowing --- compiler/rustc_mir_build/src/thir/visit.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/visit.rs b/compiler/rustc_mir_build/src/thir/visit.rs index 0f3276a1b0576..8f7e3aff11f1f 100644 --- a/compiler/rustc_mir_build/src/thir/visit.rs +++ b/compiler/rustc_mir_build/src/thir/visit.rs @@ -146,19 +146,19 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp } pub fn walk_stmt<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, stmt: &Stmt<'tcx>) { - match &stmt.kind { - StmtKind::Expr { expr, scope: _ } => visitor.visit_expr(&visitor.thir()[*expr]), + match stmt.kind { + StmtKind::Expr { expr, scope: _ } => visitor.visit_expr(&visitor.thir()[expr]), StmtKind::Let { initializer, remainder_scope: _, init_scope: _, - pattern, + ref pattern, lint_level: _, } => { if let Some(init) = initializer { - visitor.visit_expr(&visitor.thir()[*init]); + visitor.visit_expr(&visitor.thir()[init]); } - visitor.visit_pat(&pattern); + visitor.visit_pat(pattern); } } } From 281dd6d6e00fd4be40917e2279884b780571506d Mon Sep 17 00:00:00 2001 From: Smitty Date: Thu, 17 Jun 2021 10:17:35 -0400 Subject: [PATCH 07/16] Explicitly write out all fields --- compiler/rustc_mir_build/src/thir/visit.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/visit.rs b/compiler/rustc_mir_build/src/thir/visit.rs index 8f7e3aff11f1f..12c6a9c00b221 100644 --- a/compiler/rustc_mir_build/src/thir/visit.rs +++ b/compiler/rustc_mir_build/src/thir/visit.rs @@ -188,11 +188,19 @@ pub fn walk_arm<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, arm: &Arm<' pub fn walk_pat<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, pat: &Pat<'tcx>) { use PatKind::*; match pat.kind.as_ref() { - AscribeUserType { subpattern, .. } - | Deref { subpattern, .. } - | Binding { subpattern: Some(subpattern), .. } => visitor.visit_pat(&subpattern), + AscribeUserType { subpattern, ascription: _ } + | Deref { subpattern } + | Binding { + subpattern: Some(subpattern), + mutability: _, + mode: _, + var: _, + ty: _, + is_primary: _, + name: _, + } => visitor.visit_pat(&subpattern), Binding { .. } | Wild => {} - Variant { subpatterns, .. } | Leaf { subpatterns } => { + Variant { subpatterns, adt_def: _, substs: _, variant_index: _ } | Leaf { subpatterns } => { for subpattern in subpatterns { visitor.visit_pat(&subpattern.pattern); } From 382ba79380c3e294cb18c2439f6aff945ee7b2d2 Mon Sep 17 00:00:00 2001 From: LingMan Date: Thu, 17 Jun 2021 19:39:58 +0200 Subject: [PATCH 08/16] Use `map_or` instead of open-coding it --- compiler/rustc_mir/src/transform/const_prop.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_mir/src/transform/const_prop.rs b/compiler/rustc_mir/src/transform/const_prop.rs index 73a0f5537c3b3..b56c247127ce4 100644 --- a/compiler/rustc_mir/src/transform/const_prop.rs +++ b/compiler/rustc_mir/src/transform/const_prop.rs @@ -1205,12 +1205,9 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> { let mut eval_to_int = |op| { // This can be `None` if the lhs wasn't const propagated and we just // triggered the assert on the value of the rhs. - match self.eval_operand(op, source_info) { - Some(op) => DbgVal::Val( - self.ecx.read_immediate(&op).unwrap().to_const_int(), - ), - None => DbgVal::Underscore, - } + self.eval_operand(op, source_info).map_or(DbgVal::Underscore, |op| { + DbgVal::Val(self.ecx.read_immediate(&op).unwrap().to_const_int()) + }) }; let msg = match msg { AssertKind::DivisionByZero(op) => { From 88abd7d81d585ba31cab1ca404a5ed6b44511f98 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Fri, 18 Jun 2021 15:09:40 +0800 Subject: [PATCH 09/16] Lint for unused borrows as part of UNUSED_MUST_USE --- compiler/rustc_lint/src/unused.rs | 1 + compiler/rustc_macros/src/hash_stable.rs | 4 +- library/alloc/tests/str.rs | 10 ++--- library/alloc/tests/vec.rs | 10 ++--- library/std/src/sys_common/wtf8/tests.rs | 6 +-- src/test/ui/array-slice-vec/slice-panic-1.rs | 2 +- src/test/ui/array-slice-vec/slice-panic-2.rs | 2 +- src/test/ui/array-slice-vec/slice.rs | 16 +++---- .../ui/const-generics/issues/issue-61432.rs | 4 +- .../ui/dynamically-sized-types/dst-index.rs | 2 +- .../too-live-local-in-immovable-gen.rs | 2 +- .../too-live-local-in-immovable-gen.stderr | 2 +- src/test/ui/generator/yield-in-initializer.rs | 2 +- src/test/ui/issues/issue-43205.rs | 2 +- src/test/ui/issues/issue-5280.rs | 2 +- src/test/ui/issues/issue-54696.rs | 4 +- src/test/ui/lint/unused-borrows.rs | 33 ++++++++++++++ src/test/ui/lint/unused-borrows.stderr | 44 +++++++++++++++++++ 18 files changed, 113 insertions(+), 35 deletions(-) create mode 100644 src/test/ui/lint/unused-borrows.rs create mode 100644 src/test/ui/lint/unused-borrows.stderr diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 44c2a550c30e2..c431c048ca01c 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -154,6 +154,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { | hir::BinOpKind::Shl | hir::BinOpKind::Shr => Some("bitwise operation"), }, + hir::ExprKind::AddrOf(..) => Some("borrow"), hir::ExprKind::Unary(..) => Some("unary operation"), _ => None, }; diff --git a/compiler/rustc_macros/src/hash_stable.rs b/compiler/rustc_macros/src/hash_stable.rs index 30569f20793fb..b916113a0e551 100644 --- a/compiler/rustc_macros/src/hash_stable.rs +++ b/compiler/rustc_macros/src/hash_stable.rs @@ -54,7 +54,7 @@ pub fn hash_stable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_ma quote! {} } else if let Some(project) = attrs.project { quote! { - &#bi.#project.hash_stable(__hcx, __hasher); + (&#bi.#project).hash_stable(__hcx, __hasher); } } else { quote! { @@ -96,7 +96,7 @@ pub fn hash_stable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::To quote! {} } else if let Some(project) = attrs.project { quote! { - &#bi.#project.hash_stable(__hcx, __hasher); + (&#bi.#project).hash_stable(__hcx, __hasher); } } else { quote! { diff --git a/library/alloc/tests/str.rs b/library/alloc/tests/str.rs index 6df8d8c2f354f..a1e819cf8f9e4 100644 --- a/library/alloc/tests/str.rs +++ b/library/alloc/tests/str.rs @@ -534,7 +534,7 @@ mod slice_index { #[test] #[should_panic] fn test_slice_fail() { - &"中华Việt Nam"[0..2]; + let _ = &"中华Việt Nam"[0..2]; } panic_cases! { @@ -714,13 +714,13 @@ mod slice_index { #[test] #[should_panic(expected = "byte index 1024 is out of bounds of `Lorem ipsum dolor sit amet")] fn test_slice_fail_truncated_1() { - &LOREM_PARAGRAPH[..1024]; + let _ = &LOREM_PARAGRAPH[..1024]; } // check the truncation in the panic message #[test] #[should_panic(expected = "luctus, im`[...]")] fn test_slice_fail_truncated_2() { - &LOREM_PARAGRAPH[..1024]; + let _ = &LOREM_PARAGRAPH[..1024]; } } @@ -735,7 +735,7 @@ fn test_str_slice_rangetoinclusive_ok() { #[should_panic] fn test_str_slice_rangetoinclusive_notok() { let s = "abcαβγ"; - &s[..=3]; + let _ = &s[..=3]; } #[test] @@ -751,7 +751,7 @@ fn test_str_slicemut_rangetoinclusive_ok() { fn test_str_slicemut_rangetoinclusive_notok() { let mut s = "abcαβγ".to_owned(); let s: &mut str = &mut s; - &mut s[..=3]; + let _ = &mut s[..=3]; } #[test] diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index c203cdafecb03..3b7237016800f 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -542,35 +542,35 @@ fn test_index_out_of_bounds() { #[should_panic] fn test_slice_out_of_bounds_1() { let x = vec![1, 2, 3, 4, 5]; - &x[!0..]; + let _ = &x[!0..]; } #[test] #[should_panic] fn test_slice_out_of_bounds_2() { let x = vec![1, 2, 3, 4, 5]; - &x[..6]; + let _ = &x[..6]; } #[test] #[should_panic] fn test_slice_out_of_bounds_3() { let x = vec![1, 2, 3, 4, 5]; - &x[!0..4]; + let _ = &x[!0..4]; } #[test] #[should_panic] fn test_slice_out_of_bounds_4() { let x = vec![1, 2, 3, 4, 5]; - &x[1..6]; + let _ = &x[1..6]; } #[test] #[should_panic] fn test_slice_out_of_bounds_5() { let x = vec![1, 2, 3, 4, 5]; - &x[3..2]; + let _ = &x[3..2]; } #[test] diff --git a/library/std/src/sys_common/wtf8/tests.rs b/library/std/src/sys_common/wtf8/tests.rs index 385e01f92fa14..cd9c6ee325081 100644 --- a/library/std/src/sys_common/wtf8/tests.rs +++ b/library/std/src/sys_common/wtf8/tests.rs @@ -301,7 +301,7 @@ fn wtf8_slice() { #[test] #[should_panic] fn wtf8_slice_not_code_point_boundary() { - &Wtf8::from_str("aé 💩")[2..4]; + let _ = &Wtf8::from_str("aé 💩")[2..4]; } #[test] @@ -312,7 +312,7 @@ fn wtf8_slice_from() { #[test] #[should_panic] fn wtf8_slice_from_not_code_point_boundary() { - &Wtf8::from_str("aé 💩")[2..]; + let _ = &Wtf8::from_str("aé 💩")[2..]; } #[test] @@ -323,7 +323,7 @@ fn wtf8_slice_to() { #[test] #[should_panic] fn wtf8_slice_to_not_code_point_boundary() { - &Wtf8::from_str("aé 💩")[5..]; + let _ = &Wtf8::from_str("aé 💩")[5..]; } #[test] diff --git a/src/test/ui/array-slice-vec/slice-panic-1.rs b/src/test/ui/array-slice-vec/slice-panic-1.rs index 8b27d055e2be3..4134c62377835 100644 --- a/src/test/ui/array-slice-vec/slice-panic-1.rs +++ b/src/test/ui/array-slice-vec/slice-panic-1.rs @@ -17,7 +17,7 @@ impl Drop for Foo { fn foo() { let x: &[_] = &[Foo, Foo]; - &x[3..4]; + let _ = &x[3..4]; } fn main() { diff --git a/src/test/ui/array-slice-vec/slice-panic-2.rs b/src/test/ui/array-slice-vec/slice-panic-2.rs index 2ee564cadb344..2f7178fb3e132 100644 --- a/src/test/ui/array-slice-vec/slice-panic-2.rs +++ b/src/test/ui/array-slice-vec/slice-panic-2.rs @@ -21,7 +21,7 @@ fn bar() -> usize { fn foo() { let x: &[_] = &[Foo, Foo]; - &x[3..bar()]; + let _ = &x[3..bar()]; } fn main() { diff --git a/src/test/ui/array-slice-vec/slice.rs b/src/test/ui/array-slice-vec/slice.rs index 14e1ddf52eb7b..a514e20277365 100644 --- a/src/test/ui/array-slice-vec/slice.rs +++ b/src/test/ui/array-slice-vec/slice.rs @@ -67,14 +67,14 @@ impl IndexMut for Foo { fn main() { let mut x = Foo; - &x[..]; - &x[Foo..]; - &x[..Foo]; - &x[Foo..Foo]; - &mut x[..]; - &mut x[Foo..]; - &mut x[..Foo]; - &mut x[Foo..Foo]; + let _ = &x[..]; + let _ = &x[Foo..]; + let _ = &x[..Foo]; + let _ = &x[Foo..Foo]; + let _ = &mut x[..]; + let _ = &mut x[Foo..]; + let _ = &mut x[..Foo]; + let _ = &mut x[Foo..Foo]; unsafe { assert_eq!(COUNT, 8); } diff --git a/src/test/ui/const-generics/issues/issue-61432.rs b/src/test/ui/const-generics/issues/issue-61432.rs index 0e228126d7789..97ab07daccefb 100644 --- a/src/test/ui/const-generics/issues/issue-61432.rs +++ b/src/test/ui/const-generics/issues/issue-61432.rs @@ -6,9 +6,9 @@ fn promote() { // works: // // let n = N; - // &n; + // let _ = &n; - &N; + let _ = &N; } fn main() { diff --git a/src/test/ui/dynamically-sized-types/dst-index.rs b/src/test/ui/dynamically-sized-types/dst-index.rs index 980d99a6d6c11..8aa65bbfdc9e7 100644 --- a/src/test/ui/dynamically-sized-types/dst-index.rs +++ b/src/test/ui/dynamically-sized-types/dst-index.rs @@ -29,6 +29,6 @@ impl Index for T { fn main() { assert_eq!(&S[0], "hello"); - &T[0]; + let _ = &T[0]; // let x = &x as &Debug; } diff --git a/src/test/ui/generator/too-live-local-in-immovable-gen.rs b/src/test/ui/generator/too-live-local-in-immovable-gen.rs index 7f118c88e5e6e..e0b856db7a55d 100644 --- a/src/test/ui/generator/too-live-local-in-immovable-gen.rs +++ b/src/test/ui/generator/too-live-local-in-immovable-gen.rs @@ -15,7 +15,7 @@ fn main() { yield (); 4i32 }; - &a; + let _ = &a; }; } } diff --git a/src/test/ui/generator/too-live-local-in-immovable-gen.stderr b/src/test/ui/generator/too-live-local-in-immovable-gen.stderr index 88dacff7b559b..72a2bd4ebc55c 100644 --- a/src/test/ui/generator/too-live-local-in-immovable-gen.stderr +++ b/src/test/ui/generator/too-live-local-in-immovable-gen.stderr @@ -6,7 +6,7 @@ LL | | // Tests that the generator transformation finds out that `a` LL | | // during the yield expression. Type checking will also compute liveness LL | | // and it should also find out that `a` is not live. ... | -LL | | &a; +LL | | let _ = &a; LL | | }; | |__________^ | diff --git a/src/test/ui/generator/yield-in-initializer.rs b/src/test/ui/generator/yield-in-initializer.rs index 2f8754c95715f..0cab36e5f2880 100644 --- a/src/test/ui/generator/yield-in-initializer.rs +++ b/src/test/ui/generator/yield-in-initializer.rs @@ -11,7 +11,7 @@ fn main() { yield; true }; - &opt; + let _ = &opt; } }; } diff --git a/src/test/ui/issues/issue-43205.rs b/src/test/ui/issues/issue-43205.rs index 894a61f3eff0e..f47d5a347bb11 100644 --- a/src/test/ui/issues/issue-43205.rs +++ b/src/test/ui/issues/issue-43205.rs @@ -1,5 +1,5 @@ // run-pass fn main() { - &&[()][0]; + let _ = &&[()][0]; println!("{:?}", &[(),()][1]); } diff --git a/src/test/ui/issues/issue-5280.rs b/src/test/ui/issues/issue-5280.rs index 3c97dad6b148b..5c5ce6c987ad1 100644 --- a/src/test/ui/issues/issue-5280.rs +++ b/src/test/ui/issues/issue-5280.rs @@ -9,7 +9,7 @@ trait FontTableTagConversions { impl FontTableTagConversions for FontTableTag { fn tag_to_string(self) { - &self; + let _ = &self; } } diff --git a/src/test/ui/issues/issue-54696.rs b/src/test/ui/issues/issue-54696.rs index d8408ed85491f..15355d30db6a5 100644 --- a/src/test/ui/issues/issue-54696.rs +++ b/src/test/ui/issues/issue-54696.rs @@ -2,7 +2,7 @@ fn main() { // We shouldn't promote this - &(main as fn() == main as fn()); + let _ = &(main as fn() == main as fn()); // Also check nested case - &(&(main as fn()) == &(main as fn())); + let _ = &(&(main as fn()) == &(main as fn())); } diff --git a/src/test/ui/lint/unused-borrows.rs b/src/test/ui/lint/unused-borrows.rs new file mode 100644 index 0000000000000..4518522ae00f7 --- /dev/null +++ b/src/test/ui/lint/unused-borrows.rs @@ -0,0 +1,33 @@ +#![deny(unused_must_use)] + +fn foo(_: i32) -> bool { todo!() } + +fn bar() -> &'static i32 { + &42; + //~^ unused + + &mut foo(42); + //~^ unused + + &&42; + //~^ unused + + &&mut 42; + //~^ unused + + &mut &42; + //~^ unused + + let _result = foo(4) + && foo(2); // Misplaced semi-colon (perhaps due to reordering of lines) + && foo(42); + //~^ unused + + let _ = &42; // ok + + &42 // ok +} + +fn main() { + let _ = bar(); +} diff --git a/src/test/ui/lint/unused-borrows.stderr b/src/test/ui/lint/unused-borrows.stderr new file mode 100644 index 0000000000000..24899fe992b9f --- /dev/null +++ b/src/test/ui/lint/unused-borrows.stderr @@ -0,0 +1,44 @@ +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:6:5 + | +LL | &42; + | ^^^ + | +note: the lint level is defined here + --> $DIR/unused-borrows.rs:1:9 + | +LL | #![deny(unused_must_use)] + | ^^^^^^^^^^^^^^^ + +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:9:5 + | +LL | &mut foo(42); + | ^^^^^^^^^^^^ + +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:12:5 + | +LL | &&42; + | ^^^^ + +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:15:5 + | +LL | &&mut 42; + | ^^^^^^^^ + +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:18:5 + | +LL | &mut &42; + | ^^^^^^^^ + +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:23:5 + | +LL | && foo(42); + | ^^^^^^^^^^ + +error: aborting due to 6 previous errors + From d7bb7465c14eba7949c2df00c93374287b048ccc Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Fri, 18 Jun 2021 16:11:32 +0800 Subject: [PATCH 10/16] Make clippy tests happy --- src/tools/clippy/tests/ui/bytes_nth.fixed | 2 +- src/tools/clippy/tests/ui/bytes_nth.rs | 2 +- src/tools/clippy/tests/ui/bytes_nth.stderr | 6 +++--- src/tools/clippy/tests/ui/iter_count.fixed | 16 ++++++++-------- src/tools/clippy/tests/ui/iter_count.rs | 16 ++++++++-------- src/tools/clippy/tests/ui/iter_count.stderr | 18 +++++++++--------- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/tools/clippy/tests/ui/bytes_nth.fixed b/src/tools/clippy/tests/ui/bytes_nth.fixed index bf68a7bbbf1d4..46b7833f42804 100644 --- a/src/tools/clippy/tests/ui/bytes_nth.fixed +++ b/src/tools/clippy/tests/ui/bytes_nth.fixed @@ -6,6 +6,6 @@ fn main() { let s = String::from("String"); s.as_bytes().get(3); - &s.as_bytes().get(3); + let _ = &s.as_bytes().get(3); s[..].as_bytes().get(3); } diff --git a/src/tools/clippy/tests/ui/bytes_nth.rs b/src/tools/clippy/tests/ui/bytes_nth.rs index 629812cc02cb8..c5e983d4d4e00 100644 --- a/src/tools/clippy/tests/ui/bytes_nth.rs +++ b/src/tools/clippy/tests/ui/bytes_nth.rs @@ -6,6 +6,6 @@ fn main() { let s = String::from("String"); s.bytes().nth(3); - &s.bytes().nth(3); + let _ = &s.bytes().nth(3); s[..].bytes().nth(3); } diff --git a/src/tools/clippy/tests/ui/bytes_nth.stderr b/src/tools/clippy/tests/ui/bytes_nth.stderr index 9a5742928cd61..536decf5e7fc4 100644 --- a/src/tools/clippy/tests/ui/bytes_nth.stderr +++ b/src/tools/clippy/tests/ui/bytes_nth.stderr @@ -7,10 +7,10 @@ LL | s.bytes().nth(3); = note: `-D clippy::bytes-nth` implied by `-D warnings` error: called `.byte().nth()` on a `String` - --> $DIR/bytes_nth.rs:9:6 + --> $DIR/bytes_nth.rs:9:14 | -LL | &s.bytes().nth(3); - | ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)` +LL | let _ = &s.bytes().nth(3); + | ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)` error: called `.byte().nth()` on a `str` --> $DIR/bytes_nth.rs:10:5 diff --git a/src/tools/clippy/tests/ui/iter_count.fixed b/src/tools/clippy/tests/ui/iter_count.fixed index b11dadda6c24e..52f833ece696b 100644 --- a/src/tools/clippy/tests/ui/iter_count.fixed +++ b/src/tools/clippy/tests/ui/iter_count.fixed @@ -3,11 +3,11 @@ #![warn(clippy::iter_count)] #![allow( - unused_variables, - array_into_iter, - unused_mut, - clippy::into_iter_on_ref, - clippy::unnecessary_operation +unused_variables, +array_into_iter, +unused_mut, +clippy::into_iter_on_ref, +clippy::unnecessary_operation )] extern crate option_helpers; @@ -50,7 +50,7 @@ fn main() { linked_list.push_back(1); binary_heap.push(1); - &vec[..].len(); + let _ = &vec[..].len(); vec.len(); boxed_slice.len(); vec_deque.len(); @@ -62,13 +62,13 @@ fn main() { binary_heap.len(); vec.len(); - &vec[..].len(); + let _ = &vec[..].len(); vec_deque.len(); hash_map.len(); b_tree_map.len(); linked_list.len(); - &vec[..].len(); + let _ = &vec[..].len(); vec.len(); vec_deque.len(); hash_set.len(); diff --git a/src/tools/clippy/tests/ui/iter_count.rs b/src/tools/clippy/tests/ui/iter_count.rs index 7d49c6a3dbbb9..e76914aa54c1f 100644 --- a/src/tools/clippy/tests/ui/iter_count.rs +++ b/src/tools/clippy/tests/ui/iter_count.rs @@ -3,11 +3,11 @@ #![warn(clippy::iter_count)] #![allow( - unused_variables, - array_into_iter, - unused_mut, - clippy::into_iter_on_ref, - clippy::unnecessary_operation +unused_variables, +array_into_iter, +unused_mut, +clippy::into_iter_on_ref, +clippy::unnecessary_operation )] extern crate option_helpers; @@ -50,7 +50,7 @@ fn main() { linked_list.push_back(1); binary_heap.push(1); - &vec[..].iter().count(); + let _ = &vec[..].iter().count(); vec.iter().count(); boxed_slice.iter().count(); vec_deque.iter().count(); @@ -62,13 +62,13 @@ fn main() { binary_heap.iter().count(); vec.iter_mut().count(); - &vec[..].iter_mut().count(); + let _ = &vec[..].iter_mut().count(); vec_deque.iter_mut().count(); hash_map.iter_mut().count(); b_tree_map.iter_mut().count(); linked_list.iter_mut().count(); - &vec[..].into_iter().count(); + let _ = &vec[..].into_iter().count(); vec.into_iter().count(); vec_deque.into_iter().count(); hash_set.into_iter().count(); diff --git a/src/tools/clippy/tests/ui/iter_count.stderr b/src/tools/clippy/tests/ui/iter_count.stderr index f3fb98e65b990..1d2c22f9dfad5 100644 --- a/src/tools/clippy/tests/ui/iter_count.stderr +++ b/src/tools/clippy/tests/ui/iter_count.stderr @@ -1,8 +1,8 @@ error: called `.iter().count()` on a `slice` - --> $DIR/iter_count.rs:53:6 + --> $DIR/iter_count.rs:53:14 | -LL | &vec[..].iter().count(); - | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` +LL | let _ = &vec[..].iter().count(); + | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` | = note: `-D clippy::iter-count` implied by `-D warnings` @@ -67,10 +67,10 @@ LL | vec.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.len()` error: called `.iter_mut().count()` on a `slice` - --> $DIR/iter_count.rs:65:6 + --> $DIR/iter_count.rs:65:14 | -LL | &vec[..].iter_mut().count(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` +LL | let _ = &vec[..].iter_mut().count(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` error: called `.iter_mut().count()` on a `VecDeque` --> $DIR/iter_count.rs:66:5 @@ -97,10 +97,10 @@ LL | linked_list.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()` error: called `.into_iter().count()` on a `slice` - --> $DIR/iter_count.rs:71:6 + --> $DIR/iter_count.rs:71:14 | -LL | &vec[..].into_iter().count(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` +LL | let _ = &vec[..].into_iter().count(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` error: called `.into_iter().count()` on a `Vec` --> $DIR/iter_count.rs:72:5 From 884336eade854919ee17d5e4c56ecc5f9ab6529b Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Fri, 18 Jun 2021 16:20:30 +0800 Subject: [PATCH 11/16] Address comment --- src/tools/clippy/tests/ui/iter_count.fixed | 10 +++++----- src/tools/clippy/tests/ui/iter_count.rs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tools/clippy/tests/ui/iter_count.fixed b/src/tools/clippy/tests/ui/iter_count.fixed index 52f833ece696b..97c5929783d88 100644 --- a/src/tools/clippy/tests/ui/iter_count.fixed +++ b/src/tools/clippy/tests/ui/iter_count.fixed @@ -3,11 +3,11 @@ #![warn(clippy::iter_count)] #![allow( -unused_variables, -array_into_iter, -unused_mut, -clippy::into_iter_on_ref, -clippy::unnecessary_operation + unused_variables, + array_into_iter, + unused_mut, + clippy::into_iter_on_ref, + clippy::unnecessary_operation )] extern crate option_helpers; diff --git a/src/tools/clippy/tests/ui/iter_count.rs b/src/tools/clippy/tests/ui/iter_count.rs index e76914aa54c1f..70bb734763f09 100644 --- a/src/tools/clippy/tests/ui/iter_count.rs +++ b/src/tools/clippy/tests/ui/iter_count.rs @@ -3,11 +3,11 @@ #![warn(clippy::iter_count)] #![allow( -unused_variables, -array_into_iter, -unused_mut, -clippy::into_iter_on_ref, -clippy::unnecessary_operation + unused_variables, + array_into_iter, + unused_mut, + clippy::into_iter_on_ref, + clippy::unnecessary_operation )] extern crate option_helpers; From f6adaedd9b0696c559df352652bdd8da8ea47d91 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 18 Jun 2021 11:44:56 -0400 Subject: [PATCH 12/16] add various coments to explain how the code works --- compiler/rustc_middle/src/ty/context.rs | 28 ++++++++++ .../src/borrow_check/type_check/mod.rs | 56 ++++++++++++++++++- .../rustc_trait_selection/src/opaque_types.rs | 12 +--- 3 files changed, 85 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 73991436b7b6b..a74070100f413 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -392,6 +392,34 @@ pub struct TypeckResults<'tcx> { /// (including late-bound regions) are replaced with free /// equivalents. This table is not used in codegen (since regions /// are erased there) and hence is not serialized to metadata. + /// + /// This table also contains the "revealed" values for any `impl Trait` + /// that appear in the signature and whose values are being inferred + /// by this function. + /// + /// # Example + /// + /// ```rust + /// fn foo(x: &u32) -> impl Debug { *x } + /// ``` + /// + /// The function signature here would be: + /// + /// ``` + /// for<'a> fn(&'a u32) -> Foo + /// ``` + /// + /// where `Foo` is an opaque type created for this function. + /// + /// + /// The *liberated* form of this would be + /// + /// ``` + /// fn(&'a u32) -> u32 + /// ``` + /// + /// Note that `'a` is not bound (it would be an `ReFree`) and + /// that the `Foo` opaque type is replaced by its hidden type. liberated_fn_sigs: ItemLocalMap>, /// For each FRU expression, record the normalized types of the fields diff --git a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs index 09cafddeeffde..984a9a7f0539a 100644 --- a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs @@ -1206,6 +1206,35 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { Ok(()) } + /// Equates a type `anon_ty` that may contain opaque types whose + /// values are to be inferred by the MIR with def-id `anon_owner_def_id`. + /// + /// The type `revealed_ty` contains the same type as `anon_ty`, but with the + /// hidden types for impl traits revealed. + /// + /// # Example + /// + /// Consider a piece of code like + /// + /// ```rust + /// type Foo = impl Debug; + /// + /// fn foo(t: T) -> Box> { + /// Box::new((t, 22_u32)) + /// } + /// ``` + /// + /// Here, the function signature would be something like + /// `fn(T) -> Box`. The MIR return slot would have + /// the type with the opaque type revealed, so `Box<(T, u32)>`. + /// + /// In terms of our function parameters: + /// + /// * `anon_ty` would be `Box>` where `Foo` is an opaque type + /// scoped to this function (note that it is parameterized by the + /// generics of `foo`). + /// * `revealed_ty` would be `Box<(Foo, u32)>` + /// * `anon_owner_def_id` would be the def-id of `foo` fn eq_opaque_type_and_type( &mut self, revealed_ty: Ty<'tcx>, @@ -1240,6 +1269,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let tcx = infcx.tcx; let param_env = self.param_env; let body = self.body; + + // the "concrete opaque types" maps let concrete_opaque_types = &tcx.typeck(anon_owner_def_id).concrete_opaque_types; let mut opaque_type_values = VecMap::new(); @@ -1252,6 +1283,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let mut obligations = ObligationAccumulator::default(); let dummy_body_id = hir::CRATE_HIR_ID; + + // Replace the opaque types defined by this function with + // inference variables, creating a map. In our example above, + // this would transform the type `Box>` (where `Foo` is an opaque type) + // to `Box`, returning an `opaque_type_map` mapping `{Foo -> ?T}`. + // (Note that the key of the map is both the def-id of `Foo` along with + // any generic parameters.) let (output_ty, opaque_type_map) = obligations.add(infcx.instantiate_opaque_types( anon_owner_def_id, @@ -1267,6 +1305,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { revealed_ty={:?}", output_ty, opaque_type_map, revealed_ty ); + // Make sure that the inferred types are well-formed. I'm // not entirely sure this is needed (the HIR type check // didn't do this) but it seems sensible to prevent opaque @@ -1282,6 +1321,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { .eq(output_ty, revealed_ty)?, ); + // For each opaque type `Foo` inferred by this value, we want to equate + // the inference variable `?T` with the revealed type that was computed + // earlier by type check. for &(opaque_type_key, opaque_decl) in &opaque_type_map { let resolved_ty = infcx.resolve_vars_if_possible(opaque_decl.concrete_ty); let concrete_is_opaque = if let ty::Opaque(def_id, _) = resolved_ty.kind() { @@ -1290,6 +1332,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { false }; + // The revealed type computed by the earlier phase of type check. + // In our example, this would be `(U, u32)`. Note that this references + // the type parameter `U` from the definition of `Foo`. let concrete_ty = match concrete_opaque_types .get_by(|(key, _)| key.def_id == opaque_type_key.def_id) { @@ -1308,7 +1353,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { Some(concrete_ty) => concrete_ty, }; debug!("concrete_ty = {:?}", concrete_ty); + + // Apply the substitution, in this case `[U -> T]`, so that the + // concrete type becomes `Foo<(T, u32)>` let subst_opaque_defn_ty = concrete_ty.subst(tcx, opaque_type_key.substs); + + // "Renumber" this, meaning that we replace all the regions + // with fresh inference variables. Not relevant to our example. let renumbered_opaque_defn_ty = renumber::renumber_regions(infcx, subst_opaque_defn_ty); @@ -1318,8 +1369,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ); if !concrete_is_opaque { - // Equate concrete_ty (an inference variable) with - // the renumbered type from typeck. + // Equate the instantiated opaque type `opaque_decl.concrete_ty` (`?T`, + // in our example) with the renumbered version that we took from + // the type check results (`Foo<(T, u32)>`). obligations.add( infcx .at(&ObligationCause::dummy(), param_env) diff --git a/compiler/rustc_trait_selection/src/opaque_types.rs b/compiler/rustc_trait_selection/src/opaque_types.rs index 89ec211f2627b..0061ce4ed3709 100644 --- a/compiler/rustc_trait_selection/src/opaque_types.rs +++ b/compiler/rustc_trait_selection/src/opaque_types.rs @@ -5,7 +5,6 @@ use rustc_data_structures::sync::Lrc; use rustc_data_structures::vec_map::VecMap; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::Node; use rustc_infer::infer::error_reporting::unexpected_hidden_region_diagnostic; use rustc_infer::infer::free_regions::FreeRegionRelations; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; @@ -982,8 +981,8 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> { let opaque_parent_hir_id = tcx.hir().get_parent_item(opaque_hir_id); parent_def_id == tcx.hir().local_def_id(opaque_parent_hir_id) }; - let (in_definition_scope, origin) = match tcx.hir().find(opaque_hir_id) { - Some(Node::Item(item)) => match item.kind { + let (in_definition_scope, origin) = + match tcx.hir().expect_item(opaque_hir_id).kind { // Anonymous `impl Trait` hir::ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn: Some(parent), @@ -1000,12 +999,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> { origin, ), _ => (def_scope_default(), hir::OpaqueTyOrigin::Misc), - }, - _ => bug!( - "expected item, found {}", - tcx.hir().node_to_string(opaque_hir_id), - ), - }; + }; if in_definition_scope { let opaque_type_key = OpaqueTypeKey { def_id: def_id.to_def_id(), substs }; From 8776b0f41cb6b02a6e85450b81606d23acc4a7bf Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Fri, 18 Jun 2021 18:44:09 +0200 Subject: [PATCH 13/16] Update library tracking issue for libs-api rename. --- .github/ISSUE_TEMPLATE/library_tracking_issue.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/library_tracking_issue.md b/.github/ISSUE_TEMPLATE/library_tracking_issue.md index cbc4465fcfe38..e879594b87a10 100644 --- a/.github/ISSUE_TEMPLATE/library_tracking_issue.md +++ b/.github/ISSUE_TEMPLATE/library_tracking_issue.md @@ -2,7 +2,7 @@ name: Library Tracking Issue about: A tracking issue for an unstable library feature. title: Tracking Issue for XXX -labels: C-tracking-issue, T-libs +labels: C-tracking-issue, T-libs-api --- $DIR/issue-83505-repr-simd.rs:9:1 + | +LL | static CLs: Es; + | ^^^^^^^^^^^^^^- + | | + | help: provide a definition for the static: `= ;` + +error[E0517]: attribute should be applied to a struct + --> $DIR/issue-83505-repr-simd.rs:5:8 + | +LL | #[repr(simd)] + | ^^^^ +... +LL | enum Es {} + | ---------- not a struct + +error[E0084]: unsupported representation for zero-variant enum + --> $DIR/issue-83505-repr-simd.rs:5:1 + | +LL | #[repr(simd)] + | ^^^^^^^^^^^^^ +... +LL | enum Es {} + | ---------- zero-variant enum + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0084, E0517. +For more information about an error, try `rustc --explain E0084`. From 831759a4438736980574478b29a3e9ab6e837f3f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 18 Jun 2021 18:20:07 -0400 Subject: [PATCH 15/16] fix typos --- compiler/rustc_mir/src/borrow_check/type_check/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs index 984a9a7f0539a..bd951ef72b5c1 100644 --- a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs @@ -1230,10 +1230,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { /// /// In terms of our function parameters: /// - /// * `anon_ty` would be `Box>` where `Foo` is an opaque type + /// * `anon_ty` would be `Box>` where `Foo` is an opaque type /// scoped to this function (note that it is parameterized by the - /// generics of `foo`). - /// * `revealed_ty` would be `Box<(Foo, u32)>` + /// generics of `foo`). Note that `anon_ty` is not just the opaque type, + /// but the entire return type (which may contain opaque types within it). + /// * `revealed_ty` would be `Box<(T, u32)>` /// * `anon_owner_def_id` would be the def-id of `foo` fn eq_opaque_type_and_type( &mut self, From c688e70d66ad11f32e988f92f774f831ce9464ff Mon Sep 17 00:00:00 2001 From: Alexander Kiselev Date: Fri, 18 Jun 2021 17:43:18 -0700 Subject: [PATCH 16/16] Fixed typo `BorroeError` => `BorrowError` in RefCell docs --- library/core/src/cell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index f88a6e418c7c8..0c1224ce56c0d 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -578,7 +578,7 @@ pub struct RefCell { // Stores the location of the earliest currently active borrow. // This gets updated whenver we go from having zero borrows // to having a single borrow. When a borrow occurs, this gets included - // in the generated `BorroeError/`BorrowMutError` + // in the generated `BorrowError/`BorrowMutError` #[cfg(feature = "debug_refcell")] borrowed_at: Cell>>, value: UnsafeCell,