Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from rust-lang:master #5

Merged
merged 110 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
315a16f
doc: Fold inline methods from Deref
tesuji Jul 8, 2024
fbc794f
Fix style
GuillaumeGomez Jul 15, 2024
a868b3f
Create new CSS class for "big toggles"
GuillaumeGomez Jul 15, 2024
9855a38
Add tests for new toggle on deref blocks
GuillaumeGomez Jul 15, 2024
6d8f0bd
apply #[optimize(size)] to #[cold] ones and part of the panick machinery
the8472 Aug 13, 2024
79b5cfd
size-optimize some of the panic dependencies
the8472 Aug 14, 2024
fa6d54f
don't copy `.rustc-dev-contents` from CI rustc
onur-ozkan Aug 20, 2024
9d694b5
support custom clippy
onur-ozkan Aug 26, 2024
9dcc656
document `build.cargo-clippy` option
onur-ozkan Aug 26, 2024
1a991e5
add change entry for custom clippy support
onur-ozkan Aug 26, 2024
05ffd44
Box validity: update for new zero-sized rules
RalfJung Aug 29, 2024
016a2e3
Remove unused features.
nnethercote Aug 27, 2024
016a709
Condense `use rustc_*` declarations.
nnethercote Aug 27, 2024
fda52b8
Simplify a provider definition.
nnethercote Aug 27, 2024
2932e09
Simplify creation of a set.
nnethercote Aug 27, 2024
66b3585
Simplify a pattern.
nnethercote Aug 27, 2024
3b6af9a
Use a local variable.
nnethercote Aug 28, 2024
5331280
Merge some `if`s.
nnethercote Aug 28, 2024
d7cb118
Merge `DerefArgVisitor` and `PinArgVisitor`.
nnethercote Aug 28, 2024
408481f
Remove some unnecessary constants.
nnethercote Aug 28, 2024
590a021
Factor out some repetitive code.
nnethercote Aug 28, 2024
243109e
Remove an unnecessary `continue`.
nnethercote Aug 28, 2024
8541b0f
Use `let`/`else` to reduce some indentation.
nnethercote Aug 28, 2024
ac7a293
Avoid repeated interning in `SelfArgVisitor`.
nnethercote Aug 30, 2024
6c393b1
Update cargo
weihanglo Aug 31, 2024
24ad26d
Fixed some typos in the standard library documentation/comments
ranger-ross Aug 31, 2024
92f4590
Fixed typos in btree map docs
ranger-ross Aug 31, 2024
cbf92fc
Fixed more typos in library/core
ranger-ross Aug 31, 2024
175238b
Make decoding non-optional LazyArray panic if not set
compiler-errors Aug 30, 2024
bb9d5c4
Move remove_dir_all impl into a module
ChrisDenton Aug 31, 2024
4928b22
Use AttrId key for unstable<->stable expectation map.
cjgillot Jul 4, 2024
111b0a9
Rewrite lint_expectations in a single pass.
cjgillot Jul 4, 2024
5f1f45b
Remove attr_id from stable lint ids.
cjgillot Jul 4, 2024
ff1fc68
Simplify lint source computation.
cjgillot Jul 4, 2024
c3f9c4f
Use equality when relating formal and expected type in arg checking
compiler-errors Aug 20, 2024
95b9ecd
Inline expected_inputs_for_expected_output into check_argument_types/…
compiler-errors Aug 25, 2024
f78979e
Actually parse stdout json, instead of using hacky contains logic.
aDotInTheVoid Aug 31, 2024
de7a14e
Fix LLVM ABI NAME for riscv64imac-unknown-nuttx-elf
no1wudi Sep 1, 2024
a007310
Mark myself as on vacation for triagebot
tgross35 Sep 1, 2024
0e5628d
tweak wording regarding Box validity
RalfJung Sep 1, 2024
47e6b5d
Revert "Auto merge of #127537 - veluca93:struct_tf, r=BoxyUwU"
Kobzol Sep 1, 2024
32a30dd
compiler_fence documentation: emphasize synchronization, not reordering
RalfJung Sep 1, 2024
7ab44cd
Replace walk with visit so we dont skip outermost expr kind in def co…
compiler-errors Sep 1, 2024
d30b5f0
update `object` dependency to deduplicate `wasmparser`
lqd Sep 1, 2024
a48861a
Auto merge of #127313 - cjgillot:single-expect, r=jieyouxu
bors Sep 1, 2024
9185445
Deny imports of rustc_type_ir::inherent outside of type ir + new trai…
compiler-errors Aug 28, 2024
94885bc
Auto merge of #129854 - Kobzol:revert-127537, r=lqd
bors Sep 1, 2024
0064bd1
add extra linebreaks so rustdoc can identify the first sentence
lolbinarycat Aug 30, 2024
e71f952
Auto merge of #129063 - the8472:cold-opt-size, r=Amanieu
bors Sep 2, 2024
c90991d
Rollup merge of #127474 - tesuji:foldable-inline-derefs, r=t-rustdoc
matthiaskrgr Sep 2, 2024
e003917
Rollup merge of #129678 - compiler-errors:type-ir-inherent, r=fmease
matthiaskrgr Sep 2, 2024
dce2665
Rollup merge of #129738 - nnethercote:rustc_mir_transform-cleanups, r…
matthiaskrgr Sep 2, 2024
8c28989
Rollup merge of #129793 - lolbinarycat:doc-missing-newlines, r=workin…
matthiaskrgr Sep 2, 2024
820540a
Rollup merge of #129804 - ranger-ross:fixed-documentation-typos, r=No…
matthiaskrgr Sep 2, 2024
5c3370d
Rollup merge of #129837 - aDotInTheVoid:test-better-json, r=jieyouxu
matthiaskrgr Sep 2, 2024
efad457
Rollup merge of #129842 - no1wudi:master, r=saethlin
matthiaskrgr Sep 2, 2024
3ea3397
Rollup merge of #129843 - tgross35:triagebot-vacation, r=tgross35
matthiaskrgr Sep 2, 2024
38b6a66
Rollup merge of #129858 - compiler-errors:async-def, r=cjgillot
matthiaskrgr Sep 2, 2024
9b82580
Auto merge of #129798 - weihanglo:update-cargo, r=weihanglo
bors Sep 2, 2024
5780c1c
chore: Fix typos in 'compiler' (batch 3)
Sajjon Sep 2, 2024
ac69544
chore: Fix typos in 'compiler' (batch 1)
Sajjon Sep 2, 2024
00de006
chore: Fix typos in 'compiler' (batch 2)
Sajjon Sep 2, 2024
25c4aa8
chore: remove repetitive words
cuishuang Sep 2, 2024
a460185
Auto merge of #129873 - matthiaskrgr:rollup-bv849ud, r=matthiaskrgr
bors Sep 2, 2024
06e3552
Remove stray word in a comment
alex Sep 2, 2024
7494224
clarify language around non-null ptrs in slice::raw
oskgo Sep 2, 2024
bd53aa3
Auto merge of #129317 - compiler-errors:expectation-subtyping, r=lcnr
bors Sep 2, 2024
7ac5fda
mailmap: add new email for davidtwco
davidtwco Sep 2, 2024
5d47b4d
mailmapper?
BoxyUwU Sep 2, 2024
fa77b9d
Remove kobzol vacation status
Kobzol Sep 1, 2024
8be9fed
Fix compile error in solid's remove_dir_all
saethlin Sep 2, 2024
fcb7d3f
Add missing read_buf stub for x86_64-unknown-l5re-uclibc
saethlin Sep 2, 2024
003ddec
Rollup merge of #129748 - RalfJung:box-validity, r=workingjubilee
matthiaskrgr Sep 2, 2024
c6410f5
Rollup merge of #129829 - compiler-errors:decode-non-optional, r=lcnr
matthiaskrgr Sep 2, 2024
f0072bf
Rollup merge of #129856 - RalfJung:compiler_fence, r=thomcc
matthiaskrgr Sep 2, 2024
912931d
Rollup merge of #129868 - Kobzol:kobzol-vacation-remove, r=lqd
matthiaskrgr Sep 2, 2024
cfb1271
Rollup merge of #129875 - Sajjon:sajjon_fix_typos_batch_1, r=compiler…
matthiaskrgr Sep 2, 2024
1d9eb9d
Rollup merge of #129877 - Sajjon:sajjon_fix_typos_batch_2, r=fee1-dead
matthiaskrgr Sep 2, 2024
929b308
Rollup merge of #129878 - Sajjon:sajjon_fix_typos_batch_3, r=jieyouxu
matthiaskrgr Sep 2, 2024
3ddf061
Rollup merge of #129890 - alex:patch-1, r=workingjubilee
matthiaskrgr Sep 2, 2024
9dad90a
Rollup merge of #129892 - oskgo:clarify-slice-from-raw, r=RalfJung
matthiaskrgr Sep 2, 2024
f065302
Rollup merge of #129905 - davidtwco:update-davidtwco-mailmap, r=lqd
matthiaskrgr Sep 2, 2024
b1b8e3e
Rollup merge of #129906 - BoxyUwU:boxy_mailmap, r=lqd
matthiaskrgr Sep 2, 2024
d6298d3
Rollup merge of #129907 - saethlin:solid-io-error, r=WaffleLapkin
matthiaskrgr Sep 2, 2024
0a89f72
process.rs: remove "Basic usage" text where not useful
tshepang Sep 2, 2024
f1e5191
Fix parsing of beta version in dry-run mode
Kobzol Sep 2, 2024
19843bb
Add `warn(unreachable_pub)` to `rustc_sanitizers`.
nnethercote Aug 30, 2024
21a37da
Add `warn(unreachable_pub)` to `rustc_serialize`.
nnethercote Aug 30, 2024
19ff6e6
Add `warn(unreachable_pub)` to `rustc_session`.
nnethercote Aug 30, 2024
b457ab3
Add `warn(unreachable_pub)` to `rustc_smir`.
nnethercote Aug 30, 2024
b0f22ff
Add `warn(unreachable_pub)` to `rustc_span`.
nnethercote Aug 30, 2024
89deb3c
Add `warn(unreachable_pub)` to `rustc_symbol_mangling`.
nnethercote Aug 30, 2024
0fb3a50
Add `warn(unreachable_pub)` to `rustc_target`.
nnethercote Aug 30, 2024
c4f6f52
Add `warn(unreachable_pub)` to `rustc_traits`.
nnethercote Aug 30, 2024
2e358e6
Add `warn(unreachable_pub)` to `rustc_trait_selection`.
nnethercote Aug 30, 2024
e4b1e28
Add `warn(unreachable_pub)` to `rustc_transmute`.
nnethercote Aug 30, 2024
3e09c45
Add `warn(unreachable_pub)` to `rustc_type_ir`.
nnethercote Aug 30, 2024
d7caea1
Add `warn(unreachable_pub)` to `rustc_ty_utils`.
nnethercote Aug 30, 2024
88b6a78
Add `warn(unreachable_pub)` to `rustc_const_eval`.
nnethercote Aug 30, 2024
2251572
Auto merge of #129915 - matthiaskrgr:rollup-56h2xp2, r=matthiaskrgr
bors Sep 2, 2024
6199b69
Auto merge of #129777 - nnethercote:unreachable_pub-4, r=Urgau
bors Sep 3, 2024
11398ed
Rollup merge of #129152 - onur-ozkan:custom-clippy, r=Kobzol
matthiaskrgr Sep 3, 2024
44187d6
Rollup merge of #129311 - onur-ozkan:multiple-candidates-fix, r=Kobzol
matthiaskrgr Sep 3, 2024
72cc383
Rollup merge of #129800 - ChrisDenton:remove-dir-all2, r=Amanieu
matthiaskrgr Sep 3, 2024
e9cd996
Rollup merge of #129860 - lqd:remove-duplicate-deps, r=alexcrichton
matthiaskrgr Sep 3, 2024
afb9232
Rollup merge of #129885 - cuishuang:master, r=scottmcm
matthiaskrgr Sep 3, 2024
f943c53
Rollup merge of #129913 - saethlin:l4re-read-buf, r=Noratrieb
matthiaskrgr Sep 3, 2024
6e38c9b
Rollup merge of #129916 - tshepang:basic-usage, r=ChrisDenton
matthiaskrgr Sep 3, 2024
29bcf80
Rollup merge of #129917 - Kobzol:fix-beta-git, r=Mark-Simulacrum
matthiaskrgr Sep 3, 2024
d6c8169
Auto merge of #129922 - matthiaskrgr:rollup-4vqx8ct, r=matthiaskrgr
bors Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ boolean_coercion <booleancoercion@gmail.com>
Boris Egorov <jightuse@gmail.com> <egorov@linux.com>
bors <bors@rust-lang.org> bors[bot] <26634292+bors[bot]@users.noreply.github.com>
bors <bors@rust-lang.org> bors[bot] <bors[bot]@users.noreply.github.com>
Boxy <rust@boxyuwu.dev> <supbscripter@gmail.com>
Braden Nelson <moonheart08@users.noreply.github.com>
Brandon Sanderson <singingboyo@gmail.com> Brandon Sanderson <singingboyo@hotmail.com>
Brett Cannon <brett@python.org> Brett Cannon <brettcannon@users.noreply.github.com>
Expand Down Expand Up @@ -146,6 +147,7 @@ David Klein <david.klein@baesystemsdetica.com>
David Manescu <david.manescu@gmail.com> <dman2626@uni.sydney.edu.au>
David Ross <daboross@daboross.net>
David Wood <david@davidtw.co> <david.wood@huawei.com>
David Wood <david@davidtw.co> <david.wood2@arm.com>
Deadbeef <ent3rm4n@gmail.com>
Deadbeef <ent3rm4n@gmail.com> <fee1-dead-beef@protonmail.com>
dependabot[bot] <dependabot[bot]@users.noreply.github.com> <27856297+dependabot-preview[bot]@users.noreply.github.com>
Expand Down
37 changes: 14 additions & 23 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01667f6f40216b9a0b2945e05fed5f1ad0ab6470e69cb9378001e37b1c0668e4"
dependencies = [
"object 0.36.3",
"object 0.36.4",
]

