Skip to content

Commit 8ce2287

Browse files
committed
Auto merge of #142299 - fmease:rollup-u86s80a, r=fmease
Rollup of 16 pull requests Successful merges: - #134442 (Specify the behavior of `file!`) - #140372 (Exhaustively handle parsed attributes in CheckAttr) - #140766 (Stabilize keylocker) - #141642 (Note the version and PR of removed features when using it) - #141818 (Don't create .msi installer for gnullvm hosts) - #141909 (Add central execution context to bootstrap) - #141992 (use `#[naked]` for `__rust_probestack`) - #142101 (core::ptr: deduplicate more method docs) - #142102 (docs: Small clarification on the usage of read_to_string and read_to_end trait methods) - #142124 (Allow transmute casts in pre-runtime-MIR) - #142240 (deduplicate the rest of AST walker functions) - #142258 (platform-support.md: Mention specific Linux kernel version or later) - #142262 (Mark `core::slice::memchr` as `#[doc(hidden)]`) - #142271 (compiler: fn ptrs should hit different lints based on ABI) - #142275 (rustdoc: Refractor `clean_ty_generics`) - #142288 (const_eval: fix some outdated comments) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c6a9554 + 9f5c10e commit 8ce2287

File tree

75 files changed

+1837
-2312
lines changed

Some content is hidden

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

75 files changed

+1837
-2312
lines changed

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 24 additions & 592 deletions
Large diffs are not rendered by default.

compiler/rustc_ast/src/visit.rs

Lines changed: 642 additions & 573 deletions
Large diffs are not rendered by default.

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ impl OptimizeAttr {
5757
}
5858
}
5959

