Skip to content

Commit 122fefc

Browse files
committedSep 10, 2019
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
2 parents 0b36e9d + 342722e commit 122fefc

File tree

18 files changed

+490
-213
lines changed

18 files changed

+490
-213
lines changed
 

‎Cargo.lock

+384-158
Large diffs are not rendered by default.

‎src/librustc_incremental/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212
[dependencies]
1313
graphviz = { path = "../libgraphviz" }
1414
log = "0.4"
15-
rand = "0.6"
15+
rand = "0.7"
1616
rustc = { path = "../librustc" }
1717
rustc_data_structures = { path = "../librustc_data_structures" }
1818
rustc_serialize = { path = "../libserialize", package = "serialize" }

‎src/librustc_resolve/resolve_imports.rs

+55-34
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub enum ImportDirectiveSubclass<'a> {
7171
}
7272

7373
/// One import directive.
74-
#[derive(Debug,Clone)]
74+
#[derive(Debug, Clone)]
7575
crate struct ImportDirective<'a> {
7676
/// The ID of the `extern crate`, `UseTree` etc that imported this `ImportDirective`.
7777
///
@@ -447,12 +447,13 @@ impl<'a> Resolver<'a> {
447447
}
448448

449449
// Define the name or return the existing binding if there is a collision.
450-
pub fn try_define(&mut self,
451-
module: Module<'a>,
452-
ident: Ident,
453-
ns: Namespace,
454-
binding: &'a NameBinding<'a>)
455-
-> Result<(), &'a NameBinding<'a>> {
450+
pub fn try_define(
451+
&mut self,
452+
module: Module<'a>,
453+
ident: Ident,
454+
ns: Namespace,
455+
binding: &'a NameBinding<'a>,
456+
) -> Result<(), &'a NameBinding<'a>> {
456457
let res = binding.res();
457458
self.check_reserved_macro_name(ident, res);
458459
self.set_binding_parent_module(binding, module);
@@ -480,8 +481,11 @@ impl<'a> Resolver<'a> {
480481
};
481482
if glob_binding.res() != nonglob_binding.res() &&
482483
ns == MacroNS && nonglob_binding.expansion != ExpnId::root() {
483-
resolution.binding = Some(this.ambiguity(AmbiguityKind::GlobVsExpanded,
484-
nonglob_binding, glob_binding));
484+
resolution.binding = Some(this.ambiguity(
485+
AmbiguityKind::GlobVsExpanded,
486+
nonglob_binding,
487+
glob_binding,
488+
));
485489
} else {
486490
resolution.binding = Some(nonglob_binding);
487491
}
@@ -513,9 +517,11 @@ impl<'a> Resolver<'a> {
513517
})
514518
}
515519

