Skip to content
/ rust Public
forked from rust-lang/rust

Commit f3847f0

Browse files
committed
Remove some "name isn't empty" assertions.
These were low value even before rust-lang#137978 resulted in empty names being used much less. (Why check for non-emptiness in these three places? There are thousands of places in the compiler you could check.)
1 parent 990039e commit f3847f0

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

Diff for: compiler/rustc_ast_lowering/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17651765
ident: Ident,
17661766
is_anon_in_path: IsAnonInPath,
17671767
) -> &'hir hir::Lifetime {
1768-
debug_assert_ne!(ident.name, kw::Empty);
17691768
let res = self.resolver.get_lifetime_res(id).unwrap_or(LifetimeRes::Error);
17701769
let res = match res {
17711770
LifetimeRes::Param { param, .. } => hir::LifetimeName::Param(param),

Diff for: compiler/rustc_hir_typeck/src/expr.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1600,11 +1600,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16001600
Ok(method)
16011601
}
16021602
Err(error) => {
1603-
if segment.ident.name == kw::Empty {
1604-
span_bug!(rcvr.span, "empty method name")
1605-
} else {
1606-
Err(self.report_method_error(expr.hir_id, rcvr_t, error, expected, false))
1607-
}
1603+
Err(self.report_method_error(expr.hir_id, rcvr_t, error, expected, false))
16081604
}
16091605
};
16101606

@@ -2942,9 +2938,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29422938
return Ty::new_error(self.tcx(), guar);
29432939
}
29442940

2945-
let guar = if field.name == kw::Empty {
2946-
self.dcx().span_bug(field.span, "field name with no name")
2947-
} else if self.method_exists_for_diagnostic(
2941+
let guar = if self.method_exists_for_diagnostic(
29482942
field,
29492943
base_ty,
29502944
expr.hir_id,

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ use rustc_middle::ty::{
2727
};
2828
use rustc_middle::{bug, span_bug};
2929
use rustc_session::lint;
30+
use rustc_span::Span;
3031
use rustc_span::def_id::LocalDefId;
3132
use rustc_span::hygiene::DesugaringKind;
32-
use rustc_span::{Span, kw};
3333
use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded;
3434
use rustc_trait_selection::traits::{
3535
self, NormalizeExt, ObligationCauseCode, StructurallyNormalizeExt,
@@ -833,7 +833,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
833833

834834
let trait_missing_method =
835835
matches!(error, method::MethodError::NoMatch(_)) && ty.normalized.is_trait();
836-
assert_ne!(item_name.name, kw::Empty);
837836
self.report_method_error(
838837
hir_id,
839838
ty.normalized,

0 commit comments

Comments
 (0)