Skip to content

Commit 9775ffe

Browse files
committed
Auto merge of #80530 - m-ou-se:rollup-zit69ko, r=m-ou-se
Rollup of 9 pull requests Successful merges: - #78934 (refactor: removing library/alloc/src/vec/mod.rs ignore-tidy-filelength) - #79479 (Add `Iterator::intersperse`) - #80128 (Edit rustc_ast::ast::FieldPat docs) - #80424 (Don't give an error when creating a file for the first time) - #80458 (Some Promotion Refactoring) - #80488 (Do not create dangling &T in Weak<T>::drop) - #80491 (Miri: make size/align_of_val work for dangling raw ptrs) - #80495 (Rename kw::Invalid -> kw::Empty) - #80513 (Add regression test for #80062) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e226704 + 8998e31 commit 9775ffe

File tree

65 files changed

+1777
-1434
lines changed

Some content is hidden

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

65 files changed

+1777
-1434
lines changed

Diff for: compiler/rustc_ast/src/ast.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -630,16 +630,16 @@ impl Pat {
630630
}
631631
}
632632

633-
/// A single field in a struct pattern
633+
/// A single field in a struct pattern.
634634
///
635-
/// Patterns like the fields of Foo `{ x, ref y, ref mut z }`
636-
/// are treated the same as` x: x, y: ref y, z: ref mut z`,
637-
/// except is_shorthand is true
635+
/// Patterns like the fields of `Foo { x, ref y, ref mut z }`
636+
/// are treated the same as `x: x, y: ref y, z: ref mut z`,
637+
/// except when `is_shorthand` is true.
638638
#[derive(Clone, Encodable, Decodable, Debug)]
639639
pub struct FieldPat {
640-
/// The identifier for the field
640+
/// The identifier for the field.
641641
pub ident: Ident,
642-
/// The pattern the field is destructured to
642+
/// The pattern the field is destructured to.
643643
pub pat: P<Pat>,
644644
pub is_shorthand: bool,
645645
pub attrs: AttrVec,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17671767
}
17681768
self.arena.alloc_from_iter(inputs.iter().map(|param| match param.pat.kind {
17691769
PatKind::Ident(_, ident, _) => ident,
1770-
_ => Ident::new(kw::Invalid, param.pat.span),
1770+
_ => Ident::new(kw::Empty, param.pat.span),
17711771
}))
17721772
}
17731773

Diff for: compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl<'a> AstValidator<'a> {
184184
}
185185

186186
fn check_lifetime(&self, ident: Ident) {
187-
let valid_names = [kw::UnderscoreLifetime, kw::StaticLifetime, kw::Invalid];
187+
let valid_names = [kw::UnderscoreLifetime, kw::StaticLifetime, kw::Empty];
188188
if !valid_names.contains(&ident.name) && ident.without_first_quote().is_reserved() {
189189
self.err_handler().span_err(ident.span, "lifetimes cannot use keyword names");
190190
}

Diff for: compiler/rustc_ast_pretty/src/pprust/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2787,7 +2787,7 @@ impl<'a> State<'a> {
27872787
self.print_explicit_self(&eself);
27882788
} else {
27892789
let invalid = if let PatKind::Ident(_, ident, _) = input.pat.kind {
2790-
ident.name == kw::Invalid
2790+
ident.name == kw::Empty
27912791
} else {
27922792
false
27932793
};

Diff for: compiler/rustc_builtin_macros/src/llvm_asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn parse_inline_asm<'a>(
9595
})
9696
.unwrap_or(tts.len());
9797
let mut p = cx.new_parser_from_tts(tts.trees().skip(first_colon).collect());
98-
let mut asm = kw::Invalid;
98+
let mut asm = kw::Empty;
9999
let mut asm_str_style = None;
100100
let mut outputs = Vec::new();
101101
let mut inputs = Vec::new();

