Skip to content

Commit d8ed1b0

Browse files
committed
Auto merge of #73692 - Dylan-DPC:rollup-ehzsbfw, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #73638 (Remove unused crate imports in 2018 edition crates) - #73639 (Change heuristic for determining range literal) - #73646 (Add some regression tests) - #73652 (Add re-exports to use suggestions) - #73667 (Update BTreeMap::new() doc) - #73675 (Update books) Failed merges: r? @ghost
2 parents 0b66a89 + be8f381 commit d8ed1b0

File tree

38 files changed

+248
-51
lines changed

38 files changed

+248
-51
lines changed

src/liballoc/collections/btree/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ struct MergeIter<K, V, I: Iterator<Item = (K, V)>> {
488488
}
489489

490490
impl<K: Ord, V> BTreeMap<K, V> {
491-
/// Makes a new empty BTreeMap with a reasonable choice for B.
491+
/// Makes a new empty BTreeMap.
492492
///
493493
/// Does not allocate anything on its own.
494494
///

src/liballoc/collections/vec_deque/tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use super::*;
22

3-
use test;
4-
53
#[bench]
64
#[cfg_attr(miri, ignore)] // isolated Miri does not support benchmarks
75
fn bench_push_back_100(b: &mut test::Bencher) {

src/librustc_ast_pretty/pprust/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::*;
22

33
use rustc_ast::ast;
44
use rustc_ast::with_default_globals;
5-
use rustc_span;
65
use rustc_span::source_map::respan;
76
use rustc_span::symbol::Ident;
87

src/librustc_data_structures/sync.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ cfg_if! {
358358
use parking_lot::Mutex as InnerLock;
359359
use parking_lot::RwLock as InnerRwLock;
360360

361-
use std;
362361
use std::thread;
363362
pub use rayon::{join, scope};
364363

src/librustc_hir/hir.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,13 +1511,7 @@ pub fn is_range_literal(sm: &SourceMap, expr: &Expr<'_>) -> bool {
15111511
// Check whether a span corresponding to a range expression is a
15121512
// range literal, rather than an explicit struct or `new()` call.
15131513
fn is_lit(sm: &SourceMap, span: &Span) -> bool {
1514-
let end_point = sm.end_point(*span);
1515-
1516-
if let Ok(end_string) = sm.span_to_snippet(end_point) {
1517-
!(end_string.ends_with('}') || end_string.ends_with(')'))
1518-
} else {
1519-
false
1520-
}
1514+
sm.span_to_snippet(*span).map(|range_src| range_src.contains("..")).unwrap_or(false)
15211515
};
15221516

15231517
match expr.kind {

src/librustc_resolve/diagnostics.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -643,18 +643,18 @@ impl<'a> Resolver<'a> {
643643
let not_local_module = crate_name.name != kw::Crate;
644644
let mut worklist =
645645
vec![(start_module, Vec::<ast::PathSegment>::new(), true, not_local_module)];
646+
let mut worklist_via_import = vec![];
646647

647-
while let Some((in_module, path_segments, accessible, in_module_is_extern)) = worklist.pop()
648+
while let Some((in_module, path_segments, accessible, in_module_is_extern)) =
649+
match worklist.pop() {
650+
None => worklist_via_import.pop(),
651+
Some(x) => Some(x),
652+
}
648653
{
649654
// We have to visit module children in deterministic order to avoid
650655
// instabilities in reported imports (#43552).
651656
in_module.for_each_child(self, |this, ident, ns, name_binding| {
652-
// avoid imports entirely
653-
if name_binding.is_import() && !name_binding.is_extern_crate() {
654-
return;
655-
}
656-
657-
// avoid non-importable candidates as well
657+
// avoid non-importable candidates
658658
if !name_binding.is_importable() {
659659
return;
660660
}
@@ -667,6 +667,17 @@ impl<'a> Resolver<'a> {
667667
return;
668668
}
669669

670+
let via_import = name_binding.is_import() && !name_binding.is_extern_crate();
671+
672+
// There is an assumption elsewhere that paths of variants are in the enum's
673+
// declaration and not imported. With this assumption, the variant component is
674+
// chopped and the rest of the path is assumed to be the enum's own path. For
675+
// errors where a variant is used as the type instead of the enum, this causes
676+
// funny looking invalid suggestions, i.e `foo` instead of `foo::MyEnum`.
677+
if via_import && name_binding.is_possibly_imported_variant() {
678+
return;
679+
}
680+
670681
// collect results based on the filter function
671682
// avoid suggesting anything from the same module in which we are resolving
672683
if ident.name == lookup_ident.name
@@ -724,7 +735,8 @@ impl<'a> Resolver<'a> {
724735
let is_extern = in_module_is_extern || name_binding.is_extern_crate();
725736
// add the module to the lookup
726737
if seen_modules.insert(module.def_id().unwrap()) {
727-
worklist.push((module, path_segments, child_accessible, is_extern));
738+
if via_import { &mut worklist_via_import } else { &mut worklist }
739+
.push((module, path_segments, child_accessible, is_extern));
728740
}
729741
}
730742
}

0 commit comments

Comments
 (0)