Skip to content

Commit 9757e90

Browse files
committed
Auto merge of #69958 - Centril:rollup-ecgx11p, r=Centril
Rollup of 8 pull requests Successful merges: - #68746 (Make macro metavars respect (non-)hygiene) - #69189 (Erase regions in writeback) - #69402 (Extend search) - #69403 (Implement `Copy` for `IoSlice`) - #69460 (Move some `build-pass` tests to `check-pass`) - #69802 (fix more clippy findings) - #69809 (remove lifetimes that can be elided (clippy::needless_lifetimes)) - #69949 (triagebot.toml: add ping aliases) Failed merges: - #69589 (ast: `Mac`/`Macro` -> `MacCall`) r? @ghost
2 parents 54b7d21 + e1f3da1 commit 9757e90

File tree

132 files changed

+770
-552
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+770
-552
lines changed

src/liballoc/collections/linked_list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ impl<'a, T> CursorMut<'a, T> {
14271427
/// `CursorMut`, which means it cannot outlive the `CursorMut` and that the
14281428
/// `CursorMut` is frozen for the lifetime of the `Cursor`.
14291429
#[unstable(feature = "linked_list_cursors", issue = "58533")]
1430-
pub fn as_cursor<'cm>(&'cm self) -> Cursor<'cm, T> {
1430+
pub fn as_cursor(&self) -> Cursor<'_, T> {
14311431
Cursor { list: self.list, current: self.current, index: self.index }
14321432
}
14331433
}

src/libcore/str/pattern.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,7 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> {
365365
let haystack = self.haystack.as_bytes();
366366
loop {
367367
// get the haystack up to but not including the last character searched
368-
let bytes = if let Some(slice) = haystack.get(self.finger..self.finger_back) {
369-
slice
370-
} else {
371-
return None;
372-
};
368+
let bytes = haystack.get(self.finger..self.finger_back)?;
373369
// the last byte of the utf8 encoded needle
374370
// SAFETY: we have an invariant that `utf8_size < 5`
375371
let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size - 1) };
@@ -575,11 +571,12 @@ macro_rules! pattern_methods {
575571

576572
#[inline]
577573
fn is_suffix_of(self, haystack: &'a str) -> bool
578-
where $t: ReverseSearcher<'a>
574+
where
575+
$t: ReverseSearcher<'a>,
579576
{
580577
($pmap)(self).is_suffix_of(haystack)
581578
}
582-
}
579+
};
583580
}
584581

585582
macro_rules! searcher_methods {
@@ -614,7 +611,7 @@ macro_rules! searcher_methods {
614611
fn next_reject_back(&mut self) -> Option<(usize, usize)> {
615612
self.0.next_reject_back()
616613
}
617-
}
614+
};
618615
}
619616

620617
/////////////////////////////////////////////////////////////////////////////

