diff options
| author | bors <bors@rust-lang.org> | 2019-09-10 00:34:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-09-10 00:34:30 +0000 |
| commit | 122fefc63e4c2bab7f76bb24a7ab056b7bc7b37e (patch) | |
| tree | 62514217c15a544da797ecfea60d64cfd0a13307 /src | |
| parent | 0b36e9dea3f2ff25b1d0df2669836c33cce89ae5 (diff) | |
| parent | 342722e584ce08b97509de73bb76d6ccc6c68423 (diff) | |
| download | rust-122fefc63e4c2bab7f76bb24a7ab056b7bc7b37e.tar.gz rust-122fefc63e4c2bab7f76bb24a7ab056b7bc7b37e.zip | |
Auto merge of #64321 - Centril:rollup-jsj5tpl, r=Centril
Rollup of 5 pull requests Successful merges: - #63806 (Upgrade rand to 0.7) - #64054 (Always emit unresolved import errors and hide unused import lint) - #64279 (Bump RLS and Rustfmt submodules to use rustc-ap-* v583) - #64317 (Update LLVM submodule) - #64320 (Update version of `rustc-std-workspace-*` crates) Failed merges: r? @ghost
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_incremental/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/librustc_resolve/resolve_imports.rs | 89 | ||||
| -rw-r--r-- | src/libstd/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/libstd/fs.rs | 2 | ||||
| -rw-r--r-- | src/libstd/tests/env.rs | 2 | ||||
| m--------- | src/llvm-project | 0 | ||||
| -rw-r--r-- | src/test/ui/extenv/issue-55897.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/extenv/issue-55897.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/imports/unresolved-imports-used.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/imports/unresolved-imports-used.stderr | 26 | ||||
| -rw-r--r-- | src/test/ui/rust-2018/uniform-paths/deadlock.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/rust-2018/uniform-paths/deadlock.stderr | 6 | ||||
| m--------- | src/tools/rls | 0 | ||||
| -rw-r--r-- | src/tools/rustc-std-workspace-alloc/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/tools/rustc-std-workspace-core/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/tools/rustc-std-workspace-std/Cargo.toml | 2 | ||||
| m--------- | src/tools/rustfmt | 36 |
17 files changed, 121 insertions, 70 deletions
diff --git a/src/librustc_incremental/Cargo.toml b/src/librustc_incremental/Cargo.toml index a931ad3b66e..659c4c89fe3 100644 --- a/src/librustc_incremental/Cargo.toml +++ b/src/librustc_incremental/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] graphviz = { path = "../libgraphviz" } log = "0.4" -rand = "0.6" +rand = "0.7" rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_serialize = { path = "../libserialize", package = "serialize" } diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 132690dcd7d..eb509f1a01d 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -71,7 +71,7 @@ pub enum ImportDirectiveSubclass<'a> { } /// One import directive. -#[derive(Debug,Clone)] +#[derive(Debug, Clone)] crate struct ImportDirective<'a> { /// The ID of the `extern crate`, `UseTree` etc that imported this `ImportDirective`. /// @@ -447,12 +447,13 @@ impl<'a> Resolver<'a> { } // Define the name or return the existing binding if there is a collision. - pub fn try_define(&mut self, - module: Module<'a>, - ident: Ident, - ns: Namespace, - binding: &'a NameBinding<'a>) - -> Result<(), &'a NameBinding<'a>> { + pub fn try_define( + &mut self, + module: Module<'a>, + ident: Ident, + ns: Namespace, + binding: &'a NameBinding<'a>, + ) -> Result<(), &'a NameBinding<'a>> { let res = binding.res(); self.check_reserved_macro_name(ident, res); self.set_binding_parent_module(binding, module); @@ -480,8 +481,11 @@ impl<'a> Resolver<'a> { }; if glob_binding.res() != nonglob_binding.res() && ns == MacroNS && nonglob_binding.expansion != ExpnId::root() { - resolution.binding = Some(this.ambiguity(AmbiguityKind::GlobVsExpanded, - nonglob_binding, glob_binding)); + resolution.binding = Some(this.ambiguity( + AmbiguityKind::GlobVsExpanded, + nonglob_binding, + glob_binding, + )); } else { resolution.binding = Some(nonglob_binding); } @@ -513,9 +517,11 @@ impl<'a> Resolver<'a> { }) } - fn ambiguity(&self, kind: AmbiguityKind, - primary_binding: &'a NameBinding<'a>, secondary_binding: &'a NameBinding<'a>) - -> &'a NameBinding<'a> { + fn ambiguity( + &self, kind: AmbiguityKind, + primary_binding: &'a NameBinding<'a>, + secondary_binding: &'a NameBinding<'a>, + ) -> &'a NameBinding<'a> { self.arenas.alloc_name_binding(NameBinding { ambiguity: Some((secondary_binding, kind)), ..primary_binding.clone() @@ -524,8 +530,12 @@ impl<'a> Resolver<'a> { // Use `f` to mutate the resolution of the name in the module. // If the resolution becomes a success, define it in the module's glob importers. - fn update_resolution<T, F>(&mut self, module: Module<'a>, ident: Ident, ns: Namespace, f: F) - -> T + fn update_resolution<T, F>( + &mut self, module: Module<'a>, + ident: Ident, + ns: Namespace, + f: F, + ) -> T where F: FnOnce(&mut Resolver<'a>, &mut NameResolution<'a>) -> T { // Ensure that `resolution` isn't borrowed when defining in the module's glob importers, @@ -627,14 +637,18 @@ impl<'a, 'b> ImportResolver<'a, 'b> { self.finalize_resolutions_in(module); } - let mut has_errors = false; let mut seen_spans = FxHashSet::default(); let mut errors = vec![]; let mut prev_root_id: NodeId = NodeId::from_u32(0); - for i in 0 .. self.r.determined_imports.len() { - let import = self.r.determined_imports[i]; + let determined_imports = mem::take(&mut self.r.determined_imports); + let indeterminate_imports = mem::take(&mut self.r.indeterminate_imports); + + for (is_indeterminate, import) in determined_imports + .into_iter() + .map(|i| (false, i)) + .chain(indeterminate_imports.into_iter().map(|i| (true, i))) + { if let Some(err) = self.finalize_import(import) { - has_errors = true; if let SingleImport { source, ref source_bindings, .. } = import.subclass { if source.name == kw::SelfLower { @@ -666,25 +680,27 @@ impl<'a, 'b> ImportResolver<'a, 'b> { errors.push((path, err)); prev_root_id = import.root_id; } + } else if is_indeterminate { + // Consider erroneous imports used to avoid duplicate diagnostics. + self.r.used_imports.insert((import.id, TypeNS)); + let path = import_path_to_string( + &import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(), + &import.subclass, + import.span, + ); + let err = UnresolvedImportError { + span: import.span, + label: None, + note: Vec::new(), + suggestion: None, + }; + errors.push((path, err)); } } if !errors.is_empty() { self.throw_unresolved_import_error(errors.clone(), None); } - - for import in &self.r.indeterminate_imports { - // Consider erroneous imports used to avoid duplicate diagnostics. - self.r.used_imports.insert((import.id, TypeNS)); - } - // Report unresolved imports only if no hard error was already reported - // to avoid generating multiple errors on the same import. - if !has_errors { - for import in &self.r.indeterminate_imports { - self.throw_unresolved_import_error(errors, Some(MultiSpan::from(import.span))); - break; - } - } } fn throw_unresolved_import_error( @@ -839,8 +855,14 @@ impl<'a, 'b> ImportResolver<'a, 'b> { ) -> Option<UnresolvedImportError> { let orig_vis = directive.vis.replace(ty::Visibility::Invisible); let prev_ambiguity_errors_len = self.r.ambiguity_errors.len(); - let path_res = self.r.resolve_path(&directive.module_path, None, &directive.parent_scope, - true, directive.span, directive.crate_lint()); + let path_res = self.r.resolve_path( + &directive.module_path, + None, + &directive.parent_scope, + true, + directive.span, + directive.crate_lint(), + ); let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len; directive.vis.set(orig_vis); if let PathResult::Failed { .. } | PathResult::NonModule(..) = path_res { @@ -903,7 +925,6 @@ impl<'a, 'b> ImportResolver<'a, 'b> { } } }; - return Some(err); } return None; diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index b5cbec7b0fa..20442abc588 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -38,7 +38,7 @@ features = [ optional = true [dev-dependencies] -rand = "0.6.1" +rand = "0.7" [target.x86_64-apple-darwin.dependencies] rustc_asan = { path = "../librustc_asan" } diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 5f76875bd66..b14e02a2cb4 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -2144,7 +2144,7 @@ mod tests { use crate::sys_common::io::test::{TempDir, tmpdir}; use crate::thread; - use rand::{rngs::StdRng, FromEntropy, RngCore}; + use rand::{rngs::StdRng, RngCore, SeedableRng}; #[cfg(windows)] use crate::os::windows::fs::{symlink_dir, symlink_file}; diff --git a/src/libstd/tests/env.rs b/src/libstd/tests/env.rs index 06fb5533afd..f8014cb2ad9 100644 --- a/src/libstd/tests/env.rs +++ b/src/libstd/tests/env.rs @@ -5,7 +5,7 @@ use rand::{thread_rng, Rng}; use rand::distributions::Alphanumeric; fn make_rand_name() -> OsString { - let mut rng = thread_rng(); + let rng = thread_rng(); let n = format!("TEST{}", rng.sample_iter(&Alphanumeric).take(10) .collect::<String>()); let n = OsString::from(n); diff --git a/src/llvm-project b/src/llvm-project -Subproject 48818e9f5d0f2d5978a9b43ad1a2e8d0b83f6aa +Subproject 71fe7ec06b85f612fc0e4eb4134c7a7d0f23fac diff --git a/src/test/ui/extenv/issue-55897.rs b/src/test/ui/extenv/issue-55897.rs index c3975f6b925..64c4107e898 100644 --- a/src/test/ui/extenv/issue-55897.rs +++ b/src/test/ui/extenv/issue-55897.rs @@ -1,7 +1,7 @@ use prelude::*; //~ ERROR unresolved import `prelude` mod unresolved_env { - use env; + use env; //~ ERROR unresolved import `env` include!(concat!(env!("NON_EXISTENT"), "/data.rs")); //~^ ERROR cannot determine resolution for the macro `env` diff --git a/src/test/ui/extenv/issue-55897.stderr b/src/test/ui/extenv/issue-55897.stderr index 9d68131beab..c57a467cdba 100644 --- a/src/test/ui/extenv/issue-55897.stderr +++ b/src/test/ui/extenv/issue-55897.stderr @@ -19,6 +19,12 @@ LL | use prelude::*; | unresolved import | help: a similar path exists: `std::prelude` +error[E0432]: unresolved import `env` + --> $DIR/issue-55897.rs:4:9 + | +LL | use env; + | ^^^ no `env` in the root + error: cannot determine resolution for the macro `env` --> $DIR/issue-55897.rs:6:22 | @@ -27,6 +33,6 @@ LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs")); | = note: import resolution is stuck, try simplifying macro imports -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/imports/unresolved-imports-used.rs b/src/test/ui/imports/unresolved-imports-used.rs index 5398dd63c89..75cf880192c 100644 --- a/src/test/ui/imports/unresolved-imports-used.rs +++ b/src/test/ui/imports/unresolved-imports-used.rs @@ -8,11 +8,11 @@ mod qux { use qux::quz; //~ ERROR function `quz` is private use qux::bar; //~ ERROR unresolved import `qux::bar` -use foo::bar; -use baz::*; +use foo::bar; //~ ERROR unresolved import `foo` +use baz::*; //~ ERROR unresolved import `baz` use qux::bar2; //~ ERROR unresolved import `qux::bar2` -use foo2::bar2; -use baz2::*; +use foo2::bar2;//~ ERROR unresolved import `foo2` +use baz2::*; //~ ERROR unresolved import `baz2` use qux::quy; //~ ERROR unused import fn main() {} diff --git a/src/test/ui/imports/unresolved-imports-used.stderr b/src/test/ui/imports/unresolved-imports-used.stderr index c9342d17a49..b341e8e0592 100644 --- a/src/test/ui/imports/unresolved-imports-used.stderr +++ b/src/test/ui/imports/unresolved-imports-used.stderr @@ -10,6 +10,30 @@ error[E0432]: unresolved import `qux::bar2` LL | use qux::bar2; | ^^^^^^^^^ no `bar2` in `qux` +error[E0432]: unresolved import `foo` + --> $DIR/unresolved-imports-used.rs:11:5 + | +LL | use foo::bar; + | ^^^ maybe a missing crate `foo`? + +error[E0432]: unresolved import `baz` + --> $DIR/unresolved-imports-used.rs:12:5 + | +LL | use baz::*; + | ^^^ maybe a missing crate `baz`? + +error[E0432]: unresolved import `foo2` + --> $DIR/unresolved-imports-used.rs:14:5 + | +LL | use foo2::bar2; + | ^^^^ maybe a missing crate `foo2`? + +error[E0432]: unresolved import `baz2` + --> $DIR/unresolved-imports-used.rs:15:5 + | +LL | use baz2::*; + | ^^^^ maybe a missing crate `baz2`? + error[E0603]: function `quz` is private --> $DIR/unresolved-imports-used.rs:9:10 | @@ -28,7 +52,7 @@ note: lint level defined here LL | #![deny(unused_imports)] | ^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 8 previous errors Some errors have detailed explanations: E0432, E0603. For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/rust-2018/uniform-paths/deadlock.rs b/src/test/ui/rust-2018/uniform-paths/deadlock.rs index 3228d799083..83ed70a0459 100644 --- a/src/test/ui/rust-2018/uniform-paths/deadlock.rs +++ b/src/test/ui/rust-2018/uniform-paths/deadlock.rs @@ -1,7 +1,7 @@ // edition:2018 // compile-flags:--extern foo --extern bar -use foo::bar; //~ ERROR unresolved import +use foo::bar; //~ ERROR can't find crate for `foo` use bar::foo; fn main() {} diff --git a/src/test/ui/rust-2018/uniform-paths/deadlock.stderr b/src/test/ui/rust-2018/uniform-paths/deadlock.stderr index b4ac15c588e..9336e90afb7 100644 --- a/src/test/ui/rust-2018/uniform-paths/deadlock.stderr +++ b/src/test/ui/rust-2018/uniform-paths/deadlock.stderr @@ -1,9 +1,9 @@ -error[E0432]: unresolved import +error[E0463]: can't find crate for `foo` --> $DIR/deadlock.rs:4:5 | LL | use foo::bar; - | ^^^^^^^^ + | ^^^ can't find crate error: aborting due to previous error -For more information about this error, try `rustc --explain E0432`. +For more information about this error, try `rustc --explain E0463`. diff --git a/src/tools/rls b/src/tools/rls -Subproject 496c89275221303a4b0c2779cb8203fb3ce2a13 +Subproject 412fb00b37afb6b7f7fa96a35f2315c7e640b91 diff --git a/src/tools/rustc-std-workspace-alloc/Cargo.toml b/src/tools/rustc-std-workspace-alloc/Cargo.toml index ef7dc812af9..9e04b14756e 100644 --- a/src/tools/rustc-std-workspace-alloc/Cargo.toml +++ b/src/tools/rustc-std-workspace-alloc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustc-std-workspace-alloc" -version = "1.0.0" +version = "1.99.0" authors = ["Alex Crichton <alex@alexcrichton.com>"] license = 'MIT OR Apache-2.0' description = """ diff --git a/src/tools/rustc-std-workspace-core/Cargo.toml b/src/tools/rustc-std-workspace-core/Cargo.toml index 38ca56a557b..6b4e7540aff 100644 --- a/src/tools/rustc-std-workspace-core/Cargo.toml +++ b/src/tools/rustc-std-workspace-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustc-std-workspace-core" -version = "1.0.0" +version = "1.99.0" authors = ["Alex Crichton <alex@alexcrichton.com>"] license = 'MIT OR Apache-2.0' description = """ diff --git a/src/tools/rustc-std-workspace-std/Cargo.toml b/src/tools/rustc-std-workspace-std/Cargo.toml index ce1644809db..e41554b74af 100644 --- a/src/tools/rustc-std-workspace-std/Cargo.toml +++ b/src/tools/rustc-std-workspace-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustc-std-workspace-std" -version = "1.0.0" +version = "1.99.0" authors = ["Alex Crichton <alex@alexcrichton.com>"] license = 'MIT OR Apache-2.0' description = """ diff --git a/src/tools/rustfmt b/src/tools/rustfmt -Subproject f800ce47d1da2a1c02ffd260deca8b7445f7fac +Subproject afb1ee1c14594aed5bb4a762b357b01f13c9de1 |
