summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.mailmap1
-rw-r--r--src/bootstrap/builder.rs2
-rw-r--r--src/bootstrap/native.rs18
-rw-r--r--src/libcore/iter/adapters/mod.rs10
-rw-r--r--src/libcore/option.rs1
-rw-r--r--src/libcore/result.rs1
-rw-r--r--src/librustc/ty/mod.rs2
-rw-r--r--src/librustc/ty/sty.rs2
-rw-r--r--src/librustc_codegen_ssa/back/link.rs2
-rw-r--r--src/librustc_data_structures/sorted_map.rs2
-rw-r--r--src/librustc_lint/unused.rs16
-rw-r--r--src/librustc_mir/borrow_check/diagnostics/move_errors.rs29
-rw-r--r--src/librustc_mir_build/hair/pattern/_match.rs2
-rw-r--r--src/librustc_session/session.rs8
-rw-r--r--src/librustc_span/source_map.rs4
-rw-r--r--src/librustc_typeck/collect.rs11
-rw-r--r--src/libsyntax/print/pprust.rs6
-rw-r--r--src/test/ui/iterators/skip-count-overflow.rs8
-rw-r--r--src/test/ui/lint/lint-unnecessary-parens.rs7
-rw-r--r--src/test/ui/lint/lint-unnecessary-parens.stderr36
-rw-r--r--src/test/ui/suggestions/for-i-in-vec.fixed15
-rw-r--r--src/test/ui/suggestions/for-i-in-vec.rs15
-rw-r--r--src/test/ui/suggestions/for-i-in-vec.stderr12
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs13
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr14
25 files changed, 198 insertions, 39 deletions
diff --git a/.mailmap b/.mailmap
index 1634c2d..6ab6be2 100644
--- a/.mailmap
+++ b/.mailmap
@@ -211,6 +211,7 @@ Peter Liniker <peter.liniker+github@gmail.com>
211Phil Dawes <phil@phildawes.net> Phil Dawes <pdawes@drw.com> 211Phil Dawes <phil@phildawes.net> Phil Dawes <pdawes@drw.com>
212Philipp Brüschweiler <blei42@gmail.com> <blei42@gmail.com> 212Philipp Brüschweiler <blei42@gmail.com> <blei42@gmail.com>
213Philipp Brüschweiler <blei42@gmail.com> <bruphili@student.ethz.ch> 213Philipp Brüschweiler <blei42@gmail.com> <bruphili@student.ethz.ch>
214Philipp Krones <hello@philkrones.com> flip1995 <hello@philkrones.com>
214Philipp Matthias Schäfer <philipp.matthias.schaefer@posteo.de> 215Philipp Matthias Schäfer <philipp.matthias.schaefer@posteo.de>
215Przemysław Wesołek <jest@go.art.pl> Przemek Wesołek <jest@go.art.pl> 216Przemysław Wesołek <jest@go.art.pl> Przemek Wesołek <jest@go.art.pl>
216Rafael Ávila de Espíndola <respindola@mozilla.com> Rafael Avila de Espindola <espindola@dream.(none)> 217Rafael Ávila de Espíndola <respindola@mozilla.com> Rafael Avila de Espindola <espindola@dream.(none)>
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 00c8e72..d9c894a 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -874,7 +874,7 @@ impl<'a> Builder<'a> {
874 // 874 //
875 // Only clear out the directory if we're compiling std; otherwise, we 875 // Only clear out the directory if we're compiling std; otherwise, we
876 // should let Cargo take care of things for us (via depdep info) 876 // should let Cargo take care of things for us (via depdep info)
877 if !self.config.dry_run && mode == Mode::ToolStd && cmd == "build" { 877 if !self.config.dry_run && mode == Mode::Std && cmd == "build" {
878 self.clear_if_dirty(&out_dir, &self.rustc(compiler)); 878 self.clear_if_dirty(&out_dir, &self.rustc(compiler));
879 } 879 }
880 880
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 89e1a73..5bbd9f4 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -659,6 +659,24 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
659 }); 659 });
660 } 660 }
661 } 661 }
662 "x86_64-fuchsia" => {
663 for s in &["asan"] {
664 result.push(SanitizerRuntime {
665 cmake_target: format!("clang_rt.{}-x86_64", s),
666 path: out_dir.join(&format!("build/lib/fuchsia/libclang_rt.{}-x86_64.a", s)),
667 name: format!("librustc_rt.{}.a", s),
668 });
669 }
670 }
671 "aarch64-fuchsia" => {
672 for s in &["asan"] {
673 result.push(SanitizerRuntime {
674 cmake_target: format!("clang_rt.{}-aarch64", s),
675 path: out_dir.join(&format!("build/lib/fuchsia/libclang_rt.{}-aarch64.a", s)),
676 name: format!("librustc_rt.{}.a", s),
677 });
678 }
679 }
662 _ => {} 680 _ => {}
663 } 681 }
664 result 682 result
diff --git a/src/libcore/iter/adapters/mod.rs b/src/libcore/iter/adapters/mod.rs
index 6eb837e..5787b91 100644
--- a/src/libcore/iter/adapters/mod.rs
+++ b/src/libcore/iter/adapters/mod.rs
@@ -1815,8 +1815,14 @@ where
1815 } 1815 }
1816 1816
1817 #[inline] 1817 #[inline]
1818 fn count(self) -> usize { 1818 fn count(mut self) -> usize {
1819 self.iter.count().saturating_sub(self.n) 1819 if self.n > 0 {
1820 // nth(n) skips n+1
1821 if self.iter.nth(self.n - 1).is_none() {
1822 return 0;
1823 }
1824 }
1825 self.iter.count()
1820 } 1826 }
1821 1827
1822 #[inline] 1828 #[inline]
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index a471b17..cb4247d 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -151,6 +151,7 @@ use crate::{
151 151
152/// The `Option` type. See [the module level documentation](index.html) for more. 152/// The `Option` type. See [the module level documentation](index.html) for more.
153#[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] 153#[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
154#[rustc_diagnostic_item = "option_type"]
154#[stable(feature = "rust1", since = "1.0.0")] 155#[stable(feature = "rust1", since = "1.0.0")]
155pub enum Option<T> { 156pub enum Option<T> {
156 /// No value 157 /// No value
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index c657ce3..bc70dbd 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -242,6 +242,7 @@ use crate::ops::{self, Deref, DerefMut};
242/// [`Err`]: enum.Result.html#variant.Err 242/// [`Err`]: enum.Result.html#variant.Err
243#[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] 243#[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
244#[must_use = "this `Result` may be an `Err` variant, which should be handled"] 244#[must_use = "this `Result` may be an `Err` variant, which should be handled"]
245#[rustc_diagnostic_item = "result_type"]
245#[stable(feature = "rust1", since = "1.0.0")] 246#[stable(feature = "rust1", since = "1.0.0")]
246pub enum Result<T, E> { 247pub enum Result<T, E> {
247 /// Contains the success value 248 /// Contains the success value
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index 0470ab2..e67131b 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -2410,7 +2410,7 @@ impl<'tcx> AdtDef {
2410 2410
2411 #[inline] 2411 #[inline]
2412 pub fn variant_range(&self) -> Range<VariantIdx> { 2412 pub fn variant_range(&self) -> Range<VariantIdx> {
2413 (VariantIdx::new(0)..VariantIdx::new(self.variants.len())) 2413 VariantIdx::new(0)..VariantIdx::new(self.variants.len())
2414 } 2414 }
2415 2415
2416 /// Computes the discriminant value used by a specific variant. 2416 /// Computes the discriminant value used by a specific variant.
diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs
index 13f623a..837b2fc 100644
--- a/src/librustc/ty/sty.rs
+++ b/src/librustc/ty/sty.rs
@@ -529,7 +529,7 @@ impl<'tcx> GeneratorSubsts<'tcx> {
529 pub fn variant_range(&self, def_id: DefId, tcx: TyCtxt<'tcx>) -> Range<VariantIdx> { 529 pub fn variant_range(&self, def_id: DefId, tcx: TyCtxt<'tcx>) -> Range<VariantIdx> {
530 // FIXME requires optimized MIR 530 // FIXME requires optimized MIR
531 let num_variants = tcx.generator_layout(def_id).variant_fields.len(); 531 let num_variants = tcx.generator_layout(def_id).variant_fields.len();
532 (VariantIdx::new(0)..VariantIdx::new(num_variants)) 532 VariantIdx::new(0)..VariantIdx::new(num_variants)
533 } 533 }
534 534
535 /// The discriminant for the given variant. Panics if the `variant_index` is 535 /// The discriminant for the given variant. Panics if the `variant_index` is
diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
index 53ee599..f56a417 100644
--- a/src/librustc_codegen_ssa/back/link.rs
+++ b/src/librustc_codegen_ssa/back/link.rs
@@ -777,7 +777,7 @@ fn link_sanitizer_runtime(sess: &Session, crate_type: config::CrateType, linker:
777 linker.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]); 777 linker.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]);
778 linker.link_dylib(Symbol::intern(&libname)); 778 linker.link_dylib(Symbol::intern(&libname));
779 } 779 }
780 "x86_64-unknown-linux-gnu" => { 780 "x86_64-unknown-linux-gnu" | "x86_64-fuchsia" | "aarch64-fuchsia" => {
781 let filename = format!("librustc_rt.{}.a", name); 781 let filename = format!("librustc_rt.{}.a", name);
782 let path = default_tlib.join(&filename); 782 let path = default_tlib.join(&filename);
783 linker.link_whole_rlib(&path); 783 linker.link_whole_rlib(&path);
diff --git a/src/librustc_data_structures/sorted_map.rs b/src/librustc_data_structures/sorted_map.rs
index b29ffd7..08706aa 100644
--- a/src/librustc_data_structures/sorted_map.rs
+++ b/src/librustc_data_structures/sorted_map.rs
@@ -132,7 +132,7 @@ impl<K: Ord, V> SortedMap<K, V> {
132 R: RangeBounds<K>, 132 R: RangeBounds<K>,
133 { 133 {
134 let (start, end) = self.range_slice_indices(range); 134 let (start, end) = self.range_slice_indices(range);
135 (&self.data[start..end]) 135 &self.data[start..end]
136 } 136 }
137 137
138 #[inline] 138 #[inline]
diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs
index 15158c0..bb2c4fa 100644
--- a/src/librustc_lint/unused.rs
+++ b/src/librustc_lint/unused.rs
@@ -544,12 +544,20 @@ impl EarlyLintPass for UnusedParens {
544 } 544 }
545 545
546 fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) { 546 fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
547 if let ast::StmtKind::Local(ref local) = s.kind { 547 use ast::StmtKind::*;
548 self.check_unused_parens_pat(cx, &local.pat, false, false);
549 548
550 if let Some(ref value) = local.init { 549 match s.kind {
551 self.check_unused_parens_expr(cx, &value, "assigned value", false, None, None); 550 Local(ref local) => {
551 self.check_unused_parens_pat(cx, &local.pat, false, false);
552
553 if let Some(ref value) = local.init {
554 self.check_unused_parens_expr(cx, &value, "assigned value", false, None, None);
555 }
552 } 556 }
557 Expr(ref expr) => {
558 self.check_unused_parens_expr(cx, &expr, "block return value", false, None, None);
559 }
560 _ => {}
553 } 561 }
554 } 562 }
555 563
diff --git a/src/librustc_mir/borrow_check/diagnostics/move_errors.rs b/src/librustc_mir/borrow_check/diagnostics/move_errors.rs
index eb6db7c..43121b3 100644
--- a/src/librustc_mir/borrow_check/diagnostics/move_errors.rs
+++ b/src/librustc_mir/borrow_check/diagnostics/move_errors.rs
@@ -1,7 +1,8 @@
1use rustc::mir::*; 1use rustc::mir::*;
2use rustc::ty; 2use rustc::ty;
3use rustc_errors::{Applicability, DiagnosticBuilder}; 3use rustc_errors::{Applicability, DiagnosticBuilder};
4use rustc_span::Span; 4use rustc_span::source_map::DesugaringKind;
5use rustc_span::{Span, Symbol};
5 6
6use crate::borrow_check::diagnostics::UseSpans; 7use crate::borrow_check::diagnostics::UseSpans;
7use crate::borrow_check::prefixes::PrefixSet; 8use crate::borrow_check::prefixes::PrefixSet;
@@ -383,10 +384,20 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
383 } 384 }
384 } 385 }
385 }; 386 };
386 let move_ty = format!("{:?}", move_place.ty(*self.body, self.infcx.tcx).ty,);
387 if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) { 387 if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) {
388 let is_option = move_ty.starts_with("std::option::Option"); 388 let def_id = match move_place.ty(*self.body, self.infcx.tcx).ty.kind {
389 let is_result = move_ty.starts_with("std::result::Result"); 389 ty::Adt(self_def, _) => self_def.did,
390 ty::Foreign(def_id)
391 | ty::FnDef(def_id, _)
392 | ty::Closure(def_id, _)
393 | ty::Generator(def_id, ..)
394 | ty::Opaque(def_id, _) => def_id,
395 _ => return err,
396 };
397 let is_option =
398 self.infcx.tcx.is_diagnostic_item(Symbol::intern("option_type"), def_id);
399 let is_result =
400 self.infcx.tcx.is_diagnostic_item(Symbol::intern("result_type"), def_id);
390 if (is_option || is_result) && use_spans.map_or(true, |v| !v.for_closure()) { 401 if (is_option || is_result) && use_spans.map_or(true, |v| !v.for_closure()) {
391 err.span_suggestion( 402 err.span_suggestion(
392 span, 403 span,
@@ -397,6 +408,16 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
397 format!("{}.as_ref()", snippet), 408 format!("{}.as_ref()", snippet),
398 Applicability::MaybeIncorrect, 409 Applicability::MaybeIncorrect,
399 ); 410 );
411 } else if span.is_desugaring(DesugaringKind::ForLoop)
412 && self.infcx.tcx.is_diagnostic_item(Symbol::intern("vec_type"), def_id)
413 {
414 // FIXME: suggest for anything that implements `IntoIterator`.
415 err.span_suggestion(
416 span,
417 "consider iterating over a slice of the `Vec<_>`'s content",
418 format!("&{}", snippet),
419 Applicability::MaybeIncorrect,
420 );
400 } 421 }
401 } 422 }
402 err 423 err
diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/hair/pattern/_match.rs
index 20183fd..a2ce224 100644
--- a/src/librustc_mir_build/hair/pattern/_match.rs
+++ b/src/librustc_mir_build/hair/pattern/_match.rs
@@ -1530,7 +1530,7 @@ impl<'tcx> IntRange<'tcx> {
1530 // 2 -------- // 2 ------- 1530 // 2 -------- // 2 -------
1531 let (lo, hi) = self.boundaries(); 1531 let (lo, hi) = self.boundaries();
1532 let (other_lo, other_hi) = other.boundaries(); 1532 let (other_lo, other_hi) = other.boundaries();
1533 (lo == other_hi || hi == other_lo) 1533 lo == other_hi || hi == other_lo
1534 } 1534 }
1535 1535
1536 fn to_pat(&self, tcx: TyCtxt<'tcx>) -> Pat<'tcx> { 1536 fn to_pat(&self, tcx: TyCtxt<'tcx>) -> Pat<'tcx> {
diff --git a/src/librustc_session/session.rs b/src/librustc_session/session.rs
index d979247..a40d645 100644
--- a/src/librustc_session/session.rs
+++ b/src/librustc_session/session.rs
@@ -1127,8 +1127,12 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
1127 1127
1128 // Sanitizers can only be used on some tested platforms. 1128 // Sanitizers can only be used on some tested platforms.
1129 if let Some(ref sanitizer) = sess.opts.debugging_opts.sanitizer { 1129 if let Some(ref sanitizer) = sess.opts.debugging_opts.sanitizer {
1130 const ASAN_SUPPORTED_TARGETS: &[&str] = 1130 const ASAN_SUPPORTED_TARGETS: &[&str] = &[
1131 &["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"]; 1131 "x86_64-unknown-linux-gnu",
1132 "x86_64-apple-darwin",
1133 "x86_64-fuchsia",
1134 "aarch64-fuchsia",
1135 ];
1132 const TSAN_SUPPORTED_TARGETS: &[&str] = 1136 const TSAN_SUPPORTED_TARGETS: &[&str] =
1133 &["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"]; 1137 &["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
1134 const LSAN_SUPPORTED_TARGETS: &[&str] = 1138 const LSAN_SUPPORTED_TARGETS: &[&str] =
diff --git a/src/librustc_span/source_map.rs b/src/librustc_span/source_map.rs
index 9c7c0f0..e0b93b9 100644
--- a/src/librustc_span/source_map.rs
+++ b/src/librustc_span/source_map.rs
@@ -774,10 +774,10 @@ impl SourceMap {
774 // searching forwards for boundaries we've got somewhere to search. 774 // searching forwards for boundaries we've got somewhere to search.
775 let snippet = if let Some(ref src) = local_begin.sf.src { 775 let snippet = if let Some(ref src) = local_begin.sf.src {
776 let len = src.len(); 776 let len = src.len();
777 (&src[start_index..len]) 777 &src[start_index..len]
778 } else if let Some(src) = src.get_source() { 778 } else if let Some(src) = src.get_source() {
779 let len = src.len(); 779 let len = src.len();
780 (&src[start_index..len]) 780 &src[start_index..len]
781 } else { 781 } else {
782 return 1; 782 return 1;
783 }; 783 };
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 5821977..843872d 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -1673,8 +1673,15 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
1673 ty::Param(_) => true, 1673 ty::Param(_) => true,
1674 _ => false, 1674 _ => false,
1675 }; 1675 };
1676 let bad_substs: Vec<_> = 1676 let bad_substs: Vec<_> = substs
1677 substs.types().enumerate().filter(|(_, ty)| !is_param(ty)).collect(); 1677 .iter()
1678 .enumerate()
1679 .filter_map(|(i, k)| {
1680 if let GenericArgKind::Type(ty) = k.unpack() { Some((i, ty)) } else { None }
1681 })
1682 .filter(|(_, ty)| !is_param(ty))
1683 .collect();
1684
1678 if !bad_substs.is_empty() { 1685 if !bad_substs.is_empty() {
1679 let identity_substs = InternalSubsts::identity_for_item(self.tcx, self.def_id); 1686 let identity_substs = InternalSubsts::identity_for_item(self.tcx, self.def_id);
1680 for (i, bad_subst) in bad_substs { 1687 for (i, bad_subst) in bad_substs {
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index f0ef33e..d6f18fd 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -548,11 +548,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
548 let st = match style { 548 let st = match style {
549 ast::StrStyle::Cooked => (format!("\"{}\"", st.escape_debug())), 549 ast::StrStyle::Cooked => (format!("\"{}\"", st.escape_debug())),
550 ast::StrStyle::Raw(n) => { 550 ast::StrStyle::Raw(n) => {
551 (format!( 551 format!("r{delim}\"{string}\"{delim}", delim = "#".repeat(n as usize), string = st)
552 "r{delim}\"{string}\"{delim}",
553 delim = "#".repeat(n as usize),
554 string = st
555 ))
556 } 552 }
557 }; 553 };
558 self.word(st) 554 self.word(st)
diff --git a/src/test/ui/iterators/skip-count-overflow.rs b/src/test/ui/iterators/skip-count-overflow.rs
new file mode 100644
index 0000000..d8efc94
--- /dev/null
+++ b/src/test/ui/iterators/skip-count-overflow.rs
@@ -0,0 +1,8 @@
1// run-pass
2// only-32bit too impatient for 2⁶⁴ items
3// compile-flags: -C overflow-checks -C opt-level=3
4
5fn main() {
6 let i = (0..usize::max_value()).chain(0..10).skip(usize::max_value());
7 assert_eq!(i.count(), 10);
8}
diff --git a/src/test/ui/lint/lint-unnecessary-parens.rs b/src/test/ui/lint/lint-unnecessary-parens.rs
index 12ffb6d..4e8339a 100644
--- a/src/test/ui/lint/lint-unnecessary-parens.rs
+++ b/src/test/ui/lint/lint-unnecessary-parens.rs
@@ -17,6 +17,13 @@ fn unused_parens_around_return_type() -> (u32) { //~ ERROR unnecessary parenthes
17 panic!() 17 panic!()
18} 18}
19 19
20fn unused_parens_around_block_return() -> u32 {
21 let foo = {
22 (5) //~ ERROR unnecessary parentheses around block return value
23 };
24 (5) //~ ERROR unnecessary parentheses around block return value
25}
26
20trait Trait { 27trait Trait {
21 fn test(&self); 28 fn test(&self);
22} 29}
diff --git a/src/test/ui/lint/lint-unnecessary-parens.stderr b/src/test/ui/lint/lint-unnecessary-parens.stderr
index 541ae7a..ea58220 100644
--- a/src/test/ui/lint/lint-unnecessary-parens.stderr
+++ b/src/test/ui/lint/lint-unnecessary-parens.stderr
@@ -22,26 +22,38 @@ error: unnecessary parentheses around type
22LL | fn unused_parens_around_return_type() -> (u32) { 22LL | fn unused_parens_around_return_type() -> (u32) {
23 | ^^^^^ help: remove these parentheses 23 | ^^^^^ help: remove these parentheses
24 24
25error: unnecessary parentheses around block return value
26 --> $DIR/lint-unnecessary-parens.rs:22:9
27 |
28LL | (5)
29 | ^^^ help: remove these parentheses
30
31error: unnecessary parentheses around block return value
32 --> $DIR/lint-unnecessary-parens.rs:24:5
33 |
34LL | (5)
35 | ^^^ help: remove these parentheses
36
25error: unnecessary parentheses around function argument 37error: unnecessary parentheses around function argument
26 --> $DIR/lint-unnecessary-parens.rs:36:9 38 --> $DIR/lint-unnecessary-parens.rs:43:9
27 | 39 |
28LL | bar((true)); 40LL | bar((true));
29 | ^^^^^^ help: remove these parentheses 41 | ^^^^^^ help: remove these parentheses
30 42
31error: unnecessary parentheses around `if` condition 43error: unnecessary parentheses around `if` condition
32 --> $DIR/lint-unnecessary-parens.rs:38:8 44 --> $DIR/lint-unnecessary-parens.rs:45:8
33 | 45 |
34LL | if (true) {} 46LL | if (true) {}
35 | ^^^^^^ help: remove these parentheses 47 | ^^^^^^ help: remove these parentheses
36 48
37error: unnecessary parentheses around `while` condition 49error: unnecessary parentheses around `while` condition
38 --> $DIR/lint-unnecessary-parens.rs:39:11 50 --> $DIR/lint-unnecessary-parens.rs:46:11
39 | 51 |
40LL | while (true) {} 52LL | while (true) {}
41 | ^^^^^^ help: remove these parentheses 53 | ^^^^^^ help: remove these parentheses
42 54
43warning: denote infinite loops with `loop { ... }` 55warning: denote infinite loops with `loop { ... }`
44 --> $DIR/lint-unnecessary-parens.rs:39:5 56 --> $DIR/lint-unnecessary-parens.rs:46:5
45 | 57 |
46LL | while (true) {} 58LL | while (true) {}
47 | ^^^^^^^^^^^^ help: use `loop` 59 | ^^^^^^^^^^^^ help: use `loop`
@@ -49,46 +61,46 @@ LL | while (true) {}
49 = note: `#[warn(while_true)]` on by default 61 = note: `#[warn(while_true)]` on by default
50 62
51error: unnecessary parentheses around `match` head expression 63error: unnecessary parentheses around `match` head expression
52 --> $DIR/lint-unnecessary-parens.rs:41:11 64 --> $DIR/lint-unnecessary-parens.rs:48:11
53 | 65 |
54LL | match (true) { 66LL | match (true) {
55 | ^^^^^^ help: remove these parentheses 67 | ^^^^^^ help: remove these parentheses
56 68
57error: unnecessary parentheses around `let` head expression 69error: unnecessary parentheses around `let` head expression
58 --> $DIR/lint-unnecessary-parens.rs:44:16 70 --> $DIR/lint-unnecessary-parens.rs:51:16
59 | 71 |
60LL | if let 1 = (1) {} 72LL | if let 1 = (1) {}
61 | ^^^ help: remove these parentheses 73 | ^^^ help: remove these parentheses
62 74
63error: unnecessary parentheses around `let` head expression 75error: unnecessary parentheses around `let` head expression
64 --> $DIR/lint-unnecessary-parens.rs:45:19 76 --> $DIR/lint-unnecessary-parens.rs:52:19
65 | 77 |
66LL | while let 1 = (2) {} 78LL | while let 1 = (2) {}
67 | ^^^ help: remove these parentheses 79 | ^^^ help: remove these parentheses
68 80
69error: unnecessary parentheses around method argument 81error: unnecessary parentheses around method argument
70 --> $DIR/lint-unnecessary-parens.rs:59:24 82 --> $DIR/lint-unnecessary-parens.rs:66:24
71 | 83 |
72LL | X { y: false }.foo((true)); 84LL | X { y: false }.foo((true));
73 | ^^^^^^ help: remove these parentheses 85 | ^^^^^^ help: remove these parentheses
74 86
75error: unnecessary parentheses around assigned value 87error: unnecessary parentheses around assigned value
76 --> $DIR/lint-unnecessary-parens.rs:61:18 88 --> $DIR/lint-unnecessary-parens.rs:68:18
77 | 89 |
78LL | let mut _a = (0); 90LL | let mut _a = (0);
79 | ^^^ help: remove these parentheses 91 | ^^^ help: remove these parentheses
80 92
81error: unnecessary parentheses around assigned value 93error: unnecessary parentheses around assigned value
82 --> $DIR/lint-unnecessary-parens.rs:62:10 94 --> $DIR/lint-unnecessary-parens.rs:69:10
83 | 95 |
84LL | _a = (0); 96LL | _a = (0);
85 | ^^^ help: remove these parentheses 97 | ^^^ help: remove these parentheses
86 98
87error: unnecessary parentheses around assigned value 99error: unnecessary parentheses around assigned value
88 --> $DIR/lint-unnecessary-parens.rs:63:11 100 --> $DIR/lint-unnecessary-parens.rs:70:11
89 | 101 |
90LL | _a += (1); 102LL | _a += (1);
91 | ^^^ help: remove these parentheses 103 | ^^^ help: remove these parentheses
92 104
93error: aborting due to 13 previous errors 105error: aborting due to 15 previous errors
94 106
diff --git a/src/test/ui/suggestions/for-i-in-vec.fixed b/src/test/ui/suggestions/for-i-in-vec.fixed
new file mode 100644
index 0000000..ec7358b
--- /dev/null
+++ b/src/test/ui/suggestions/for-i-in-vec.fixed
@@ -0,0 +1,15 @@
1// run-rustfix
2#![allow(dead_code)]
3
4struct Foo {
5 v: Vec<u32>,
6}
7
8impl Foo {
9 fn bar(&self) {
10 for _ in &self.v { //~ ERROR cannot move out of `self.v` which is behind a shared reference
11 }
12 }
13}
14
15fn main() {}
diff --git a/src/test/ui/suggestions/for-i-in-vec.rs b/src/test/ui/suggestions/for-i-in-vec.rs
new file mode 100644
index 0000000..304fe8c
--- /dev/null
+++ b/src/test/ui/suggestions/for-i-in-vec.rs
@@ -0,0 +1,15 @@
1// run-rustfix
2#![allow(dead_code)]
3
4struct Foo {
5 v: Vec<u32>,
6}
7
8impl Foo {
9 fn bar(&self) {
10 for _ in self.v { //~ ERROR cannot move out of `self.v` which is behind a shared reference
11 }
12 }
13}
14
15fn main() {}
diff --git a/src/test/ui/suggestions/for-i-in-vec.stderr b/src/test/ui/suggestions/for-i-in-vec.stderr
new file mode 100644
index 0000000..576a7cc
--- /dev/null
+++ b/src/test/ui/suggestions/for-i-in-vec.stderr
@@ -0,0 +1,12 @@
1error[E0507]: cannot move out of `self.v` which is behind a shared reference
2 --> $DIR/for-i-in-vec.rs:10:18
3 |
4LL | for _ in self.v {
5 | ^^^^^^
6 | |
7 | move occurs because `self.v` has type `std::vec::Vec<u32>`, which does not implement the `Copy` trait
8 | help: consider iterating over a slice of the `Vec<_>`'s content: `&self.v`
9
10error: aborting due to previous error
11
12For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs
new file mode 100644
index 0000000..d00f8d7
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs
@@ -0,0 +1,13 @@
1// Regression test for issue #68368
2// Ensures that we don't ICE when emitting an error
3// for a non-defining use when lifetimes are involved
4
5#![feature(type_alias_impl_trait)]
6trait Trait<T> {}
7type Alias<'a, U> = impl Trait<U>; //~ ERROR could not find defining uses
8fn f<'a>() -> Alias<'a, ()> {}
9//~^ ERROR defining opaque type use does not fully define opaque type: generic parameter `U`
10
11fn main() {}
12
13impl Trait<()> for () {}
diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr
new file mode 100644
index 0000000..b585942
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr
@@ -0,0 +1,14 @@
1error: defining opaque type use does not fully define opaque type: generic parameter `U` is specified as concrete type `()`
2 --> $DIR/issue-68368-non-defining-use.rs:8:1
3 |
4LL | fn f<'a>() -> Alias<'a, ()> {}
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6
7error: could not find defining uses
8 --> $DIR/issue-68368-non-defining-use.rs:7:1
9 |
10LL | type Alias<'a, U> = impl Trait<U>;
11 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12
13error: aborting due to 2 previous errors
14