Diff for: compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
170170
// (after #67586 gets fixed).
171171
None
172172
} else {
173-
let name = kw::Invalid;
173+
let name = kw::Empty;
174174
let decl = &self.mir.local_decls[local];
175175
let dbg_var = if full_debug_info {
176176
self.adjusted_span_and_dbg_scope(decl.source_info).map(
@@ -204,7 +204,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
204204
None
205205
} else {
206206
Some(match whole_local_var.or(fallback_var) {
207-
Some(var) if var.name != kw::Invalid => var.name.to_string(),
207+
Some(var) if var.name != kw::Empty => var.name.to_string(),
208208
_ => format!("{:?}", local),
209209
})
210210
};

Diff for: compiler/rustc_hir/src/hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct Lifetime {
2828
pub span: Span,
2929

3030
/// Either "`'a`", referring to a named lifetime definition,
31-
/// or "``" (i.e., `kw::Invalid`), for elision placeholders.
31+
/// or "``" (i.e., `kw::Empty`), for elision placeholders.
3232
///
3333
/// HIR lowering inserts these placeholders in type paths that
3434
/// refer to type definitions needing lifetime parameters,

Diff for: compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ impl EarlyLintPass for AnonymousParameters {
868868
if let ast::AssocItemKind::Fn(_, ref sig, _, _) = it.kind {
869869
for arg in sig.decl.inputs.iter() {
870870
if let ast::PatKind::Ident(_, ident, None) = arg.pat.kind {
871-
if ident.name == kw::Invalid {
871+
if ident.name == kw::Empty {
872872
cx.struct_span_lint(ANONYMOUS_PARAMETERS, arg.pat.span, |lint| {
873873
let ty_snip = cx.sess.source_map().span_to_snippet(arg.ty.span);
874874

Diff for: compiler/rustc_lint/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ impl<'tcx> LateContext<'tcx> {
728728

729729
/// Check if a `DefId`'s path matches the given absolute type path usage.
730730
///
731-
/// Anonymous scopes such as `extern` imports are matched with `kw::Invalid`;
731+
/// Anonymous scopes such as `extern` imports are matched with `kw::Empty`;
732732
/// inherent `impl` blocks are matched with the name of the type.
733733
///
734734
/// Instead of using this method, it is often preferable to instead use

Diff for: compiler/rustc_metadata/src/native_libs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
132132

133133
impl Collector<'tcx> {
134134
fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLib) {
135-
if lib.name.as_ref().map(|&s| s == kw::Invalid).unwrap_or(false) {
135+
if lib.name.as_ref().map(|&s| s == kw::Empty).unwrap_or(false) {
136136
match span {
137137
Some(span) => {
138138
struct_span_err!(

Diff for: compiler/rustc_middle/src/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl<'hir> Map<'hir> {
379379
pub fn body_param_names(&self, id: BodyId) -> impl Iterator<Item = Ident> + 'hir {
380380
self.body(id).params.iter().map(|arg| match arg.pat.kind {
381381
PatKind::Binding(_, _, ident, _) => ident,
382-
_ => Ident::new(kw::Invalid, rustc_span::DUMMY_SP),
382+
_ => Ident::new(kw::Empty, rustc_span::DUMMY_SP),
383383
})
384384
}
385385

Diff for: compiler/rustc_middle/src/ty/print/pretty.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
14811481
// FIXME(eddyb) `name` should never be empty, but it
14821482
// currently is for `extern { ... }` "foreign modules".
14831483
let name = disambiguated_data.data.name();
1484-
if name != DefPathDataName::Named(kw::Invalid) {
1484+
if name != DefPathDataName::Named(kw::Empty) {
14851485
if !self.empty_path {
14861486
write!(self, "::")?;
14871487
}
@@ -1608,14 +1608,14 @@ impl<F: fmt::Write> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> {
16081608

16091609
match *region {
16101610
ty::ReEarlyBound(ref data) => {
1611-
data.name != kw::Invalid && data.name != kw::UnderscoreLifetime
1611+
data.name != kw::Empty && data.name != kw::UnderscoreLifetime
16121612
}
16131613

16141614
ty::ReLateBound(_, ty::BoundRegion { kind: br })
16151615
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
16161616
| ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
16171617
if let ty::BrNamed(_, name) = br {
1618-
if name != kw::Invalid && name != kw::UnderscoreLifetime {
1618+
if name != kw::Empty && name != kw::UnderscoreLifetime {
16191619
return true;
16201620
}
16211621
}
@@ -1685,7 +1685,7 @@ impl<F: fmt::Write> FmtPrinter<'_, '_, F> {
16851685
// `explain_region()` or `note_and_explain_region()`.
16861686
match *region {
16871687
ty::ReEarlyBound(ref data) => {
1688-
if data.name != kw::Invalid {
1688+
if data.name != kw::Empty {
16891689
p!(write("{}", data.name));
16901690
return Ok(self);
16911691
}
@@ -1694,7 +1694,7 @@ impl<F: fmt::Write> FmtPrinter<'_, '_, F> {
16941694
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
16951695
| ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
16961696
if let ty::BrNamed(_, name) = br {
1697-
if name != kw::Invalid && name != kw::UnderscoreLifetime {
1697+
if name != kw::Empty && name != kw::UnderscoreLifetime {
16981698
p!(write("{}", name));
16991699
return Ok(self);
17001700
}

Diff for: compiler/rustc_mir/src/interpret/intrinsics.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
141141
}
142142

143143
sym::min_align_of_val | sym::size_of_val => {
144-
let place = self.deref_operand(args[0])?;
144+
// Avoid `deref_operand` -- this is not a deref, the ptr does not have to be
145+
// dereferencable!
146+
let place = self.ref_to_mplace(self.read_immediate(args[0])?)?;
145147
let (size, align) = self
146-
.size_and_align_of(place.meta, place.layout)?
148+
.size_and_align_of_mplace(place)?
147149
.ok_or_else(|| err_unsup_format!("`extern type` does not have known layout"))?;
148150

149151
let result = match intrinsic_name {

Diff for: compiler/rustc_mir/src/interpret/validity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
391391
}
392392
// Make sure this is dereferenceable and all.
393393
let size_and_align = try_validation!(
394-
self.ecx.size_and_align_of(place.meta, place.layout),
394+
self.ecx.size_and_align_of_mplace(place),
395395
self.path,
396396
err_ub!(InvalidMeta(msg)) => { "invalid {} metadata: {}", kind, msg },
397397
);

0 commit comments

Comments
 (0)