From dbb65199378b394a42180edd4cab88bc914b1385 Mon Sep 17 00:00:00 2001 From: ritiek Date: Sat, 20 Jan 2018 11:14:03 +0530 Subject: [PATCH 01/11] NLL test for mutating &mut references --- src/test/run-pass/nll/mutating_references.rs | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/run-pass/nll/mutating_references.rs diff --git a/src/test/run-pass/nll/mutating_references.rs b/src/test/run-pass/nll/mutating_references.rs new file mode 100644 index 0000000000000..f1511875a95e2 --- /dev/null +++ b/src/test/run-pass/nll/mutating_references.rs @@ -0,0 +1,34 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +struct List { + value: T, + next: Option>>, +} + +fn to_refs(mut list: &mut List) -> Vec<&mut T> { + let mut result = vec![]; + loop { + result.push(&mut list.value); + if let Some(n) = list.next.as_mut() { + list = n; + } else { + return result; + } + } +} + +fn main() { + let mut list = List { value: 1, next: None }; + let vec = to_refs(&mut list); + assert_eq!(vec![&mut 1], vec); +} From 4121ddb041aaa20769c8b31bc6496906c6330170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 17 Jan 2018 20:15:13 -0800 Subject: [PATCH 02/11] Do not suggest private traits that have missing method When encountering a method call for an ADT that doesn't have any implementation of it, we search for traits that could be implemented that do have that method. Filter out private non-local traits that would not be able to be implemented. This doesn't account for public traits that are in a private scope, but works as a first approximation and is a more correct behavior than the current one. --- src/librustc_typeck/check/method/suggest.rs | 9 +++++++-- src/librustc_typeck/lib.rs | 3 ++- .../impl-trait/no-method-suggested-traits.stderr | 12 ++++-------- src/test/ui/method-call-err-msg.stderr | 6 ++---- .../dont-suggest-private-trait-method.rs | 16 ++++++++++++++++ .../dont-suggest-private-trait-method.stderr | 11 +++++++++++ 6 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 src/test/ui/suggestions/dont-suggest-private-trait-method.rs create mode 100644 src/test/ui/suggestions/dont-suggest-private-trait-method.stderr diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 3f8792aa637a9..4556b5a42b3d6 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -513,8 +513,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // this isn't perfect (that is, there are cases when // implementing a trait would be legal but is rejected // here). - (type_is_local || info.def_id.is_local()) - && self.associated_item(info.def_id, item_name, Namespace::Value).is_some() + (type_is_local || info.def_id.is_local()) && + self.associated_item(info.def_id, item_name, Namespace::Value) + .filter(|item| { + // We only want to suggest public or local traits (#45781). + item.vis == ty::Visibility::Public || info.def_id.is_local() + }) + .is_some() }) .collect::>(); diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 786a678344064..75a74e1069c31 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -75,12 +75,13 @@ This API is completely unstable and subject to change. #![feature(advanced_slice_patterns)] #![feature(box_patterns)] #![feature(box_syntax)] -#![feature(crate_visibility_modifier)] #![feature(conservative_impl_trait)] #![feature(copy_closures, clone_closures)] +#![feature(crate_visibility_modifier)] #![feature(from_ref)] #![feature(match_default_bindings)] #![feature(never_type)] +#![feature(option_filter)] #![feature(quote)] #![feature(refcell_replace_swap)] #![feature(rustc_diagnostic_macros)] diff --git a/src/test/ui/impl-trait/no-method-suggested-traits.stderr b/src/test/ui/impl-trait/no-method-suggested-traits.stderr index 4517f09d07c32..882113b8176ea 100644 --- a/src/test/ui/impl-trait/no-method-suggested-traits.stderr +++ b/src/test/ui/impl-trait/no-method-suggested-traits.stderr @@ -95,10 +95,8 @@ error[E0599]: no method named `method` found for type `Foo` in the current scope = note: the following traits define an item `method`, perhaps you need to implement one of them: candidate #1: `foo::Bar` candidate #2: `no_method_suggested_traits::foo::PubPub` - candidate #3: `no_method_suggested_traits::bar::PubPriv` - candidate #4: `no_method_suggested_traits::qux::PrivPub` - candidate #5: `no_method_suggested_traits::quz::PrivPriv` - candidate #6: `no_method_suggested_traits::Reexported` + candidate #3: `no_method_suggested_traits::qux::PrivPub` + candidate #4: `no_method_suggested_traits::Reexported` error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::boxed::Box<&Foo>>` in the current scope --> $DIR/no-method-suggested-traits.rs:52:43 @@ -110,10 +108,8 @@ error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::box = note: the following traits define an item `method`, perhaps you need to implement one of them: candidate #1: `foo::Bar` candidate #2: `no_method_suggested_traits::foo::PubPub` - candidate #3: `no_method_suggested_traits::bar::PubPriv` - candidate #4: `no_method_suggested_traits::qux::PrivPub` - candidate #5: `no_method_suggested_traits::quz::PrivPriv` - candidate #6: `no_method_suggested_traits::Reexported` + candidate #3: `no_method_suggested_traits::qux::PrivPub` + candidate #4: `no_method_suggested_traits::Reexported` error[E0599]: no method named `method2` found for type `u64` in the current scope --> $DIR/no-method-suggested-traits.rs:55:10 diff --git a/src/test/ui/method-call-err-msg.stderr b/src/test/ui/method-call-err-msg.stderr index 8685d0fc9c134..f9524696ed724 100644 --- a/src/test/ui/method-call-err-msg.stderr +++ b/src/test/ui/method-call-err-msg.stderr @@ -38,10 +38,8 @@ error[E0599]: no method named `take` found for type `Foo` in the current scope `&mut Foo : std::iter::Iterator` = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `take`, perhaps you need to implement one of them: - candidate #1: `std::collections::hash::Recover` - candidate #2: `std::io::Read` - candidate #3: `std::iter::Iterator` - candidate #4: `alloc::btree::Recover` + candidate #1: `std::io::Read` + candidate #2: `std::iter::Iterator` error: aborting due to 4 previous errors diff --git a/src/test/ui/suggestions/dont-suggest-private-trait-method.rs b/src/test/ui/suggestions/dont-suggest-private-trait-method.rs new file mode 100644 index 0000000000000..99bee0d3c59e2 --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-private-trait-method.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct T; + +fn main() { + T::new(); + //~^ ERROR no function or associated item named `new` found for type `T` in the current scope +} diff --git a/src/test/ui/suggestions/dont-suggest-private-trait-method.stderr b/src/test/ui/suggestions/dont-suggest-private-trait-method.stderr new file mode 100644 index 0000000000000..97f424f9fbf6d --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-private-trait-method.stderr @@ -0,0 +1,11 @@ +error[E0599]: no function or associated item named `new` found for type `T` in the current scope + --> $DIR/dont-suggest-private-trait-method.rs:14:5 + | +11 | struct T; + | --------- function or associated item `new` not found for this +... +14 | T::new(); + | ^^^^^^ function or associated item not found in `T` + +error: aborting due to previous error + From 5de8e040d2ed8f3d9da79a4f12b9ece51c352f2e Mon Sep 17 00:00:00 2001 From: Ryan Cumming Date: Tue, 23 Jan 2018 19:42:46 +1100 Subject: [PATCH 03/11] Remove broken redundant backtrace hint When the compiler driver panics it attempts to show a hint about using `RUST_BACKTRACE`. However, the logic is currently reversed to the hint is only shown if `RUST_BACKTRACE` is *already* set: ```shell > RUST_BACKTRACE=1 rustc /dev/null --crate-type proc-macro error: internal compiler error: unexpected panic ... note: run with `RUST_BACKTRACE=1` for a backtrace thread 'rustc' panicked at 'attempt to subtract with overflow', librustc_errors/emitter.rs:287:49 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. > RUST_BACKTRACE=0 rustc /dev/null --crate-type proc-macro error: internal compiler error: unexpected panic ... thread 'rustc' panicked at 'attempt to subtract with overflow', librustc_errors/emitter.rs:287:49 note: Run with `RUST_BACKTRACE=1` for a backtrace. ``` As the `panic` itself already has a working `RUST_BACKTRACE` hint just remove the broken duplicate hint entirely. --- src/librustc_driver/lib.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index de5559c8b1440..53586c47ae0a8 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1276,14 +1276,6 @@ pub fn monitor(f: F) { ¬e, errors::Level::Note); } - if match env::var_os("RUST_BACKTRACE") { - Some(val) => &val != "0", - None => false, - } { - handler.emit(&MultiSpan::new(), - "run with `RUST_BACKTRACE=1` for a backtrace", - errors::Level::Note); - } eprintln!("{}", str::from_utf8(&data.lock().unwrap()).unwrap()); } From 06d123d4be25d8c9f24e562f8e6c0c21c549a423 Mon Sep 17 00:00:00 2001 From: ritiek Date: Tue, 23 Jan 2018 22:45:10 +0530 Subject: [PATCH 04/11] Remove similar test that does not run the result --- .../borrowck-nll-iterating-and-updating.rs | 34 ------------------- src/test/run-pass/nll/mutating_references.rs | 2 +- 2 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 src/test/run-pass/borrowck/borrowck-nll-iterating-and-updating.rs diff --git a/src/test/run-pass/borrowck/borrowck-nll-iterating-and-updating.rs b/src/test/run-pass/borrowck/borrowck-nll-iterating-and-updating.rs deleted file mode 100644 index 043f1215ea572..0000000000000 --- a/src/test/run-pass/borrowck/borrowck-nll-iterating-and-updating.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z borrowck=mir -Z nll - -// This example comes from the NLL RFC. - -struct List { - value: T, - next: Option>>, -} - -fn to_refs(list: &mut List) -> Vec<&mut T> { - let mut list = list; - let mut result = vec![]; - loop { - result.push(&mut list.value); - if let Some(n) = list.next.as_mut() { - list = n; - } else { - return result; - } - } -} - -fn main() { -} diff --git a/src/test/run-pass/nll/mutating_references.rs b/src/test/run-pass/nll/mutating_references.rs index f1511875a95e2..96b7362e4d939 100644 --- a/src/test/run-pass/nll/mutating_references.rs +++ b/src/test/run-pass/nll/mutating_references.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // From e6af9ebea280aac2fc98e67816403ec350aba7b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 23 Jan 2018 15:34:16 -0800 Subject: [PATCH 05/11] Point at unknown lang item attribute --- src/librustc/middle/lang_items.rs | 16 +++++++++------- src/librustc/middle/weak_lang_items.rs | 4 ++-- src/test/compile-fail/E0522.rs | 3 ++- src/test/ui/unknown-language-item.rs | 20 ++++++++++++++++++++ src/test/ui/unknown-language-item.stderr | 8 ++++++++ 5 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 src/test/ui/unknown-language-item.rs create mode 100644 src/test/ui/unknown-language-item.stderr diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index dca676130b9a7..447ce46ee5c5c 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -28,6 +28,7 @@ use util::nodemap::FxHashMap; use syntax::ast; use syntax::symbol::Symbol; +use syntax_pos::Span; use hir::itemlikevisit::ItemLikeVisitor; use hir; @@ -104,17 +105,18 @@ struct LanguageItemCollector<'a, 'tcx: 'a> { impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { - if let Some(value) = extract(&item.attrs) { + if let Some((value, span)) = extract(&item.attrs) { let item_index = self.item_refs.get(&*value.as_str()).cloned(); if let Some(item_index) = item_index { let def_id = self.tcx.hir.local_def_id(item.id); self.collect_item(item_index, def_id); } else { - let span = self.tcx.hir.span(item.id); - span_err!(self.tcx.sess, span, E0522, - "definition of an unknown language item: `{}`.", - value); + let mut err = struct_span_err!(self.tcx.sess, span, E0522, + "definition of an unknown language item: `{}`", + value); + err.span_label(span, format!("definition of unknown language item `{}`", value)); + err.emit(); } } } @@ -177,11 +179,11 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> { } } -pub fn extract(attrs: &[ast::Attribute]) -> Option { +pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> { for attribute in attrs { if attribute.check_name("lang") { if let Some(value) = attribute.value_str() { - return Some(value) + return Some((value, attribute.span)); } } } diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index 50fb584070262..95e75b4f0646e 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -55,7 +55,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } pub fn link_name(attrs: &[ast::Attribute]) -> Option { - lang_items::extract(attrs).and_then(|name| { + lang_items::extract(attrs).and_then(|(name, _)| { $(if name == stringify!($name) { Some(Symbol::intern(stringify!($sym))) } else)* { @@ -129,7 +129,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> { } fn visit_foreign_item(&mut self, i: &hir::ForeignItem) { - if let Some(lang_item) = lang_items::extract(&i.attrs) { + if let Some((lang_item, _)) = lang_items::extract(&i.attrs) { self.register(&lang_item.as_str(), i.span); } intravisit::walk_foreign_item(self, i) diff --git a/src/test/compile-fail/E0522.rs b/src/test/compile-fail/E0522.rs index 5103c83cafce3..3d4377853464b 100644 --- a/src/test/compile-fail/E0522.rs +++ b/src/test/compile-fail/E0522.rs @@ -11,6 +11,7 @@ #![feature(lang_items)] #[lang = "cookie"] -fn cookie() -> ! { //~ E0522 +fn cookie() -> ! { +//~^^ ERROR definition of an unknown language item: `cookie` [E0522] loop {} } diff --git a/src/test/ui/unknown-language-item.rs b/src/test/ui/unknown-language-item.rs new file mode 100644 index 0000000000000..3c2105997127d --- /dev/null +++ b/src/test/ui/unknown-language-item.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] +#![feature(lang_items)] + +#[lang = "foo"] +fn bar() -> ! { +//~^^ ERROR definition of an unknown language item: `foo` + loop {} +} + +fn main() {} diff --git a/src/test/ui/unknown-language-item.stderr b/src/test/ui/unknown-language-item.stderr new file mode 100644 index 0000000000000..c4b4a789c3dcc --- /dev/null +++ b/src/test/ui/unknown-language-item.stderr @@ -0,0 +1,8 @@ +error[E0522]: definition of an unknown language item: `foo` + --> $DIR/unknown-language-item.rs:14:1 + | +14 | #[lang = "foo"] + | ^^^^^^^^^^^^^^^ definition of unknown language item `foo` + +error: aborting due to previous error + From 583b382debc028d7003850ca6970798515a2fbee Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 24 Jan 2018 08:30:17 +0100 Subject: [PATCH 06/11] Remove workarounds for cc 1.0.3. Now that the Rust codebase depends on cc 1.0.4, there is no longer any need to specify a compiler for CloudABI manually. Cargo will automatically call into the right compiler executable. --- src/ci/docker/dist-various-2/Dockerfile | 7 ------- src/ci/docker/dist-various-2/build-cloudabi-toolchain.sh | 6 ------ 2 files changed, 13 deletions(-) diff --git a/src/ci/docker/dist-various-2/Dockerfile b/src/ci/docker/dist-various-2/Dockerfile index d8f09bf47a491..5f342eb570502 100644 --- a/src/ci/docker/dist-various-2/Dockerfile +++ b/src/ci/docker/dist-various-2/Dockerfile @@ -47,13 +47,6 @@ ENV \ CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc \ CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++ -# FIXME(EdSchouten): Remove this once cc ≥1.0.4 has been merged. It can -# automatically pick the right compiler path. -ENV \ - AR_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-ar \ - CC_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang \ - CXX_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang++ - ENV TARGETS=x86_64-unknown-fuchsia ENV TARGETS=$TARGETS,aarch64-unknown-fuchsia ENV TARGETS=$TARGETS,sparcv9-sun-solaris diff --git a/src/ci/docker/dist-various-2/build-cloudabi-toolchain.sh b/src/ci/docker/dist-various-2/build-cloudabi-toolchain.sh index d64da43663997..8c04d849e8d0a 100755 --- a/src/ci/docker/dist-various-2/build-cloudabi-toolchain.sh +++ b/src/ci/docker/dist-various-2/build-cloudabi-toolchain.sh @@ -40,12 +40,6 @@ ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-c++ ln -s ../lib/llvm-5.0/bin/lld /usr/bin/${target}-ld ln -s ../../${target} /usr/lib/llvm-5.0/${target} -# FIXME(EdSchouten): Remove this once cc ≥1.0.4 has been merged. It -# can make use of ${target}-cc and ${target}-c++, without incorrectly -# assuming it's MSVC. -ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-clang -ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-clang++ - # Install the C++ runtime libraries from CloudABI Ports. echo deb https://nuxi.nl/distfiles/cloudabi-ports/debian/ cloudabi cloudabi > \ /etc/apt/sources.list.d/cloudabi.list From 65b1e86aed22bfcd3a4ce27da9be2b14c7d5738e Mon Sep 17 00:00:00 2001 From: Ryan Cumming Date: Wed, 24 Jan 2018 20:31:36 +1100 Subject: [PATCH 07/11] Fix into() cast paren check precedence As discussed in #47699 the logic for determining if an expression needs parenthesis when suggesting an `.into()` cast is incorrect. Two broken examples from nightly are: ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(foo as i8); | ^^^^^^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(foo as i8.into()); | ``` ``` error[E0308]: mismatched types --> main.rs:4:10 | 4 | test(*foo); | ^^^^ expected i32, found i8 help: you can cast an `i8` to `i32`, which will sign-extend the source value | 4 | test(*foo.into()); | ``` As suggested by @petrochenkov switch the precedence check to PREC_POSTFIX. This catches both `as` and unary operators. Fixes #47699. --- src/librustc_typeck/check/demand.rs | 4 ++-- src/test/ui/suggestions/numeric-cast.rs | 5 +++++ src/test/ui/suggestions/numeric-cast.stderr | 22 ++++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index b6b863cfea6e6..d2702d0810ed9 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -15,7 +15,7 @@ use rustc::infer::InferOk; use rustc::traits::ObligationCause; use syntax::ast; -use syntax::util::parser::AssocOp; +use syntax::util::parser::PREC_POSTFIX; use syntax_pos::{self, Span}; use rustc::hir; use rustc::hir::print; @@ -336,7 +336,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // For now, don't suggest casting with `as`. let can_cast = false; - let needs_paren = expr.precedence().order() < (AssocOp::As.precedence() as i8); + let needs_paren = expr.precedence().order() < (PREC_POSTFIX as i8); if let Ok(src) = self.tcx.sess.codemap().span_to_snippet(expr.span) { let msg = format!("you can cast an `{}` to `{}`", checked_ty, expected_ty); diff --git a/src/test/ui/suggestions/numeric-cast.rs b/src/test/ui/suggestions/numeric-cast.rs index 6e144037ec220..69bfdfa94b13e 100644 --- a/src/test/ui/suggestions/numeric-cast.rs +++ b/src/test/ui/suggestions/numeric-cast.rs @@ -312,4 +312,9 @@ fn main() { foo::(x_f64); //~^ ERROR mismatched types foo::(x_f32); + + foo::(x_u8 as u16); + //~^ ERROR mismatched types + foo::(-x_i8); + //~^ ERROR mismatched types } diff --git a/src/test/ui/suggestions/numeric-cast.stderr b/src/test/ui/suggestions/numeric-cast.stderr index 0ce3d087f3509..cef22ad922e84 100644 --- a/src/test/ui/suggestions/numeric-cast.stderr +++ b/src/test/ui/suggestions/numeric-cast.stderr @@ -882,5 +882,25 @@ error[E0308]: mismatched types 312 | foo::(x_f64); | ^^^^^ expected f32, found f64 -error: aborting due to 132 previous errors +error[E0308]: mismatched types + --> $DIR/numeric-cast.rs:316:16 + | +316 | foo::(x_u8 as u16); + | ^^^^^^^^^^^ expected u32, found u16 +help: you can cast an `u16` to `u32`, which will zero-extend the source value + | +316 | foo::((x_u8 as u16).into()); + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast.rs:318:16 + | +318 | foo::(-x_i8); + | ^^^^^ expected i32, found i8 +help: you can cast an `i8` to `i32`, which will sign-extend the source value + | +318 | foo::((-x_i8).into()); + | ^^^^^^^^^^^^^^ + +error: aborting due to 134 previous errors From 05652d2ae32cb9116c68e36b119fbbc816c4dc37 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 24 Jan 2018 09:25:46 -0700 Subject: [PATCH 08/11] fix for documentation error issue 47716 --- src/doc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/README.md b/src/doc/README.md index e1d95732b467c..5f25894afd76d 100644 --- a/src/doc/README.md +++ b/src/doc/README.md @@ -29,4 +29,4 @@ rustdoc reference.md An overview of how to use the `rustdoc` command is available [in the docs][1]. Further details are available from the command line by with `rustdoc --help`. -[1]: https://github.com/rust-lang/rust/blob/master/src/doc/book/documentation.md +[1]: https://github.com/rust-lang/rust/blob/master/src/doc/rustdoc/src/what-is-rustdoc.md From e1e991d3d20158823bb517c9eb3ad984ea4b6f81 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 24 Jan 2018 19:15:41 +0100 Subject: [PATCH 09/11] Fix experimental text display on default theme --- src/librustdoc/html/static/themes/main.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustdoc/html/static/themes/main.css b/src/librustdoc/html/static/themes/main.css index 84b21e7239fc1..1c3b6cb9c6d87 100644 --- a/src/librustdoc/html/static/themes/main.css +++ b/src/librustdoc/html/static/themes/main.css @@ -189,6 +189,10 @@ a.test-arrow { .stab.deprecated { background: #F3DFFF; border-color: #7F0087; } .stab.portability { background: #C4ECFF; border-color: #7BA5DB; } +.module-item .stab { + color: #000; +} + #help > div { background: #e9e9e9; border-color: #bfbfbf; From 0847ac026568b70f0927b85a1a2e3d2f79a6b48f Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 24 Jan 2018 23:32:17 +0100 Subject: [PATCH 10/11] Fix wrong span for nested empty groups --- src/librustc_resolve/check_unused.rs | 9 ++++++- ...import-generates-unused-import-lint.stderr | 14 ---------- ...rs => use-nested-groups-unused-imports.rs} | 19 +++++++++++--- .../use-nested-groups-unused-imports.stderr | 26 +++++++++++++++++++ 4 files changed, 50 insertions(+), 18 deletions(-) delete mode 100644 src/test/ui/owl-import-generates-unused-import-lint.stderr rename src/test/ui/{owl-import-generates-unused-import-lint.rs => use-nested-groups-unused-imports.rs} (52%) create mode 100644 src/test/ui/use-nested-groups-unused-imports.stderr diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 0fb3d96cd50d4..5a321053b7ae8 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -102,11 +102,18 @@ impl<'a, 'b> Visitor<'a> for UnusedImportCheckVisitor<'a, 'b> { } if let ast::UseTreeKind::Nested(ref items) = use_tree.kind { + // If it's the parent group, cover the entire use item + let span = if nested { + use_tree.span + } else { + self.item_span + }; + if items.len() == 0 { self.unused_imports .entry(self.base_id) .or_insert_with(NodeMap) - .insert(id, self.item_span); + .insert(id, span); } } else { let base_id = self.base_id; diff --git a/src/test/ui/owl-import-generates-unused-import-lint.stderr b/src/test/ui/owl-import-generates-unused-import-lint.stderr deleted file mode 100644 index 79089b2a93c73..0000000000000 --- a/src/test/ui/owl-import-generates-unused-import-lint.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unused import: `*` - --> $DIR/owl-import-generates-unused-import-lint.rs:18:14 - | -18 | use foo::{*, *}; //~ ERROR unused import: `*` - | ^ - | -note: lint level defined here - --> $DIR/owl-import-generates-unused-import-lint.rs:12:9 - | -12 | #![deny(unused_imports)] - | ^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/owl-import-generates-unused-import-lint.rs b/src/test/ui/use-nested-groups-unused-imports.rs similarity index 52% rename from src/test/ui/owl-import-generates-unused-import-lint.rs rename to src/test/ui/use-nested-groups-unused-imports.rs index dc30c31835299..ddbf54fdd48b1 100644 --- a/src/test/ui/owl-import-generates-unused-import-lint.rs +++ b/src/test/ui/use-nested-groups-unused-imports.rs @@ -1,4 +1,4 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -9,13 +9,26 @@ // except according to those terms. #![feature(use_nested_groups)] +#![allow(dead_code)] #![deny(unused_imports)] mod foo { - pub enum Bar {} + pub mod bar { + pub mod baz { + pub struct Bar(); + } + pub mod foobar {} + } + + pub struct Foo(); } -use foo::{*, *}; //~ ERROR unused import: `*` +use foo::{Foo, bar::{baz::{}, foobar::*}, *}; + //~^ ERROR unused imports: `*`, `Foo`, `baz::{}`, `foobar::*` +use foo::bar::baz::{*, *}; + //~^ ERROR unused import: `*` +use foo::{}; + //~^ ERROR unused import: `use foo::{};` fn main() { let _: Bar; diff --git a/src/test/ui/use-nested-groups-unused-imports.stderr b/src/test/ui/use-nested-groups-unused-imports.stderr new file mode 100644 index 0000000000000..0686310dbf53a --- /dev/null +++ b/src/test/ui/use-nested-groups-unused-imports.stderr @@ -0,0 +1,26 @@ +error: unused imports: `*`, `Foo`, `baz::{}`, `foobar::*` + --> $DIR/use-nested-groups-unused-imports.rs:26:11 + | +26 | use foo::{Foo, bar::{baz::{}, foobar::*}, *}; + | ^^^ ^^^^^^^ ^^^^^^^^^ ^ + | +note: lint level defined here + --> $DIR/use-nested-groups-unused-imports.rs:13:9 + | +13 | #![deny(unused_imports)] + | ^^^^^^^^^^^^^^ + +error: unused import: `*` + --> $DIR/use-nested-groups-unused-imports.rs:28:24 + | +28 | use foo::bar::baz::{*, *}; + | ^ + +error: unused import: `use foo::{};` + --> $DIR/use-nested-groups-unused-imports.rs:30:1 + | +30 | use foo::{}; + | ^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + From 15899b0c1204ca7e2eac0ca9dd048650738d44d6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 Jan 2018 20:01:42 -0800 Subject: [PATCH 11/11] Update Cargo submodule to master Just a routine update --- src/Cargo.lock | 36 +++++++++++++++++++++++++++++++++++- src/tools/cargo | 2 +- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index ae9e755b7a0e4..7bf343ba3f61f 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -179,7 +179,7 @@ dependencies = [ "crypto-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -265,6 +265,15 @@ name = "cfg-if" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "chrono" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "clap" version = "2.29.0" @@ -601,6 +610,18 @@ dependencies = [ "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "env_logger" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "error-chain" version = "0.8.1" @@ -2654,6 +2675,16 @@ dependencies = [ name = "tidy" version = "0.1.0" +[[package]] +name = "time" +version = "0.1.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "toml" version = "0.2.1" @@ -2903,6 +2934,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum cargo_metadata 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20d6fb2b5574726329c85cdba0df0347fddfec3cf9c8b588f9931708280f5643" "checksum cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "deaf9ec656256bb25b404c51ef50097207b9cbb29c933d31f92cae5a8a0ffee0" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" +"checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" "checksum clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)" = "110d43e343eb29f4f51c1db31beb879d546db27998577e5715270a54bcf41d3f" "checksum cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "56d741ea7a69e577f6d06b36b7dff4738f680593dc27a701ffa8506b73ce28bb" "checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd" @@ -2929,6 +2961,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" "checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" +"checksum env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f15f0b172cb4f52ed5dbf47f774a387cd2315d1bf7894ab5af9b083ae27efa5a" "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" "checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" "checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" @@ -3085,6 +3118,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" "checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" +"checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098" "checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" diff --git a/src/tools/cargo b/src/tools/cargo index 6a8eb71f6d226..91e36aa86c703 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 6a8eb71f6d226f9ac869dbacd5ff6aa76deef1c4 +Subproject commit 91e36aa86c7037de50642f2fec1cf47c3d18af02