[[package]]
Expand Down Expand Up @@ -2453,17 +2453,17 @@ dependencies = [

[[package]]
name = "object"
version = "0.36.3"
version = "0.36.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9"
checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a"
dependencies = [
"crc32fast",
"flate2",
"hashbrown",
"indexmap",
"memchr",
"ruzstd 0.7.0",
"wasmparser 0.215.0",
"wasmparser",
]

[[package]]
Expand Down Expand Up @@ -3129,11 +3129,11 @@ dependencies = [
"build_helper",
"gimli 0.31.0",
"libc",
"object 0.36.3",
"object 0.36.4",
"regex",
"serde_json",
"similar",
"wasmparser 0.216.0",
"wasmparser",
]

[[package]]
Expand Down Expand Up @@ -3408,7 +3408,7 @@ dependencies = [
"itertools",
"libc",
"measureme",
"object 0.36.3",
"object 0.36.4",
"rustc-demangle",
"rustc_ast",
"rustc_attr",
Expand Down Expand Up @@ -3447,7 +3447,7 @@ dependencies = [
"itertools",
"jobserver",
"libc",
"object 0.36.3",
"object 0.36.4",
"pathdiff",
"regex",
"rustc_arena",
Expand Down Expand Up @@ -4431,7 +4431,7 @@ name = "rustc_target"
version = "0.0.0"
dependencies = [
"bitflags 2.6.0",
"object 0.36.3",
"object 0.36.4",
"rustc_abi",
"rustc_data_structures",
"rustc_feature",
Expand Down Expand Up @@ -5849,7 +5849,7 @@ dependencies = [
"lexopt",
"tempfile",
"wasi-preview1-component-adapter-provider",
"wasmparser 0.216.0",
"wasmparser",
"wat",
"wit-component",
"wit-parser",
Expand All @@ -5869,7 +5869,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04c23aebea22c8a75833ae08ed31ccc020835b12a41999e58c31464271b94a88"
dependencies = [
"leb128",
"wasmparser 0.216.0",
"wasmparser",
]

[[package]]
Expand All @@ -5885,16 +5885,7 @@ dependencies = [
"serde_json",
"spdx",
"wasm-encoder",
"wasmparser 0.216.0",
]

[[package]]
name = "wasmparser"
version = "0.215.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53fbde0881f24199b81cf49b6ff8f9c145ac8eb1b7fc439adb5c099734f7d90e"
dependencies = [
"bitflags 2.6.0",
"wasmparser",
]

[[package]]
Expand Down Expand Up @@ -6228,7 +6219,7 @@ dependencies = [
"serde_json",
"wasm-encoder",
"wasm-metadata",
"wasmparser 0.216.0",
"wasmparser",
"wit-parser",
]

Expand All @@ -6247,7 +6238,7 @@ dependencies = [
"serde_derive",
"serde_json",
"unicode-xid",
"wasmparser 0.216.0",
"wasmparser",
]

[[package]]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn has_self(&self, def_id: DefId, span: Span) -> bool {
if let Some(local_sig_id) = def_id.as_local() {
// The value may be missing due to recursive delegation.
// Error will be emmited later during HIR ty lowering.
// Error will be emitted later during HIR ty lowering.
self.resolver.delegation_fn_sigs.get(&local_sig_id).map_or(false, |sig| sig.has_self)
} else {
match self.tcx.def_kind(def_id) {
Expand Down Expand Up @@ -139,7 +139,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn param_count(&self, sig_id: DefId) -> (usize, bool /*c_variadic*/) {
if let Some(local_sig_id) = sig_id.as_local() {
// Map may be filled incorrectly due to recursive delegation.
// Error will be emmited later during HIR ty lowering.
// Error will be emitted later during HIR ty lowering.
match self.resolver.delegation_fn_sigs.get(&local_sig_id) {
Some(sig) => (sig.param_count, sig.c_variadic),
None => (0, false),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
for field in &variant.fields {
// In practice unless there are more than one field with the same type, we'll be
// suggesting a single field at a type, because we don't aggregate multiple borrow
// checker errors involving the functional record update sytnax into a single one.
// checker errors involving the functional record update syntax into a single one.
let field_ty = field.ty(self.infcx.tcx, args);
let ident = field.ident(self.infcx.tcx);
if field_ty == ty && fields.iter().all(|field| field.ident.name != ident.name) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/liveness/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl<'a, 'me, 'typeck, 'flow, 'tcx> LivenessResults<'a, 'me, 'typeck, 'flow, 'tc
// This collect is more necessary than immediately apparent
// because these facts go into `add_drop_live_facts_for()`,
// which also writes to `all_facts`, and so this is genuinely
// a simulatneous overlapping mutable borrow.
// a simultaneous overlapping mutable borrow.
// FIXME for future hackers: investigate whether this is
// actually necessary; these facts come from Polonius
// and probably maybe plausibly does not need to go back in.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ fn prepare_usage_sets<'tcx>(tcx: TyCtxt<'tcx>) -> UsageSets<'tcx> {
(instance.def_id(), body)
});

// Functions whose coverage statments were found inlined into other functions.
// Functions whose coverage statements were found inlined into other functions.
let mut used_via_inlining = FxHashSet::default();
// Functions that were instrumented, but had all of their coverage statements
// removed by later MIR transforms (e.g. UnreachablePropagation).
Expand Down
125 changes: 10 additions & 115 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use rustc_ast::{ast, attr, MetaItemKind, NestedMetaItem};
use rustc_attr::{list_contains_name, InlineAttr, InstructionSetAttr, OptimizeAttr};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::codes::*;
use rustc_errors::{struct_span_code_err, DiagMessage, SubdiagMessage};
use rustc_hir as hir;
Expand All @@ -9,7 +8,7 @@ use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS;
use rustc_hir::{lang_items, LangItem};
use rustc_middle::middle::codegen_fn_attrs::{
CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry, TargetFeature,
CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry,
};
use rustc_middle::mir::mono::Linkage;
use rustc_middle::query::Providers;
Expand All @@ -18,7 +17,6 @@ use rustc_session::lint;
use rustc_session::parse::feature_err;
use rustc_span::symbol::Ident;
use rustc_span::{sym, Span};
use rustc_target::abi::VariantIdx;
use rustc_target::spec::{abi, SanitizerSet};

use crate::errors;
Expand Down Expand Up @@ -80,26 +78,23 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
let mut link_ordinal_span = None;
let mut no_sanitize_span = None;

let fn_sig_outer = || {
use DefKind::*;

let def_kind = tcx.def_kind(did);
if let Fn | AssocFn | Variant | Ctor(..) = def_kind { Some(tcx.fn_sig(did)) } else { None }
};

for attr in attrs.iter() {
// In some cases, attribute are only valid on functions, but it's the `check_attr`
// pass that check that they aren't used anywhere else, rather this module.
// In these cases, we bail from performing further checks that are only meaningful for
// functions (such as calling `fn_sig`, which ICEs if given a non-function). We also
// report a delayed bug, just in case `check_attr` isn't doing its job.
let fn_sig = || {
let sig = fn_sig_outer();
if sig.is_none() {
use DefKind::*;

let def_kind = tcx.def_kind(did);
if let Fn | AssocFn | Variant | Ctor(..) = def_kind {
Some(tcx.fn_sig(did))
} else {
tcx.dcx()
.span_delayed_bug(attr.span, "this attribute can only be applied to functions");
None
}
sig
};

let Some(Ident { name, .. }) = attr.ident() else {
Expand Down Expand Up @@ -618,93 +613,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
}
}

if let Some(sig) = fn_sig_outer() {
// Collect target features from types reachable from arguments.
// We define a type as "reachable" if:
// - it is a function argument
// - it is a field of a reachable struct
// - there is a reachable reference to it
// FIXME(struct_target_features): we may want to cache the result of this computation.
let mut visited_types = FxHashSet::default();
let mut reachable_types: Vec<_> = sig.skip_binder().inputs().skip_binder().to_owned();
let mut additional_tf = vec![];

while let Some(ty) = reachable_types.pop() {
if visited_types.contains(&ty) {
continue;
}
visited_types.insert(ty);
match ty.kind() {
ty::Alias(..) => {
if let Ok(t) =
tcx.try_normalize_erasing_regions(tcx.param_env(did.to_def_id()), ty)
{
reachable_types.push(t)
}
}

ty::Ref(_, inner, _) => reachable_types.push(*inner),
ty::Tuple(tys) => reachable_types.extend(tys.iter()),
ty::Adt(adt_def, args) => {
additional_tf.extend_from_slice(tcx.struct_target_features(adt_def.did()));
// This only recurses into structs as i.e. an Option<TargetFeature> is an ADT
// that doesn't actually always contain a TargetFeature.
if adt_def.is_struct() {
reachable_types.extend(
adt_def
.variant(VariantIdx::from_usize(0))
.fields
.iter()
.map(|field| field.ty(tcx, args)),
);
}
}
ty::Bool
| ty::Char
| ty::Int(..)
| ty::Uint(..)
| ty::Float(..)
| ty::Foreign(..)
| ty::Str
| ty::Array(..)
| ty::Pat(..)
| ty::Slice(..)
| ty::RawPtr(..)
| ty::FnDef(..)
| ty::FnPtr(..)
| ty::Dynamic(..)
| ty::Closure(..)
| ty::CoroutineClosure(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Never
| ty::Param(..)
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Infer(..)
| ty::Error(..) => (),
}
}

// FIXME(struct_target_features): is this really necessary?
if !additional_tf.is_empty() && sig.skip_binder().abi() != abi::Abi::Rust {
tcx.dcx().span_err(
tcx.hir().span(tcx.local_def_id_to_hir_id(did)),
"cannot use a struct with target features in a function with non-Rust ABI",
);
}
if !additional_tf.is_empty() && codegen_fn_attrs.inline == InlineAttr::Always {
tcx.dcx().span_err(
tcx.hir().span(tcx.local_def_id_to_hir_id(did)),
"cannot use a struct with target features in a #[inline(always)] function",
);
}
codegen_fn_attrs
.target_features
.extend(additional_tf.iter().map(|tf| TargetFeature { implied: true, ..*tf }));
}

// If a function uses non-default target_features it can't be inlined into general
// If a function uses #[target_feature] it can't be inlined into general
// purpose functions as they wouldn't have the right target features
// enabled. For that reason we also forbid #[inline(always)] as it can't be
// respected.
Expand Down Expand Up @@ -849,20 +758,6 @@ fn check_link_name_xor_ordinal(
}
}

fn struct_target_features(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &[TargetFeature] {
let mut features = vec![];
let supported_features = tcx.supported_target_features(LOCAL_CRATE);
for attr in tcx.get_attrs(def_id, sym::target_feature) {
from_target_feature(tcx, attr, supported_features, &mut features);
}
tcx.arena.alloc_slice(&features)
}

pub fn provide(providers: &mut Providers) {
*providers = Providers {
codegen_fn_attrs,
should_inherit_track_caller,
struct_target_features,
..*providers
};
*providers = Providers { codegen_fn_attrs, should_inherit_track_caller, ..*providers };
}
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
match ty.kind() {
ty::Int(ity) => {
// FIXME: directly extract the bits from a valtree instead of evaluating an
// alreay evaluated `Const` in order to get the bits.
// already evaluated `Const` in order to get the bits.
let bits = ct.eval_bits(tcx, ty::ParamEnv::reveal_all());
let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128;
write!(output, "{val}")
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
/// Returns `true` if `local` is `NeedsDrop` at the given `Location`.
///
/// Only updates the cursor if absolutely necessary
pub fn needs_drop(
fn needs_drop(
&mut self,
ccx: &'mir ConstCx<'mir, 'tcx>,
local: Local,
Expand Down Expand Up @@ -76,7 +76,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
/// Returns `true` if `local` is `NeedsNonConstDrop` at the given `Location`.
///
/// Only updates the cursor if absolutely necessary
pub fn needs_non_const_drop(
pub(crate) fn needs_non_const_drop(
&mut self,
ccx: &'mir ConstCx<'mir, 'tcx>,
local: Local,
Expand Down Expand Up @@ -106,7 +106,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
/// Returns `true` if `local` is `HasMutInterior` at the given `Location`.
///
/// Only updates the cursor if absolutely necessary.
pub fn has_mut_interior(
fn has_mut_interior(
&mut self,
ccx: &'mir ConstCx<'mir, 'tcx>,
local: Local,
Expand Down
Loading