516-
fn ambiguity(&self, kind: AmbiguityKind,
517-
primary_binding: &'a NameBinding<'a>, secondary_binding: &'a NameBinding<'a>)
518-
-> &'a NameBinding<'a> {
520+
fn ambiguity(
521+
&self, kind: AmbiguityKind,
522+
primary_binding: &'a NameBinding<'a>,
523+
secondary_binding: &'a NameBinding<'a>,
524+
) -> &'a NameBinding<'a> {
519525
self.arenas.alloc_name_binding(NameBinding {
520526
ambiguity: Some((secondary_binding, kind)),
521527
..primary_binding.clone()
@@ -524,8 +530,12 @@ impl<'a> Resolver<'a> {
524530

525531
// Use `f` to mutate the resolution of the name in the module.
526532
// If the resolution becomes a success, define it in the module's glob importers.
527-
fn update_resolution<T, F>(&mut self, module: Module<'a>, ident: Ident, ns: Namespace, f: F)
528-
-> T
533+
fn update_resolution<T, F>(
534+
&mut self, module: Module<'a>,
535+
ident: Ident,
536+
ns: Namespace,
537+
f: F,
538+
) -> T
529539
where F: FnOnce(&mut Resolver<'a>, &mut NameResolution<'a>) -> T
530540
{
531541
// Ensure that `resolution` isn't borrowed when defining in the module's glob importers,
@@ -627,14 +637,18 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
627637
self.finalize_resolutions_in(module);
628638
}
629639

630-
let mut has_errors = false;
631640
let mut seen_spans = FxHashSet::default();
632641
let mut errors = vec![];
633642
let mut prev_root_id: NodeId = NodeId::from_u32(0);
634-
for i in 0 .. self.r.determined_imports.len() {
635-
let import = self.r.determined_imports[i];
643+
let determined_imports = mem::take(&mut self.r.determined_imports);
644+
let indeterminate_imports = mem::take(&mut self.r.indeterminate_imports);
645+
646+
for (is_indeterminate, import) in determined_imports
647+
.into_iter()
648+
.map(|i| (false, i))
649+
.chain(indeterminate_imports.into_iter().map(|i| (true, i)))
650+
{
636651
if let Some(err) = self.finalize_import(import) {
637-
has_errors = true;
638652

639653
if let SingleImport { source, ref source_bindings, .. } = import.subclass {
640654
if source.name == kw::SelfLower {
@@ -666,25 +680,27 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
666680
errors.push((path, err));
667681
prev_root_id = import.root_id;
668682
}
683+
} else if is_indeterminate {
684+
// Consider erroneous imports used to avoid duplicate diagnostics.
685+
self.r.used_imports.insert((import.id, TypeNS));
686+
let path = import_path_to_string(
687+
&import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(),
688+
&import.subclass,
689+
import.span,
690+
);
691+
let err = UnresolvedImportError {
692+
span: import.span,
693+
label: None,
694+
note: Vec::new(),
695+
suggestion: None,
696+
};
697+
errors.push((path, err));
669698
}
670699
}
671700

672701
if !errors.is_empty() {
673702
self.throw_unresolved_import_error(errors.clone(), None);
674703
}
675-
676-
for import in &self.r.indeterminate_imports {
677-
// Consider erroneous imports used to avoid duplicate diagnostics.
678-
self.r.used_imports.insert((import.id, TypeNS));
679-
}
680-
// Report unresolved imports only if no hard error was already reported
681-
// to avoid generating multiple errors on the same import.
682-
if !has_errors {
683-
for import in &self.r.indeterminate_imports {
684-
self.throw_unresolved_import_error(errors, Some(MultiSpan::from(import.span)));
685-
break;
686-
}
687-
}
688704
}
689705

690706
fn throw_unresolved_import_error(
@@ -839,8 +855,14 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
839855
) -> Option<UnresolvedImportError> {
840856
let orig_vis = directive.vis.replace(ty::Visibility::Invisible);
841857
let prev_ambiguity_errors_len = self.r.ambiguity_errors.len();
842-
let path_res = self.r.resolve_path(&directive.module_path, None, &directive.parent_scope,
843-
true, directive.span, directive.crate_lint());
858+
let path_res = self.r.resolve_path(
859+
&directive.module_path,
860+
None,
861+
&directive.parent_scope,
862+
true,
863+
directive.span,
864+
directive.crate_lint(),
865+
);
844866
let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len;
845867
directive.vis.set(orig_vis);
846868
if let PathResult::Failed { .. } | PathResult::NonModule(..) = path_res {
@@ -903,7 +925,6 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
903925
}
904926
}
905927
};
906-
907928
return Some(err);
908929
}
909930
return None;

‎src/libstd/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ features = [
3838
optional = true
3939

4040
[dev-dependencies]
41-
rand = "0.6.1"
41+
rand = "0.7"
4242

4343
[target.x86_64-apple-darwin.dependencies]
4444
rustc_asan = { path = "../librustc_asan" }

‎src/libstd/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2144,7 +2144,7 @@ mod tests {
21442144
use crate::sys_common::io::test::{TempDir, tmpdir};
21452145
use crate::thread;
21462146

2147-
use rand::{rngs::StdRng, FromEntropy, RngCore};
2147+
use rand::{rngs::StdRng, RngCore, SeedableRng};
21482148

21492149
#[cfg(windows)]
21502150
use crate::os::windows::fs::{symlink_dir, symlink_file};

‎src/libstd/tests/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rand::{thread_rng, Rng};
55
use rand::distributions::Alphanumeric;
66

77
fn make_rand_name() -> OsString {
8-
let mut rng = thread_rng();
8+
let rng = thread_rng();
99
let n = format!("TEST{}", rng.sample_iter(&Alphanumeric).take(10)
1010
.collect::<String>());
1111
let n = OsString::from(n);

‎src/llvm-project

Submodule llvm-project updated 229 files

‎src/test/ui/extenv/issue-55897.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use prelude::*; //~ ERROR unresolved import `prelude`
22

33
mod unresolved_env {
4-
use env;
4+
use env; //~ ERROR unresolved import `env`
55

66
include!(concat!(env!("NON_EXISTENT"), "/data.rs"));
77
//~^ ERROR cannot determine resolution for the macro `env`

‎src/test/ui/extenv/issue-55897.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ LL | use prelude::*;
1919
| unresolved import
2020
| help: a similar path exists: `std::prelude`
2121

22+
error[E0432]: unresolved import `env`
23+
--> $DIR/issue-55897.rs:4:9
24+
|
25+
LL | use env;
26+
| ^^^ no `env` in the root
27+
2228
error: cannot determine resolution for the macro `env`
2329
--> $DIR/issue-55897.rs:6:22
2430
|
@@ -27,6 +33,6 @@ LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs"));
2733
|
2834
= note: import resolution is stuck, try simplifying macro imports
2935

30-
error: aborting due to 4 previous errors
36+
error: aborting due to 5 previous errors
3137

3238
For more information about this error, try `rustc --explain E0432`.

‎src/test/ui/imports/unresolved-imports-used.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ mod qux {
88

99
use qux::quz; //~ ERROR function `quz` is private
1010
use qux::bar; //~ ERROR unresolved import `qux::bar`
11-
use foo::bar;
12-
use baz::*;
11+
use foo::bar; //~ ERROR unresolved import `foo`
12+
use baz::*; //~ ERROR unresolved import `baz`
1313
use qux::bar2; //~ ERROR unresolved import `qux::bar2`
14-
use foo2::bar2;
15-
use baz2::*;
14+
use foo2::bar2;//~ ERROR unresolved import `foo2`
15+
use baz2::*; //~ ERROR unresolved import `baz2`
1616
use qux::quy; //~ ERROR unused import
1717

1818
fn main() {}

‎src/test/ui/imports/unresolved-imports-used.stderr

+25-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@ error[E0432]: unresolved import `qux::bar2`
1010
LL | use qux::bar2;
1111
| ^^^^^^^^^ no `bar2` in `qux`
1212

13+
error[E0432]: unresolved import `foo`
14+
--> $DIR/unresolved-imports-used.rs:11:5
15+
|
16+
LL | use foo::bar;
17+
| ^^^ maybe a missing crate `foo`?
18+
19+
error[E0432]: unresolved import `baz`
20+
--> $DIR/unresolved-imports-used.rs:12:5
21+
|
22+
LL | use baz::*;
23+
| ^^^ maybe a missing crate `baz`?
24+
25+
error[E0432]: unresolved import `foo2`
26+
--> $DIR/unresolved-imports-used.rs:14:5
27+
|
28+
LL | use foo2::bar2;
29+
| ^^^^ maybe a missing crate `foo2`?
30+
31+
error[E0432]: unresolved import `baz2`
32+
--> $DIR/unresolved-imports-used.rs:15:5
33+
|
34+
LL | use baz2::*;
35+
| ^^^^ maybe a missing crate `baz2`?
36+
1337
error[E0603]: function `quz` is private
1438
--> $DIR/unresolved-imports-used.rs:9:10
1539
|
@@ -28,7 +52,7 @@ note: lint level defined here
2852
LL | #![deny(unused_imports)]
2953
| ^^^^^^^^^^^^^^
3054

31-
error: aborting due to 4 previous errors
55+
error: aborting due to 8 previous errors
3256

3357
Some errors have detailed explanations: E0432, E0603.
3458
For more information about an error, try `rustc --explain E0432`.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// edition:2018
22
// compile-flags:--extern foo --extern bar
33

4-
use foo::bar; //~ ERROR unresolved import
4+
use foo::bar; //~ ERROR can't find crate for `foo`
55
use bar::foo;
66

77
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
error[E0432]: unresolved import
1+
error[E0463]: can't find crate for `foo`
22
--> $DIR/deadlock.rs:4:5
33
|
44
LL | use foo::bar;
5-
| ^^^^^^^^
5+
| ^^^ can't find crate
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0432`.
9+
For more information about this error, try `rustc --explain E0463`.

‎src/tools/rls

Submodule rls updated from 496c892 to 412fb00

‎src/tools/rustc-std-workspace-alloc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustc-std-workspace-alloc"
3-
version = "1.0.0"
3+
version = "1.99.0"
44
authors = ["Alex Crichton <alex@alexcrichton.com>"]
55
license = 'MIT OR Apache-2.0'
66
description = """

‎src/tools/rustc-std-workspace-core/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustc-std-workspace-core"
3-
version = "1.0.0"
3+
version = "1.99.0"
44
authors = ["Alex Crichton <alex@alexcrichton.com>"]
55
license = 'MIT OR Apache-2.0'
66
description = """

‎src/tools/rustc-std-workspace-std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustc-std-workspace-std"
3-
version = "1.0.0"
3+
version = "1.99.0"
44
authors = ["Alex Crichton <alex@alexcrichton.com>"]
55
license = 'MIT OR Apache-2.0'
66
description = """

‎src/tools/rustfmt

0 commit comments

Comments
 (0)
Please sign in to comment.