60-
#[derive(Clone, Debug, Encodable, Decodable, HashStable_Generic, PrintAttribute)]
61-
pub enum DiagnosticAttribute {
62-
// tidy-alphabetical-start
63-
DoNotRecommend,
64-
OnUnimplemented,
65-
// tidy-alphabetical-end
66-
}
67-
6860
#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, HashStable_Generic, PrintAttribute)]
6961
pub enum ReprAttr {
7062
ReprInt(IntType),
@@ -160,40 +152,52 @@ impl Deprecation {
160152
#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
161153
pub enum AttributeKind {
162154
// tidy-alphabetical-start
155+
/// Represents `#[rustc_allow_const_fn_unstable]`.
163156
AllowConstFnUnstable(ThinVec<Symbol>),
157+
158+
/// Represents `#[allow_internal_unstable]`.
164159
AllowInternalUnstable(ThinVec<(Symbol, Span)>),
160+
161+
/// Represents `#[rustc_default_body_unstable]`.
165162
BodyStability {
166163
stability: DefaultBodyStability,
167164
/// Span of the `#[rustc_default_body_unstable(...)]` attribute
168165
span: Span,
169166
},
167+
168+
/// Represents `#[rustc_confusables]`.
170169
Confusables {
171170
symbols: ThinVec<Symbol>,
172171
// FIXME(jdonszelmann): remove when target validation code is moved
173172
first_span: Span,
174173
},
174+
175+
/// Represents `#[rustc_const_stable]` and `#[rustc_const_unstable]`.
175176
ConstStability {
176177
stability: PartialConstStability,
177178
/// Span of the `#[rustc_const_stable(...)]` or `#[rustc_const_unstable(...)]` attribute
178179
span: Span,
179180
},
181+
182+
/// Represents `#[rustc_const_stable_indirect]`.
180183
ConstStabilityIndirect,
181-
Deprecation {
182-
deprecation: Deprecation,
183-
span: Span,
184-
},
185-
Diagnostic(DiagnosticAttribute),
186-
DocComment {
187-
style: AttrStyle,
188-
kind: CommentKind,
189-
span: Span,
190-
comment: Symbol,
191-
},
184+
185+
/// Represents [`#[deprecated]`](https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html#the-deprecated-attribute).
186+
Deprecation { deprecation: Deprecation, span: Span },
187+
188+
/// Represents [`#[doc]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html).
189+
DocComment { style: AttrStyle, kind: CommentKind, span: Span, comment: Symbol },
190+
191+
/// Represents `#[rustc_macro_transparency]`.
192192
MacroTransparency(Transparency),
193+
194+
/// Represents [`#[repr]`](https://doc.rust-lang.org/stable/reference/type-layout.html#representations).
193195
Repr(ThinVec<(ReprAttr, Span)>),
196+
197+
/// Represents `#[stable]`, `#[unstable]` and `#[rustc_allowed_through_unstable_modules]`.
194198
Stability {
195199
stability: Stability,
196-
/// Span of the `#[stable(...)]` or `#[unstable(...)]` attribute
200+
/// Span of the attribute.
197201
span: Span,
198202
},
199203
// tidy-alphabetical-end

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rustc_hir::def_id::DefId;
55
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFunctionEntry};
66
use rustc_middle::ty::{self, TyCtxt};
77
use rustc_session::config::{BranchProtection, FunctionReturn, OptLevel, PAuthKey, PacRet};
8+
use rustc_symbol_mangling::mangle_internal_symbol;
89
use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtector};
910
use smallvec::SmallVec;
1011

@@ -256,11 +257,11 @@ fn probestack_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
256257
StackProbeType::Inline => "inline-asm",
257258
// Flag our internal `__rust_probestack` function as the stack probe symbol.
258259
// This is defined in the `compiler-builtins` crate for each architecture.
259-
StackProbeType::Call => "__rust_probestack",
260+
StackProbeType::Call => &mangle_internal_symbol(cx.tcx, "__rust_probestack"),
260261
// Pick from the two above based on the LLVM version.
261262
StackProbeType::InlineOrCall { min_llvm_version_for_inline } => {
262263
if llvm_util::get_version() < min_llvm_version_for_inline {
263-
"__rust_probestack"
264+
&mangle_internal_symbol(cx.tcx, "__rust_probestack")
264265
} else {
265266
"inline-asm"
266267
}

compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
356356
hir::ConstContext::ConstFn => true,
357357
_ => {
358358
// For indirect places, we are not creating a new permanent borrow, it's just as
359-
// transient as the already existing one. For reborrowing references this is handled
360-
// at the top of `visit_rvalue`, but for raw pointers we handle it here.
361-
// Pointers/references to `static mut` and cases where the `*` is not the first
362-
// projection also end up here.
359+
// transient as the already existing one.
363360
// Locals with StorageDead do not live beyond the evaluation and can
364361
// thus safely be borrowed without being able to be leaked to the final
365362
// value of the constant.

compiler/rustc_const_eval/src/interpret/intern.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,11 @@ pub fn intern_const_alloc_recursive<'tcx, M: CompileTimeMachine<'tcx, const_eval
227227

228228
// Keep interning as long as there are things to intern.
229229
// We show errors if there are dangling pointers, or mutable pointers in immutable contexts
230-
// (i.e., everything except for `static mut`). When these errors affect references, it is
231-
// unfortunate that we show these errors here and not during validation, since validation can
232-
// show much nicer errors. However, we do need these checks to be run on all pointers, including
233-
// raw pointers, so we cannot rely on validation to catch them -- and since interning runs
234-
// before validation, and interning doesn't know the type of anything, this means we can't show
235-
// better errors. Maybe we should consider doing validation before interning in the future.
230+
// (i.e., everything except for `static mut`). We only return these errors as a `Result`
231+
// so that the caller can run validation, and subsequently only report interning errors
232+
// if validation fails. Validation has the better error messages so we prefer those, but
233+
// interning has better coverage since it "sees" *all* pointers, including raw pointers and
234+
// references stored in unions.
236235
while let Some(prov) = todo.pop() {
237236
trace!(?prov);
238237
let alloc_id = prov.alloc_id();
@@ -279,12 +278,12 @@ pub fn intern_const_alloc_recursive<'tcx, M: CompileTimeMachine<'tcx, const_eval
279278
// when there is memory there that someone might expect to be mutable, but we make it immutable.
280279
let dangling = !is_already_global && !ecx.memory.alloc_map.contains_key(&alloc_id);
281280
if !dangling {
282-
// Found a mutable reference inside a const where inner allocations should be
281+
// Found a mutable pointer inside a const where inner allocations should be
283282
// immutable.
284283
if !ecx.tcx.sess.opts.unstable_opts.unleash_the_miri_inside_of_you {
285284
span_bug!(
286285
ecx.tcx.span,
287-
"the static const safety checks accepted mutable references they should not have accepted"
286+
"the static const safety checks accepted a mutable pointer they should not have accepted"
288287
);
289288
}
290289
// Prefer dangling pointer errors over mutable pointer errors

compiler/rustc_expand/messages.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ expand_feature_not_allowed =
6262
expand_feature_removed =
6363
feature has been removed
6464
.label = feature has been removed
65+
.note = removed in {$removed_rustc_version} (you are using {$current_rustc_version}){$pull_note}
6566
.reason = {$reason}
6667
6768
expand_glob_delegation_outside_impls =

compiler/rustc_expand/src/config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,20 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
8080

8181
// If the enabled feature has been removed, issue an error.
8282
if let Some(f) = REMOVED_LANG_FEATURES.iter().find(|f| name == f.feature.name) {
83+
let pull_note = if let Some(pull) = f.pull {
84+
format!(
85+
"; see <https://github.com/rust-lang/rust/pull/{}> for more information",
86+
pull
87+
)
88+
} else {
89+
"".to_owned()
90+
};
8391
sess.dcx().emit_err(FeatureRemoved {
8492
span: mi.span(),
8593
reason: f.reason.map(|reason| FeatureRemovedReason { reason }),
94+
removed_rustc_version: f.feature.since,
95+
current_rustc_version: sess.cfg_version,
96+
pull_note,
8697
});
8798
continue;
8899
}

compiler/rustc_expand/src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,16 @@ pub(crate) struct HelperAttributeNameInvalid {
154154

155155
#[derive(Diagnostic)]
156156
#[diag(expand_feature_removed, code = E0557)]
157+
#[note]
157158
pub(crate) struct FeatureRemoved<'a> {
158159
#[primary_span]
159160
#[label]
160161
pub span: Span,
161162
#[subdiagnostic]
162163
pub reason: Option<FeatureRemovedReason<'a>>,
164+
pub removed_rustc_version: &'a str,
165+
pub current_rustc_version: &'a str,
166+
pub pull_note: String,
163167
}
164168

165169
#[derive(Subdiagnostic)]

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ declare_features! (
259259
/// Allows some increased flexibility in the name resolution rules,
260260
/// especially around globs and shadowing (RFC 1560).
261261
(accepted, item_like_imports, "1.15.0", Some(35120)),
262+
// Allows using the `kl` and `widekl` target features and the associated intrinsics
263+
(accepted, keylocker_x86, "CURRENT_RUSTC_VERSION", Some(134813)),
262264
/// Allows `'a: { break 'a; }`.
263265
(accepted, label_break_value, "1.65.0", Some(48594)),
264266
/// Allows `let...else` statements.

0 commit comments

Comments
 (0)