Skip to content

Commit 903427b

Browse files
committedMar 25, 2022
Auto merge of #95255 - petrochenkov:suggresolve, r=michaelwoerister
resolve: Do not build expensive suggestions if they are not actually used And remove a bunch of (conditionally) unused parameters from path resolution functions. This helps with performance issues in #94857, and should be helpful in general even without that.
·
1.88.01.61.0
2 parents e70e211 + 1ad64a2 commit 903427b

25 files changed

+457
-824
lines changed
 

‎compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::def_collector::collect_definitions;
99
use crate::imports::{Import, ImportKind};
1010
use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
1111
use crate::Namespace::{self, MacroNS, TypeNS, ValueNS};
12-
use crate::{CrateLint, Determinacy, ExternPreludeEntry, Module, ModuleKind, ModuleOrUniformRoot};
12+
use crate::{Determinacy, ExternPreludeEntry, Finalize, Module, ModuleKind, ModuleOrUniformRoot};
1313
use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, PerNS, ResolutionError};
1414
use crate::{Resolver, ResolverArenas, Segment, ToNameBinding, VisResolutionError};
1515

@@ -235,16 +235,16 @@ impl<'a> AsMut<Resolver<'a>> for BuildReducedGraphVisitor<'a, '_> {
235235

236236
impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
237237
fn resolve_visibility(&mut self, vis: &ast::Visibility) -> ty::Visibility {
238-
self.resolve_visibility_speculative(vis, false).unwrap_or_else(|err| {
238+
self.try_resolve_visibility(vis, true).unwrap_or_else(|err| {
239239
self.r.report_vis_error(err);
240240
ty::Visibility::Public
241241
})
242242
}
243243

244-
fn resolve_visibility_speculative<'ast>(
244+
fn try_resolve_visibility<'ast>(
245245
&mut self,
246246
vis: &'ast ast::Visibility,
247-
speculative: bool,
247+
finalize: bool,
248248
) -> Result<ty::Visibility, VisResolutionError<'ast>> {
249249
let parent_scope = &self.parent_scope;
250250
match vis.kind {
@@ -296,13 +296,11 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
296296
&segments,
297297
Some(TypeNS),
298298
parent_scope,
299-
!speculative,
300-
path.span,
301-
CrateLint::SimplePath(id),
299+
if finalize { Finalize::SimplePath(id, path.span) } else { Finalize::No },
302300
) {
303301
PathResult::Module(ModuleOrUniformRoot::Module(module)) => {
304302
let res = module.res().expect("visibility resolved to unnamed block");
305-
if !speculative {
303+
if finalize {
306304
self.r.record_partial_res(id, PartialRes::new(res));
307305
}
308306
if module.is_normal() {
@@ -772,7 +770,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
772770
// correct visibilities for unnamed field placeholders specifically, so the
773771
// constructor visibility should still be determined correctly.
774772
let field_vis = self
775-
.resolve_visibility_speculative(&field.vis, true)
773+
.try_resolve_visibility(&field.vis, false)
776774
.unwrap_or(ty::Visibility::Public);
777775
if ctor_vis.is_at_least(field_vis, &*self.r) {
778776
ctor_vis = field_vis;
@@ -1131,8 +1129,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
11311129
ident,
11321130
MacroNS,
11331131
&self.parent_scope,
1134-
false,
1135-
ident.span,
1132+
None,
11361133
);
11371134
if let Ok(binding) = result {
11381135
let import = macro_use_import(self, ident.span);
@@ -1272,9 +1269,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
12721269
let vis = match item.kind {
12731270
// Visibilities must not be resolved non-speculatively twice
12741271
// and we already resolved this one as a `fn` item visibility.
1275-
ItemKind::Fn(..) => self
1276-
.resolve_visibility_speculative(&item.vis, true)
1277-
.unwrap_or(ty::Visibility::Public),
1272+
ItemKind::Fn(..) => {
1273+
self.try_resolve_visibility(&item.vis, false).unwrap_or(ty::Visibility::Public)
1274+
}
12781275
_ => self.resolve_visibility(&item.vis),
12791276
};
12801277
if vis != ty::Visibility::Public {

‎compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ use tracing::debug;
2424
use crate::imports::{Import, ImportKind, ImportResolver};
2525
use crate::path_names_to_string;
2626
use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind};
27-
use crate::{
28-
BindingError, CrateLint, HasGenericParams, MacroRulesScope, Module, ModuleOrUniformRoot,
29-
};
30-
use crate::{NameBinding, NameBindingKind, PrivacyError, VisResolutionError};
27+
use crate::{BindingError, HasGenericParams, MacroRulesScope, Module, ModuleOrUniformRoot};
28+
use crate::{Finalize, NameBinding, NameBindingKind, PrivacyError, VisResolutionError};
3129
use crate::{ParentScope, PathResult, ResolutionError, Resolver, Scope, ScopeSet, Segment};
3230

3331
type Res = def::Res<ast::NodeId>;
@@ -1076,9 +1074,8 @@ impl<'a> Resolver<'a> {
10761074
ident,
10771075
ScopeSet::All(ns, false),
10781076
&parent_scope,
1077+
None,
10791078
false,
1080-
false,
1081-
ident.span,
10821079
) {
10831080
let desc = match binding.res() {
10841081
Res::Def(DefKind::Macro(MacroKind::Bang), _) => {
@@ -1405,10 +1402,10 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
14051402
_ => return None,
14061403
}
14071404

1408-
self.make_missing_self_suggestion(span, path.clone(), parent_scope)
1409-
.or_else(|| self.make_missing_crate_suggestion(span, path.clone(), parent_scope))
1410-
.or_else(|| self.make_missing_super_suggestion(span, path.clone(), parent_scope))
1411-
.or_else(|| self.make_external_crate_suggestion(span, path, parent_scope))
1405+
self.make_missing_self_suggestion(path.clone(), parent_scope)
1406+
.or_else(|| self.make_missing_crate_suggestion(path.clone(), parent_scope))
1407+
.or_else(|| self.make_missing_super_suggestion(path.clone(), parent_scope))
1408+
.or_else(|| self.make_external_crate_suggestion(path, parent_scope))
14121409
}
14131410

14141411
/// Suggest a missing `self::` if that resolves to an correct module.
@@ -1420,13 +1417,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
14201417
/// ```
14211418
fn make_missing_self_suggestion(
14221419
&mut self,
1423-
span: Span,
14241420
mut path: Vec<Segment>,
14251421
parent_scope: &ParentScope<'b>,
14261422
) -> Option<(Vec<Segment>, Vec<String>)> {
14271423
// Replace first ident with `self` and check if that is valid.
14281424
path[0].ident.name = kw::SelfLower;
1429-
let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No);
1425+
let result = self.r.resolve_path(&path, None, parent_scope, Finalize::No);
14301426
debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result);
14311427
if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
14321428
}
@@ -1440,13 +1436,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
14401436
/// ```
14411437
fn make_missing_crate_suggestion(
14421438
&mut self,
1443-
span: Span,
14441439
mut path: Vec<Segment>,
14451440
parent_scope: &ParentScope<'b>,
14461441
) -> Option<(Vec<Segment>, Vec<String>)> {
14471442
// Replace first ident with `crate` and check if that is valid.
14481443
path[0].ident.name = kw::Crate;
1449-
let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No);
1444+
let result = self.r.resolve_path(&path, None, parent_scope, Finalize::No);
14501445
debug!("make_missing_crate_suggestion: path={:?} result={:?}", path, result);
14511446
if let PathResult::Module(..) = result {
14521447
Some((
@@ -1472,13 +1467,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
14721467
/// ```
14731468
fn make_missing_super_suggestion(
14741469
&mut self,
1475-
span: Span,
14761470
mut path: Vec<Segment>,
14771471
parent_scope: &ParentScope<'b>,
14781472
) -> Option<(Vec<Segment>, Vec<String>)> {
14791473
// Replace first ident with `crate` and check if that is valid.
14801474
path[0].ident.name = kw::Super;
1481-
let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No);
1475+
let result = self.r.resolve_path(&path, None, parent_scope, Finalize::No);
14821476
debug!("make_missing_super_suggestion: path={:?} result={:?}", path, result);
14831477
if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
14841478
}
@@ -1495,7 +1489,6 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
14951489
/// name as the first part of path.
14961490
fn make_external_crate_suggestion(
14971491
&mut self,
1498-
span: Span,
14991492
mut path: Vec<Segment>,
15001493
parent_scope: &ParentScope<'b>,
15011494
) -> Option<(Vec<Segment>, Vec<String>)> {
@@ -1513,7 +1506,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
15131506
for name in extern_crate_names.into_iter() {
15141507
// Replace first ident with a crate name and check if that is valid.
15151508
path[0].ident.name = name;
1516-
let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No);
1509+
let result = self.r.resolve_path(&path, None, parent_scope, Finalize::No);
15171510
debug!(
15181511
"make_external_crate_suggestion: name={:?} path={:?} result={:?}",
15191512
name, path, result

‎compiler/rustc_resolve/src/imports.rs

Lines changed: 30 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::Namespace::{self, MacroNS, TypeNS};
66
use crate::{module_to_string, names_to_string};
77
use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind};
88
use crate::{BindingKey, ModuleKind, ResolutionError, Resolver, Segment};
9-
use crate::{CrateLint, Module, ModuleOrUniformRoot, ParentScope, PerNS, ScopeSet, Weak};
9+
use crate::{Finalize, Module, ModuleOrUniformRoot, ParentScope, PerNS, ScopeSet, Weak};
1010
use crate::{NameBinding, NameBindingKind, PathResult, PrivacyError, ToNameBinding};
1111

1212
use rustc_ast::NodeId;
@@ -123,10 +123,6 @@ impl<'a> Import<'a> {
123123
_ => false,
124124
}
125125
}
126-
127-
crate fn crate_lint(&self) -> CrateLint {
128-
CrateLint::UsePath { root_id: self.root_id, root_span: self.root_span }
129-
}
130126
}
131127

132128
#[derive(Clone, Default, Debug)]
@@ -179,32 +175,29 @@ impl<'a> Resolver<'a> {
179175
ident: Ident,
180176
ns: Namespace,
181177
parent_scope: &ParentScope<'a>,
182-
record_used: bool,
183-
path_span: Span,
178+
finalize: Option<Span>,
184179
) -> Result<&'a NameBinding<'a>, Determinacy> {
185180
self.resolve_ident_in_module_unadjusted_ext(
186181
module,
187182
ident,
188183
ns,
189184
parent_scope,
190185
false,
191-
record_used,
192-
path_span,
186+
finalize,
193187
)
194188
.map_err(|(determinacy, _)| determinacy)
195189
}
196190

197191
/// Attempts to resolve `ident` in namespaces `ns` of `module`.
198-
/// Invariant: if `record_used` is `Some`, expansion and import resolution must be complete.
192+
/// Invariant: if `finalize` is `Some`, expansion and import resolution must be complete.
199193
crate fn resolve_ident_in_module_unadjusted_ext(
200194
&mut self,
201195
module: ModuleOrUniformRoot<'a>,
202196
ident: Ident,
203197
ns: Namespace,
204198
parent_scope: &ParentScope<'a>,
205199
restricted_shadowing: bool,
206-
record_used: bool,
207-
path_span: Span,
200+
finalize: Option<Span>,
208201
) -> Result<&'a NameBinding<'a>, (Determinacy, Weak)> {
209202
let module = match module {
210203
ModuleOrUniformRoot::Module(module) => module,
@@ -214,17 +207,16 @@ impl<'a> Resolver<'a> {
214207
ident,
215208
ScopeSet::AbsolutePath(ns),
216209
parent_scope,
217-
record_used,
218-
record_used,
219-
path_span,
210+
finalize,
211+
finalize.is_some(),
220212
);
221213
return binding.map_err(|determinacy| (determinacy, Weak::No));
222214
}
223215
ModuleOrUniformRoot::ExternPrelude => {
224216
assert!(!restricted_shadowing);
225217
return if ns != TypeNS {
226218
Err((Determined, Weak::No))
227-
} else if let Some(binding) = self.extern_prelude_get(ident, !record_used) {
219+
} else if let Some(binding) = self.extern_prelude_get(ident, finalize.is_some()) {
228220
Ok(binding)
229221
} else if !self.graph_root.unexpanded_invocations.borrow().is_empty() {
230222
// Macro-expanded `extern crate` items can add names to extern prelude.
@@ -254,9 +246,8 @@ impl<'a> Resolver<'a> {
254246
ident,
255247
scopes,
256248
parent_scope,
257-
record_used,
258-
record_used,
259-
path_span,
249+
finalize,
250+
finalize.is_some(),
260251
);
261252
return binding.map_err(|determinacy| (determinacy, Weak::No));
262253
}
@@ -266,7 +257,7 @@ impl<'a> Resolver<'a> {
266257
let resolution =
267258
self.resolution(module, key).try_borrow_mut().map_err(|_| (Determined, Weak::No))?; // This happens when there is a cycle of imports.
268259

269-
if let Some(binding) = resolution.binding {
260+
if let Some(binding) = resolution.binding && let Some(path_span) = finalize {
270261
if !restricted_shadowing && binding.expansion != LocalExpnId::ROOT {
271262
if let NameBindingKind::Res(_, true) = binding.kind {
272263
self.macro_expanded_macro_export_errors.insert((path_span, binding.span));
@@ -284,7 +275,7 @@ impl<'a> Resolver<'a> {
284275
if usable { Ok(binding) } else { Err((Determined, Weak::No)) }
285276
};
286277

287-
if record_used {
278+
if let Some(path_span) = finalize {
288279
return resolution
289280
.binding
290281
.and_then(|binding| {
@@ -357,14 +348,8 @@ impl<'a> Resolver<'a> {
357348
let ImportKind::Single { source: ident, .. } = single_import.kind else {
358349
unreachable!();
359350
};
360-
match self.resolve_ident_in_module(
361-
module,
362-
ident,
363-
ns,
364-
&single_import.parent_scope,
365-
false,
366-
path_span,
367-
) {
351+
match self.resolve_ident_in_module(module, ident, ns, &single_import.parent_scope, None)
352+
{
368353
Err(Determined) => continue,
369354
Ok(binding)
370355
if !self.is_accessible_from(binding.vis, single_import.parent_scope.module) =>
@@ -438,8 +423,7 @@ impl<'a> Resolver<'a> {
438423
ident,
439424
ns,
440425
adjusted_parent_scope,
441-
false,
442-
path_span,
426+
None,
443427
);
444428

445429
match result {
@@ -787,14 +771,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
787771
// For better failure detection, pretend that the import will
788772
// not define any names while resolving its module path.
789773
let orig_vis = import.vis.replace(ty::Visibility::Invisible);
790-
let path_res = self.r.resolve_path(
791-
&import.module_path,
792-
None,
793-
&import.parent_scope,
794-
false,
795-
import.span,
796-
import.crate_lint(),
797-
);
774+
let path_res =
775+
self.r.resolve_path(&import.module_path, None, &import.parent_scope, Finalize::No);
798776
import.vis.set(orig_vis);
799777

800778
match path_res {
@@ -833,8 +811,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
833811
source,
834812
ns,
835813
&import.parent_scope,
836-
false,
837-
import.span,
814+
None,
838815
);
839816
import.vis.set(orig_vis);
840817
source_bindings[ns].set(binding);
@@ -887,14 +864,13 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
887864
_ => None,
888865
};
889866
let prev_ambiguity_errors_len = self.r.ambiguity_errors.len();
890-
let path_res = self.r.resolve_path(
891-
&import.module_path,
892-
None,
893-
&import.parent_scope,
894-
true,
895-
import.span,
896-
import.crate_lint(),
897-
);
867+
let finalize = Finalize::UsePath {
868+
root_id: import.root_id,
869+
root_span: import.root_span,
870+
path_span: import.span,
871+
};
872+
let path_res =
873+
self.r.resolve_path(&import.module_path, None, &import.parent_scope, finalize);
898874
let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len;
899875
if let Some(orig_unusable_binding) = orig_unusable_binding {
900876
self.r.unusable_binding = orig_unusable_binding;
@@ -981,12 +957,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
981957
// 2 segments, so the `resolve_path` above won't trigger it.
982958
let mut full_path = import.module_path.clone();
983959
full_path.push(Segment::from_ident(Ident::empty()));
984-
self.r.lint_if_path_starts_with_module(
985-
import.crate_lint(),
986-
&full_path,
987-
import.span,
988-
None,
989-
);
960+
self.r.lint_if_path_starts_with_module(finalize, &full_path, None);
990961
}
991962

992963
if let ModuleOrUniformRoot::Module(module) = module {
@@ -1024,8 +995,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
1024995
ident,
1025996
ns,
1026997
&import.parent_scope,
1027-
true,
1028-
import.span,
998+
Some(import.span),
1029999
);
10301000
this.last_import_segment = orig_last_import_segment;
10311001
this.unusable_binding = orig_unusable_binding;
@@ -1086,8 +1056,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
10861056
ident,
10871057
ns,
10881058
&import.parent_scope,
1089-
true,
1090-
import.span,
1059+
Some(import.span),
10911060
);
10921061
if binding.is_ok() {
10931062
all_ns_failed = false;
@@ -1253,12 +1222,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
12531222
full_path.push(Segment::from_ident(ident));
12541223
self.r.per_ns(|this, ns| {
12551224
if let Ok(binding) = source_bindings[ns].get() {
1256-
this.lint_if_path_starts_with_module(
1257-
import.crate_lint(),
1258-
&full_path,
1259-
import.span,
1260-
Some(binding),
1261-
);
1225+
this.lint_if_path_starts_with_module(finalize, &full_path, Some(binding));
12621226
}
12631227
});
12641228
}
@@ -1314,9 +1278,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
13141278
target,
13151279
ScopeSet::All(ns, false),
13161280
&import.parent_scope,
1281+
None,
13171282
false,
1318-
false,
1319-
import.span,
13201283
) {
13211284
Ok(other_binding) => {
13221285
is_redundant[ns] = Some(

‎compiler/rustc_resolve/src/late.rs

Lines changed: 53 additions & 85 deletions
Large diffs are not rendered by default.

‎compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::diagnostics::{ImportSuggestion, LabelSuggestion, TypoSuggestion};
22
use crate::late::lifetimes::{ElisionFailureInfo, LifetimeContext};
33
use crate::late::{AliasPossibility, LateResolutionVisitor, RibKind};
44
use crate::path_names_to_string;
5-
use crate::{CrateLint, Module, ModuleKind, ModuleOrUniformRoot};
5+
use crate::{Finalize, Module, ModuleKind, ModuleOrUniformRoot};
66
use crate::{PathResult, PathSource, Segment};
77

88
use rustc_ast::visit::FnKind;
@@ -187,12 +187,11 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
187187
(String::new(), "the crate root".to_string())
188188
} else {
189189
let mod_path = &path[..path.len() - 1];
190-
let mod_prefix =
191-
match self.resolve_path(mod_path, Some(TypeNS), false, span, CrateLint::No) {
192-
PathResult::Module(ModuleOrUniformRoot::Module(module)) => module.res(),
193-
_ => None,
194-
}
195-
.map_or_else(String::new, |res| format!("{} ", res.descr()));
190+
let mod_prefix = match self.resolve_path(mod_path, Some(TypeNS), Finalize::No) {
191+
PathResult::Module(ModuleOrUniformRoot::Module(module)) => module.res(),
192+
_ => None,
193+
}
194+
.map_or_else(String::new, |res| format!("{} ", res.descr()));
196195
(mod_prefix, format!("`{}`", Segment::names_to_string(mod_path)))
197196
};
198197
(
@@ -232,7 +231,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
232231
_ => {}
233232
}
234233

235-
let is_assoc_fn = self.self_type_is_available(span);
234+
let is_assoc_fn = self.self_type_is_available();
236235
// Emit help message for fake-self from other languages (e.g., `this` in Javascript).
237236
if ["this", "my"].contains(&item_str.as_str()) && is_assoc_fn {
238237
err.span_suggestion_short(
@@ -241,7 +240,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
241240
"self".to_string(),
242241
Applicability::MaybeIncorrect,
243242
);
244-
if !self.self_value_is_available(path[0].ident.span, span) {
243+
if !self.self_value_is_available(path[0].ident.span) {
245244
if let Some((FnKind::Fn(_, _, sig, ..), fn_span)) =
246245
&self.diagnostic_metadata.current_function
247246
{
@@ -402,9 +401,9 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
402401
);
403402
}
404403
}
405-
if path.len() == 1 && self.self_type_is_available(span) {
404+
if path.len() == 1 && self.self_type_is_available() {
406405
if let Some(candidate) = self.lookup_assoc_candidate(ident, ns, is_expected) {
407-
let self_is_available = self.self_value_is_available(path[0].ident.span, span);
406+
let self_is_available = self.self_value_is_available(path[0].ident.span);
408407
match candidate {
409408
AssocSuggestion::Field => {
410409
if self_is_available {
@@ -461,7 +460,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
461460
}
462461

463462
// Try Levenshtein algorithm.
464-
let typo_sugg = self.lookup_typo_candidate(path, ns, is_expected, span);
463+
let typo_sugg = self.lookup_typo_candidate(path, ns, is_expected);
465464
// Try context-dependent help if relaxed lookup didn't work.
466465
if let Some(res) = res {
467466
if self.smart_resolve_context_dependent_help(
@@ -562,7 +561,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
562561
}
563562

564563
// If the trait has a single item (which wasn't matched by Levenshtein), suggest it
565-
let suggestion = self.get_single_associated_item(&path, span, &source, is_expected);
564+
let suggestion = self.get_single_associated_item(&path, &source, is_expected);
566565
self.r.add_typo_suggestion(&mut err, suggestion, ident_span);
567566
}
568567
if fallback {
@@ -641,14 +640,13 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
641640
fn get_single_associated_item(
642641
&mut self,
643642
path: &[Segment],
644-
span: Span,
645643
source: &PathSource<'_>,
646644
filter_fn: &impl Fn(Res) -> bool,
647645
) -> Option<TypoSuggestion> {
648646
if let crate::PathSource::TraitItem(_) = source {
649647
let mod_path = &path[..path.len() - 1];
650648
if let PathResult::Module(ModuleOrUniformRoot::Module(module)) =
651-
self.resolve_path(mod_path, None, false, span, CrateLint::No)
649+
self.resolve_path(mod_path, None, Finalize::No)
652650
{
653651
let resolutions = self.r.resolutions(module).borrow();
654652
let targets: Vec<_> =
@@ -699,13 +697,12 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
699697
{
700698
// use this to verify that ident is a type param.
701699
let Ok(Some(partial_res)) = self.resolve_qpath_anywhere(
702-
bounded_ty.id,
703700
None,
704701
&Segment::from_path(path),
705702
Namespace::TypeNS,
706703
span,
707704
true,
708-
CrateLint::No,
705+
Finalize::No,
709706
) else {
710707
return false;
711708
};
@@ -724,13 +721,12 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
724721
if let ast::TyKind::Path(None, type_param_path) = &ty.peel_refs().kind {
725722
// Confirm that the `SelfTy` is a type parameter.
726723
let Ok(Some(partial_res)) = self.resolve_qpath_anywhere(
727-
bounded_ty.id,
728724
None,
729725
&Segment::from_path(type_param_path),
730726
Namespace::TypeNS,
731727
span,
732728
true,
733-
CrateLint::No,
729+
Finalize::No,
734730
) else {
735731
return false;
736732
};
@@ -1292,8 +1288,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
12921288
ident,
12931289
ns,
12941290
&self.parent_scope,
1295-
false,
1296-
module.span,
1291+
None,
12971292
) {
12981293
let res = binding.res();
12991294
if filter_fn(res) {
@@ -1323,7 +1318,6 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
13231318
path: &[Segment],
13241319
ns: Namespace,
13251320
filter_fn: &impl Fn(Res) -> bool,
1326-
span: Span,
13271321
) -> Option<TypoSuggestion> {
13281322
let mut names = Vec::new();
13291323
if path.len() == 1 {
@@ -1384,7 +1378,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
13841378
// Search in module.
13851379
let mod_path = &path[..path.len() - 1];
13861380
if let PathResult::Module(ModuleOrUniformRoot::Module(module)) =
1387-
self.resolve_path(mod_path, Some(TypeNS), false, span, CrateLint::No)
1381+
self.resolve_path(mod_path, Some(TypeNS), Finalize::No)
13881382
{
13891383
self.r.add_module_candidates(module, &mut names, &filter_fn);
13901384
}

‎compiler/rustc_resolve/src/lib.rs

Lines changed: 272 additions & 358 deletions
Large diffs are not rendered by default.

‎compiler/rustc_resolve/src/macros.rs

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use crate::imports::ImportResolver;
55
use crate::Namespace::*;
66
use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, BuiltinMacroState, Determinacy};
7-
use crate::{CrateLint, DeriveData, ParentScope, ResolutionError, Resolver, Scope, ScopeSet, Weak};
7+
use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, Scope, ScopeSet, Weak};
88
use crate::{ModuleKind, ModuleOrUniformRoot, NameBinding, PathResult, Segment, ToNameBinding};
99
use rustc_ast::{self as ast, Inline, ItemKind, ModKind, NodeId};
1010
use rustc_ast_lowering::ResolverAstLowering;
@@ -415,7 +415,7 @@ impl<'a> ResolverExpand for Resolver<'a> {
415415

416416
let mut indeterminate = false;
417417
for ns in [TypeNS, ValueNS, MacroNS].iter().copied() {
418-
match self.resolve_path(path, Some(ns), &parent_scope, false, span, CrateLint::No) {
418+
match self.resolve_path(path, Some(ns), &parent_scope, Finalize::No) {
419419
PathResult::Module(ModuleOrUniformRoot::Module(_)) => return Ok(true),
420420
PathResult::NonModule(partial_res) if partial_res.unresolved_segments() == 0 => {
421421
return Ok(true);
@@ -575,14 +575,7 @@ impl<'a> Resolver<'a> {
575575
}
576576

577577
let res = if path.len() > 1 {
578-
let res = match self.resolve_path(
579-
&path,
580-
Some(MacroNS),
581-
parent_scope,
582-
false,
583-
path_span,
584-
CrateLint::No,
585-
) {
578+
let res = match self.resolve_path(&path, Some(MacroNS), parent_scope, Finalize::No) {
586579
PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => {
587580
Ok(path_res.base_res())
588581
}
@@ -612,9 +605,8 @@ impl<'a> Resolver<'a> {
612605
path[0].ident,
613606
scope_set,
614607
parent_scope,
615-
false,
608+
None,
616609
force,
617-
path_span,
618610
);
619611
if let Err(Determinacy::Undetermined) = binding {
620612
return Err(Determinacy::Undetermined);
@@ -648,9 +640,8 @@ impl<'a> Resolver<'a> {
648640
orig_ident: Ident,
649641
scope_set: ScopeSet<'a>,
650642
parent_scope: &ParentScope<'a>,
651-
record_used: bool,
643+
finalize: Option<Span>,
652644
force: bool,
653-
path_span: Span,
654645
) -> Result<&'a NameBinding<'a>, Determinacy> {
655646
bitflags::bitflags! {
656647
struct Flags: u8 {
@@ -662,7 +653,7 @@ impl<'a> Resolver<'a> {
662653
}
663654
}
664655

665-
assert!(force || !record_used); // `record_used` implies `force`
656+
assert!(force || !finalize.is_some()); // `finalize` implies `force`
666657

667658
// Make sure `self`, `super` etc produce an error when passed to here.
668659
if orig_ident.is_path_segment_keyword() {
@@ -769,8 +760,7 @@ impl<'a> Resolver<'a> {
769760
ident,
770761
ns,
771762
parent_scope,
772-
record_used,
773-
path_span,
763+
finalize,
774764
);
775765
match binding {
776766
Ok(binding) => Ok((binding, Flags::MODULE | Flags::MISC_SUGGEST_CRATE)),
@@ -791,8 +781,7 @@ impl<'a> Resolver<'a> {
791781
ns,
792782
adjusted_parent_scope,
793783
!matches!(scope_set, ScopeSet::Late(..)),
794-
record_used,
795-
path_span,
784+
finalize,
796785
);
797786
match binding {
798787
Ok(binding) => {
@@ -856,12 +845,14 @@ impl<'a> Resolver<'a> {
856845
Err(Determinacy::Determined)
857846
}
858847
}
859-
Scope::ExternPrelude => match this.extern_prelude_get(ident, !record_used) {
860-
Some(binding) => Ok((binding, Flags::empty())),
861-
None => Err(Determinacy::determined(
862-
this.graph_root.unexpanded_invocations.borrow().is_empty(),
863-
)),
864-
},
848+
Scope::ExternPrelude => {
849+
match this.extern_prelude_get(ident, finalize.is_some()) {
850+
Some(binding) => Ok((binding, Flags::empty())),
851+
None => Err(Determinacy::determined(
852+
this.graph_root.unexpanded_invocations.borrow().is_empty(),
853+
)),
854+
}
855+
}
865856
Scope::ToolPrelude => match this.registered_tools.get(&ident).cloned() {
866857
Some(ident) => ok(Res::ToolMod, ident.span, this.arenas),
867858
None => Err(Determinacy::Determined),
@@ -874,8 +865,7 @@ impl<'a> Resolver<'a> {
874865
ident,
875866
ns,
876867
parent_scope,
877-
false,
878-
path_span,
868+
None,
879869
) {
880870
if use_prelude || this.is_builtin_macro(binding.res()) {
881871
result = Ok((binding, Flags::MISC_FROM_PRELUDE));
@@ -894,7 +884,7 @@ impl<'a> Resolver<'a> {
894884
Ok((binding, flags))
895885
if sub_namespace_match(binding.macro_kind(), macro_kind) =>
896886
{
897-
if !record_used || matches!(scope_set, ScopeSet::Late(..)) {
887+
if finalize.is_none() || matches!(scope_set, ScopeSet::Late(..)) {
898888
return Some(Ok(binding));
899889
}
900890

@@ -1033,9 +1023,7 @@ impl<'a> Resolver<'a> {
10331023
&path,
10341024
Some(MacroNS),
10351025
&parent_scope,
1036-
true,
1037-
path_span,
1038-
CrateLint::No,
1026+
Finalize::SimplePath(ast::CRATE_NODE_ID, path_span),
10391027
) {
10401028
PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => {
10411029
let res = path_res.base_res();
@@ -1069,9 +1057,8 @@ impl<'a> Resolver<'a> {
10691057
ident,
10701058
ScopeSet::Macro(kind),
10711059
&parent_scope,
1060+
Some(ident.span),
10721061
true,
1073-
true,
1074-
ident.span,
10751062
) {
10761063
Ok(binding) => {
10771064
let initial_res = initial_binding.map(|initial_binding| {
@@ -1111,9 +1098,8 @@ impl<'a> Resolver<'a> {
11111098
ident,
11121099
ScopeSet::Macro(MacroKind::Attr),
11131100
&parent_scope,
1101+
Some(ident.span),
11141102
true,
1115-
true,
1116-
ident.span,
11171103
);
11181104
}
11191105
}

‎src/bootstrap/native.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ fn configure_cmake(
568568
// We also do this if the user explicitly requested static libstdc++.
569569
if builder.config.llvm_static_stdcpp {
570570
if !target.contains("msvc") && !target.contains("netbsd") {
571-
if target.contains("apple") {
571+
if target.contains("apple") || target.contains("windows") {
572572
ldflags.push_all("-static-libstdc++");
573573
} else {
574574
ldflags.push_all("-Wl,-Bsymbolic -static-libstdc++");

‎src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -487,12 +487,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
487487
module_id: DefId,
488488
) -> Result<Res, ResolutionFailure<'a>> {
489489
self.cx.enter_resolver(|resolver| {
490-
// NOTE: this needs 2 separate lookups because `resolve_str_path_error` doesn't take
490+
// NOTE: this needs 2 separate lookups because `resolve_rustdoc_path` doesn't take
491491
// lexical scope into account (it ignores all macros not defined at the mod-level)
492492
debug!("resolving {} as a macro in the module {:?}", path_str, module_id);
493-
if let Ok((_, res)) =
494-
resolver.resolve_str_path_error(DUMMY_SP, path_str, MacroNS, module_id)
495-
{
493+
if let Some(res) = resolver.resolve_rustdoc_path(path_str, MacroNS, module_id) {
496494
// don't resolve builtins like `#[derive]`
497495
if let Ok(res) = res.try_into() {
498496
return Ok(res);
@@ -540,10 +538,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
540538
})
541539
}
542540

543-
/// Convenience wrapper around `resolve_str_path_error`.
541+
/// Convenience wrapper around `resolve_rustdoc_path`.
544542
///
545543
/// This also handles resolving `true` and `false` as booleans.
546-
/// NOTE: `resolve_str_path_error` knows only about paths, not about types.
544+
/// NOTE: `resolve_rustdoc_path` knows only about paths, not about types.
547545
/// Associated items will never be resolved by this function.
548546
fn resolve_path(
549547
&self,
@@ -556,18 +554,14 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
556554
return res;
557555
}
558556

559-
let result = self.cx.enter_resolver(|resolver| {
560-
resolver
561-
.resolve_str_path_error(DUMMY_SP, path_str, ns, module_id)
562-
.and_then(|(_, res)| res.try_into())
563-
});
557+
// Resolver doesn't know about true, false, and types that aren't paths (e.g. `()`).
558+
let result = self
559+
.cx
560+
.enter_resolver(|resolver| resolver.resolve_rustdoc_path(path_str, ns, module_id))
561+
.and_then(|res| res.try_into().ok())
562+
.or_else(|| resolve_primitive(path_str, ns));
564563
debug!("{} resolved to {:?} in namespace {:?}", path_str, result, ns);
565-
match result {
566-
// resolver doesn't know about true, false, and types that aren't paths (e.g. `()`)
567-
// manually as bool
568-
Err(()) => resolve_primitive(path_str, ns),
569-
Ok(res) => Some(res),
570-
}
564+
result
571565
}
572566

573567
/// Resolves a string as a path within a particular namespace. Returns an

‎src/librustdoc/passes/collect_intra_doc_links/early.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_hir::TraitCandidate;
1313
use rustc_middle::ty::{DefIdTree, Visibility};
1414
use rustc_resolve::{ParentScope, Resolver};
1515
use rustc_session::config::Externs;
16-
use rustc_span::{Span, SyntaxContext, DUMMY_SP};
16+
use rustc_span::SyntaxContext;
1717

1818
use std::collections::hash_map::Entry;
1919
use std::mem;
@@ -39,7 +39,7 @@ crate fn early_resolve_intra_doc_links(
3939

4040
// Overridden `visit_item` below doesn't apply to the crate root,
4141
// so we have to visit its attributes and reexports separately.
42-
loader.load_links_in_attrs(&krate.attrs, krate.spans.inner_span);
42+
loader.load_links_in_attrs(&krate.attrs);
4343
loader.process_module_children_or_reexports(CRATE_DEF_ID.to_def_id());
4444
visit::walk_crate(&mut loader, krate);
4545
loader.add_foreign_traits_in_scope();
@@ -49,12 +49,7 @@ crate fn early_resolve_intra_doc_links(
4949
// DO NOT REMOVE THIS without first testing on the reproducer in
5050
// https://github.com/jyn514/objr/commit/edcee7b8124abf0e4c63873e8422ff81beb11ebb
5151
for (extern_name, _) in externs.iter().filter(|(_, entry)| entry.add_prelude) {
52-
let _ = loader.resolver.resolve_str_path_error(
53-
DUMMY_SP,
54-
extern_name,
55-
TypeNS,
56-
CRATE_DEF_ID.to_def_id(),
57-
);
52+
loader.resolver.resolve_rustdoc_path(extern_name, TypeNS, CRATE_DEF_ID.to_def_id());
5853
}
5954

6055
ResolverCaches {
@@ -151,7 +146,7 @@ impl IntraLinkCrateLoader<'_, '_> {
151146
}
152147
}
153148

154-
fn load_links_in_attrs(&mut self, attrs: &[ast::Attribute], span: Span) {
149+
fn load_links_in_attrs(&mut self, attrs: &[ast::Attribute]) {
155150
// FIXME: this needs to consider reexport inlining.
156151
let attrs = clean::Attributes::from_ast(attrs, None);
157152
for (parent_module, doc) in attrs.collapsed_doc_value_by_module_level() {
@@ -165,7 +160,7 @@ impl IntraLinkCrateLoader<'_, '_> {
165160
} else {
166161
continue;
167162
};
168-
let _ = self.resolver.resolve_str_path_error(span, &path_str, TypeNS, module_id);
163+
self.resolver.resolve_rustdoc_path(&path_str, TypeNS, module_id);
169164
}
170165
}
171166
}
@@ -201,7 +196,7 @@ impl Visitor<'_> for IntraLinkCrateLoader<'_, '_> {
201196
// loaded, even if the module itself has no doc comments.
202197
self.add_traits_in_parent_scope(self.current_mod.to_def_id());
203198

204-
self.load_links_in_attrs(&item.attrs, item.span);
199+
self.load_links_in_attrs(&item.attrs);
205200
self.process_module_children_or_reexports(self.current_mod.to_def_id());
206201
visit::walk_item(self, item);
207202

@@ -216,28 +211,28 @@ impl Visitor<'_> for IntraLinkCrateLoader<'_, '_> {
216211
}
217212
_ => {}
218213
}
219-
self.load_links_in_attrs(&item.attrs, item.span);
214+
self.load_links_in_attrs(&item.attrs);
220215
visit::walk_item(self, item);
221216
}
222217
}
223218

224219
fn visit_assoc_item(&mut self, item: &ast::AssocItem, ctxt: AssocCtxt) {
225-
self.load_links_in_attrs(&item.attrs, item.span);
220+
self.load_links_in_attrs(&item.attrs);
226221
visit::walk_assoc_item(self, item, ctxt)
227222
}
228223

229224
fn visit_foreign_item(&mut self, item: &ast::ForeignItem) {
230-
self.load_links_in_attrs(&item.attrs, item.span);
225+
self.load_links_in_attrs(&item.attrs);
231226
visit::walk_foreign_item(self, item)
232227
}
233228

234229
fn visit_variant(&mut self, v: &ast::Variant) {
235-
self.load_links_in_attrs(&v.attrs, v.span);
230+
self.load_links_in_attrs(&v.attrs);
236231
visit::walk_variant(self, v)
237232
}
238233

239234
fn visit_field_def(&mut self, field: &ast::FieldDef) {
240-
self.load_links_in_attrs(&field.attrs, field.span);
235+
self.load_links_in_attrs(&field.attrs);
241236
visit::walk_field_def(self, field)
242237
}
243238

‎src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,18 @@ crate mod foo {
1717
use crate::foo::{bar::{baz::{}}};
1818
//~^ ERROR absolute paths must start with
1919
//~| WARN this is accepted in the current edition
20-
//~| ERROR absolute paths must start with
21-
//~| WARN this is accepted in the current edition
2220

2321
use crate::foo::{bar::{XX, baz::{}}};
2422
//~^ ERROR absolute paths must start with
2523
//~| WARN this is accepted in the current edition
2624
//~| ERROR absolute paths must start with
2725
//~| WARN this is accepted in the current edition
28-
//~| ERROR absolute paths must start with
29-
//~| WARN this is accepted in the current edition
30-
//~| ERROR absolute paths must start with
31-
//~| WARN this is accepted in the current edition
3226

3327
use crate::foo::{bar::{baz::{}, baz1::{}}};
3428
//~^ ERROR absolute paths must start with
3529
//~| WARN this is accepted in the current edition
3630
//~| ERROR absolute paths must start with
3731
//~| WARN this is accepted in the current edition
38-
//~| ERROR absolute paths must start with
39-
//~| WARN this is accepted in the current edition
40-
//~| ERROR absolute paths must start with
41-
//~| WARN this is accepted in the current edition
4232

4333
fn main() {
4434
}

‎src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,18 @@ crate mod foo {
1717
use foo::{bar::{baz::{}}};
1818
//~^ ERROR absolute paths must start with
1919
//~| WARN this is accepted in the current edition
20-
//~| ERROR absolute paths must start with
21-
//~| WARN this is accepted in the current edition
2220

2321
use foo::{bar::{XX, baz::{}}};
2422
//~^ ERROR absolute paths must start with
2523
//~| WARN this is accepted in the current edition
2624
//~| ERROR absolute paths must start with
2725
//~| WARN this is accepted in the current edition
28-
//~| ERROR absolute paths must start with
29-
//~| WARN this is accepted in the current edition
30-
//~| ERROR absolute paths must start with
31-
//~| WARN this is accepted in the current edition
3226

3327
use foo::{bar::{baz::{}, baz1::{}}};
3428
//~^ ERROR absolute paths must start with
3529
//~| WARN this is accepted in the current edition
3630
//~| ERROR absolute paths must start with
3731
//~| WARN this is accepted in the current edition
38-
//~| ERROR absolute paths must start with
39-
//~| WARN this is accepted in the current edition
40-
//~| ERROR absolute paths must start with
41-
//~| WARN this is accepted in the current edition
4232

4333
fn main() {
4434
}

‎src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,7 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
1313
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
1414

1515
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
16-
--> $DIR/edition-lint-nested-empty-paths.rs:17:5
17-
|
18-
LL | use foo::{bar::{baz::{}}};
19-
| ^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}}}`
20-
|
21-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
22-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
23-
24-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
25-
--> $DIR/edition-lint-nested-empty-paths.rs:23:5
16+
--> $DIR/edition-lint-nested-empty-paths.rs:21:5
2617
|
2718
LL | use foo::{bar::{XX, baz::{}}};
2819
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
@@ -31,7 +22,7 @@ LL | use foo::{bar::{XX, baz::{}}};
3122
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
3223

3324
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
34-
--> $DIR/edition-lint-nested-empty-paths.rs:23:5
25+
--> $DIR/edition-lint-nested-empty-paths.rs:21:5
3526
|
3627
LL | use foo::{bar::{XX, baz::{}}};
3728
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
@@ -40,43 +31,7 @@ LL | use foo::{bar::{XX, baz::{}}};
4031
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
4132

4233
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
43-
--> $DIR/edition-lint-nested-empty-paths.rs:23:5
44-
|
45-
LL | use foo::{bar::{XX, baz::{}}};
46-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
47-
|
48-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
49-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
50-
51-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
52-
--> $DIR/edition-lint-nested-empty-paths.rs:23:5
53-
|
54-
LL | use foo::{bar::{XX, baz::{}}};
55-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
56-
|
57-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
58-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
59-
60-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
61-
--> $DIR/edition-lint-nested-empty-paths.rs:33:5
62-
|
63-
LL | use foo::{bar::{baz::{}, baz1::{}}};
64-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
65-
|
66-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
67-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
68-
69-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
70-
--> $DIR/edition-lint-nested-empty-paths.rs:33:5
71-
|
72-
LL | use foo::{bar::{baz::{}, baz1::{}}};
73-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
74-
|
75-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
76-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
77-
78-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
79-
--> $DIR/edition-lint-nested-empty-paths.rs:33:5
34+
--> $DIR/edition-lint-nested-empty-paths.rs:27:5
8035
|
8136
LL | use foo::{bar::{baz::{}, baz1::{}}};
8237
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
@@ -85,13 +40,13 @@ LL | use foo::{bar::{baz::{}, baz1::{}}};
8540
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
8641

8742
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
88-
--> $DIR/edition-lint-nested-empty-paths.rs:33:5
43+
--> $DIR/edition-lint-nested-empty-paths.rs:27:5
8944
|
9045
LL | use foo::{bar::{baz::{}, baz1::{}}};
9146
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
9247
|
9348
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
9449
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
9550

96-
error: aborting due to 10 previous errors
51+
error: aborting due to 5 previous errors
9752

‎src/test/ui/rust-2018/edition-lint-nested-paths.fixed

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ use crate::foo::{a, b};
88
//~| this is accepted in the current edition
99
//~| ERROR absolute paths must start with
1010
//~| this is accepted in the current edition
11-
//~| ERROR absolute paths must start with
12-
//~| this is accepted in the current edition
13-
//~| ERROR absolute paths must start with
14-
//~| this is accepted in the current edition
1511

1612
mod foo {
1713
crate fn a() {}
@@ -29,8 +25,6 @@ fn main() {
2925
//~| this is accepted in the current edition
3026
//~| ERROR absolute paths must start with
3127
//~| this is accepted in the current edition
32-
//~| ERROR absolute paths must start with
33-
//~| this is accepted in the current edition
3428
x::a();
3529
c();
3630
}

‎src/test/ui/rust-2018/edition-lint-nested-paths.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ use foo::{a, b};
88
//~| this is accepted in the current edition
99
//~| ERROR absolute paths must start with
1010
//~| this is accepted in the current edition
11-
//~| ERROR absolute paths must start with
12-
//~| this is accepted in the current edition
13-
//~| ERROR absolute paths must start with
14-
//~| this is accepted in the current edition
1511

1612
mod foo {
1713
crate fn a() {}
@@ -29,8 +25,6 @@ fn main() {
2925
//~| this is accepted in the current edition
3026
//~| ERROR absolute paths must start with
3127
//~| this is accepted in the current edition
32-
//~| ERROR absolute paths must start with
33-
//~| this is accepted in the current edition
3428
x::a();
3529
c();
3630
}

‎src/test/ui/rust-2018/edition-lint-nested-paths.stderr

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,7 @@ LL | use foo::{a, b};
2222
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
2323

2424
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
25-
--> $DIR/edition-lint-nested-paths.rs:6:5
26-
|
27-
LL | use foo::{a, b};
28-
| ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
29-
|
30-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
31-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
32-
33-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
34-
--> $DIR/edition-lint-nested-paths.rs:6:5
35-
|
36-
LL | use foo::{a, b};
37-
| ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
38-
|
39-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
40-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
41-
42-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
43-
--> $DIR/edition-lint-nested-paths.rs:27:13
44-
|
45-
LL | use foo::{self as x, c};
46-
| ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
47-
|
48-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
49-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
50-
51-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
52-
--> $DIR/edition-lint-nested-paths.rs:27:13
25+
--> $DIR/edition-lint-nested-paths.rs:23:13
5326
|
5427
LL | use foo::{self as x, c};
5528
| ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
@@ -58,13 +31,13 @@ LL | use foo::{self as x, c};
5831
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
5932

6033
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
61-
--> $DIR/edition-lint-nested-paths.rs:27:13
34+
--> $DIR/edition-lint-nested-paths.rs:23:13
6235
|
6336
LL | use foo::{self as x, c};
6437
| ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
6538
|
6639
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
6740
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
6841

69-
error: aborting due to 7 previous errors
42+
error: aborting due to 4 previous errors
7043

‎src/test/ui/rust-2018/edition-lint-paths.fixed

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ pub mod foo {
1212
use crate::bar::Bar;
1313
//~^ ERROR absolute
1414
//~| WARN this is accepted in the current edition
15-
//~| ERROR absolute
16-
//~| WARN this is accepted in the current edition
1715

1816
use super::bar::Bar2;
1917
use crate::bar::Bar3;
@@ -42,8 +40,6 @@ pub mod foo {
4240
use crate::bar::Bar;
4341
//~^ ERROR absolute
4442
//~| WARN this is accepted in the current edition
45-
//~| ERROR absolute
46-
//~| WARN this is accepted in the current edition
4743

4844
pub mod bar {
4945
use edition_lint_paths as foo;
@@ -61,8 +57,6 @@ mod baz {
6157
impl crate::foo::SomeTrait for u32 {}
6258
//~^ ERROR absolute
6359
//~| WARN this is accepted in the current edition
64-
//~| ERROR absolute
65-
//~| WARN this is accepted in the current edition
6660

6761
fn main() {
6862
let x = crate::bar::Bar;

‎src/test/ui/rust-2018/edition-lint-paths.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ pub mod foo {
1212
use bar::Bar;
1313
//~^ ERROR absolute
1414
//~| WARN this is accepted in the current edition
15-
//~| ERROR absolute
16-
//~| WARN this is accepted in the current edition
1715

1816
use super::bar::Bar2;
1917
use crate::bar::Bar3;
@@ -42,8 +40,6 @@ pub mod foo {
4240
use bar::Bar;
4341
//~^ ERROR absolute
4442
//~| WARN this is accepted in the current edition
45-
//~| ERROR absolute
46-
//~| WARN this is accepted in the current edition
4743

4844
pub mod bar {
4945
use edition_lint_paths as foo;
@@ -61,8 +57,6 @@ mod baz {
6157
impl ::foo::SomeTrait for u32 {}
6258
//~^ ERROR absolute
6359
//~| WARN this is accepted in the current edition
64-
//~| ERROR absolute
65-
//~| WARN this is accepted in the current edition
6660

6761
fn main() {
6862
let x = ::bar::Bar;

‎src/test/ui/rust-2018/edition-lint-paths.stderr

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,7 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
1313
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
1414

1515
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
16-
--> $DIR/edition-lint-paths.rs:12:9
17-
|
18-
LL | use bar::Bar;
19-
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
20-
|
21-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
22-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
23-
24-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
25-
--> $DIR/edition-lint-paths.rs:21:9
16+
--> $DIR/edition-lint-paths.rs:19:9
2617
|
2718
LL | use bar;
2819
| ^^^ help: use `crate`: `crate::bar`
@@ -31,7 +22,7 @@ LL | use bar;
3122
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
3223

3324
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
34-
--> $DIR/edition-lint-paths.rs:27:9
25+
--> $DIR/edition-lint-paths.rs:25:9
3526
|
3627
LL | use {main, Bar as SomethingElse};
3728
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@@ -40,7 +31,7 @@ LL | use {main, Bar as SomethingElse};
4031
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
4132

4233
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
43-
--> $DIR/edition-lint-paths.rs:27:9
34+
--> $DIR/edition-lint-paths.rs:25:9
4435
|
4536
LL | use {main, Bar as SomethingElse};
4637
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@@ -49,7 +40,7 @@ LL | use {main, Bar as SomethingElse};
4940
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
5041

5142
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
52-
--> $DIR/edition-lint-paths.rs:27:9
43+
--> $DIR/edition-lint-paths.rs:25:9
5344
|
5445
LL | use {main, Bar as SomethingElse};
5546
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@@ -58,7 +49,7 @@ LL | use {main, Bar as SomethingElse};
5849
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
5950

6051
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
61-
--> $DIR/edition-lint-paths.rs:42:5
52+
--> $DIR/edition-lint-paths.rs:40:5
6253
|
6354
LL | use bar::Bar;
6455
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
@@ -67,16 +58,7 @@ LL | use bar::Bar;
6758
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
6859

6960
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
70-
--> $DIR/edition-lint-paths.rs:42:5
71-
|
72-
LL | use bar::Bar;
73-
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
74-
|
75-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
76-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
77-
78-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
79-
--> $DIR/edition-lint-paths.rs:56:9
61+
--> $DIR/edition-lint-paths.rs:52:9
8062
|
8163
LL | use *;
8264
| ^ help: use `crate`: `crate::*`
@@ -85,16 +67,7 @@ LL | use *;
8567
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
8668

8769
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
88-
--> $DIR/edition-lint-paths.rs:61:6
89-
|
90-
LL | impl ::foo::SomeTrait for u32 {}
91-
| ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait`
92-
|
93-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
94-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
95-
96-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
97-
--> $DIR/edition-lint-paths.rs:61:6
70+
--> $DIR/edition-lint-paths.rs:57:6
9871
|
9972
LL | impl ::foo::SomeTrait for u32 {}
10073
| ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait`
@@ -103,13 +76,13 @@ LL | impl ::foo::SomeTrait for u32 {}
10376
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
10477

10578
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
106-
--> $DIR/edition-lint-paths.rs:68:13
79+
--> $DIR/edition-lint-paths.rs:62:13
10780
|
10881
LL | let x = ::bar::Bar;
10982
| ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar`
11083
|
11184
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
11285
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
11386

114-
error: aborting due to 12 previous errors
87+
error: aborting due to 9 previous errors
11588

‎src/test/ui/rust-2018/extern-crate-rename.fixed

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ extern crate edition_lint_paths as my_crate;
1212
use crate::my_crate::foo;
1313
//~^ ERROR absolute paths must start
1414
//~| WARNING this is accepted in the current edition
15-
//~| ERROR absolute paths must start
16-
//~| WARNING this is accepted in the current edition
1715

1816
fn main() {
1917
foo();

‎src/test/ui/rust-2018/extern-crate-rename.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ extern crate edition_lint_paths as my_crate;
1212
use my_crate::foo;
1313
//~^ ERROR absolute paths must start
1414
//~| WARNING this is accepted in the current edition
15-
//~| ERROR absolute paths must start
16-
//~| WARNING this is accepted in the current edition
1715

1816
fn main() {
1917
foo();

‎src/test/ui/rust-2018/extern-crate-rename.stderr

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,5 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
1212
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
1313
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
1414

15-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
16-
--> $DIR/extern-crate-rename.rs:12:5
17-
|
18-
LL | use my_crate::foo;
19-
| ^^^^^^^^^^^^^ help: use `crate`: `crate::my_crate::foo`
20-
|
21-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
22-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
23-
24-
error: aborting due to 2 previous errors
15+
error: aborting due to previous error
2516

‎src/test/ui/rust-2018/extern-crate-submod.fixed

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ mod m {
1919
use crate::m::edition_lint_paths::foo;
2020
//~^ ERROR absolute paths must start
2121
//~| WARNING this is accepted in the current edition
22-
//~| ERROR absolute paths must start
23-
//~| WARNING this is accepted in the current edition
24-
2522

2623
fn main() {
2724
foo();

‎src/test/ui/rust-2018/extern-crate-submod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ mod m {
1919
use m::edition_lint_paths::foo;
2020
//~^ ERROR absolute paths must start
2121
//~| WARNING this is accepted in the current edition
22-
//~| ERROR absolute paths must start
23-
//~| WARNING this is accepted in the current edition
24-
2522

2623
fn main() {
2724
foo();

‎src/test/ui/rust-2018/extern-crate-submod.stderr

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,5 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
1212
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
1313
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
1414

15-
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
16-
--> $DIR/extern-crate-submod.rs:19:5
17-
|
18-
LL | use m::edition_lint_paths::foo;
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::m::edition_lint_paths::foo`
20-
|
21-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
22-
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
23-
24-
error: aborting due to 2 previous errors
15+
error: aborting due to previous error
2516

0 commit comments

Comments
 (0)
Please sign in to comment.