src/librustc/dep_graph/dep_node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ macro_rules! define_dep_nodes {
179179
$(
180180
#[inline(always)]
181181
#[allow(unreachable_code, non_snake_case)]
182-
pub fn $variant<'tcx>(_tcx: TyCtxt<'tcx>, $(arg: $tuple_arg_ty)*) -> DepNode {
182+
pub fn $variant(_tcx: TyCtxt<'_>, $(arg: $tuple_arg_ty)*) -> DepNode {
183183
// tuple args
184184
$({
185185
erase!($tuple_arg_ty);

src/librustc/hir/map/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
340340
/// deep walking so that we walk nested items in the context of
341341
/// their outer items.
342342
343-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
343+
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
344344
panic!("`visit_nested_xxx` must be manually implemented in this visitor");
345345
}
346346

src/librustc/hir/map/hir_id_validator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
135135
impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
136136
type Map = Map<'hir>;
137137

138-
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> {
138+
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
139139
intravisit::NestedVisitorMap::OnlyBodies(self.hir_map)
140140
}
141141

src/librustc/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl<'hir> Map<'hir> {
298298
}
299299

300300
pub fn def_kind(&self, hir_id: HirId) -> Option<DefKind> {
301-
let node = if let Some(node) = self.find(hir_id) { node } else { return None };
301+
let node = self.find(hir_id)?;
302302

303303
Some(match node {
304304
Node::Item(item) => match item.kind {

src/librustc/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ pub enum ClearCrossCrate<T> {
403403
}
404404

405405
impl<T> ClearCrossCrate<T> {
406-
pub fn as_ref(&'a self) -> ClearCrossCrate<&'a T> {
406+
pub fn as_ref(&self) -> ClearCrossCrate<&T> {
407407
match self {
408408
ClearCrossCrate::Clear => ClearCrossCrate::Clear,
409409
ClearCrossCrate::Set(v) => ClearCrossCrate::Set(v),
@@ -2503,7 +2503,7 @@ impl UserTypeProjection {
25032503

25042504
pub(crate) fn variant(
25052505
mut self,
2506-
adt_def: &'tcx AdtDef,
2506+
adt_def: &AdtDef,
25072507
variant_index: VariantIdx,
25082508
field: Field,
25092509
) -> Self {

src/librustc/ty/context.rs

-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use crate::mir::{
2222
};
2323
use crate::traits;
2424
use crate::traits::{Clause, Clauses, Goal, GoalKind, Goals};
25-
use crate::ty::free_region_map::FreeRegionMap;
2625
use crate::ty::layout::{LayoutDetails, TargetDataLayout, VariantIdx};
2726
use crate::ty::query;
2827
use crate::ty::steal::Steal;
@@ -415,11 +414,6 @@ pub struct TypeckTables<'tcx> {
415414
/// this field will be set to `true`.
416415
pub tainted_by_errors: bool,
417416

418-
/// Stores the free-region relationships that were deduced from
419-
/// its where-clauses and parameter types. These are then
420-
/// read-again by borrowck.
421-
pub free_region_map: FreeRegionMap<'tcx>,
422-
423417
/// All the opaque types that are restricted to concrete types
424418
/// by this function.
425419
pub concrete_opaque_types: FxHashMap<DefId, ResolvedOpaqueTy<'tcx>>,
@@ -455,7 +449,6 @@ impl<'tcx> TypeckTables<'tcx> {
455449
coercion_casts: Default::default(),
456450
used_trait_imports: Lrc::new(Default::default()),
457451
tainted_by_errors: false,
458-
free_region_map: Default::default(),
459452
concrete_opaque_types: Default::default(),
460453
upvar_list: Default::default(),
461454
generator_interior_types: Default::default(),
@@ -718,7 +711,6 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckTables<'tcx> {
718711

719712
ref used_trait_imports,
720713
tainted_by_errors,
721-
ref free_region_map,
722714
ref concrete_opaque_types,
723715
ref upvar_list,
724716
ref generator_interior_types,
@@ -756,7 +748,6 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckTables<'tcx> {
756748
coercion_casts.hash_stable(hcx, hasher);
757749
used_trait_imports.hash_stable(hcx, hasher);
758750
tainted_by_errors.hash_stable(hcx, hasher);
759-
free_region_map.hash_stable(hcx, hasher);
760751
concrete_opaque_types.hash_stable(hcx, hasher);
761752
upvar_list.hash_stable(hcx, hasher);
762753
generator_interior_types.hash_stable(hcx, hasher);

src/librustc/ty/util.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,7 @@ impl<'tcx> TyCtxt<'tcx> {
346346
adt_did: DefId,
347347
validate: &mut dyn FnMut(Self, DefId) -> Result<(), ErrorReported>,
348348
) -> Option<ty::Destructor> {
349-
let drop_trait = if let Some(def_id) = self.lang_items().drop_trait() {
350-
def_id
351-
} else {
352-
return None;
353-
};
354-
349+
let drop_trait = self.lang_items().drop_trait()?;
355350
self.ensure().coherent_trait(drop_trait);
356351

357352
let mut dtor_did = None;

src/librustc_codegen_llvm/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
320320
}
321321
}
322322

323-
pub fn val_ty(v: &'ll Value) -> &'ll Type {
323+
pub fn val_ty(v: &Value) -> &Type {
324324
unsafe { llvm::LLVMTypeOf(v) }
325325
}
326326

@@ -342,6 +342,6 @@ fn hi_lo_to_u128(lo: u64, hi: u64) -> u128 {
342342
((hi as u128) << 64) | (lo as u128)
343343
}
344344

345-
fn try_as_const_integral(v: &'ll Value) -> Option<&'ll ConstantInt> {
345+
fn try_as_const_integral(v: &Value) -> Option<&ConstantInt> {
346346
unsafe { llvm::LLVMIsAConstantInt(v) }
347347
}

src/librustc_codegen_llvm/llvm/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ impl Drop for SectionIter<'a> {
185185
}
186186
}
187187

188-
pub fn mk_section_iter(llof: &'a ffi::ObjectFile) -> SectionIter<'a> {
188+
pub fn mk_section_iter(llof: &ffi::ObjectFile) -> SectionIter<'_> {
189189
unsafe { SectionIter { llsi: LLVMGetSections(llof) } }
190190
}
191191

192192
/// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
193-
pub fn get_param(llfn: &'a Value, index: c_uint) -> &'a Value {
193+
pub fn get_param(llfn: &Value, index: c_uint) -> &Value {
194194
unsafe {
195195
assert!(
196196
index < LLVMCountParams(llfn),
@@ -203,7 +203,7 @@ pub fn get_param(llfn: &'a Value, index: c_uint) -> &'a Value {
203203
}
204204

205205
/// Safe wrapper for `LLVMGetValueName2` into a byte slice
206-
pub fn get_value_name(value: &'a Value) -> &'a [u8] {
206+
pub fn get_value_name(value: &Value) -> &[u8] {
207207
unsafe {
208208
let mut len = 0;
209209
let data = LLVMGetValueName2(value, &mut len);

src/librustc_codegen_llvm/type_.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl Type {
240240
unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) }
241241
}
242242

243-
pub fn i8p_llcx(llcx: &'ll llvm::Context) -> &'ll Type {
243+
pub fn i8p_llcx(llcx: &llvm::Context) -> &Type {
244244
Type::i8_llcx(llcx).ptr_to()
245245
}
246246

src/librustc_data_structures/graph/scc/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<N: Idx, S: Idx> GraphSuccessors<'graph> for Sccs<N, S> {
9797
}
9898

9999
impl<N: Idx, S: Idx> WithSuccessors for Sccs<N, S> {
100-
fn successors<'graph>(&'graph self, node: S) -> <Self as GraphSuccessors<'graph>>::Iter {
100+
fn successors(&self, node: S) -> <Self as GraphSuccessors<'_>>::Iter {
101101
self.successors(node).iter().cloned()
102102
}
103103
}

src/librustc_data_structures/graph/vec_graph/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<N: Idx> GraphSuccessors<'graph> for VecGraph<N> {
101101
}
102102

103103
impl<N: Idx> WithSuccessors for VecGraph<N> {
104-
fn successors<'graph>(&'graph self, node: N) -> <Self as GraphSuccessors<'graph>>::Iter {
104+
fn successors(&self, node: N) -> <Self as GraphSuccessors<'_>>::Iter {
105105
self.successors(node).iter().cloned()
106106
}
107107
}

src/librustc_driver/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1124,12 +1124,7 @@ fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
11241124
return None;
11251125
}
11261126

1127-
let matches = if let Some(matches) = handle_options(&args) {
1128-
matches
1129-
} else {
1130-
return None;
1131-
};
1132-
1127+
let matches = handle_options(&args)?;
11331128
let mut result = Vec::new();
11341129
let mut excluded_cargo_defaults = false;
11351130
for flag in ICE_REPORT_COMPILER_FLAGS {

src/librustc_driver/pretty.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ trait PrinterSupport: pprust::PpAnn {
9696
///
9797
/// (Rust does not yet support upcasting from a trait object to
9898
/// an object for one of its super-traits.)
99-
fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn;
99+
fn pp_ann(&self) -> &dyn pprust::PpAnn;
100100
}
101101

102102
trait HirPrinterSupport<'hir>: pprust_hir::PpAnn {
@@ -106,13 +106,13 @@ trait HirPrinterSupport<'hir>: pprust_hir::PpAnn {
106106

107107
/// Provides a uniform interface for re-extracting a reference to an
108108
/// `hir_map::Map` from a value that now owns it.
109-
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>>;
109+
fn hir_map(&self) -> Option<&hir_map::Map<'hir>>;
110110

111111
/// Produces the pretty-print annotation object.
112112
///
113113
/// (Rust does not yet support upcasting from a trait object to
114114
/// an object for one of its super-traits.)
115-
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn;
115+
fn pp_ann(&self) -> &dyn pprust_hir::PpAnn;
116116

117117
/// Computes an user-readable representation of a path, if possible.
118118
fn node_path(&self, id: hir::HirId) -> Option<String> {
@@ -132,7 +132,7 @@ impl<'hir> PrinterSupport for NoAnn<'hir> {
132132
self.sess
133133
}
134134

135-
fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn {
135+
fn pp_ann(&self) -> &dyn pprust::PpAnn {
136136
self
137137
}
138138
}
@@ -142,11 +142,11 @@ impl<'hir> HirPrinterSupport<'hir> for NoAnn<'hir> {
142142
self.sess
143143
}
144144

145-
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> {
145+
fn hir_map(&self) -> Option<&hir_map::Map<'hir>> {
146146
self.tcx.map(|tcx| *tcx.hir())
147147
}
148148

149-
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn {
149+
fn pp_ann(&self) -> &dyn pprust_hir::PpAnn {
150150
self
151151
}
152152
}
@@ -170,7 +170,7 @@ impl<'hir> PrinterSupport for IdentifiedAnnotation<'hir> {
170170
self.sess
171171
}
172172

173-
fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn {
173+
fn pp_ann(&self) -> &dyn pprust::PpAnn {
174174
self
175175
}
176176
}
@@ -216,11 +216,11 @@ impl<'hir> HirPrinterSupport<'hir> for IdentifiedAnnotation<'hir> {
216216
self.sess
217217
}
218218

219-
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> {
219+
fn hir_map(&self) -> Option<&hir_map::Map<'hir>> {
220220
self.tcx.map(|tcx| *tcx.hir())
221221
}
222222

223-
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn {
223+
fn pp_ann(&self) -> &dyn pprust_hir::PpAnn {
224224
self
225225
}
226226
}
@@ -315,11 +315,11 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
315315
&self.tcx.sess
316316
}
317317

318-
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> {
318+
fn hir_map(&self) -> Option<&hir_map::Map<'tcx>> {
319319
Some(&self.tcx.hir())
320320
}
321321

322-
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn {
322+
fn pp_ann(&self) -> &dyn pprust_hir::PpAnn {
323323
self
324324
}
325325

src/librustc_expand/mbe/macro_check.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ use rustc_data_structures::fx::FxHashMap;
112112
use rustc_session::lint::builtin::META_VARIABLE_MISUSE;
113113
use rustc_session::parse::ParseSess;
114114
use rustc_span::symbol::kw;
115-
use rustc_span::{symbol::Ident, MultiSpan, Span};
115+
use rustc_span::{symbol::LegacyIdent, MultiSpan, Span};
116116

117117
use smallvec::SmallVec;
118118

@@ -179,7 +179,7 @@ struct BinderInfo {
179179
}
180180

181181
/// An environment of meta-variables to their binder information.
182-
type Binders = FxHashMap<Ident, BinderInfo>;
182+
type Binders = FxHashMap<LegacyIdent, BinderInfo>;
183183

184184
/// The state at which we entered a macro definition in the RHS of another macro definition.
185185
struct MacroState<'a> {
@@ -245,6 +245,7 @@ fn check_binders(
245245
if macros.is_empty() {
246246
sess.span_diagnostic.span_bug(span, "unexpected MetaVar in lhs");
247247
}
248+
let name = LegacyIdent::new(name);
248249
// There are 3 possibilities:
249250
if let Some(prev_info) = binders.get(&name) {
250251
// 1. The meta-variable is already bound in the current LHS: This is an error.
@@ -264,6 +265,7 @@ fn check_binders(
264265
if !macros.is_empty() {
265266
sess.span_diagnostic.span_bug(span, "unexpected MetaVarDecl in nested lhs");
266267
}
268+
let name = LegacyIdent::new(name);
267269
if let Some(prev_info) = get_binder_info(macros, binders, name) {
268270
// Duplicate binders at the top-level macro definition are errors. The lint is only
269271
// for nested macro definitions.
@@ -300,7 +302,7 @@ fn check_binders(
300302
fn get_binder_info<'a>(
301303
mut macros: &'a Stack<'a, MacroState<'a>>,
302304
binders: &'a Binders,
303-
name: Ident,
305+
name: LegacyIdent,
304306
) -> Option<&'a BinderInfo> {
305307
binders.get(&name).or_else(|| macros.find_map(|state| state.binders.get(&name)))
306308
}
@@ -331,6 +333,7 @@ fn check_occurrences(
331333
sess.span_diagnostic.span_bug(span, "unexpected MetaVarDecl in rhs")
332334
}
333335
TokenTree::MetaVar(span, name) => {
336+
let name = LegacyIdent::new(name);
334337
check_ops_is_prefix(sess, node_id, macros, binders, ops, span, name);
335338
}
336339
TokenTree::Delimited(_, ref del) => {
@@ -552,7 +555,7 @@ fn check_ops_is_prefix(
552555
binders: &Binders,
553556
ops: &Stack<'_, KleeneToken>,
554557
span: Span,
555-
name: Ident,
558+
name: LegacyIdent,
556559
) {
557560
let macros = macros.push(MacroState { binders, ops: ops.into() });
558561
// Accumulates the stacks the operators of each state until (and including when) the
@@ -598,7 +601,7 @@ fn ops_is_prefix(
598601
sess: &ParseSess,
599602
node_id: NodeId,
600603
span: Span,
601-
name: Ident,
604+
name: LegacyIdent,
602605
binder_ops: &[KleeneToken],
603606
occurrence_ops: &[KleeneToken],
604607
) {

0 commit comments

Comments
 (0)