| author | bors <bors@rust-lang.org> 2026-04-07 19:43:18 UTC |
| committer | bors <bors@rust-lang.org> 2026-04-07 19:43:18 UTC |
| log | c756124775121dea0e640652c5ee3c89e3dd0eb4 |
| tree | e47fe8ad8ed0c21c2ede138b8ed9389ad0af2102 |
| parent | ad4b9354009cb6bd5a9ff1b5f5a63a13ec98ebc9 |
| parent | 2895451ff3f1adc536b4905a0dcd4b02fc936f1f |
Rollup of 22 pull requests
Successful merges:
- rust-lang/rust#150965 (Fix no results when searching for == in doc)
- rust-lang/rust#153999 (Remove `TaggedQueryKey::def_kind`)
- rust-lang/rust#154146 (Split out the creation of `Cycle` to a new `process_cycle` function)
- rust-lang/rust#154147 (Do not attempt generating DllImport for extern types)
- rust-lang/rust#154812 (Update Fira Mono License Information)
- rust-lang/rust#154880 (bootstrap: minor improvements to download-rustc)
- rust-lang/rust#154886 (Stabilize check-cfg suggestions for symbol)
- rust-lang/rust#154889 (Update wasm-component-ld to 0.5.22)
- rust-lang/rust#154928 (Fix pin docs)
- rust-lang/rust#154942 (delegation: generate more verbose error delegation)
- rust-lang/rust#153269 (GCI: During reachability analysis don't try to evaluate the initializer of overly generic free const items)
- rust-lang/rust#154506 (Migrate some tests from `tests/ui/issues` to appropriate directories)
- rust-lang/rust#154673 (Use a different name for fast try builds)
- rust-lang/rust#154761 (coretests: add argument order regression tests for min_by/max_by/minmax_by)
- rust-lang/rust#154795 (Add more info about where autodiff can be applied)
- rust-lang/rust#154808 (Post-attribute ports cleanup pt. 1)
- rust-lang/rust#154825 (constify `Step for NonZero<u*>`)
- rust-lang/rust#154837 (library: std: motor: use OS' process::exit in abort_internal)
- rust-lang/rust#154866 (add regression test for rust-lang/rust#146514)
- rust-lang/rust#154922 (c-b: Export inverse hyperbolic trigonometric functions)
- rust-lang/rust#154931 (delegation(small cleanup): remove not needed PhantomData)
- rust-lang/rust#154950 (library: no `cfg(target_arch)` on scalable intrinsics)79 files changed, 1435 insertions(+), 1766 deletions(-)
Cargo.lock+26-26| ... | ... | @@ -6221,9 +6221,9 @@ dependencies = [ |
| 6221 | 6221 | |
| 6222 | 6222 | [[package]] |
| 6223 | 6223 | name = "wasi-preview1-component-adapter-provider" |
| 6224 | version = "40.0.0" | |
| 6224 | version = "43.0.0" | |
| 6225 | 6225 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 6226 | checksum = "bb5e2b9858989c3a257de4ca169977f4f79897b64e4f482f188f4fcf8ac557d1" | |
| 6226 | checksum = "93759d6fd0db242718bdcc6e4626eff8b0f3124ee7e58e47177a59f561baf164" | |
| 6227 | 6227 | |
| 6228 | 6228 | [[package]] |
| 6229 | 6229 | name = "wasm-bindgen" |
| ... | ... | @@ -6272,9 +6272,9 @@ dependencies = [ |
| 6272 | 6272 | |
| 6273 | 6273 | [[package]] |
| 6274 | 6274 | name = "wasm-component-ld" |
| 6275 | version = "0.5.21" | |
| 6275 | version = "0.5.22" | |
| 6276 | 6276 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 6277 | checksum = "59dcd765f510df84d1677a502c49057761486597a95950b4c92153e5707af091" | |
| 6277 | checksum = "216ca7b603f362831b31db4e2cdea1fa3609edd7177792fa64f62a80e10aa917" | |
| 6278 | 6278 | dependencies = [ |
| 6279 | 6279 | "anyhow", |
| 6280 | 6280 | "clap", |
| ... | ... | @@ -6283,7 +6283,7 @@ dependencies = [ |
| 6283 | 6283 | "libc", |
| 6284 | 6284 | "tempfile", |
| 6285 | 6285 | "wasi-preview1-component-adapter-provider", |
| 6286 | "wasmparser 0.245.1", | |
| 6286 | "wasmparser 0.246.2", | |
| 6287 | 6287 | "wat", |
| 6288 | 6288 | "windows-sys 0.61.2", |
| 6289 | 6289 | "winsplit", |
| ... | ... | @@ -6310,24 +6310,24 @@ dependencies = [ |
| 6310 | 6310 | |
| 6311 | 6311 | [[package]] |
| 6312 | 6312 | name = "wasm-encoder" |
| 6313 | version = "0.245.1" | |
| 6313 | version = "0.246.2" | |
| 6314 | 6314 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 6315 | checksum = "3f9dca005e69bf015e45577e415b9af8c67e8ee3c0e38b5b0add5aa92581ed5c" | |
| 6315 | checksum = "61fb705ce81adde29d2a8e99d87995e39a6e927358c91398f374474746070ef7" | |
| 6316 | 6316 | dependencies = [ |
| 6317 | 6317 | "leb128fmt", |
| 6318 | "wasmparser 0.245.1", | |
| 6318 | "wasmparser 0.246.2", | |
| 6319 | 6319 | ] |
| 6320 | 6320 | |
| 6321 | 6321 | [[package]] |
| 6322 | 6322 | name = "wasm-metadata" |
| 6323 | version = "0.245.1" | |
| 6323 | version = "0.246.2" | |
| 6324 | 6324 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 6325 | checksum = "da55e60097e8b37b475a0fa35c3420dd71d9eb7bd66109978ab55faf56a57efb" | |
| 6325 | checksum = "e3e4c2aa916c425dcca61a6887d3e135acdee2c6d0ed51fd61c08d41ddaf62b1" | |
| 6326 | 6326 | dependencies = [ |
| 6327 | 6327 | "anyhow", |
| 6328 | 6328 | "indexmap", |
| 6329 | "wasm-encoder 0.245.1", | |
| 6330 | "wasmparser 0.245.1", | |
| 6329 | "wasm-encoder 0.246.2", | |
| 6330 | "wasmparser 0.246.2", | |
| 6331 | 6331 | ] |
| 6332 | 6332 | |
| 6333 | 6333 | [[package]] |
| ... | ... | @@ -6352,9 +6352,9 @@ dependencies = [ |
| 6352 | 6352 | |
| 6353 | 6353 | [[package]] |
| 6354 | 6354 | name = "wasmparser" |
| 6355 | version = "0.245.1" | |
| 6355 | version = "0.246.2" | |
| 6356 | 6356 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 6357 | checksum = "4f08c9adee0428b7bddf3890fc27e015ac4b761cc608c822667102b8bfd6995e" | |
| 6357 | checksum = "71cde4757396defafd25417cfb36aa3161027d06d865b0c24baaae229aac005d" | |
| 6358 | 6358 | dependencies = [ |
| 6359 | 6359 | "bitflags", |
| 6360 | 6360 | "hashbrown 0.16.1", |
| ... | ... | @@ -6365,22 +6365,22 @@ dependencies = [ |
| 6365 | 6365 | |
| 6366 | 6366 | [[package]] |
| 6367 | 6367 | name = "wast" |
| 6368 | version = "245.0.1" | |
| 6368 | version = "246.0.2" | |
| 6369 | 6369 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 6370 | checksum = "28cf1149285569120b8ce39db8b465e8a2b55c34cbb586bd977e43e2bc7300bf" | |
| 6370 | checksum = "fe3fe8e3bf88ad96d031b4181ddbd64634b17cb0d06dfc3de589ef43591a9a62" | |
| 6371 | 6371 | dependencies = [ |
| 6372 | 6372 | "bumpalo", |
| 6373 | 6373 | "leb128fmt", |
| 6374 | 6374 | "memchr", |
| 6375 | 6375 | "unicode-width 0.2.2", |
| 6376 | "wasm-encoder 0.245.1", | |
| 6376 | "wasm-encoder 0.246.2", | |
| 6377 | 6377 | ] |
| 6378 | 6378 | |
| 6379 | 6379 | [[package]] |
| 6380 | 6380 | name = "wat" |
| 6381 | version = "1.245.1" | |
| 6381 | version = "1.246.2" | |
| 6382 | 6382 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 6383 | checksum = "cd48d1679b6858988cb96b154dda0ec5bbb09275b71db46057be37332d5477be" | |
| 6383 | checksum = "4bd7fda1199b94fff395c2d19a153f05dbe7807630316fa9673367666fd2ad8c" | |
| 6384 | 6384 | dependencies = [ |
| 6385 | 6385 | "wast", |
| 6386 | 6386 | ] |
| ... | ... | @@ -6811,9 +6811,9 @@ dependencies = [ |
| 6811 | 6811 | |
| 6812 | 6812 | [[package]] |
| 6813 | 6813 | name = "wit-component" |
| 6814 | version = "0.245.1" | |
| 6814 | version = "0.246.2" | |
| 6815 | 6815 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 6816 | checksum = "4894f10d2d5cbc17c77e91f86a1e48e191a788da4425293b55c98b44ba3fcac9" | |
| 6816 | checksum = "1936c26cb24b93dc36bf78fb5dc35c55cd37f66ecdc2d2663a717d9fb3ee951e" | |
| 6817 | 6817 | dependencies = [ |
| 6818 | 6818 | "anyhow", |
| 6819 | 6819 | "bitflags", |
| ... | ... | @@ -6822,17 +6822,17 @@ dependencies = [ |
| 6822 | 6822 | "serde", |
| 6823 | 6823 | "serde_derive", |
| 6824 | 6824 | "serde_json", |
| 6825 | "wasm-encoder 0.245.1", | |
| 6825 | "wasm-encoder 0.246.2", | |
| 6826 | 6826 | "wasm-metadata", |
| 6827 | "wasmparser 0.245.1", | |
| 6827 | "wasmparser 0.246.2", | |
| 6828 | 6828 | "wit-parser", |
| 6829 | 6829 | ] |
| 6830 | 6830 | |
| 6831 | 6831 | [[package]] |
| 6832 | 6832 | name = "wit-parser" |
| 6833 | version = "0.245.1" | |
| 6833 | version = "0.246.2" | |
| 6834 | 6834 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 6835 | checksum = "330698718e82983499419494dd1e3d7811a457a9bf9f69734e8c5f07a2547929" | |
| 6835 | checksum = "fd979042b5ff288607ccf3b314145435453f20fc67173195f91062d2289b204d" | |
| 6836 | 6836 | dependencies = [ |
| 6837 | 6837 | "anyhow", |
| 6838 | 6838 | "hashbrown 0.16.1", |
| ... | ... | @@ -6844,7 +6844,7 @@ dependencies = [ |
| 6844 | 6844 | "serde_derive", |
| 6845 | 6845 | "serde_json", |
| 6846 | 6846 | "unicode-xid", |
| 6847 | "wasmparser 0.245.1", | |
| 6847 | "wasmparser 0.246.2", | |
| 6848 | 6848 | ] |
| 6849 | 6849 | |
| 6850 | 6850 | [[package]] |
compiler/rustc_ast_lowering/src/delegation.rs+34-41| ... | ... | @@ -37,7 +37,6 @@ |
| 37 | 37 | //! also be emitted during HIR ty lowering. |
| 38 | 38 | |
| 39 | 39 | use std::iter; |
| 40 | use std::marker::PhantomData; | |
| 41 | 40 | |
| 42 | 41 | use ast::visit::Visitor; |
| 43 | 42 | use hir::def::{DefKind, PartialRes, Res}; |
| ... | ... | @@ -128,14 +127,12 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { |
| 128 | 127 | { |
| 129 | 128 | self.get_sig_id(delegation_info.resolution_node, span) |
| 130 | 129 | } else { |
| 131 | return self.generate_delegation_error( | |
| 132 | self.dcx().span_delayed_bug( | |
| 133 | span, | |
| 134 | format!("LoweringContext: the delegation {:?} is unresolved", item_id), | |
| 135 | ), | |
| 130 | self.dcx().span_delayed_bug( | |
| 136 | 131 | span, |
| 137 | delegation, | |
| 132 | format!("LoweringContext: the delegation {:?} is unresolved", item_id), | |
| 138 | 133 | ); |
| 134 | ||
| 135 | return self.generate_delegation_error(span, delegation); | |
| 139 | 136 | }; |
| 140 | 137 | |
| 141 | 138 | match sig_id { |
| ... | ... | @@ -172,7 +169,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { |
| 172 | 169 | |
| 173 | 170 | DelegationResults { body_id, sig, ident, generics } |
| 174 | 171 | } |
| 175 | Err(err) => self.generate_delegation_error(err, span, delegation), | |
| 172 | Err(_) => self.generate_delegation_error(span, delegation), | |
| 176 | 173 | } |
| 177 | 174 | } |
| 178 | 175 | |
| ... | ... | @@ -420,7 +417,6 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { |
| 420 | 417 | resolver: this.resolver, |
| 421 | 418 | path_id: delegation.id, |
| 422 | 419 | self_param_id: pat_node_id, |
| 423 | phantom: PhantomData, | |
| 424 | 420 | }; |
| 425 | 421 | self_resolver.visit_block(block); |
| 426 | 422 | // Target expr needs to lower `self` path. |
| ... | ... | @@ -604,7 +600,6 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { |
| 604 | 600 | |
| 605 | 601 | fn generate_delegation_error( |
| 606 | 602 | &mut self, |
| 607 | err: ErrorGuaranteed, | |
| 608 | 603 | span: Span, |
| 609 | 604 | delegation: &Delegation, |
| 610 | 605 | ) -> DelegationResults<'hir> { |
| ... | ... | @@ -622,36 +617,35 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { |
| 622 | 617 | let ident = self.lower_ident(delegation.ident); |
| 623 | 618 | |
| 624 | 619 | let body_id = self.lower_body(|this| { |
| 625 | let body_expr = match delegation.body.as_ref() { | |
| 626 | Some(box block) => { | |
| 627 | // Generates a block when we failed to resolve delegation, where a target expression is its only statement, | |
| 628 | // thus there will be no ICEs on further stages of analysis (see #144594) | |
| 629 | ||
| 630 | // As we generate a void function we want to convert target expression to statement to avoid additional | |
| 631 | // errors, such as mismatched return type | |
| 632 | let stmts = this.arena.alloc_from_iter([hir::Stmt { | |
| 633 | hir_id: this.next_id(), | |
| 634 | kind: rustc_hir::StmtKind::Semi( | |
| 635 | this.arena.alloc(this.lower_target_expr(block)), | |
| 636 | ), | |
| 637 | span, | |
| 638 | }]); | |
| 639 | ||
| 640 | let block = this.arena.alloc(hir::Block { | |
| 641 | stmts, | |
| 642 | expr: None, | |
| 643 | hir_id: this.next_id(), | |
| 644 | rules: hir::BlockCheckMode::DefaultBlock, | |
| 645 | span, | |
| 646 | targeted_by_break: false, | |
| 647 | }); | |
| 620 | let path = this.lower_qpath( | |
| 621 | delegation.id, | |
| 622 | &delegation.qself, | |
| 623 | &delegation.path, | |
| 624 | ParamMode::Optional, | |
| 625 | AllowReturnTypeNotation::No, | |
| 626 | ImplTraitContext::Disallowed(ImplTraitPosition::Path), | |
| 627 | None, | |
| 628 | ); | |
| 648 | 629 | |
| 649 | hir::ExprKind::Block(block, None) | |
| 650 | } | |
| 651 | None => hir::ExprKind::Err(err), | |
| 630 | let callee_path = this.arena.alloc(this.mk_expr(hir::ExprKind::Path(path), span)); | |
| 631 | let args = if let Some(box block) = delegation.body.as_ref() { | |
| 632 | this.arena.alloc_slice(&[this.lower_target_expr(block)]) | |
| 633 | } else { | |
| 634 | &mut [] | |
| 652 | 635 | }; |
| 653 | 636 | |
| 654 | (&[], this.mk_expr(body_expr, span)) | |
| 637 | let call = this.arena.alloc(this.mk_expr(hir::ExprKind::Call(callee_path, args), span)); | |
| 638 | ||
| 639 | let block = this.arena.alloc(hir::Block { | |
| 640 | stmts: &[], | |
| 641 | expr: Some(call), | |
| 642 | hir_id: this.next_id(), | |
| 643 | rules: hir::BlockCheckMode::DefaultBlock, | |
| 644 | span, | |
| 645 | targeted_by_break: false, | |
| 646 | }); | |
| 647 | ||
| 648 | (&[], this.mk_expr(hir::ExprKind::Block(block, None), span)) | |
| 655 | 649 | }); |
| 656 | 650 | |
| 657 | 651 | let generics = hir::Generics::empty(); |
| ... | ... | @@ -673,14 +667,13 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { |
| 673 | 667 | } |
| 674 | 668 | } |
| 675 | 669 | |
| 676 | struct SelfResolver<'a, 'tcx, R> { | |
| 670 | struct SelfResolver<'a, R> { | |
| 677 | 671 | resolver: &'a mut R, |
| 678 | 672 | path_id: NodeId, |
| 679 | 673 | self_param_id: NodeId, |
| 680 | phantom: PhantomData<&'tcx ()>, | |
| 681 | 674 | } |
| 682 | 675 | |
| 683 | impl<'tcx, R: ResolverAstLoweringExt<'tcx>> SelfResolver<'_, 'tcx, R> { | |
| 676 | impl<'tcx, R: ResolverAstLoweringExt<'tcx>> SelfResolver<'_, R> { | |
| 684 | 677 | fn try_replace_id(&mut self, id: NodeId) { |
| 685 | 678 | if let Some(res) = self.resolver.get_partial_res(id) |
| 686 | 679 | && let Some(Res::Local(sig_id)) = res.full_res() |
| ... | ... | @@ -692,7 +685,7 @@ impl<'tcx, R: ResolverAstLoweringExt<'tcx>> SelfResolver<'_, 'tcx, R> { |
| 692 | 685 | } |
| 693 | 686 | } |
| 694 | 687 | |
| 695 | impl<'ast, 'a, 'tcx, R: ResolverAstLoweringExt<'tcx>> Visitor<'ast> for SelfResolver<'a, 'tcx, R> { | |
| 688 | impl<'ast, 'tcx, R: ResolverAstLoweringExt<'tcx>> Visitor<'ast> for SelfResolver<'_, R> { | |
| 696 | 689 | fn visit_id(&mut self, id: NodeId) { |
| 697 | 690 | self.try_replace_id(id); |
| 698 | 691 | } |
compiler/rustc_attr_parsing/src/validate_attr.rs+14-47| ... | ... | @@ -1,15 +1,14 @@ |
| 1 | 1 | //! Meta-syntax validation logic of attributes for post-expansion. |
| 2 | 2 | |
| 3 | 3 | use std::convert::identity; |
| 4 | use std::slice; | |
| 5 | 4 | |
| 6 | 5 | use rustc_ast::token::Delimiter; |
| 7 | 6 | use rustc_ast::tokenstream::DelimSpan; |
| 8 | 7 | use rustc_ast::{ |
| 9 | 8 | self as ast, AttrArgs, Attribute, DelimArgs, MetaItem, MetaItemInner, MetaItemKind, Safety, |
| 10 | 9 | }; |
| 11 | use rustc_errors::{Applicability, FatalError, PResult}; | |
| 12 | use rustc_feature::{AttributeTemplate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute}; | |
| 10 | use rustc_errors::{Applicability, PResult}; | |
| 11 | use rustc_feature::{AttributeTemplate, BUILTIN_ATTRIBUTE_MAP}; | |
| 13 | 12 | use rustc_hir::AttrPath; |
| 14 | 13 | use rustc_hir::lints::AttributeLintKind; |
| 15 | 14 | use rustc_parse::parse_in; |
| ... | ... | @@ -19,43 +18,23 @@ use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT; |
| 19 | 18 | use rustc_session::parse::ParseSess; |
| 20 | 19 | use rustc_span::{Span, Symbol, sym}; |
| 21 | 20 | |
| 22 | use crate::{AttributeParser, Late, session_diagnostics as errors}; | |
| 21 | use crate::session_diagnostics as errors; | |
| 23 | 22 | |
| 24 | 23 | pub fn check_attr(psess: &ParseSess, attr: &Attribute) { |
| 25 | if attr.is_doc_comment() || attr.has_name(sym::cfg_trace) || attr.has_name(sym::cfg_attr_trace) | |
| 24 | // Built-in attributes are parsed in their respective attribute parsers, so can be ignored here | |
| 25 | if attr.is_doc_comment() | |
| 26 | || attr.name().is_some_and(|name| BUILTIN_ATTRIBUTE_MAP.contains_key(&name)) | |
| 26 | 27 | { |
| 27 | 28 | return; |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | let builtin_attr_info = attr.name().and_then(|name| BUILTIN_ATTRIBUTE_MAP.get(&name)); | |
| 31 | ||
| 32 | // Check input tokens for built-in and key-value attributes. | |
| 33 | match builtin_attr_info { | |
| 34 | // `rustc_dummy` doesn't have any restrictions specific to built-in attributes. | |
| 35 | Some(BuiltinAttribute { name, template, .. }) => { | |
| 36 | if AttributeParser::<Late>::is_parsed_attribute(slice::from_ref(&name)) { | |
| 37 | return; | |
| 38 | } | |
| 39 | match parse_meta(psess, attr) { | |
| 40 | // Don't check safety again, we just did that | |
| 41 | Ok(meta) => { | |
| 42 | check_builtin_meta_item(psess, &meta, attr.style, *name, *template, false) | |
| 43 | } | |
| 44 | Err(err) => { | |
| 45 | err.emit(); | |
| 46 | } | |
| 47 | } | |
| 48 | } | |
| 49 | _ => { | |
| 50 | let attr_item = attr.get_normal_item(); | |
| 51 | if let AttrArgs::Eq { .. } = attr_item.args.unparsed_ref().unwrap() { | |
| 52 | // All key-value attributes are restricted to meta-item syntax. | |
| 53 | match parse_meta(psess, attr) { | |
| 54 | Ok(_) => {} | |
| 55 | Err(err) => { | |
| 56 | err.emit(); | |
| 57 | } | |
| 58 | } | |
| 31 | let attr_item = attr.get_normal_item(); | |
| 32 | if let AttrArgs::Eq { .. } = attr_item.args.unparsed_ref().unwrap() { | |
| 33 | // All key-value attributes are restricted to meta-item syntax. | |
| 34 | match parse_meta(psess, attr) { | |
| 35 | Ok(_) => {} | |
| 36 | Err(err) => { | |
| 37 | err.emit(); | |
| 59 | 38 | } |
| 60 | 39 | } |
| 61 | 40 | } |
| ... | ... | @@ -170,7 +149,7 @@ pub fn check_builtin_meta_item( |
| 170 | 149 | } |
| 171 | 150 | } |
| 172 | 151 | |
| 173 | fn emit_malformed_attribute( | |
| 152 | pub fn emit_malformed_attribute( | |
| 174 | 153 | psess: &ParseSess, |
| 175 | 154 | style: ast::AttrStyle, |
| 176 | 155 | span: Span, |
| ... | ... | @@ -232,15 +211,3 @@ fn emit_malformed_attribute( |
| 232 | 211 | err.emit(); |
| 233 | 212 | } |
| 234 | 213 | } |
| 235 | ||
| 236 | pub fn emit_fatal_malformed_builtin_attribute( | |
| 237 | psess: &ParseSess, | |
| 238 | attr: &Attribute, | |
| 239 | name: Symbol, | |
| 240 | ) -> ! { | |
| 241 | let template = BUILTIN_ATTRIBUTE_MAP.get(&name).expect("builtin attr defined").template; | |
| 242 | emit_malformed_attribute(psess, attr.style, attr.span, name, template); | |
| 243 | // This is fatal, otherwise it will likely cause a cascade of other errors | |
| 244 | // (and an error here is expected to be very rare). | |
| 245 | FatalError.raise() | |
| 246 | } |
compiler/rustc_expand/src/errors.rs-18| ... | ... | @@ -603,21 +603,3 @@ pub(crate) struct TrailingMacro { |
| 603 | 603 | pub is_trailing: bool, |
| 604 | 604 | pub name: Ident, |
| 605 | 605 | } |
| 606 | ||
| 607 | #[derive(Diagnostic)] | |
| 608 | #[diag("unused attribute `{$attr_name}`")] | |
| 609 | pub(crate) struct UnusedBuiltinAttribute { | |
| 610 | #[note( | |
| 611 | "the built-in attribute `{$attr_name}` will be ignored, since it's applied to the macro invocation `{$macro_name}`" | |
| 612 | )] | |
| 613 | pub invoc_span: Span, | |
| 614 | pub attr_name: Symbol, | |
| 615 | pub macro_name: String, | |
| 616 | #[suggestion( | |
| 617 | "remove the attribute", | |
| 618 | code = "", | |
| 619 | applicability = "machine-applicable", | |
| 620 | style = "tool-only" | |
| 621 | )] | |
| 622 | pub attr_span: Span, | |
| 623 | } |
compiler/rustc_expand/src/expand.rs+3-18| ... | ... | @@ -15,8 +15,8 @@ use rustc_ast::{ |
| 15 | 15 | use rustc_ast_pretty::pprust; |
| 16 | 16 | use rustc_attr_parsing::parser::AllowExprMetavar; |
| 17 | 17 | use rustc_attr_parsing::{ |
| 18 | AttributeParser, CFG_TEMPLATE, Early, EvalConfigResult, ShouldEmit, eval_config_entry, | |
| 19 | parse_cfg, validate_attr, | |
| 18 | AttributeParser, CFG_TEMPLATE, EvalConfigResult, ShouldEmit, eval_config_entry, parse_cfg, | |
| 19 | validate_attr, | |
| 20 | 20 | }; |
| 21 | 21 | use rustc_data_structures::flat_map_in_place::FlatMapInPlace; |
| 22 | 22 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| ... | ... | @@ -30,7 +30,7 @@ use rustc_parse::parser::{ |
| 30 | 30 | RecoverColon, RecoverComma, Recovery, token_descr, |
| 31 | 31 | }; |
| 32 | 32 | use rustc_session::Session; |
| 33 | use rustc_session::lint::builtin::{UNUSED_ATTRIBUTES, UNUSED_DOC_COMMENTS}; | |
| 33 | use rustc_session::lint::builtin::UNUSED_DOC_COMMENTS; | |
| 34 | 34 | use rustc_session::parse::feature_err; |
| 35 | 35 | use rustc_span::hygiene::SyntaxContext; |
| 36 | 36 | use rustc_span::{ErrorGuaranteed, FileName, Ident, LocalExpnId, Span, Symbol, sym}; |
| ... | ... | @@ -2274,21 +2274,6 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { |
| 2274 | 2274 | self.cx.current_expansion.lint_node_id, |
| 2275 | 2275 | crate::errors::MacroCallUnusedDocComment { span: attr.span }, |
| 2276 | 2276 | ); |
| 2277 | } else if rustc_attr_parsing::is_builtin_attr(attr) | |
| 2278 | && !AttributeParser::<Early>::is_parsed_attribute(&attr.path()) | |
| 2279 | { | |
| 2280 | let attr_name = attr.name().unwrap(); | |
| 2281 | self.cx.sess.psess.buffer_lint( | |
| 2282 | UNUSED_ATTRIBUTES, | |
| 2283 | attr.span, | |
| 2284 | self.cx.current_expansion.lint_node_id, | |
| 2285 | crate::errors::UnusedBuiltinAttribute { | |
| 2286 | attr_name, | |
| 2287 | macro_name: pprust::path_to_string(&call.path), | |
| 2288 | invoc_span: call.path.span, | |
| 2289 | attr_span: attr.span, | |
| 2290 | }, | |
| 2291 | ); | |
| 2292 | 2277 | } |
| 2293 | 2278 | } |
| 2294 | 2279 | } |
compiler/rustc_expand/src/module.rs+15-2| ... | ... | @@ -2,12 +2,14 @@ use std::iter::once; |
| 2 | 2 | use std::path::{self, Path, PathBuf}; |
| 3 | 3 | |
| 4 | 4 | use rustc_ast::{AttrVec, Attribute, Inline, Item, ModSpans}; |
| 5 | use rustc_attr_parsing::validate_attr; | |
| 5 | use rustc_attr_parsing::validate_attr::emit_malformed_attribute; | |
| 6 | 6 | use rustc_errors::{Diag, ErrorGuaranteed}; |
| 7 | use rustc_feature::template; | |
| 7 | 8 | use rustc_parse::lexer::StripTokens; |
| 8 | 9 | use rustc_parse::{exp, new_parser_from_file, unwrap_or_emit_fatal}; |
| 9 | 10 | use rustc_session::Session; |
| 10 | 11 | use rustc_session::parse::ParseSess; |
| 12 | use rustc_span::fatal_error::FatalError; | |
| 11 | 13 | use rustc_span::{Ident, Span, sym}; |
| 12 | 14 | use thin_vec::ThinVec; |
| 13 | 15 | |
| ... | ... | @@ -184,6 +186,7 @@ pub(crate) fn mod_file_path_from_attr( |
| 184 | 186 | attrs: &[Attribute], |
| 185 | 187 | dir_path: &Path, |
| 186 | 188 | ) -> Option<PathBuf> { |
| 189 | // FIXME(154781) use a parsed attribute here | |
| 187 | 190 | // Extract path string from first `#[path = "path_string"]` attribute. |
| 188 | 191 | let first_path = attrs.iter().find(|at| at.has_name(sym::path))?; |
| 189 | 192 | let Some(path_sym) = first_path.value_str() else { |
| ... | ... | @@ -195,7 +198,17 @@ pub(crate) fn mod_file_path_from_attr( |
| 195 | 198 | // Usually bad forms are checked during semantic analysis via |
| 196 | 199 | // `TyCtxt::check_mod_attrs`), but by the time that runs the macro |
| 197 | 200 | // is expanded, and it doesn't give an error. |
| 198 | validate_attr::emit_fatal_malformed_builtin_attribute(&sess.psess, first_path, sym::path); | |
| 201 | emit_malformed_attribute( | |
| 202 | &sess.psess, | |
| 203 | first_path.style, | |
| 204 | first_path.span, | |
| 205 | sym::path, | |
| 206 | template!( | |
| 207 | NameValueStr: "file", | |
| 208 | "https://doc.rust-lang.org/reference/items/modules.html#the-path-attribute" | |
| 209 | ), | |
| 210 | ); | |
| 211 | FatalError.raise() | |
| 199 | 212 | }; |
| 200 | 213 | |
| 201 | 214 | let path_str = path_sym.as_str(); |
compiler/rustc_feature/src/builtin_attrs.rs+231-1005| ... | ... | @@ -2,12 +2,9 @@ |
| 2 | 2 | |
| 3 | 3 | use std::sync::LazyLock; |
| 4 | 4 | |
| 5 | use AttributeDuplicates::*; | |
| 6 | 5 | use AttributeGate::*; |
| 7 | use AttributeType::*; | |
| 8 | 6 | use rustc_data_structures::fx::FxHashMap; |
| 9 | 7 | use rustc_hir::AttrStyle; |
| 10 | use rustc_hir::attrs::EncodeCrossCrate; | |
| 11 | 8 | use rustc_span::edition::Edition; |
| 12 | 9 | use rustc_span::{Symbol, sym}; |
| 13 | 10 | |
| ... | ... | @@ -73,21 +70,10 @@ pub fn find_gated_cfg(pred: impl Fn(Symbol) -> bool) -> Option<&'static GatedCfg |
| 73 | 70 | // move that documentation into the relevant place in the other docs, and |
| 74 | 71 | // remove the chapter on the flag. |
| 75 | 72 | |
| 76 | #[derive(Copy, Clone, PartialEq, Debug)] | |
| 77 | pub enum AttributeType { | |
| 78 | /// Normal, builtin attribute that is consumed | |
| 79 | /// by the compiler before the unused_attribute check | |
| 80 | Normal, | |
| 81 | ||
| 82 | /// Builtin attribute that is only allowed at the crate level | |
| 83 | CrateLevel, | |
| 84 | } | |
| 85 | ||
| 86 | 73 | #[derive(Copy, Clone, PartialEq, Debug)] |
| 87 | 74 | pub enum AttributeSafety { |
| 88 | 75 | /// Normal attribute that does not need `#[unsafe(...)]` |
| 89 | 76 | Normal, |
| 90 | ||
| 91 | 77 | /// Unsafe attribute that requires safety obligations to be discharged. |
| 92 | 78 | /// |
| 93 | 79 | /// An error is emitted when `#[unsafe(...)]` is omitted, except when the attribute's edition |
| ... | ... | @@ -181,57 +167,6 @@ impl AttributeTemplate { |
| 181 | 167 | } |
| 182 | 168 | } |
| 183 | 169 | |
| 184 | /// How to handle multiple duplicate attributes on the same item. | |
| 185 | #[derive(Clone, Copy, Default)] | |
| 186 | pub enum AttributeDuplicates { | |
| 187 | /// Duplicates of this attribute are allowed. | |
| 188 | /// | |
| 189 | /// This should only be used with attributes where duplicates have semantic | |
| 190 | /// meaning, or some kind of "additive" behavior. For example, `#[warn(..)]` | |
| 191 | /// can be specified multiple times, and it combines all the entries. Or use | |
| 192 | /// this if there is validation done elsewhere. | |
| 193 | #[default] | |
| 194 | DuplicatesOk, | |
| 195 | /// Duplicates after the first attribute will be an unused_attribute warning. | |
| 196 | /// | |
| 197 | /// This is usually used for "word" attributes, where they are used as a | |
| 198 | /// boolean marker, like `#[used]`. It is not necessarily wrong that there | |
| 199 | /// are duplicates, but the others should probably be removed. | |
| 200 | WarnFollowing, | |
| 201 | /// Same as `WarnFollowing`, but only issues warnings for word-style attributes. | |
| 202 | /// | |
| 203 | /// This is only for special cases, for example multiple `#[macro_use]` can | |
| 204 | /// be warned, but multiple `#[macro_use(...)]` should not because the list | |
| 205 | /// form has different meaning from the word form. | |
| 206 | WarnFollowingWordOnly, | |
| 207 | /// Duplicates after the first attribute will be an error. | |
| 208 | /// | |
| 209 | /// This should be used where duplicates would be ignored, but carry extra | |
| 210 | /// meaning that could cause confusion. For example, `#[stable(since="1.0")] | |
| 211 | /// #[stable(since="2.0")]`, which version should be used for `stable`? | |
| 212 | ErrorFollowing, | |
| 213 | /// Duplicates preceding the last instance of the attribute will be an error. | |
| 214 | /// | |
| 215 | /// This is the same as `ErrorFollowing`, except the last attribute is the | |
| 216 | /// one that is "used". This is typically used in cases like codegen | |
| 217 | /// attributes which usually only honor the last attribute. | |
| 218 | ErrorPreceding, | |
| 219 | /// Duplicates after the first attribute will be an unused_attribute warning | |
| 220 | /// with a note that this will be an error in the future. | |
| 221 | /// | |
| 222 | /// This should be used for attributes that should be `ErrorFollowing`, but | |
| 223 | /// because older versions of rustc silently accepted (and ignored) the | |
| 224 | /// attributes, this is used to transition. | |
| 225 | FutureWarnFollowing, | |
| 226 | /// Duplicates preceding the last instance of the attribute will be a | |
| 227 | /// warning, with a note that this will be an error in the future. | |
| 228 | /// | |
| 229 | /// This is the same as `FutureWarnFollowing`, except the last attribute is | |
| 230 | /// the one that is "used". Ideally these can eventually migrate to | |
| 231 | /// `ErrorPreceding`. | |
| 232 | FutureWarnPreceding, | |
| 233 | } | |
| 234 | ||
| 235 | 170 | /// A convenience macro for constructing attribute templates. |
| 236 | 171 | /// E.g., `template!(Word, List: "description")` means that the attribute |
| 237 | 172 | /// supports forms `#[attr]` and `#[attr(description)]`. |
| ... | ... | @@ -268,50 +203,31 @@ macro_rules! template { |
| 268 | 203 | } |
| 269 | 204 | |
| 270 | 205 | macro_rules! ungated { |
| 271 | (unsafe($edition:ident) $attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $encode_cross_crate:expr $(,)?) => { | |
| 206 | (unsafe($edition:ident) $attr:ident $(,)?) => { | |
| 272 | 207 | BuiltinAttribute { |
| 273 | 208 | name: sym::$attr, |
| 274 | encode_cross_crate: $encode_cross_crate, | |
| 275 | type_: $typ, | |
| 276 | 209 | safety: AttributeSafety::Unsafe { unsafe_since: Some(Edition::$edition) }, |
| 277 | template: $tpl, | |
| 278 | 210 | gate: Ungated, |
| 279 | duplicates: $duplicates, | |
| 280 | 211 | } |
| 281 | 212 | }; |
| 282 | (unsafe $attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $encode_cross_crate:expr $(,)?) => { | |
| 213 | (unsafe $attr:ident $(,)?) => { | |
| 283 | 214 | BuiltinAttribute { |
| 284 | 215 | name: sym::$attr, |
| 285 | encode_cross_crate: $encode_cross_crate, | |
| 286 | type_: $typ, | |
| 287 | 216 | safety: AttributeSafety::Unsafe { unsafe_since: None }, |
| 288 | template: $tpl, | |
| 289 | 217 | gate: Ungated, |
| 290 | duplicates: $duplicates, | |
| 291 | 218 | } |
| 292 | 219 | }; |
| 293 | ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $encode_cross_crate:expr $(,)?) => { | |
| 294 | BuiltinAttribute { | |
| 295 | name: sym::$attr, | |
| 296 | encode_cross_crate: $encode_cross_crate, | |
| 297 | type_: $typ, | |
| 298 | safety: AttributeSafety::Normal, | |
| 299 | template: $tpl, | |
| 300 | gate: Ungated, | |
| 301 | duplicates: $duplicates, | |
| 302 | } | |
| 220 | ($attr:ident $(,)?) => { | |
| 221 | BuiltinAttribute { name: sym::$attr, safety: AttributeSafety::Normal, gate: Ungated } | |
| 303 | 222 | }; |
| 304 | 223 | } |
| 305 | 224 | |
| 306 | 225 | macro_rules! gated { |
| 307 | (unsafe $attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $encode_cross_crate:expr, $gate:ident, $message:expr $(,)?) => { | |
| 226 | (unsafe $attr:ident, $gate:ident, $message:expr $(,)?) => { | |
| 308 | 227 | BuiltinAttribute { |
| 309 | 228 | name: sym::$attr, |
| 310 | encode_cross_crate: $encode_cross_crate, | |
| 311 | type_: $typ, | |
| 312 | 229 | safety: AttributeSafety::Unsafe { unsafe_since: None }, |
| 313 | template: $tpl, | |
| 314 | duplicates: $duplicates, | |
| 230 | ||
| 315 | 231 | gate: Gated { |
| 316 | 232 | feature: sym::$gate, |
| 317 | 233 | message: $message, |
| ... | ... | @@ -320,14 +236,11 @@ macro_rules! gated { |
| 320 | 236 | }, |
| 321 | 237 | } |
| 322 | 238 | }; |
| 323 | (unsafe $attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $encode_cross_crate:expr, $message:expr $(,)?) => { | |
| 239 | (unsafe $attr:ident, $message:expr $(,)?) => { | |
| 324 | 240 | BuiltinAttribute { |
| 325 | 241 | name: sym::$attr, |
| 326 | encode_cross_crate: $encode_cross_crate, | |
| 327 | type_: $typ, | |
| 328 | 242 | safety: AttributeSafety::Unsafe { unsafe_since: None }, |
| 329 | template: $tpl, | |
| 330 | duplicates: $duplicates, | |
| 243 | ||
| 331 | 244 | gate: Gated { |
| 332 | 245 | feature: sym::$attr, |
| 333 | 246 | message: $message, |
| ... | ... | @@ -336,14 +249,11 @@ macro_rules! gated { |
| 336 | 249 | }, |
| 337 | 250 | } |
| 338 | 251 | }; |
| 339 | ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $encode_cross_crate:expr, $gate:ident, $message:expr $(,)?) => { | |
| 252 | ($attr:ident, $gate:ident, $message:expr $(,)?) => { | |
| 340 | 253 | BuiltinAttribute { |
| 341 | 254 | name: sym::$attr, |
| 342 | encode_cross_crate: $encode_cross_crate, | |
| 343 | type_: $typ, | |
| 344 | 255 | safety: AttributeSafety::Normal, |
| 345 | template: $tpl, | |
| 346 | duplicates: $duplicates, | |
| 256 | ||
| 347 | 257 | gate: Gated { |
| 348 | 258 | feature: sym::$gate, |
| 349 | 259 | message: $message, |
| ... | ... | @@ -352,14 +262,11 @@ macro_rules! gated { |
| 352 | 262 | }, |
| 353 | 263 | } |
| 354 | 264 | }; |
| 355 | ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $encode_cross_crate:expr, $message:expr $(,)?) => { | |
| 265 | ($attr:ident, $message:expr $(,)?) => { | |
| 356 | 266 | BuiltinAttribute { |
| 357 | 267 | name: sym::$attr, |
| 358 | encode_cross_crate: $encode_cross_crate, | |
| 359 | type_: $typ, | |
| 360 | 268 | safety: AttributeSafety::Normal, |
| 361 | template: $tpl, | |
| 362 | duplicates: $duplicates, | |
| 269 | ||
| 363 | 270 | gate: Gated { |
| 364 | 271 | feature: sym::$attr, |
| 365 | 272 | message: $message, |
| ... | ... | @@ -371,13 +278,8 @@ macro_rules! gated { |
| 371 | 278 | } |
| 372 | 279 | |
| 373 | 280 | macro_rules! rustc_attr { |
| 374 | (TEST, $attr:ident, $typ:expr, $tpl:expr, $duplicate:expr, $encode_cross_crate:expr $(,)?) => { | |
| 375 | rustc_attr!( | |
| 376 | $attr, | |
| 377 | $typ, | |
| 378 | $tpl, | |
| 379 | $duplicate, | |
| 380 | $encode_cross_crate, | |
| 281 | (TEST, $attr:ident $(,)?) => { | |
| 282 | rustc_attr!( $attr, | |
| 381 | 283 | concat!( |
| 382 | 284 | "the `#[", |
| 383 | 285 | stringify!($attr), |
| ... | ... | @@ -385,14 +287,10 @@ macro_rules! rustc_attr { |
| 385 | 287 | ), |
| 386 | 288 | ) |
| 387 | 289 | }; |
| 388 | ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $encode_cross_crate:expr, $($notes:expr),* $(,)?) => { | |
| 290 | ($attr:ident $(, $notes:expr)* $(,)?) => { | |
| 389 | 291 | BuiltinAttribute { |
| 390 | 292 | name: sym::$attr, |
| 391 | encode_cross_crate: $encode_cross_crate, | |
| 392 | type_: $typ, | |
| 393 | 293 | safety: AttributeSafety::Normal, |
| 394 | template: $tpl, | |
| 395 | duplicates: $duplicates, | |
| 396 | 294 | gate: Gated { |
| 397 | 295 | feature: sym::rustc_attrs, |
| 398 | 296 | message: "use of an internal attribute", |
| ... | ... | @@ -416,15 +314,7 @@ macro_rules! experimental { |
| 416 | 314 | |
| 417 | 315 | pub struct BuiltinAttribute { |
| 418 | 316 | pub name: Symbol, |
| 419 | /// Whether this attribute is encode cross crate. | |
| 420 | /// | |
| 421 | /// If so, it is encoded in the crate metadata. | |
| 422 | /// Otherwise, it can only be used in the local crate. | |
| 423 | pub encode_cross_crate: EncodeCrossCrate, | |
| 424 | pub type_: AttributeType, | |
| 425 | 317 | pub safety: AttributeSafety, |
| 426 | pub template: AttributeTemplate, | |
| 427 | pub duplicates: AttributeDuplicates, | |
| 428 | 318 | pub gate: AttributeGate, |
| 429 | 319 | } |
| 430 | 320 | |
| ... | ... | @@ -436,379 +326,100 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ |
| 436 | 326 | // ========================================================================== |
| 437 | 327 | |
| 438 | 328 | // Conditional compilation: |
| 439 | ungated!( | |
| 440 | cfg, Normal, | |
| 441 | template!( | |
| 442 | List: &["predicate"], | |
| 443 | "https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute" | |
| 444 | ), | |
| 445 | DuplicatesOk, EncodeCrossCrate::No | |
| 446 | ), | |
| 447 | ungated!( | |
| 448 | cfg_attr, Normal, | |
| 449 | template!( | |
| 450 | List: &["predicate, attr1, attr2, ..."], | |
| 451 | "https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute" | |
| 452 | ), | |
| 453 | DuplicatesOk, EncodeCrossCrate::No | |
| 454 | ), | |
| 329 | ungated!(cfg), | |
| 330 | ungated!(cfg_attr), | |
| 455 | 331 | |
| 456 | 332 | // Testing: |
| 457 | ungated!( | |
| 458 | ignore, Normal, | |
| 459 | template!( | |
| 460 | Word, | |
| 461 | NameValueStr: "reason", | |
| 462 | "https://doc.rust-lang.org/reference/attributes/testing.html#the-ignore-attribute" | |
| 463 | ), | |
| 464 | WarnFollowing, EncodeCrossCrate::No, | |
| 465 | ), | |
| 466 | ungated!( | |
| 467 | should_panic, Normal, | |
| 468 | template!( | |
| 469 | Word, | |
| 470 | List: &[r#"expected = "reason""#], | |
| 471 | NameValueStr: "reason", | |
| 472 | "https://doc.rust-lang.org/reference/attributes/testing.html#the-should_panic-attribute" | |
| 473 | ), | |
| 474 | FutureWarnFollowing, EncodeCrossCrate::No, | |
| 475 | ), | |
| 333 | ungated!(ignore), | |
| 334 | ungated!(should_panic), | |
| 476 | 335 | |
| 477 | 336 | // Macros: |
| 478 | ungated!( | |
| 479 | automatically_derived, Normal, | |
| 480 | template!( | |
| 481 | Word, | |
| 482 | "https://doc.rust-lang.org/reference/attributes/derive.html#the-automatically_derived-attribute" | |
| 483 | ), | |
| 484 | WarnFollowing, EncodeCrossCrate::Yes | |
| 485 | ), | |
| 486 | ungated!( | |
| 487 | macro_use, Normal, | |
| 488 | template!( | |
| 489 | Word, | |
| 490 | List: &["name1, name2, ..."], | |
| 491 | "https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute" | |
| 492 | ), | |
| 493 | WarnFollowingWordOnly, EncodeCrossCrate::No, | |
| 494 | ), | |
| 495 | ungated!(macro_escape, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No), // Deprecated synonym for `macro_use`. | |
| 496 | ungated!( | |
| 497 | macro_export, Normal, | |
| 498 | template!( | |
| 499 | Word, | |
| 500 | List: &["local_inner_macros"], | |
| 501 | "https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope" | |
| 502 | ), | |
| 503 | WarnFollowing, EncodeCrossCrate::Yes | |
| 504 | ), | |
| 505 | ungated!( | |
| 506 | proc_macro, Normal, | |
| 507 | template!( | |
| 508 | Word, | |
| 509 | "https://doc.rust-lang.org/reference/procedural-macros.html#function-like-procedural-macros"), | |
| 510 | ErrorFollowing, EncodeCrossCrate::No | |
| 511 | ), | |
| 512 | ungated!( | |
| 513 | proc_macro_derive, Normal, | |
| 514 | template!( | |
| 515 | List: &["TraitName", "TraitName, attributes(name1, name2, ...)"], | |
| 516 | "https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros" | |
| 517 | ), | |
| 518 | ErrorFollowing, EncodeCrossCrate::No, | |
| 519 | ), | |
| 520 | ungated!( | |
| 521 | proc_macro_attribute, Normal, | |
| 522 | template!(Word, "https://doc.rust-lang.org/reference/procedural-macros.html#attribute-macros"), | |
| 523 | ErrorFollowing, EncodeCrossCrate::No | |
| 524 | ), | |
| 337 | ungated!(automatically_derived), | |
| 338 | ungated!(macro_use), | |
| 339 | ungated!(macro_escape), // Deprecated synonym for `macro_use`. | |
| 340 | ungated!(macro_export), | |
| 341 | ungated!(proc_macro), | |
| 342 | ungated!(proc_macro_derive), | |
| 343 | ungated!(proc_macro_attribute), | |
| 525 | 344 | |
| 526 | 345 | // Lints: |
| 527 | ungated!( | |
| 528 | warn, Normal, | |
| 529 | template!( | |
| 530 | List: &["lint1", "lint1, lint2, ...", r#"lint1, lint2, lint3, reason = "...""#], | |
| 531 | "https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes" | |
| 532 | ), | |
| 533 | DuplicatesOk, EncodeCrossCrate::No, | |
| 534 | ), | |
| 535 | ungated!( | |
| 536 | allow, Normal, | |
| 537 | template!( | |
| 538 | List: &["lint1", "lint1, lint2, ...", r#"lint1, lint2, lint3, reason = "...""#], | |
| 539 | "https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes" | |
| 540 | ), | |
| 541 | DuplicatesOk, EncodeCrossCrate::No, | |
| 542 | ), | |
| 543 | ungated!( | |
| 544 | expect, Normal, | |
| 545 | template!( | |
| 546 | List: &["lint1", "lint1, lint2, ...", r#"lint1, lint2, lint3, reason = "...""#], | |
| 547 | "https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes" | |
| 548 | ), | |
| 549 | DuplicatesOk, EncodeCrossCrate::No, | |
| 550 | ), | |
| 551 | ungated!( | |
| 552 | forbid, Normal, | |
| 553 | template!( | |
| 554 | List: &["lint1", "lint1, lint2, ...", r#"lint1, lint2, lint3, reason = "...""#], | |
| 555 | "https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes" | |
| 556 | ), | |
| 557 | DuplicatesOk, EncodeCrossCrate::No | |
| 558 | ), | |
| 559 | ungated!( | |
| 560 | deny, Normal, | |
| 561 | template!( | |
| 562 | List: &["lint1", "lint1, lint2, ...", r#"lint1, lint2, lint3, reason = "...""#], | |
| 563 | "https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes" | |
| 564 | ), | |
| 565 | DuplicatesOk, EncodeCrossCrate::No | |
| 566 | ), | |
| 567 | ungated!( | |
| 568 | must_use, Normal, | |
| 569 | template!( | |
| 570 | Word, | |
| 571 | NameValueStr: "reason", | |
| 572 | "https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute" | |
| 573 | ), | |
| 574 | FutureWarnFollowing, EncodeCrossCrate::Yes | |
| 575 | ), | |
| 576 | gated!( | |
| 577 | must_not_suspend, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing, | |
| 578 | EncodeCrossCrate::Yes, experimental!(must_not_suspend) | |
| 579 | ), | |
| 580 | ungated!( | |
| 581 | deprecated, Normal, | |
| 582 | template!( | |
| 583 | Word, | |
| 584 | List: &[r#"/*opt*/ since = "version", /*opt*/ note = "reason""#], | |
| 585 | NameValueStr: "reason", | |
| 586 | "https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute" | |
| 587 | ), | |
| 588 | ErrorFollowing, EncodeCrossCrate::Yes | |
| 589 | ), | |
| 346 | ungated!(warn), | |
| 347 | ungated!(allow), | |
| 348 | ungated!(expect), | |
| 349 | ungated!(forbid), | |
| 350 | ungated!(deny), | |
| 351 | ungated!(must_use), | |
| 352 | gated!(must_not_suspend, experimental!(must_not_suspend)), | |
| 353 | ungated!(deprecated), | |
| 590 | 354 | |
| 591 | 355 | // Crate properties: |
| 592 | ungated!( | |
| 593 | crate_name, CrateLevel, | |
| 594 | template!( | |
| 595 | NameValueStr: "name", | |
| 596 | "https://doc.rust-lang.org/reference/crates-and-source-files.html#the-crate_name-attribute" | |
| 597 | ), | |
| 598 | FutureWarnFollowing, EncodeCrossCrate::No, | |
| 599 | ), | |
| 600 | ungated!( | |
| 601 | crate_type, CrateLevel, | |
| 602 | template!( | |
| 603 | NameValueStr: ["bin", "lib", "dylib", "cdylib", "rlib", "staticlib", "sdylib", "proc-macro"], | |
| 604 | "https://doc.rust-lang.org/reference/linkage.html" | |
| 605 | ), | |
| 606 | DuplicatesOk, EncodeCrossCrate::No, | |
| 607 | ), | |
| 356 | ungated!(crate_name), | |
| 357 | ungated!(crate_type), | |
| 608 | 358 | |
| 609 | 359 | // ABI, linking, symbols, and FFI |
| 610 | ungated!( | |
| 611 | link, Normal, | |
| 612 | template!(List: &[ | |
| 613 | r#"name = "...""#, | |
| 614 | r#"name = "...", kind = "dylib|static|...""#, | |
| 615 | r#"name = "...", wasm_import_module = "...""#, | |
| 616 | r#"name = "...", import_name_type = "decorated|noprefix|undecorated""#, | |
| 617 | r#"name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated""#, | |
| 618 | ], "https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute"), | |
| 619 | DuplicatesOk, EncodeCrossCrate::No, | |
| 620 | ), | |
| 621 | ungated!( | |
| 622 | link_name, Normal, | |
| 623 | template!(NameValueStr: "name", "https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_name-attribute"), | |
| 624 | FutureWarnPreceding, EncodeCrossCrate::Yes | |
| 625 | ), | |
| 626 | ungated!( | |
| 627 | no_link, Normal, | |
| 628 | template!(Word, "https://doc.rust-lang.org/reference/items/extern-crates.html#the-no_link-attribute"), | |
| 629 | WarnFollowing, EncodeCrossCrate::No | |
| 630 | ), | |
| 631 | ungated!( | |
| 632 | repr, Normal, | |
| 633 | template!( | |
| 634 | List: &["C", "Rust", "transparent", "align(...)", "packed(...)", "<integer type>"], | |
| 635 | "https://doc.rust-lang.org/reference/type-layout.html#representations" | |
| 636 | ), | |
| 637 | DuplicatesOk, EncodeCrossCrate::No | |
| 638 | ), | |
| 360 | ungated!(link), | |
| 361 | ungated!(link_name), | |
| 362 | ungated!(no_link), | |
| 363 | ungated!(repr), | |
| 639 | 364 | // FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity |
| 640 | gated!(rustc_align, Normal, template!(List: &["alignment"]), DuplicatesOk, EncodeCrossCrate::No, fn_align, experimental!(rustc_align)), | |
| 641 | gated!(rustc_align_static, Normal, template!(List: &["alignment"]), DuplicatesOk, EncodeCrossCrate::No, static_align, experimental!(rustc_align_static)), | |
| 642 | ungated!( | |
| 643 | unsafe(Edition2024) export_name, Normal, | |
| 644 | template!(NameValueStr: "name", "https://doc.rust-lang.org/reference/abi.html#the-export_name-attribute"), | |
| 645 | FutureWarnPreceding, EncodeCrossCrate::No | |
| 646 | ), | |
| 647 | ungated!( | |
| 648 | unsafe(Edition2024) link_section, Normal, | |
| 649 | template!(NameValueStr: "name", "https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute"), | |
| 650 | FutureWarnPreceding, EncodeCrossCrate::No | |
| 651 | ), | |
| 652 | ungated!( | |
| 653 | unsafe(Edition2024) no_mangle, Normal, | |
| 654 | template!(Word, "https://doc.rust-lang.org/reference/abi.html#the-no_mangle-attribute"), | |
| 655 | WarnFollowing, EncodeCrossCrate::No | |
| 656 | ), | |
| 657 | ungated!( | |
| 658 | used, Normal, | |
| 659 | template!(Word, List: &["compiler", "linker"], "https://doc.rust-lang.org/reference/abi.html#the-used-attribute"), | |
| 660 | WarnFollowing, EncodeCrossCrate::No | |
| 661 | ), | |
| 662 | ungated!( | |
| 663 | link_ordinal, Normal, | |
| 664 | template!(List: &["ordinal"], "https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute"), | |
| 665 | ErrorPreceding, EncodeCrossCrate::Yes | |
| 666 | ), | |
| 667 | ungated!( | |
| 668 | unsafe naked, Normal, | |
| 669 | template!(Word, "https://doc.rust-lang.org/reference/attributes/codegen.html#the-naked-attribute"), | |
| 670 | WarnFollowing, EncodeCrossCrate::No | |
| 671 | ), | |
| 365 | gated!(rustc_align,fn_align, experimental!(rustc_align)), | |
| 366 | gated!(rustc_align_static,static_align, experimental!(rustc_align_static)), | |
| 367 | ungated!(unsafe(Edition2024) export_name), | |
| 368 | ungated!(unsafe(Edition2024) link_section), | |
| 369 | ungated!(unsafe(Edition2024) no_mangle), | |
| 370 | ungated!(used), | |
| 371 | ungated!(link_ordinal), | |
| 372 | ungated!(unsafe naked), | |
| 672 | 373 | // See `TyAndLayout::pass_indirectly_in_non_rustic_abis` for details. |
| 673 | rustc_attr!( | |
| 674 | rustc_pass_indirectly_in_non_rustic_abis, Normal, template!(Word), ErrorFollowing, | |
| 675 | EncodeCrossCrate::No, | |
| 676 | "types marked with `#[rustc_pass_indirectly_in_non_rustic_abis]` are always passed indirectly by non-Rustic ABIs" | |
| 677 | ), | |
| 374 | rustc_attr!(rustc_pass_indirectly_in_non_rustic_abis, "types marked with `#[rustc_pass_indirectly_in_non_rustic_abis]` are always passed indirectly by non-Rustic ABIs"), | |
| 678 | 375 | |
| 679 | 376 | // Limits: |
| 680 | ungated!( | |
| 681 | recursion_limit, CrateLevel, | |
| 682 | template!(NameValueStr: "N", "https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute"), | |
| 683 | FutureWarnFollowing, EncodeCrossCrate::No | |
| 684 | ), | |
| 685 | ungated!( | |
| 686 | type_length_limit, CrateLevel, | |
| 687 | template!(NameValueStr: "N", "https://doc.rust-lang.org/reference/attributes/limits.html#the-type_length_limit-attribute"), | |
| 688 | FutureWarnFollowing, EncodeCrossCrate::No | |
| 689 | ), | |
| 377 | ungated!(recursion_limit), | |
| 378 | ungated!(type_length_limit), | |
| 690 | 379 | gated!( |
| 691 | move_size_limit, CrateLevel, template!(NameValueStr: "N"), ErrorFollowing, | |
| 692 | EncodeCrossCrate::No, large_assignments, experimental!(move_size_limit) | |
| 380 | move_size_limit, large_assignments, experimental!(move_size_limit) | |
| 693 | 381 | ), |
| 694 | 382 | |
| 695 | 383 | // Entry point: |
| 696 | ungated!( | |
| 697 | no_main, CrateLevel, | |
| 698 | template!(Word, "https://doc.rust-lang.org/reference/crates-and-source-files.html#the-no_main-attribute"), | |
| 699 | WarnFollowing, EncodeCrossCrate::No | |
| 700 | ), | |
| 384 | ungated!(no_main), | |
| 701 | 385 | |
| 702 | 386 | // Modules, prelude, and resolution: |
| 703 | ungated!( | |
| 704 | path, Normal, | |
| 705 | template!(NameValueStr: "file", "https://doc.rust-lang.org/reference/items/modules.html#the-path-attribute"), | |
| 706 | FutureWarnFollowing, EncodeCrossCrate::No | |
| 707 | ), | |
| 708 | ungated!( | |
| 709 | no_std, CrateLevel, | |
| 710 | template!(Word, "https://doc.rust-lang.org/reference/names/preludes.html#the-no_std-attribute"), | |
| 711 | WarnFollowing, EncodeCrossCrate::No | |
| 712 | ), | |
| 713 | ungated!( | |
| 714 | no_implicit_prelude, Normal, | |
| 715 | template!(Word, "https://doc.rust-lang.org/reference/names/preludes.html#the-no_implicit_prelude-attribute"), | |
| 716 | WarnFollowing, EncodeCrossCrate::No | |
| 717 | ), | |
| 718 | ungated!( | |
| 719 | non_exhaustive, Normal, | |
| 720 | template!(Word, "https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute"), | |
| 721 | WarnFollowing, EncodeCrossCrate::Yes | |
| 722 | ), | |
| 387 | ungated!(path), | |
| 388 | ungated!(no_std), | |
| 389 | ungated!(no_implicit_prelude), | |
| 390 | ungated!(non_exhaustive), | |
| 723 | 391 | |
| 724 | 392 | // Runtime |
| 725 | ungated!( | |
| 726 | windows_subsystem, CrateLevel, | |
| 727 | template!(NameValueStr: ["windows", "console"], "https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute"), | |
| 728 | FutureWarnFollowing, EncodeCrossCrate::No | |
| 729 | ), | |
| 730 | ungated!( // RFC 2070 | |
| 731 | panic_handler, Normal, | |
| 732 | template!(Word, "https://doc.rust-lang.org/reference/panic.html#the-panic_handler-attribute"), | |
| 733 | WarnFollowing, EncodeCrossCrate::Yes | |
| 393 | ungated!(windows_subsystem), | |
| 394 | ungated!(// RFC 2070 | |
| 395 | panic_handler | |
| 734 | 396 | ), |
| 735 | 397 | |
| 736 | 398 | // Code generation: |
| 737 | ungated!( | |
| 738 | inline, Normal, | |
| 739 | template!( | |
| 740 | Word, | |
| 741 | List: &["always", "never"], | |
| 742 | "https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute" | |
| 743 | ), | |
| 744 | FutureWarnFollowing, EncodeCrossCrate::No | |
| 745 | ), | |
| 746 | ungated!( | |
| 747 | cold, Normal, | |
| 748 | template!(Word, "https://doc.rust-lang.org/reference/attributes/codegen.html#the-cold-attribute"), | |
| 749 | WarnFollowing, EncodeCrossCrate::No | |
| 750 | ), | |
| 751 | ungated!( | |
| 752 | no_builtins, CrateLevel, | |
| 753 | template!(Word, "https://doc.rust-lang.org/reference/attributes/codegen.html#the-no_builtins-attribute"), | |
| 754 | WarnFollowing, EncodeCrossCrate::Yes | |
| 755 | ), | |
| 756 | ungated!( | |
| 757 | target_feature, Normal, | |
| 758 | template!(List: &[r#"enable = "name""#], "https://doc.rust-lang.org/reference/attributes/codegen.html#the-target_feature-attribute"), | |
| 759 | DuplicatesOk, EncodeCrossCrate::No, | |
| 760 | ), | |
| 761 | ungated!( | |
| 762 | track_caller, Normal, | |
| 763 | template!(Word, "https://doc.rust-lang.org/reference/attributes/codegen.html#the-track_caller-attribute"), | |
| 764 | WarnFollowing, EncodeCrossCrate::Yes | |
| 765 | ), | |
| 766 | ungated!( | |
| 767 | instruction_set, Normal, | |
| 768 | template!(List: &["set"], "https://doc.rust-lang.org/reference/attributes/codegen.html#the-instruction_set-attribute"), | |
| 769 | ErrorPreceding, EncodeCrossCrate::No | |
| 770 | ), | |
| 399 | ungated!(inline), | |
| 400 | ungated!(cold), | |
| 401 | ungated!(no_builtins), | |
| 402 | ungated!(target_feature), | |
| 403 | ungated!(track_caller), | |
| 404 | ungated!(instruction_set), | |
| 771 | 405 | gated!( |
| 772 | unsafe force_target_feature, Normal, template!(List: &[r#"enable = "name""#]), | |
| 773 | DuplicatesOk, EncodeCrossCrate::No, effective_target_features, experimental!(force_target_feature) | |
| 406 | unsafe force_target_feature, | |
| 407 | effective_target_features, experimental!(force_target_feature) | |
| 774 | 408 | ), |
| 775 | 409 | gated!( |
| 776 | sanitize, Normal, template!(List: &[r#"address = "on|off""#, r#"kernel_address = "on|off""#, r#"cfi = "on|off""#, r#"hwaddress = "on|off""#, r#"kernel_hwaddress = "on|off""#, r#"kcfi = "on|off""#, r#"memory = "on|off""#, r#"memtag = "on|off""#, r#"shadow_call_stack = "on|off""#, r#"thread = "on|off""#]), ErrorPreceding, | |
| 777 | EncodeCrossCrate::No, sanitize, experimental!(sanitize), | |
| 410 | sanitize, | |
| 411 | sanitize, experimental!(sanitize) | |
| 778 | 412 | ), |
| 779 | 413 | gated!( |
| 780 | coverage, Normal, template!(OneOf: &[sym::off, sym::on]), | |
| 781 | ErrorPreceding, EncodeCrossCrate::No, | |
| 414 | coverage, | |
| 782 | 415 | coverage_attribute, experimental!(coverage) |
| 783 | 416 | ), |
| 784 | 417 | |
| 785 | ungated!( | |
| 786 | doc, Normal, | |
| 787 | template!( | |
| 788 | List: &["hidden", "inline"], | |
| 789 | NameValueStr: "string", | |
| 790 | "https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html" | |
| 791 | ), | |
| 792 | DuplicatesOk, EncodeCrossCrate::Yes | |
| 793 | ), | |
| 418 | ungated!(doc), | |
| 794 | 419 | |
| 795 | 420 | // Debugging |
| 796 | ungated!( | |
| 797 | debugger_visualizer, Normal, | |
| 798 | template!( | |
| 799 | List: &[r#"natvis_file = "...", gdb_script_file = "...""#], | |
| 800 | "https://doc.rust-lang.org/reference/attributes/debugger.html#the-debugger_visualizer-attribute" | |
| 801 | ), | |
| 802 | DuplicatesOk, EncodeCrossCrate::No | |
| 803 | ), | |
| 804 | ungated!( | |
| 805 | collapse_debuginfo, Normal, | |
| 806 | template!( | |
| 807 | List: &["no", "external", "yes"], | |
| 808 | "https://doc.rust-lang.org/reference/attributes/debugger.html#the-collapse_debuginfo-attribute" | |
| 809 | ), | |
| 810 | ErrorFollowing, EncodeCrossCrate::Yes | |
| 811 | ), | |
| 421 | ungated!(debugger_visualizer), | |
| 422 | ungated!(collapse_debuginfo), | |
| 812 | 423 | |
| 813 | 424 | // ========================================================================== |
| 814 | 425 | // Unstable attributes: |
| ... | ... | @@ -816,71 +427,61 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ |
| 816 | 427 | |
| 817 | 428 | // Linking: |
| 818 | 429 | gated!( |
| 819 | export_stable, Normal, template!(Word), WarnFollowing, | |
| 820 | EncodeCrossCrate::No, experimental!(export_stable) | |
| 430 | export_stable, experimental!(export_stable) | |
| 821 | 431 | ), |
| 822 | 432 | |
| 823 | 433 | // Testing: |
| 824 | 434 | gated!( |
| 825 | test_runner, CrateLevel, template!(List: &["path"]), ErrorFollowing, | |
| 826 | EncodeCrossCrate::Yes, custom_test_frameworks, | |
| 827 | "custom test frameworks are an unstable feature", | |
| 435 | test_runner, custom_test_frameworks, | |
| 436 | "custom test frameworks are an unstable feature" | |
| 828 | 437 | ), |
| 829 | 438 | |
| 830 | 439 | gated!( |
| 831 | reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"), ErrorFollowing, | |
| 832 | EncodeCrossCrate::No, custom_test_frameworks, | |
| 833 | "custom test frameworks are an unstable feature", | |
| 440 | reexport_test_harness_main, custom_test_frameworks, | |
| 441 | "custom test frameworks are an unstable feature" | |
| 834 | 442 | ), |
| 835 | 443 | |
| 836 | 444 | // RFC #1268 |
| 837 | 445 | gated!( |
| 838 | marker, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, | |
| 839 | marker_trait_attr, experimental!(marker) | |
| 446 | marker,marker_trait_attr, experimental!(marker) | |
| 840 | 447 | ), |
| 841 | 448 | gated!( |
| 842 | thread_local, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, | |
| 843 | "`#[thread_local]` is an experimental feature, and does not currently handle destructors", | |
| 449 | thread_local,"`#[thread_local]` is an experimental feature, and does not currently handle destructors" | |
| 844 | 450 | ), |
| 845 | 451 | gated!( |
| 846 | no_core, CrateLevel, template!(Word), WarnFollowing, | |
| 847 | EncodeCrossCrate::No, experimental!(no_core) | |
| 452 | no_core, experimental!(no_core) | |
| 848 | 453 | ), |
| 849 | 454 | // RFC 2412 |
| 850 | 455 | gated!( |
| 851 | optimize, Normal, template!(List: &["none", "size", "speed"]), ErrorPreceding, | |
| 852 | EncodeCrossCrate::No, optimize_attribute, experimental!(optimize) | |
| 456 | optimize, | |
| 457 | optimize_attribute, experimental!(optimize) | |
| 853 | 458 | ), |
| 854 | 459 | |
| 855 | 460 | gated!( |
| 856 | unsafe ffi_pure, Normal, template!(Word), WarnFollowing, | |
| 857 | EncodeCrossCrate::No, experimental!(ffi_pure) | |
| 461 | unsafe ffi_pure, experimental!(ffi_pure) | |
| 858 | 462 | ), |
| 859 | 463 | gated!( |
| 860 | unsafe ffi_const, Normal, template!(Word), WarnFollowing, | |
| 861 | EncodeCrossCrate::No, experimental!(ffi_const) | |
| 464 | unsafe ffi_const, experimental!(ffi_const) | |
| 862 | 465 | ), |
| 863 | 466 | gated!( |
| 864 | register_tool, CrateLevel, template!(List: &["tool1, tool2, ..."]), DuplicatesOk, | |
| 865 | EncodeCrossCrate::No, experimental!(register_tool), | |
| 467 | register_tool, experimental!(register_tool) | |
| 866 | 468 | ), |
| 867 | 469 | // `#[cfi_encoding = ""]` |
| 868 | 470 | gated!( |
| 869 | cfi_encoding, Normal, template!(NameValueStr: "encoding"), ErrorPreceding, | |
| 870 | EncodeCrossCrate::Yes, experimental!(cfi_encoding) | |
| 471 | cfi_encoding, | |
| 472 | experimental!(cfi_encoding) | |
| 871 | 473 | ), |
| 872 | 474 | |
| 873 | 475 | // `#[coroutine]` attribute to be applied to closures to make them coroutines instead |
| 874 | 476 | gated!( |
| 875 | coroutine, Normal, template!(Word), ErrorFollowing, | |
| 876 | EncodeCrossCrate::No, coroutines, experimental!(coroutine) | |
| 477 | coroutine,coroutines, experimental!(coroutine) | |
| 877 | 478 | ), |
| 878 | 479 | |
| 879 | 480 | // RFC 3543 |
| 880 | 481 | // `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` |
| 881 | 482 | gated!( |
| 882 | patchable_function_entry, Normal, template!(List: &["prefix_nops = m, entry_nops = n"]), ErrorPreceding, | |
| 883 | EncodeCrossCrate::Yes, experimental!(patchable_function_entry) | |
| 483 | patchable_function_entry, | |
| 484 | experimental!(patchable_function_entry) | |
| 884 | 485 | ), |
| 885 | 486 | |
| 886 | 487 | // The `#[loop_match]` and `#[const_continue]` attributes are part of the |
| ... | ... | @@ -888,12 +489,10 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ |
| 888 | 489 | // |
| 889 | 490 | // - https://github.com/rust-lang/rust/issues/132306 |
| 890 | 491 | gated!( |
| 891 | const_continue, Normal, template!(Word), ErrorFollowing, | |
| 892 | EncodeCrossCrate::No, loop_match, experimental!(const_continue) | |
| 492 | const_continue,loop_match, experimental!(const_continue) | |
| 893 | 493 | ), |
| 894 | 494 | gated!( |
| 895 | loop_match, Normal, template!(Word), ErrorFollowing, | |
| 896 | EncodeCrossCrate::No, loop_match, experimental!(loop_match) | |
| 495 | loop_match,loop_match, experimental!(loop_match) | |
| 897 | 496 | ), |
| 898 | 497 | |
| 899 | 498 | // The `#[pin_v2]` attribute is part of the `pin_ergonomics` experiment |
| ... | ... | @@ -901,74 +500,40 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ |
| 901 | 500 | // |
| 902 | 501 | // - https://github.com/rust-lang/rust/issues/130494 |
| 903 | 502 | gated!( |
| 904 | pin_v2, Normal, template!(Word), ErrorFollowing, | |
| 905 | EncodeCrossCrate::Yes, pin_ergonomics, experimental!(pin_v2), | |
| 503 | pin_v2,pin_ergonomics, experimental!(pin_v2), | |
| 906 | 504 | ), |
| 907 | 505 | |
| 908 | 506 | // ========================================================================== |
| 909 | 507 | // Internal attributes: Stability, deprecation, and unsafe: |
| 910 | 508 | // ========================================================================== |
| 911 | 509 | |
| 912 | ungated!( | |
| 913 | feature, CrateLevel, | |
| 914 | template!(List: &["name1, name2, ..."]), DuplicatesOk, EncodeCrossCrate::No, | |
| 915 | ), | |
| 510 | ungated!(feature), | |
| 916 | 511 | // DuplicatesOk since it has its own validation |
| 917 | ungated!( | |
| 918 | stable, Normal, | |
| 919 | template!(List: &[r#"feature = "name", since = "version""#]), DuplicatesOk, EncodeCrossCrate::No, | |
| 920 | ), | |
| 921 | ungated!( | |
| 922 | unstable, Normal, | |
| 923 | template!(List: &[r#"feature = "name", reason = "...", issue = "N""#]), DuplicatesOk, | |
| 924 | EncodeCrossCrate::Yes | |
| 925 | ), | |
| 926 | ungated!( | |
| 927 | unstable_feature_bound, Normal, template!(Word, List: &["feat1, feat2, ..."]), | |
| 928 | DuplicatesOk, EncodeCrossCrate::No, | |
| 929 | ), | |
| 930 | ungated!( | |
| 931 | rustc_const_unstable, Normal, template!(List: &[r#"feature = "name""#]), | |
| 932 | DuplicatesOk, EncodeCrossCrate::Yes | |
| 933 | ), | |
| 934 | ungated!( | |
| 935 | rustc_const_stable, Normal, | |
| 936 | template!(List: &[r#"feature = "name""#]), DuplicatesOk, EncodeCrossCrate::No, | |
| 937 | ), | |
| 938 | ungated!( | |
| 939 | rustc_default_body_unstable, Normal, | |
| 940 | template!(List: &[r#"feature = "name", reason = "...", issue = "N""#]), | |
| 941 | DuplicatesOk, EncodeCrossCrate::No | |
| 942 | ), | |
| 943 | gated!( | |
| 944 | allow_internal_unstable, Normal, template!(Word, List: &["feat1, feat2, ..."]), | |
| 945 | DuplicatesOk, EncodeCrossCrate::Yes, | |
| 512 | ungated!(stable), | |
| 513 | ungated!(unstable), | |
| 514 | ungated!(unstable_feature_bound), | |
| 515 | ungated!(rustc_const_unstable), | |
| 516 | ungated!(rustc_const_stable), | |
| 517 | ungated!(rustc_default_body_unstable), | |
| 518 | gated!( | |
| 519 | allow_internal_unstable, | |
| 946 | 520 | "allow_internal_unstable side-steps feature gating and stability checks", |
| 947 | 521 | ), |
| 948 | 522 | gated!( |
| 949 | allow_internal_unsafe, Normal, template!(Word), WarnFollowing, | |
| 950 | EncodeCrossCrate::No, "allow_internal_unsafe side-steps the unsafe_code lint", | |
| 523 | allow_internal_unsafe, "allow_internal_unsafe side-steps the unsafe_code lint", | |
| 951 | 524 | ), |
| 952 | 525 | gated!( |
| 953 | rustc_eii_foreign_item, Normal, template!(Word), | |
| 954 | ErrorFollowing, EncodeCrossCrate::Yes, eii_internals, | |
| 526 | rustc_eii_foreign_item, | |
| 527 | eii_internals, | |
| 955 | 528 | "used internally to mark types with a `transparent` representation when it is guaranteed by the documentation", |
| 956 | 529 | ), |
| 957 | rustc_attr!( | |
| 958 | rustc_allowed_through_unstable_modules, Normal, template!(NameValueStr: "deprecation message"), | |
| 959 | WarnFollowing, EncodeCrossCrate::No, | |
| 530 | rustc_attr!(rustc_allowed_through_unstable_modules, | |
| 960 | 531 | "rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \ |
| 961 | 532 | through unstable paths" |
| 962 | 533 | ), |
| 963 | rustc_attr!( | |
| 964 | rustc_deprecated_safe_2024, Normal, template!(List: &[r#"audit_that = "...""#]), | |
| 965 | ErrorFollowing, EncodeCrossCrate::Yes, | |
| 966 | "`#[rustc_deprecated_safe_2024]` is used to declare functions unsafe across the edition 2024 boundary", | |
| 534 | rustc_attr!(rustc_deprecated_safe_2024,"`#[rustc_deprecated_safe_2024]` is used to declare functions unsafe across the edition 2024 boundary", | |
| 967 | 535 | ), |
| 968 | rustc_attr!( | |
| 969 | rustc_pub_transparent, Normal, template!(Word), | |
| 970 | ErrorFollowing, EncodeCrossCrate::Yes, | |
| 971 | "used internally to mark types with a `transparent` representation when it is guaranteed by the documentation", | |
| 536 | rustc_attr!(rustc_pub_transparent,"used internally to mark types with a `transparent` representation when it is guaranteed by the documentation", | |
| 972 | 537 | ), |
| 973 | 538 | |
| 974 | 539 | |
| ... | ... | @@ -976,25 +541,13 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ |
| 976 | 541 | // Internal attributes: Type system related: |
| 977 | 542 | // ========================================================================== |
| 978 | 543 | |
| 979 | gated!(fundamental, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes, experimental!(fundamental)), | |
| 544 | gated!(fundamental, experimental!(fundamental)), | |
| 980 | 545 | gated!( |
| 981 | may_dangle, Normal, template!(Word), WarnFollowing, | |
| 982 | EncodeCrossCrate::No, dropck_eyepatch, | |
| 983 | "`may_dangle` has unstable semantics and may be removed in the future", | |
| 546 | may_dangle, dropck_eyepatch, | |
| 547 | "`may_dangle` has unstable semantics and may be removed in the future" | |
| 984 | 548 | ), |
| 985 | 549 | |
| 986 | rustc_attr!( | |
| 987 | rustc_never_type_options, | |
| 988 | Normal, | |
| 989 | template!(List: &[ | |
| 990 | "", | |
| 991 | r#"fallback = "unit""#, | |
| 992 | r#"fallback = "niko""#, | |
| 993 | r#"fallback = "never""#, | |
| 994 | r#"fallback = "no""#, | |
| 995 | ]), | |
| 996 | ErrorFollowing, | |
| 997 | EncodeCrossCrate::No, | |
| 550 | rustc_attr!(rustc_never_type_options, | |
| 998 | 551 | "`rustc_never_type_options` is used to experiment with never type fallback and work on \ |
| 999 | 552 | never type stabilization" |
| 1000 | 553 | ), |
| ... | ... | @@ -1003,57 +556,33 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ |
| 1003 | 556 | // Internal attributes: Runtime related: |
| 1004 | 557 | // ========================================================================== |
| 1005 | 558 | |
| 1006 | rustc_attr!( | |
| 1007 | rustc_allocator, Normal, template!(Word), WarnFollowing, | |
| 1008 | EncodeCrossCrate::No, | |
| 1009 | ), | |
| 1010 | rustc_attr!( | |
| 1011 | rustc_nounwind, Normal, template!(Word), WarnFollowing, | |
| 1012 | EncodeCrossCrate::No, | |
| 1013 | ), | |
| 1014 | rustc_attr!( | |
| 1015 | rustc_reallocator, Normal, template!(Word), WarnFollowing, | |
| 1016 | EncodeCrossCrate::No, | |
| 1017 | ), | |
| 1018 | rustc_attr!( | |
| 1019 | rustc_deallocator, Normal, template!(Word), WarnFollowing, | |
| 1020 | EncodeCrossCrate::No, | |
| 1021 | ), | |
| 1022 | rustc_attr!( | |
| 1023 | rustc_allocator_zeroed, Normal, template!(Word), WarnFollowing, | |
| 1024 | EncodeCrossCrate::No, | |
| 1025 | ), | |
| 1026 | rustc_attr!( | |
| 1027 | rustc_allocator_zeroed_variant, Normal, template!(NameValueStr: "function"), ErrorPreceding, | |
| 1028 | EncodeCrossCrate::Yes, | |
| 1029 | ), | |
| 559 | rustc_attr!(rustc_allocator), | |
| 560 | rustc_attr!(rustc_nounwind), | |
| 561 | rustc_attr!(rustc_reallocator), | |
| 562 | rustc_attr!(rustc_deallocator), | |
| 563 | rustc_attr!(rustc_allocator_zeroed), | |
| 564 | rustc_attr!(rustc_allocator_zeroed_variant), | |
| 1030 | 565 | gated!( |
| 1031 | default_lib_allocator, Normal, template!(Word), WarnFollowing, | |
| 1032 | EncodeCrossCrate::No, allocator_internals, experimental!(default_lib_allocator), | |
| 566 | default_lib_allocator, allocator_internals, experimental!(default_lib_allocator), | |
| 1033 | 567 | ), |
| 1034 | 568 | gated!( |
| 1035 | needs_allocator, Normal, template!(Word), WarnFollowing, | |
| 1036 | EncodeCrossCrate::No, allocator_internals, experimental!(needs_allocator), | |
| 569 | needs_allocator, allocator_internals, experimental!(needs_allocator), | |
| 1037 | 570 | ), |
| 1038 | 571 | gated!( |
| 1039 | panic_runtime, CrateLevel, template!(Word), WarnFollowing, | |
| 1040 | EncodeCrossCrate::No, experimental!(panic_runtime) | |
| 572 | panic_runtime, experimental!(panic_runtime) | |
| 1041 | 573 | ), |
| 1042 | 574 | gated!( |
| 1043 | needs_panic_runtime, CrateLevel, template!(Word), WarnFollowing, | |
| 1044 | EncodeCrossCrate::No, experimental!(needs_panic_runtime) | |
| 575 | needs_panic_runtime, experimental!(needs_panic_runtime) | |
| 1045 | 576 | ), |
| 1046 | 577 | gated!( |
| 1047 | compiler_builtins, CrateLevel, template!(Word), WarnFollowing, | |
| 1048 | EncodeCrossCrate::No, | |
| 578 | compiler_builtins, | |
| 1049 | 579 | "the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \ |
| 1050 | which contains compiler-rt intrinsics and will never be stable", | |
| 580 | which contains compiler-rt intrinsics and will never be stable" | |
| 1051 | 581 | ), |
| 1052 | 582 | gated!( |
| 1053 | profiler_runtime, CrateLevel, template!(Word), WarnFollowing, | |
| 1054 | EncodeCrossCrate::No, | |
| 583 | profiler_runtime, | |
| 1055 | 584 | "the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \ |
| 1056 | which contains the profiler runtime and will never be stable", | |
| 585 | which contains the profiler runtime and will never be stable" | |
| 1057 | 586 | ), |
| 1058 | 587 | |
| 1059 | 588 | // ========================================================================== |
| ... | ... | @@ -1061,277 +590,123 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ |
| 1061 | 590 | // ========================================================================== |
| 1062 | 591 | |
| 1063 | 592 | gated!( |
| 1064 | linkage, Normal, template!(NameValueStr: [ | |
| 1065 | "available_externally", | |
| 1066 | "common", | |
| 1067 | "extern_weak", | |
| 1068 | "external", | |
| 1069 | "internal", | |
| 1070 | "linkonce", | |
| 1071 | "linkonce_odr", | |
| 1072 | "weak", | |
| 1073 | "weak_odr", | |
| 1074 | ], "https://doc.rust-lang.org/reference/linkage.html"), | |
| 1075 | ErrorPreceding, EncodeCrossCrate::No, | |
| 1076 | "the `linkage` attribute is experimental and not portable across platforms", | |
| 1077 | ), | |
| 1078 | rustc_attr!( | |
| 1079 | rustc_std_internal_symbol, Normal, template!(Word), WarnFollowing, | |
| 1080 | EncodeCrossCrate::No, | |
| 1081 | ), | |
| 1082 | rustc_attr!( | |
| 1083 | rustc_objc_class, Normal, template!(NameValueStr: "ClassName"), ErrorPreceding, | |
| 1084 | EncodeCrossCrate::No, | |
| 1085 | ), | |
| 1086 | rustc_attr!( | |
| 1087 | rustc_objc_selector, Normal, template!(NameValueStr: "methodName"), ErrorPreceding, | |
| 1088 | EncodeCrossCrate::No, | |
| 593 | linkage, | |
| 594 | "the `linkage` attribute is experimental and not portable across platforms" | |
| 1089 | 595 | ), |
| 596 | rustc_attr!(rustc_std_internal_symbol), | |
| 597 | rustc_attr!(rustc_objc_class), | |
| 598 | rustc_attr!(rustc_objc_selector), | |
| 1090 | 599 | |
| 1091 | 600 | // ========================================================================== |
| 1092 | 601 | // Internal attributes, Macro related: |
| 1093 | 602 | // ========================================================================== |
| 1094 | 603 | |
| 1095 | rustc_attr!( | |
| 1096 | rustc_builtin_macro, Normal, | |
| 1097 | template!(Word, List: &["name", "name, /*opt*/ attributes(name1, name2, ...)"]), ErrorFollowing, | |
| 1098 | EncodeCrossCrate::Yes, | |
| 1099 | ), | |
| 1100 | rustc_attr!( | |
| 1101 | rustc_proc_macro_decls, Normal, template!(Word), WarnFollowing, | |
| 1102 | EncodeCrossCrate::No, | |
| 1103 | ), | |
| 1104 | rustc_attr!( | |
| 1105 | rustc_macro_transparency, Normal, | |
| 1106 | template!(NameValueStr: ["transparent", "semiopaque", "opaque"]), ErrorFollowing, | |
| 1107 | EncodeCrossCrate::Yes, "used internally for testing macro hygiene", | |
| 1108 | ), | |
| 1109 | rustc_attr!( | |
| 1110 | rustc_autodiff, Normal, | |
| 1111 | template!(Word, List: &[r#""...""#]), DuplicatesOk, | |
| 1112 | EncodeCrossCrate::Yes, | |
| 1113 | ), | |
| 1114 | rustc_attr!( | |
| 1115 | rustc_offload_kernel, Normal, | |
| 1116 | template!(Word), DuplicatesOk, | |
| 1117 | EncodeCrossCrate::Yes, | |
| 604 | rustc_attr!(rustc_builtin_macro), | |
| 605 | rustc_attr!(rustc_proc_macro_decls), | |
| 606 | rustc_attr!(rustc_macro_transparency, | |
| 607 | "used internally for testing macro hygiene" | |
| 1118 | 608 | ), |
| 609 | rustc_attr!(rustc_autodiff), | |
| 610 | rustc_attr!(rustc_offload_kernel), | |
| 1119 | 611 | // Traces that are left when `cfg` and `cfg_attr` attributes are expanded. |
| 1120 | 612 | // The attributes are not gated, to avoid stability errors, but they cannot be used in stable |
| 1121 | 613 | // or unstable code directly because `sym::cfg_(attr_)trace` are not valid identifiers, they |
| 1122 | 614 | // can only be generated by the compiler. |
| 1123 | ungated!( | |
| 1124 | cfg_trace, Normal, template!(Word /* irrelevant */), DuplicatesOk, | |
| 1125 | EncodeCrossCrate::Yes | |
| 615 | ungated!(cfg_trace | |
| 1126 | 616 | ), |
| 1127 | ungated!( | |
| 1128 | cfg_attr_trace, Normal, template!(Word /* irrelevant */), DuplicatesOk, | |
| 1129 | EncodeCrossCrate::No | |
| 617 | ungated!(cfg_attr_trace | |
| 1130 | 618 | ), |
| 1131 | 619 | |
| 1132 | 620 | // ========================================================================== |
| 1133 | 621 | // Internal attributes, Diagnostics related: |
| 1134 | 622 | // ========================================================================== |
| 1135 | 623 | |
| 1136 | rustc_attr!( | |
| 1137 | rustc_on_unimplemented, Normal, | |
| 1138 | template!( | |
| 1139 | List: &[r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#], | |
| 1140 | NameValueStr: "message" | |
| 1141 | ), | |
| 1142 | ErrorFollowing, EncodeCrossCrate::Yes, | |
| 1143 | "see `#[diagnostic::on_unimplemented]` for the stable equivalent of this attribute" | |
| 1144 | ), | |
| 1145 | rustc_attr!( | |
| 1146 | rustc_confusables, Normal, | |
| 1147 | template!(List: &[r#""name1", "name2", ..."#]), | |
| 1148 | ErrorFollowing, EncodeCrossCrate::Yes, | |
| 624 | rustc_attr!(rustc_on_unimplemented,"see `#[diagnostic::on_unimplemented]` for the stable equivalent of this attribute" | |
| 1149 | 625 | ), |
| 626 | rustc_attr!(rustc_confusables), | |
| 1150 | 627 | // Enumerates "identity-like" conversion methods to suggest on type mismatch. |
| 1151 | rustc_attr!( | |
| 1152 | rustc_conversion_suggestion, Normal, template!(Word), | |
| 1153 | WarnFollowing, EncodeCrossCrate::Yes, | |
| 1154 | ), | |
| 628 | rustc_attr!(rustc_conversion_suggestion), | |
| 1155 | 629 | // Prevents field reads in the marked trait or method to be considered |
| 1156 | 630 | // during dead code analysis. |
| 1157 | rustc_attr!( | |
| 1158 | rustc_trivial_field_reads, Normal, template!(Word), | |
| 1159 | WarnFollowing, EncodeCrossCrate::Yes, | |
| 1160 | ), | |
| 631 | rustc_attr!(rustc_trivial_field_reads), | |
| 1161 | 632 | // Used by the `rustc::potential_query_instability` lint to warn methods which |
| 1162 | 633 | // might not be stable during incremental compilation. |
| 1163 | rustc_attr!( | |
| 1164 | rustc_lint_query_instability, Normal, template!(Word), | |
| 1165 | WarnFollowing, EncodeCrossCrate::Yes, | |
| 1166 | ), | |
| 634 | rustc_attr!(rustc_lint_query_instability), | |
| 1167 | 635 | // Used by the `rustc::untracked_query_information` lint to warn methods which |
| 1168 | 636 | // might not be stable during incremental compilation. |
| 1169 | rustc_attr!( | |
| 1170 | rustc_lint_untracked_query_information, Normal, template!(Word), | |
| 1171 | WarnFollowing, EncodeCrossCrate::Yes, | |
| 1172 | ), | |
| 637 | rustc_attr!(rustc_lint_untracked_query_information), | |
| 1173 | 638 | // Used by the `rustc::bad_opt_access` lint to identify `DebuggingOptions` and `CodegenOptions` |
| 1174 | 639 | // types (as well as any others in future). |
| 1175 | rustc_attr!( | |
| 1176 | rustc_lint_opt_ty, Normal, template!(Word), | |
| 1177 | WarnFollowing, EncodeCrossCrate::Yes, | |
| 1178 | ), | |
| 640 | rustc_attr!(rustc_lint_opt_ty), | |
| 1179 | 641 | // Used by the `rustc::bad_opt_access` lint on fields |
| 1180 | 642 | // types (as well as any others in future). |
| 1181 | rustc_attr!( | |
| 1182 | rustc_lint_opt_deny_field_access, Normal, template!(List: &["message"]), | |
| 1183 | WarnFollowing, EncodeCrossCrate::Yes, | |
| 1184 | ), | |
| 643 | rustc_attr!(rustc_lint_opt_deny_field_access), | |
| 1185 | 644 | |
| 1186 | 645 | // ========================================================================== |
| 1187 | 646 | // Internal attributes, Const related: |
| 1188 | 647 | // ========================================================================== |
| 1189 | 648 | |
| 1190 | rustc_attr!( | |
| 1191 | rustc_promotable, Normal, template!(Word), WarnFollowing, | |
| 1192 | EncodeCrossCrate::No, ), | |
| 1193 | rustc_attr!( | |
| 1194 | rustc_legacy_const_generics, Normal, template!(List: &["N"]), ErrorFollowing, | |
| 1195 | EncodeCrossCrate::Yes, | |
| 1196 | ), | |
| 649 | rustc_attr!(rustc_promotable), | |
| 650 | rustc_attr!(rustc_legacy_const_generics), | |
| 1197 | 651 | // Do not const-check this function's body. It will always get replaced during CTFE via `hook_special_const_fn`. |
| 1198 | rustc_attr!( | |
| 1199 | rustc_do_not_const_check, Normal, template!(Word), WarnFollowing, | |
| 1200 | EncodeCrossCrate::Yes, "`#[rustc_do_not_const_check]` skips const-check for this function's body", | |
| 1201 | ), | |
| 1202 | rustc_attr!( | |
| 1203 | rustc_const_stable_indirect, Normal, | |
| 1204 | template!(Word), | |
| 1205 | WarnFollowing, | |
| 1206 | EncodeCrossCrate::No, | |
| 1207 | "this is an internal implementation detail", | |
| 1208 | ), | |
| 1209 | rustc_attr!( | |
| 1210 | rustc_intrinsic_const_stable_indirect, Normal, | |
| 1211 | template!(Word), WarnFollowing, EncodeCrossCrate::No, "this is an internal implementation detail", | |
| 1212 | ), | |
| 1213 | rustc_attr!( | |
| 1214 | rustc_allow_const_fn_unstable, Normal, | |
| 1215 | template!(Word, List: &["feat1, feat2, ..."]), DuplicatesOk, EncodeCrossCrate::No, | |
| 1216 | "rustc_allow_const_fn_unstable side-steps feature gating and stability checks" | |
| 652 | rustc_attr!(rustc_do_not_const_check, "`#[rustc_do_not_const_check]` skips const-check for this function's body"), | |
| 653 | rustc_attr!(rustc_const_stable_indirect, | |
| 654 | "this is an internal implementation detail"), | |
| 655 | rustc_attr!(rustc_intrinsic_const_stable_indirect, | |
| 656 | "this is an internal implementation detail"), | |
| 657 | rustc_attr!(rustc_allow_const_fn_unstable, | |
| 658 | "rustc_allow_const_fn_unstable side-steps feature gating and stability checks" | |
| 1217 | 659 | ), |
| 1218 | 660 | |
| 1219 | 661 | // ========================================================================== |
| 1220 | 662 | // Internal attributes, Layout related: |
| 1221 | 663 | // ========================================================================== |
| 1222 | 664 | |
| 1223 | rustc_attr!( | |
| 1224 | rustc_layout_scalar_valid_range_start, Normal, template!(List: &["value"]), ErrorFollowing, | |
| 1225 | EncodeCrossCrate::Yes, | |
| 1226 | "the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable \ | |
| 1227 | niche optimizations in the standard library", | |
| 1228 | ), | |
| 1229 | rustc_attr!( | |
| 1230 | rustc_layout_scalar_valid_range_end, Normal, template!(List: &["value"]), ErrorFollowing, | |
| 1231 | EncodeCrossCrate::Yes, | |
| 1232 | "the `#[rustc_layout_scalar_valid_range_end]` attribute is just used to enable \ | |
| 1233 | niche optimizations in the standard library", | |
| 1234 | ), | |
| 1235 | rustc_attr!( | |
| 1236 | rustc_simd_monomorphize_lane_limit, Normal, template!(NameValueStr: "N"), ErrorFollowing, | |
| 1237 | EncodeCrossCrate::Yes, | |
| 1238 | "the `#[rustc_simd_monomorphize_lane_limit]` attribute is just used by std::simd \ | |
| 1239 | for better error messages", | |
| 1240 | ), | |
| 1241 | rustc_attr!( | |
| 1242 | rustc_nonnull_optimization_guaranteed, Normal, template!(Word), WarnFollowing, | |
| 1243 | EncodeCrossCrate::Yes, | |
| 665 | rustc_attr!(rustc_layout_scalar_valid_range_start, "the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable \ | |
| 666 | niche optimizations in the standard library"), | |
| 667 | rustc_attr!(rustc_layout_scalar_valid_range_end, "the `#[rustc_layout_scalar_valid_range_end]` attribute is just used to enable \ | |
| 668 | niche optimizations in the standard library"), | |
| 669 | rustc_attr!(rustc_simd_monomorphize_lane_limit, "the `#[rustc_simd_monomorphize_lane_limit]` attribute is just used by std::simd \ | |
| 670 | for better error messages"), | |
| 671 | rustc_attr!(rustc_nonnull_optimization_guaranteed, | |
| 1244 | 672 | "the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document \ |
| 1245 | 673 | guaranteed niche optimizations in the standard library", |
| 1246 | 674 | "the compiler does not even check whether the type indeed is being non-null-optimized; \ |
| 1247 | it is your responsibility to ensure that the attribute is only used on types that are optimized", | |
| 1248 | ), | |
| 675 | it is your responsibility to ensure that the attribute is only used on types that are optimized"), | |
| 1249 | 676 | |
| 1250 | 677 | // ========================================================================== |
| 1251 | 678 | // Internal attributes, Misc: |
| 1252 | 679 | // ========================================================================== |
| 1253 | 680 | gated!( |
| 1254 | lang, Normal, template!(NameValueStr: "name"), DuplicatesOk, EncodeCrossCrate::No, lang_items, | |
| 1255 | "lang items are subject to change", | |
| 1256 | ), | |
| 1257 | rustc_attr!( | |
| 1258 | rustc_as_ptr, Normal, template!(Word), ErrorFollowing, | |
| 1259 | EncodeCrossCrate::Yes, | |
| 1260 | "`#[rustc_as_ptr]` is used to mark functions returning pointers to their inner allocations" | |
| 1261 | ), | |
| 1262 | rustc_attr!( | |
| 1263 | rustc_should_not_be_called_on_const_items, Normal, template!(Word), ErrorFollowing, | |
| 1264 | EncodeCrossCrate::Yes, | |
| 1265 | "`#[rustc_should_not_be_called_on_const_items]` is used to mark methods that don't make sense to be called on interior mutable consts" | |
| 1266 | ), | |
| 1267 | rustc_attr!( | |
| 1268 | rustc_pass_by_value, Normal, template!(Word), ErrorFollowing, | |
| 1269 | EncodeCrossCrate::Yes, | |
| 1270 | "`#[rustc_pass_by_value]` is used to mark types that must be passed by value instead of reference" | |
| 1271 | ), | |
| 1272 | rustc_attr!( | |
| 1273 | rustc_never_returns_null_ptr, Normal, template!(Word), ErrorFollowing, | |
| 1274 | EncodeCrossCrate::Yes, | |
| 1275 | "`#[rustc_never_returns_null_ptr]` is used to mark functions returning non-null pointers" | |
| 1276 | ), | |
| 1277 | rustc_attr!( | |
| 1278 | rustc_no_implicit_autorefs, AttributeType::Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::Yes, | |
| 1279 | "`#[rustc_no_implicit_autorefs]` is used to mark functions for which an autoref to the dereference of a raw pointer should not be used as an argument" | |
| 1280 | ), | |
| 1281 | rustc_attr!( | |
| 1282 | rustc_coherence_is_core, AttributeType::CrateLevel, template!(Word), ErrorFollowing, EncodeCrossCrate::No, | |
| 1283 | "`#![rustc_coherence_is_core]` allows inherent methods on builtin types, only intended to be used in `core`" | |
| 1284 | ), | |
| 1285 | rustc_attr!( | |
| 1286 | rustc_coinductive, AttributeType::Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, | |
| 1287 | "`#[rustc_coinductive]` changes a trait to be coinductive, allowing cycles in the trait solver" | |
| 1288 | ), | |
| 1289 | rustc_attr!( | |
| 1290 | rustc_allow_incoherent_impl, AttributeType::Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::No, | |
| 1291 | "`#[rustc_allow_incoherent_impl]` has to be added to all impl items of an incoherent inherent impl" | |
| 1292 | ), | |
| 1293 | rustc_attr!( | |
| 1294 | rustc_preserve_ub_checks, AttributeType::CrateLevel, template!(Word), ErrorFollowing, EncodeCrossCrate::No, | |
| 1295 | "`#![rustc_preserve_ub_checks]` prevents the designated crate from evaluating whether UB checks are enabled when optimizing MIR", | |
| 1296 | ), | |
| 1297 | rustc_attr!( | |
| 1298 | rustc_deny_explicit_impl, | |
| 1299 | AttributeType::Normal, | |
| 1300 | template!(Word), | |
| 1301 | ErrorFollowing, | |
| 1302 | EncodeCrossCrate::No, | |
| 681 | lang,lang_items, | |
| 682 | "lang items are subject to change" | |
| 683 | ), | |
| 684 | rustc_attr!(rustc_as_ptr, "`#[rustc_as_ptr]` is used to mark functions returning pointers to their inner allocations"), | |
| 685 | rustc_attr!(rustc_should_not_be_called_on_const_items, "`#[rustc_should_not_be_called_on_const_items]` is used to mark methods that don't make sense to be called on interior mutable consts"), | |
| 686 | rustc_attr!(rustc_pass_by_value, "`#[rustc_pass_by_value]` is used to mark types that must be passed by value instead of reference"), | |
| 687 | rustc_attr!(rustc_never_returns_null_ptr, "`#[rustc_never_returns_null_ptr]` is used to mark functions returning non-null pointers"), | |
| 688 | rustc_attr!(rustc_no_implicit_autorefs, "`#[rustc_no_implicit_autorefs]` is used to mark functions for which an autoref to the dereference of a raw pointer should not be used as an argument"), | |
| 689 | rustc_attr!(rustc_coherence_is_core, "`#![rustc_coherence_is_core]` allows inherent methods on builtin types, only intended to be used in `core`"), | |
| 690 | rustc_attr!(rustc_coinductive, "`#[rustc_coinductive]` changes a trait to be coinductive, allowing cycles in the trait solver"), | |
| 691 | rustc_attr!(rustc_allow_incoherent_impl, "`#[rustc_allow_incoherent_impl]` has to be added to all impl items of an incoherent inherent impl"), | |
| 692 | rustc_attr!(rustc_preserve_ub_checks, "`#![rustc_preserve_ub_checks]` prevents the designated crate from evaluating whether UB checks are enabled when optimizing MIR"), | |
| 693 | rustc_attr!(rustc_deny_explicit_impl, | |
| 1303 | 694 | "`#[rustc_deny_explicit_impl]` enforces that a trait can have no user-provided impls" |
| 1304 | 695 | ), |
| 1305 | rustc_attr!( | |
| 1306 | rustc_dyn_incompatible_trait, | |
| 1307 | AttributeType::Normal, | |
| 1308 | template!(Word), | |
| 1309 | ErrorFollowing, | |
| 1310 | EncodeCrossCrate::No, | |
| 696 | rustc_attr!(rustc_dyn_incompatible_trait, | |
| 1311 | 697 | "`#[rustc_dyn_incompatible_trait]` marks a trait as dyn-incompatible, \ |
| 1312 | 698 | even if it otherwise satisfies the requirements to be dyn-compatible." |
| 1313 | 699 | ), |
| 1314 | rustc_attr!( | |
| 1315 | rustc_has_incoherent_inherent_impls, AttributeType::Normal, template!(Word), | |
| 1316 | ErrorFollowing, EncodeCrossCrate::Yes, | |
| 1317 | "`#[rustc_has_incoherent_inherent_impls]` allows the addition of incoherent inherent impls for \ | |
| 700 | rustc_attr!(rustc_has_incoherent_inherent_impls, "`#[rustc_has_incoherent_inherent_impls]` allows the addition of incoherent inherent impls for \ | |
| 1318 | 701 | the given type by annotating all impl items with `#[rustc_allow_incoherent_impl]`" |
| 1319 | 702 | ), |
| 1320 | rustc_attr!( | |
| 1321 | rustc_non_const_trait_method, AttributeType::Normal, template!(Word), | |
| 1322 | ErrorFollowing, EncodeCrossCrate::No, | |
| 1323 | "`#[rustc_non_const_trait_method]` should only used by the standard library to mark trait methods \ | |
| 703 | rustc_attr!(rustc_non_const_trait_method, "`#[rustc_non_const_trait_method]` should only used by the standard library to mark trait methods \ | |
| 1324 | 704 | as non-const to allow large traits an easier transition to const" |
| 1325 | 705 | ), |
| 1326 | 706 | |
| 1327 | 707 | BuiltinAttribute { |
| 1328 | 708 | name: sym::rustc_diagnostic_item, |
| 1329 | // FIXME: This can be `true` once we always use `tcx.is_diagnostic_item`. | |
| 1330 | encode_cross_crate: EncodeCrossCrate::Yes, | |
| 1331 | type_: Normal, | |
| 1332 | 709 | safety: AttributeSafety::Normal, |
| 1333 | template: template!(NameValueStr: "name"), | |
| 1334 | duplicates: ErrorFollowing, | |
| 1335 | 710 | gate: Gated { |
| 1336 | 711 | feature: sym::rustc_attrs, |
| 1337 | 712 | message: "use of an internal attribute", |
| ... | ... | @@ -1342,236 +717,87 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ |
| 1342 | 717 | }, |
| 1343 | 718 | gated!( |
| 1344 | 719 | // Used in resolve: |
| 1345 | prelude_import, Normal, template!(Word), WarnFollowing, | |
| 1346 | EncodeCrossCrate::No, "`#[prelude_import]` is for use by rustc only", | |
| 720 | prelude_import, "`#[prelude_import]` is for use by rustc only", | |
| 1347 | 721 | ), |
| 1348 | 722 | gated!( |
| 1349 | rustc_paren_sugar, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, | |
| 1350 | unboxed_closures, "unboxed_closures are still evolving", | |
| 723 | rustc_paren_sugar,unboxed_closures, "unboxed_closures are still evolving", | |
| 1351 | 724 | ), |
| 1352 | rustc_attr!( | |
| 1353 | rustc_inherit_overflow_checks, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, | |
| 1354 | "the `#[rustc_inherit_overflow_checks]` attribute is just used to control \ | |
| 725 | rustc_attr!(rustc_inherit_overflow_checks,"the `#[rustc_inherit_overflow_checks]` attribute is just used to control \ | |
| 1355 | 726 | overflow checking behavior of several functions in the standard library that are inlined \ |
| 1356 | across crates", | |
| 727 | across crates" | |
| 1357 | 728 | ), |
| 1358 | rustc_attr!( | |
| 1359 | rustc_reservation_impl, Normal, | |
| 1360 | template!(NameValueStr: "reservation message"), ErrorFollowing, EncodeCrossCrate::Yes, | |
| 1361 | "the `#[rustc_reservation_impl]` attribute is internally used \ | |
| 729 | rustc_attr!(rustc_reservation_impl,"the `#[rustc_reservation_impl]` attribute is internally used \ | |
| 1362 | 730 | for reserving `impl<T> From<!> for T` as part of the effort to stabilize `!`" |
| 1363 | 731 | ), |
| 1364 | rustc_attr!( | |
| 1365 | rustc_test_marker, Normal, template!(NameValueStr: "name"), WarnFollowing, | |
| 1366 | EncodeCrossCrate::No, "the `#[rustc_test_marker]` attribute is used internally to track tests", | |
| 1367 | ), | |
| 1368 | rustc_attr!( | |
| 1369 | rustc_unsafe_specialization_marker, Normal, template!(Word), | |
| 1370 | WarnFollowing, EncodeCrossCrate::No, | |
| 732 | rustc_attr!(rustc_test_marker, "the `#[rustc_test_marker]` attribute is used internally to track tests"), | |
| 733 | rustc_attr!(rustc_unsafe_specialization_marker, | |
| 1371 | 734 | "the `#[rustc_unsafe_specialization_marker]` attribute is used to check specializations" |
| 1372 | 735 | ), |
| 1373 | rustc_attr!( | |
| 1374 | rustc_specialization_trait, Normal, template!(Word), | |
| 1375 | WarnFollowing, EncodeCrossCrate::No, | |
| 736 | rustc_attr!(rustc_specialization_trait, | |
| 1376 | 737 | "the `#[rustc_specialization_trait]` attribute is used to check specializations" |
| 1377 | 738 | ), |
| 1378 | rustc_attr!( | |
| 1379 | rustc_main, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, | |
| 1380 | "the `#[rustc_main]` attribute is used internally to specify test entry point function", | |
| 1381 | ), | |
| 1382 | rustc_attr!( | |
| 1383 | rustc_skip_during_method_dispatch, Normal, template!(List: &["array, boxed_slice"]), ErrorFollowing, | |
| 1384 | EncodeCrossCrate::No, | |
| 1385 | "the `#[rustc_skip_during_method_dispatch]` attribute is used to exclude a trait \ | |
| 739 | rustc_attr!(rustc_main,"the `#[rustc_main]` attribute is used internally to specify test entry point function"), | |
| 740 | rustc_attr!(rustc_skip_during_method_dispatch, "the `#[rustc_skip_during_method_dispatch]` attribute is used to exclude a trait \ | |
| 1386 | 741 | from method dispatch when the receiver is of the following type, for compatibility in \ |
| 1387 | 742 | editions < 2021 (array) or editions < 2024 (boxed_slice)" |
| 1388 | 743 | ), |
| 1389 | rustc_attr!( | |
| 1390 | rustc_must_implement_one_of, Normal, template!(List: &["function1, function2, ..."]), | |
| 1391 | ErrorFollowing, EncodeCrossCrate::No, | |
| 1392 | "the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete \ | |
| 744 | rustc_attr!(rustc_must_implement_one_of,"the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete \ | |
| 1393 | 745 | definition of a trait. Its syntax and semantics are highly experimental and will be \ |
| 1394 | 746 | subject to change before stabilization", |
| 1395 | 747 | ), |
| 1396 | rustc_attr!( | |
| 1397 | rustc_doc_primitive, Normal, template!(NameValueStr: "primitive name"), ErrorFollowing, | |
| 1398 | EncodeCrossCrate::Yes, "the `#[rustc_doc_primitive]` attribute is used by the standard library \ | |
| 748 | rustc_attr!(rustc_doc_primitive,"the `#[rustc_doc_primitive]` attribute is used by the standard library \ | |
| 1399 | 749 | to provide a way to generate documentation for primitive types", |
| 1400 | 750 | ), |
| 1401 | 751 | gated!( |
| 1402 | rustc_intrinsic, Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::Yes, intrinsics, | |
| 1403 | "the `#[rustc_intrinsic]` attribute is used to declare intrinsics as function items", | |
| 1404 | ), | |
| 1405 | rustc_attr!( | |
| 1406 | rustc_no_mir_inline, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes, | |
| 1407 | "`#[rustc_no_mir_inline]` prevents the MIR inliner from inlining a function while not affecting codegen" | |
| 1408 | ), | |
| 1409 | rustc_attr!( | |
| 1410 | rustc_force_inline, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing, EncodeCrossCrate::Yes, | |
| 1411 | "`#[rustc_force_inline]` forces a free function to be inlined" | |
| 1412 | ), | |
| 1413 | rustc_attr!( | |
| 1414 | rustc_scalable_vector, Normal, template!(List: &["count"]), WarnFollowing, EncodeCrossCrate::Yes, | |
| 1415 | "`#[rustc_scalable_vector]` defines a scalable vector type" | |
| 752 | rustc_intrinsic,intrinsics, | |
| 753 | "the `#[rustc_intrinsic]` attribute is used to declare intrinsics as function items"), | |
| 754 | rustc_attr!(rustc_no_mir_inline,"`#[rustc_no_mir_inline]` prevents the MIR inliner from inlining a function while not affecting codegen" | |
| 1416 | 755 | ), |
| 756 | rustc_attr!(rustc_force_inline,"`#[rustc_force_inline]` forces a free function to be inlined"), | |
| 757 | rustc_attr!(rustc_scalable_vector,"`#[rustc_scalable_vector]` defines a scalable vector type"), | |
| 1417 | 758 | |
| 1418 | 759 | // ========================================================================== |
| 1419 | 760 | // Internal attributes, Testing: |
| 1420 | 761 | // ========================================================================== |
| 1421 | 762 | |
| 1422 | rustc_attr!(TEST, rustc_effective_visibility, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes), | |
| 1423 | rustc_attr!( | |
| 1424 | TEST, rustc_dump_inferred_outlives, Normal, template!(Word), | |
| 1425 | WarnFollowing, EncodeCrossCrate::No | |
| 1426 | ), | |
| 1427 | rustc_attr!( | |
| 1428 | TEST, rustc_capture_analysis, Normal, template!(Word), | |
| 1429 | WarnFollowing, EncodeCrossCrate::No | |
| 1430 | ), | |
| 1431 | rustc_attr!( | |
| 1432 | TEST, rustc_insignificant_dtor, Normal, template!(Word), | |
| 1433 | WarnFollowing, EncodeCrossCrate::Yes | |
| 1434 | ), | |
| 1435 | rustc_attr!( | |
| 1436 | TEST, rustc_no_implicit_bounds, CrateLevel, template!(Word), | |
| 1437 | WarnFollowing, EncodeCrossCrate::No | |
| 1438 | ), | |
| 1439 | rustc_attr!( | |
| 1440 | TEST, rustc_strict_coherence, Normal, template!(Word), | |
| 1441 | WarnFollowing, EncodeCrossCrate::Yes | |
| 1442 | ), | |
| 1443 | rustc_attr!( | |
| 1444 | TEST, rustc_dump_variances, Normal, template!(Word), | |
| 1445 | WarnFollowing, EncodeCrossCrate::No | |
| 1446 | ), | |
| 1447 | rustc_attr!( | |
| 1448 | TEST, rustc_dump_variances_of_opaques, Normal, template!(Word), | |
| 1449 | WarnFollowing, EncodeCrossCrate::No | |
| 1450 | ), | |
| 1451 | rustc_attr!( | |
| 1452 | TEST, rustc_hidden_type_of_opaques, Normal, template!(Word), | |
| 1453 | WarnFollowing, EncodeCrossCrate::No | |
| 1454 | ), | |
| 1455 | rustc_attr!( | |
| 1456 | TEST, rustc_layout, Normal, template!(List: &["field1, field2, ..."]), | |
| 1457 | WarnFollowing, EncodeCrossCrate::Yes | |
| 1458 | ), | |
| 1459 | rustc_attr!( | |
| 1460 | TEST, rustc_abi, Normal, template!(List: &["field1, field2, ..."]), | |
| 1461 | WarnFollowing, EncodeCrossCrate::No | |
| 1462 | ), | |
| 1463 | rustc_attr!( | |
| 1464 | TEST, rustc_regions, Normal, template!(Word), | |
| 1465 | WarnFollowing, EncodeCrossCrate::No | |
| 1466 | ), | |
| 1467 | rustc_attr!( | |
| 1468 | TEST, rustc_delayed_bug_from_inside_query, Normal, | |
| 1469 | template!(Word), | |
| 1470 | WarnFollowing, EncodeCrossCrate::No | |
| 1471 | ), | |
| 1472 | rustc_attr!( | |
| 1473 | TEST, rustc_dump_user_args, Normal, template!(Word), | |
| 1474 | WarnFollowing, EncodeCrossCrate::No | |
| 1475 | ), | |
| 1476 | rustc_attr!( | |
| 1477 | TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing, | |
| 1478 | EncodeCrossCrate::Yes | |
| 1479 | ), | |
| 1480 | rustc_attr!( | |
| 1481 | TEST, rustc_if_this_changed, Normal, template!(Word, List: &["DepNode"]), DuplicatesOk, | |
| 1482 | EncodeCrossCrate::No | |
| 1483 | ), | |
| 1484 | rustc_attr!( | |
| 1485 | TEST, rustc_then_this_would_need, Normal, template!(List: &["DepNode"]), DuplicatesOk, | |
| 1486 | EncodeCrossCrate::No | |
| 1487 | ), | |
| 1488 | rustc_attr!( | |
| 1489 | TEST, rustc_clean, Normal, | |
| 1490 | template!(List: &[r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#]), | |
| 1491 | DuplicatesOk, EncodeCrossCrate::No | |
| 1492 | ), | |
| 1493 | rustc_attr!( | |
| 1494 | TEST, rustc_partition_reused, Normal, | |
| 1495 | template!(List: &[r#"cfg = "...", module = "...""#]), DuplicatesOk, EncodeCrossCrate::No | |
| 1496 | ), | |
| 1497 | rustc_attr!( | |
| 1498 | TEST, rustc_partition_codegened, Normal, | |
| 1499 | template!(List: &[r#"cfg = "...", module = "...""#]), DuplicatesOk, EncodeCrossCrate::No | |
| 1500 | ), | |
| 1501 | rustc_attr!( | |
| 1502 | TEST, rustc_expected_cgu_reuse, Normal, | |
| 1503 | template!(List: &[r#"cfg = "...", module = "...", kind = "...""#]), DuplicatesOk, | |
| 1504 | EncodeCrossCrate::No | |
| 1505 | ), | |
| 1506 | rustc_attr!( | |
| 1507 | TEST, rustc_symbol_name, Normal, template!(Word), | |
| 1508 | WarnFollowing, EncodeCrossCrate::No | |
| 1509 | ), | |
| 1510 | rustc_attr!( | |
| 1511 | TEST, rustc_def_path, Normal, template!(Word), | |
| 1512 | WarnFollowing, EncodeCrossCrate::No | |
| 1513 | ), | |
| 1514 | rustc_attr!( | |
| 1515 | TEST, rustc_mir, Normal, template!(List: &["arg1, arg2, ..."]), | |
| 1516 | DuplicatesOk, EncodeCrossCrate::Yes | |
| 1517 | ), | |
| 1518 | gated!( | |
| 1519 | custom_mir, Normal, template!(List: &[r#"dialect = "...", phase = "...""#]), | |
| 1520 | ErrorFollowing, EncodeCrossCrate::No, | |
| 1521 | "the `#[custom_mir]` attribute is just used for the Rust test suite", | |
| 1522 | ), | |
| 1523 | rustc_attr!( | |
| 1524 | TEST, rustc_dump_item_bounds, Normal, template!(Word), | |
| 1525 | WarnFollowing, EncodeCrossCrate::No | |
| 1526 | ), | |
| 1527 | rustc_attr!( | |
| 1528 | TEST, rustc_dump_predicates, Normal, template!(Word), | |
| 1529 | WarnFollowing, EncodeCrossCrate::No | |
| 1530 | ), | |
| 1531 | rustc_attr!( | |
| 1532 | TEST, rustc_dump_def_parents, Normal, template!(Word), | |
| 1533 | WarnFollowing, EncodeCrossCrate::No | |
| 1534 | ), | |
| 1535 | rustc_attr!( | |
| 1536 | TEST, rustc_dump_object_lifetime_defaults, Normal, template!(Word), | |
| 1537 | WarnFollowing, EncodeCrossCrate::No | |
| 1538 | ), | |
| 1539 | rustc_attr!( | |
| 1540 | TEST, rustc_dump_vtable, Normal, template!(Word), | |
| 1541 | WarnFollowing, EncodeCrossCrate::No | |
| 1542 | ), | |
| 1543 | rustc_attr!( | |
| 1544 | TEST, rustc_dummy, Normal, template!(Word /* doesn't matter*/), | |
| 1545 | DuplicatesOk, EncodeCrossCrate::No | |
| 1546 | ), | |
| 1547 | rustc_attr!( | |
| 1548 | TEST, pattern_complexity_limit, CrateLevel, template!(NameValueStr: "N"), | |
| 1549 | ErrorFollowing, EncodeCrossCrate::No, | |
| 1550 | ), | |
| 763 | rustc_attr!(TEST, rustc_effective_visibility), | |
| 764 | rustc_attr!(TEST, rustc_dump_inferred_outlives), | |
| 765 | rustc_attr!(TEST, rustc_capture_analysis), | |
| 766 | rustc_attr!(TEST, rustc_insignificant_dtor), | |
| 767 | rustc_attr!(TEST, rustc_no_implicit_bounds), | |
| 768 | rustc_attr!(TEST, rustc_strict_coherence), | |
| 769 | rustc_attr!(TEST, rustc_dump_variances), | |
| 770 | rustc_attr!(TEST, rustc_dump_variances_of_opaques), | |
| 771 | rustc_attr!(TEST, rustc_hidden_type_of_opaques), | |
| 772 | rustc_attr!(TEST, rustc_layout), | |
| 773 | rustc_attr!(TEST, rustc_abi), | |
| 774 | rustc_attr!(TEST, rustc_regions), | |
| 775 | rustc_attr!(TEST, rustc_delayed_bug_from_inside_query), | |
| 776 | rustc_attr!(TEST, rustc_dump_user_args), | |
| 777 | rustc_attr!(TEST, rustc_evaluate_where_clauses), | |
| 778 | rustc_attr!(TEST, rustc_if_this_changed), | |
| 779 | rustc_attr!(TEST, rustc_then_this_would_need), | |
| 780 | rustc_attr!(TEST, rustc_clean), | |
| 781 | rustc_attr!(TEST, rustc_partition_reused), | |
| 782 | rustc_attr!(TEST, rustc_partition_codegened), | |
| 783 | rustc_attr!(TEST, rustc_expected_cgu_reuse), | |
| 784 | rustc_attr!(TEST, rustc_symbol_name), | |
| 785 | rustc_attr!(TEST, rustc_def_path), | |
| 786 | rustc_attr!(TEST, rustc_mir), | |
| 787 | gated!(custom_mir,"the `#[custom_mir]` attribute is just used for the Rust test suite"), | |
| 788 | rustc_attr!(TEST, rustc_dump_item_bounds), | |
| 789 | rustc_attr!(TEST, rustc_dump_predicates), | |
| 790 | rustc_attr!(TEST, rustc_dump_def_parents), | |
| 791 | rustc_attr!(TEST, rustc_dump_object_lifetime_defaults), | |
| 792 | rustc_attr!(TEST, rustc_dump_vtable), | |
| 793 | rustc_attr!(TEST, rustc_dummy), | |
| 794 | rustc_attr!(TEST, pattern_complexity_limit), | |
| 1551 | 795 | ]; |
| 1552 | 796 | |
| 1553 | 797 | pub fn is_builtin_attr_name(name: Symbol) -> bool { |
| 1554 | 798 | BUILTIN_ATTRIBUTE_MAP.get(&name).is_some() |
| 1555 | 799 | } |
| 1556 | 800 | |
| 1557 | /// Whether this builtin attribute is encoded cross crate. | |
| 1558 | /// This means it can be used cross crate. | |
| 1559 | pub fn encode_cross_crate(name: Symbol) -> bool { | |
| 1560 | if let Some(attr) = BUILTIN_ATTRIBUTE_MAP.get(&name) { | |
| 1561 | attr.encode_cross_crate == EncodeCrossCrate::Yes | |
| 1562 | } else { | |
| 1563 | true | |
| 1564 | } | |
| 1565 | } | |
| 1566 | ||
| 1567 | pub fn is_valid_for_get_attr(name: Symbol) -> bool { | |
| 1568 | BUILTIN_ATTRIBUTE_MAP.get(&name).is_some_and(|attr| match attr.duplicates { | |
| 1569 | WarnFollowing | ErrorFollowing | ErrorPreceding | FutureWarnFollowing | |
| 1570 | | FutureWarnPreceding => true, | |
| 1571 | DuplicatesOk | WarnFollowingWordOnly => false, | |
| 1572 | }) | |
| 1573 | } | |
| 1574 | ||
| 1575 | 801 | pub static BUILTIN_ATTRIBUTE_MAP: LazyLock<FxHashMap<Symbol, &BuiltinAttribute>> = |
| 1576 | 802 | LazyLock::new(|| { |
| 1577 | 803 | let mut map = FxHashMap::default(); |
compiler/rustc_feature/src/lib.rs+3-4| ... | ... | @@ -129,10 +129,9 @@ pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option<NonZero<u |
| 129 | 129 | |
| 130 | 130 | pub use accepted::ACCEPTED_LANG_FEATURES; |
| 131 | 131 | pub use builtin_attrs::{ |
| 132 | AttrSuggestionStyle, AttributeDuplicates, AttributeGate, AttributeSafety, AttributeTemplate, | |
| 133 | AttributeType, BUILTIN_ATTRIBUTE_MAP, BUILTIN_ATTRIBUTES, BuiltinAttribute, GatedCfg, | |
| 134 | encode_cross_crate, find_gated_cfg, is_builtin_attr_name, is_stable_diagnostic_attribute, | |
| 135 | is_valid_for_get_attr, | |
| 132 | AttrSuggestionStyle, AttributeGate, AttributeSafety, AttributeTemplate, BUILTIN_ATTRIBUTE_MAP, | |
| 133 | BUILTIN_ATTRIBUTES, BuiltinAttribute, GatedCfg, find_gated_cfg, is_builtin_attr_name, | |
| 134 | is_stable_diagnostic_attribute, | |
| 136 | 135 | }; |
| 137 | 136 | pub use removed::REMOVED_LANG_FEATURES; |
| 138 | 137 | pub use unstable::{ |
compiler/rustc_lint/src/early/diagnostics/check_cfg.rs+5-3| ... | ... | @@ -438,10 +438,10 @@ pub(super) fn unexpected_cfg_value( |
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | /// Ordering of the output is not stable, use this only in diagnostic code. | |
| 442 | 441 | fn possible_well_known_names_for_cfg_value(sess: &Session, value: Symbol) -> Vec<Symbol> { |
| 443 | 442 | #[allow(rustc::potential_query_instability)] |
| 444 | sess.psess | |
| 443 | let mut names = sess | |
| 444 | .psess | |
| 445 | 445 | .check_config |
| 446 | 446 | .well_known_names |
| 447 | 447 | .iter() |
| ... | ... | @@ -454,5 +454,7 @@ fn possible_well_known_names_for_cfg_value(sess: &Session, value: Symbol) -> Vec |
| 454 | 454 | .unwrap_or_default() |
| 455 | 455 | }) |
| 456 | 456 | .copied() |
| 457 | .collect() | |
| 457 | .collect::<Vec<_>>(); | |
| 458 | names.sort_by(|a, b| a.as_str().cmp(b.as_str())); | |
| 459 | names | |
| 458 | 460 | } |
compiler/rustc_metadata/src/native_libs.rs+5-3| ... | ... | @@ -224,7 +224,7 @@ impl<'tcx> Collector<'tcx> { |
| 224 | 224 | let dll_imports = match attr.kind { |
| 225 | 225 | NativeLibKind::RawDylib { .. } => foreign_items |
| 226 | 226 | .iter() |
| 227 | .map(|&child_item| { | |
| 227 | .filter_map(|&child_item| { | |
| 228 | 228 | self.build_dll_import( |
| 229 | 229 | abi, |
| 230 | 230 | attr.import_name_type.map(|(import_name_type, _)| import_name_type), |
| ... | ... | @@ -388,7 +388,7 @@ impl<'tcx> Collector<'tcx> { |
| 388 | 388 | abi: ExternAbi, |
| 389 | 389 | import_name_type: Option<PeImportNameType>, |
| 390 | 390 | item: DefId, |
| 391 | ) -> DllImport { | |
| 391 | ) -> Option<DllImport> { | |
| 392 | 392 | let span = self.tcx.def_span(item); |
| 393 | 393 | |
| 394 | 394 | // This `extern` block should have been checked for general ABI support before, but let's |
| ... | ... | @@ -465,6 +465,8 @@ impl<'tcx> Collector<'tcx> { |
| 465 | 465 | } else { |
| 466 | 466 | DllImportSymbolType::Static |
| 467 | 467 | } |
| 468 | } else if def_kind == DefKind::ForeignTy { | |
| 469 | return None; | |
| 468 | 470 | } else { |
| 469 | 471 | bug!("Unexpected type for raw-dylib: {}", def_kind.descr(item)); |
| 470 | 472 | }; |
| ... | ... | @@ -482,6 +484,6 @@ impl<'tcx> Collector<'tcx> { |
| 482 | 484 | } |
| 483 | 485 | }; |
| 484 | 486 | |
| 485 | DllImport { name, import_name_type, calling_convention, span, symbol_type, size } | |
| 487 | Some(DllImport { name, import_name_type, calling_convention, span, symbol_type, size }) | |
| 486 | 488 | } |
| 487 | 489 | } |
compiler/rustc_metadata/src/rmeta/encoder.rs-4| ... | ... | @@ -864,10 +864,6 @@ fn analyze_attr(attr: &hir::Attribute, state: &mut AnalyzeAttrState<'_>) -> bool |
| 864 | 864 | && p.encode_cross_crate() == EncodeCrossCrate::No |
| 865 | 865 | { |
| 866 | 866 | // Attributes not marked encode-cross-crate don't need to be encoded for downstream crates. |
| 867 | } else if let Some(name) = attr.name() | |
| 868 | && !rustc_feature::encode_cross_crate(name) | |
| 869 | { | |
| 870 | // Attributes not marked encode-cross-crate don't need to be encoded for downstream crates. | |
| 871 | 867 | } else if let hir::Attribute::Parsed(AttributeKind::DocComment { .. }) = attr { |
| 872 | 868 | // We keep all doc comments reachable to rustdoc because they might be "imported" into |
| 873 | 869 | // downstream crates if they use `#[doc(inline)]` to copy an item's documentation into |
compiler/rustc_middle/src/query/plumbing.rs-24| ... | ... | @@ -464,30 +464,6 @@ macro_rules! define_callbacks { |
| 464 | 464 | )* |
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | ||
| 468 | pub fn def_kind(&self, tcx: TyCtxt<'tcx>) -> Option<DefKind> { | |
| 469 | // This is used to reduce code generation as it | |
| 470 | // can be reused for queries with the same key type. | |
| 471 | fn inner<'tcx>(key: &impl $crate::query::QueryKey, tcx: TyCtxt<'tcx>) | |
| 472 | -> Option<DefKind> | |
| 473 | { | |
| 474 | key | |
| 475 | .key_as_def_id() | |
| 476 | .and_then(|def_id| def_id.as_local()) | |
| 477 | .map(|def_id| tcx.def_kind(def_id)) | |
| 478 | } | |
| 479 | ||
| 480 | if let TaggedQueryKey::def_kind(..) = self { | |
| 481 | // Try to avoid infinite recursion. | |
| 482 | return None | |
| 483 | } | |
| 484 | ||
| 485 | match self { | |
| 486 | $( | |
| 487 | TaggedQueryKey::$name(key) => inner(key, tcx), | |
| 488 | )* | |
| 489 | } | |
| 490 | } | |
| 491 | 467 | } |
| 492 | 468 | |
| 493 | 469 | /// Holds a `QueryVTable` for each query. |
compiler/rustc_middle/src/ty/mod.rs+2-7| ... | ... | @@ -1725,13 +1725,8 @@ impl<'tcx> TyCtxt<'tcx> { |
| 1725 | 1725 | |
| 1726 | 1726 | #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to call rustc_hir::find_attr! instead."] |
| 1727 | 1727 | pub fn get_attr(self, did: impl Into<DefId>, attr: Symbol) -> Option<&'tcx hir::Attribute> { |
| 1728 | if cfg!(debug_assertions) && !rustc_feature::is_valid_for_get_attr(attr) { | |
| 1729 | let did: DefId = did.into(); | |
| 1730 | bug!("get_attr: unexpected called with DefId `{:?}`, attr `{:?}`", did, attr); | |
| 1731 | } else { | |
| 1732 | #[allow(deprecated)] | |
| 1733 | self.get_attrs(did, attr).next() | |
| 1734 | } | |
| 1728 | #[allow(deprecated)] | |
| 1729 | self.get_attrs(did, attr).next() | |
| 1735 | 1730 | } |
| 1736 | 1731 | |
| 1737 | 1732 | /// Determines whether an item is annotated with an attribute. |
compiler/rustc_passes/src/check_attr.rs+1-123| ... | ... | @@ -6,17 +6,15 @@ |
| 6 | 6 | //! item. |
| 7 | 7 | |
| 8 | 8 | use std::cell::Cell; |
| 9 | use std::collections::hash_map::Entry; | |
| 10 | 9 | use std::slice; |
| 11 | 10 | |
| 12 | 11 | use rustc_abi::ExternAbi; |
| 13 | 12 | use rustc_ast::ast; |
| 14 | 13 | use rustc_attr_parsing::{AttributeParser, Late}; |
| 15 | use rustc_data_structures::fx::FxHashMap; | |
| 16 | 14 | use rustc_data_structures::thin_vec::ThinVec; |
| 17 | 15 | use rustc_data_structures::unord::UnordMap; |
| 18 | 16 | use rustc_errors::{DiagCtxtHandle, IntoDiagArg, MultiSpan, msg}; |
| 19 | use rustc_feature::{AttributeDuplicates, AttributeType, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute}; | |
| 17 | use rustc_feature::BUILTIN_ATTRIBUTE_MAP; | |
| 20 | 18 | use rustc_hir::attrs::diagnostic::Directive; |
| 21 | 19 | use rustc_hir::attrs::{ |
| 22 | 20 | AttributeKind, CrateType, DocAttribute, DocInline, EiiDecl, EiiImpl, EiiImplResolution, |
| ... | ... | @@ -137,7 +135,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 137 | 135 | target: Target, |
| 138 | 136 | item: Option<ItemLike<'_>>, |
| 139 | 137 | ) { |
| 140 | let mut seen = FxHashMap::default(); | |
| 141 | 138 | let attrs = self.tcx.hir_attrs(hir_id); |
| 142 | 139 | for attr in attrs { |
| 143 | 140 | match attr { |
| ... | ... | @@ -404,64 +401,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 404 | 401 | } |
| 405 | 402 | } |
| 406 | 403 | |
| 407 | if hir_id != CRATE_HIR_ID { | |
| 408 | match attr { | |
| 409 | Attribute::Parsed(_) => { /* Already validated. */ } | |
| 410 | Attribute::Unparsed(attr) => { | |
| 411 | // FIXME(jdonszelmann): remove once all crate-level attrs are parsed and caught by | |
| 412 | // the above | |
| 413 | if let Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) = | |
| 414 | attr.path | |
| 415 | .segments | |
| 416 | .first() | |
| 417 | .and_then(|name| BUILTIN_ATTRIBUTE_MAP.get(&name)) | |
| 418 | { | |
| 419 | match attr.style { | |
| 420 | ast::AttrStyle::Outer => { | |
| 421 | let attr_span = attr.span; | |
| 422 | let bang_position = self | |
| 423 | .tcx | |
| 424 | .sess | |
| 425 | .source_map() | |
| 426 | .span_until_char(attr_span, '[') | |
| 427 | .shrink_to_hi(); | |
| 428 | ||
| 429 | self.tcx.emit_node_span_lint( | |
| 430 | UNUSED_ATTRIBUTES, | |
| 431 | hir_id, | |
| 432 | attr.span, | |
| 433 | errors::OuterCrateLevelAttr { | |
| 434 | suggestion: errors::OuterCrateLevelAttrSuggestion { | |
| 435 | bang_position, | |
| 436 | }, | |
| 437 | }, | |
| 438 | ) | |
| 439 | } | |
| 440 | ast::AttrStyle::Inner => self.tcx.emit_node_span_lint( | |
| 441 | UNUSED_ATTRIBUTES, | |
| 442 | hir_id, | |
| 443 | attr.span, | |
| 444 | errors::InnerCrateLevelAttr, | |
| 445 | ), | |
| 446 | } | |
| 447 | } | |
| 448 | } | |
| 449 | } | |
| 450 | } | |
| 451 | ||
| 452 | if let Attribute::Unparsed(unparsed_attr) = attr | |
| 453 | && let Some(BuiltinAttribute { duplicates, .. }) = | |
| 454 | attr.name().and_then(|name| BUILTIN_ATTRIBUTE_MAP.get(&name)) | |
| 455 | { | |
| 456 | check_duplicates( | |
| 457 | self.tcx, | |
| 458 | unparsed_attr.span, | |
| 459 | attr, | |
| 460 | hir_id, | |
| 461 | *duplicates, | |
| 462 | &mut seen, | |
| 463 | ); | |
| 464 | } | |
| 465 | 404 | self.check_unused_attribute(hir_id, attr) |
| 466 | 405 | } |
| 467 | 406 | |
| ... | ... | @@ -1994,67 +1933,6 @@ pub(crate) fn provide(providers: &mut Providers) { |
| 1994 | 1933 | *providers = Providers { check_mod_attrs, ..*providers }; |
| 1995 | 1934 | } |
| 1996 | 1935 | |
| 1997 | // FIXME(jdonszelmann): remove, check during parsing | |
| 1998 | fn check_duplicates( | |
| 1999 | tcx: TyCtxt<'_>, | |
| 2000 | attr_span: Span, | |
| 2001 | attr: &Attribute, | |
| 2002 | hir_id: HirId, | |
| 2003 | duplicates: AttributeDuplicates, | |
| 2004 | seen: &mut FxHashMap<Symbol, Span>, | |
| 2005 | ) { | |
| 2006 | use AttributeDuplicates::*; | |
| 2007 | if matches!(duplicates, WarnFollowingWordOnly) && !attr.is_word() { | |
| 2008 | return; | |
| 2009 | } | |
| 2010 | let attr_name = attr.name().unwrap(); | |
| 2011 | match duplicates { | |
| 2012 | DuplicatesOk => {} | |
| 2013 | WarnFollowing | FutureWarnFollowing | WarnFollowingWordOnly | FutureWarnPreceding => { | |
| 2014 | match seen.entry(attr_name) { | |
| 2015 | Entry::Occupied(mut entry) => { | |
| 2016 | let (this, other) = if matches!(duplicates, FutureWarnPreceding) { | |
| 2017 | let to_remove = entry.insert(attr_span); | |
| 2018 | (to_remove, attr_span) | |
| 2019 | } else { | |
| 2020 | (attr_span, *entry.get()) | |
| 2021 | }; | |
| 2022 | tcx.emit_node_span_lint( | |
| 2023 | UNUSED_ATTRIBUTES, | |
| 2024 | hir_id, | |
| 2025 | this, | |
| 2026 | errors::UnusedDuplicate { | |
| 2027 | this, | |
| 2028 | other, | |
| 2029 | warning: matches!( | |
| 2030 | duplicates, | |
| 2031 | FutureWarnFollowing | FutureWarnPreceding | |
| 2032 | ), | |
| 2033 | }, | |
| 2034 | ); | |
| 2035 | } | |
| 2036 | Entry::Vacant(entry) => { | |
| 2037 | entry.insert(attr_span); | |
| 2038 | } | |
| 2039 | } | |
| 2040 | } | |
| 2041 | ErrorFollowing | ErrorPreceding => match seen.entry(attr_name) { | |
| 2042 | Entry::Occupied(mut entry) => { | |
| 2043 | let (this, other) = if matches!(duplicates, ErrorPreceding) { | |
| 2044 | let to_remove = entry.insert(attr_span); | |
| 2045 | (to_remove, attr_span) | |
| 2046 | } else { | |
| 2047 | (attr_span, *entry.get()) | |
| 2048 | }; | |
| 2049 | tcx.dcx().emit_err(errors::UnusedMultiple { this, other, name: attr_name }); | |
| 2050 | } | |
| 2051 | Entry::Vacant(entry) => { | |
| 2052 | entry.insert(attr_span); | |
| 2053 | } | |
| 2054 | }, | |
| 2055 | } | |
| 2056 | } | |
| 2057 | ||
| 2058 | 1936 | fn doc_fake_variadic_is_allowed_self_ty(self_ty: &hir::Ty<'_>) -> bool { |
| 2059 | 1937 | matches!(&self_ty.kind, hir::TyKind::Tup([_])) |
| 2060 | 1938 | || if let hir::TyKind::FnPtr(fn_ptr_ty) = &self_ty.kind { |
compiler/rustc_passes/src/errors.rs-24| ... | ... | @@ -326,30 +326,6 @@ pub(crate) struct InvalidMayDangle { |
| 326 | 326 | pub attr_span: Span, |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | #[derive(Diagnostic)] | |
| 330 | #[diag("unused attribute")] | |
| 331 | pub(crate) struct UnusedDuplicate { | |
| 332 | #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")] | |
| 333 | pub this: Span, | |
| 334 | #[note("attribute also specified here")] | |
| 335 | pub other: Span, | |
| 336 | #[warning( | |
| 337 | "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" | |
| 338 | )] | |
| 339 | pub warning: bool, | |
| 340 | } | |
| 341 | ||
| 342 | #[derive(Diagnostic)] | |
| 343 | #[diag("multiple `{$name}` attributes")] | |
| 344 | pub(crate) struct UnusedMultiple { | |
| 345 | #[primary_span] | |
| 346 | #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")] | |
| 347 | pub this: Span, | |
| 348 | #[note("attribute also specified here")] | |
| 349 | pub other: Span, | |
| 350 | pub name: Symbol, | |
| 351 | } | |
| 352 | ||
| 353 | 329 | #[derive(Diagnostic)] |
| 354 | 330 | #[diag("this `#[deprecated]` annotation has no effect")] |
| 355 | 331 | pub(crate) struct DeprecatedAnnotationHasNoEffect { |
compiler/rustc_passes/src/reachable.rs+15-7| ... | ... | @@ -214,18 +214,26 @@ impl<'tcx> ReachableContext<'tcx> { |
| 214 | 214 | self.visit_const_item_rhs(init); |
| 215 | 215 | } |
| 216 | 216 | hir::ItemKind::Const(_, _, _, init) => { |
| 217 | // Only things actually ending up in the final constant value are reachable | |
| 218 | // for codegen. Everything else is only needed during const-eval, so even if | |
| 219 | // const-eval happens in a downstream crate, all they need is | |
| 220 | // `mir_for_ctfe`. | |
| 217 | if self.tcx.generics_of(item.owner_id).own_requires_monomorphization() { | |
| 218 | // In this case, we don't want to evaluate the const initializer. | |
| 219 | // In lieu of that, we have to consider everything mentioned in it | |
| 220 | // as reachable, since it *may* end up in the final value. | |
| 221 | self.visit_const_item_rhs(init); | |
| 222 | return; | |
| 223 | } | |
| 224 | ||
| 221 | 225 | match self.tcx.const_eval_poly_to_alloc(item.owner_id.def_id.into()) { |
| 222 | 226 | Ok(alloc) => { |
| 227 | // Only things actually ending up in the final constant value are | |
| 228 | // reachable for codegen. Everything else is only needed during | |
| 229 | // const-eval, so even if const-eval happens in a downstream crate, | |
| 230 | // all they need is `mir_for_ctfe`. | |
| 223 | 231 | let alloc = self.tcx.global_alloc(alloc.alloc_id).unwrap_memory(); |
| 224 | 232 | self.propagate_from_alloc(alloc); |
| 225 | 233 | } |
| 226 | // We can't figure out which value the constant will evaluate to. In | |
| 227 | // lieu of that, we have to consider everything mentioned in the const | |
| 228 | // initializer reachable, since it *may* end up in the final value. | |
| 234 | // Trivially unsatisfiable bounds on the item prevented us from | |
| 235 | // normalizing the initializer. Similar to the other case, we have to | |
| 236 | // everything mentioned in it as reachable. | |
| 229 | 237 | Err(ErrorHandled::TooGeneric(_)) => self.visit_const_item_rhs(init), |
| 230 | 238 | // If there was an error evaluating the const, nothing can be reachable |
| 231 | 239 | // via it, and anyway compilation will fail. |
compiler/rustc_query_impl/src/job.rs+91-79| ... | ... | @@ -229,6 +229,80 @@ fn connected_to_root<'tcx>( |
| 229 | 229 | false |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | /// Processes a found query cycle into a `Cycle` | |
| 233 | fn process_cycle<'tcx>(job_map: &QueryJobMap<'tcx>, stack: Vec<(Span, QueryJobId)>) -> Cycle<'tcx> { | |
| 234 | // The stack is a vector of pairs of spans and queries; reverse it so that | |
| 235 | // the earlier entries require later entries | |
| 236 | let (mut spans, queries): (Vec<_>, Vec<_>) = stack.into_iter().rev().unzip(); | |
| 237 | ||
| 238 | // Shift the spans so that queries are matched with the span for their waitee | |
| 239 | spans.rotate_right(1); | |
| 240 | ||
| 241 | // Zip them back together | |
| 242 | let mut stack: Vec<_> = iter::zip(spans, queries).collect(); | |
| 243 | ||
| 244 | struct EntryPoint { | |
| 245 | query_in_cycle: QueryJobId, | |
| 246 | query_waiting_on_cycle: Option<(Span, QueryJobId)>, | |
| 247 | } | |
| 248 | ||
| 249 | // Find the queries in the cycle which are | |
| 250 | // connected to queries outside the cycle | |
| 251 | let entry_points = stack | |
| 252 | .iter() | |
| 253 | .filter_map(|&(_, query_in_cycle)| { | |
| 254 | let mut entrypoint = false; | |
| 255 | let mut query_waiting_on_cycle = None; | |
| 256 | ||
| 257 | // Find a direct waiter who leads to the root | |
| 258 | for abstracted_waiter in abstracted_waiters_of(job_map, query_in_cycle) { | |
| 259 | let Some(parent) = abstracted_waiter.parent else { | |
| 260 | // The query in the cycle is directly connected to root. | |
| 261 | entrypoint = true; | |
| 262 | continue; | |
| 263 | }; | |
| 264 | ||
| 265 | // Mark all the other queries in the cycle as already visited, | |
| 266 | // so paths to the root through the cycle itself won't count. | |
| 267 | let mut visited = FxHashSet::from_iter(stack.iter().map(|q| q.1)); | |
| 268 | ||
| 269 | if connected_to_root(job_map, parent, &mut visited) { | |
| 270 | query_waiting_on_cycle = Some((abstracted_waiter.span, parent)); | |
| 271 | entrypoint = true; | |
| 272 | break; | |
| 273 | } | |
| 274 | } | |
| 275 | ||
| 276 | entrypoint.then_some(EntryPoint { query_in_cycle, query_waiting_on_cycle }) | |
| 277 | }) | |
| 278 | .collect::<Vec<EntryPoint>>(); | |
| 279 | ||
| 280 | // Pick an entry point, preferring ones with waiters | |
| 281 | let entry_point = entry_points | |
| 282 | .iter() | |
| 283 | .find(|entry_point| entry_point.query_waiting_on_cycle.is_some()) | |
| 284 | .unwrap_or(&entry_points[0]); | |
| 285 | ||
| 286 | // Shift the stack so that our entry point is first | |
| 287 | let entry_point_pos = stack.iter().position(|(_, query)| *query == entry_point.query_in_cycle); | |
| 288 | if let Some(pos) = entry_point_pos { | |
| 289 | stack.rotate_left(pos); | |
| 290 | } | |
| 291 | ||
| 292 | let usage = entry_point | |
| 293 | .query_waiting_on_cycle | |
| 294 | .map(|(span, job)| QueryStackFrame { span, tagged_key: job_map.tagged_key_of(job) }); | |
| 295 | ||
| 296 | // Create the cycle error | |
| 297 | Cycle { | |
| 298 | usage, | |
| 299 | frames: stack | |
| 300 | .iter() | |
| 301 | .map(|&(span, job)| QueryStackFrame { span, tagged_key: job_map.tagged_key_of(job) }) | |
| 302 | .collect(), | |
| 303 | } | |
| 304 | } | |
| 305 | ||
| 232 | 306 | /// Looks for a query cycle using the last query in `jobs`. |
| 233 | 307 | /// If a cycle is found, all queries in the cycle is removed from `jobs` and |
| 234 | 308 | /// the function return true. |
| ... | ... | @@ -245,16 +319,6 @@ fn remove_cycle<'tcx>( |
| 245 | 319 | if let ControlFlow::Break(resumable) = |
| 246 | 320 | find_cycle(job_map, jobs.pop().unwrap(), DUMMY_SP, &mut stack, &mut visited) |
| 247 | 321 | { |
| 248 | // The stack is a vector of pairs of spans and queries; reverse it so that | |
| 249 | // the earlier entries require later entries | |
| 250 | let (mut spans, queries): (Vec<_>, Vec<_>) = stack.into_iter().rev().unzip(); | |
| 251 | ||
| 252 | // Shift the spans so that queries are matched with the span for their waitee | |
| 253 | spans.rotate_right(1); | |
| 254 | ||
| 255 | // Zip them back together | |
| 256 | let mut stack: Vec<_> = iter::zip(spans, queries).collect(); | |
| 257 | ||
| 258 | 322 | // Remove the queries in our cycle from the list of jobs to look at |
| 259 | 323 | for r in &stack { |
| 260 | 324 | if let Some(pos) = jobs.iter().position(|j| j == &r.1) { |
| ... | ... | @@ -262,70 +326,8 @@ fn remove_cycle<'tcx>( |
| 262 | 326 | } |
| 263 | 327 | } |
| 264 | 328 | |
| 265 | struct EntryPoint { | |
| 266 | query_in_cycle: QueryJobId, | |
| 267 | query_waiting_on_cycle: Option<(Span, QueryJobId)>, | |
| 268 | } | |
| 269 | ||
| 270 | // Find the queries in the cycle which are | |
| 271 | // connected to queries outside the cycle | |
| 272 | let entry_points = stack | |
| 273 | .iter() | |
| 274 | .filter_map(|&(_, query_in_cycle)| { | |
| 275 | let mut entrypoint = false; | |
| 276 | let mut query_waiting_on_cycle = None; | |
| 277 | ||
| 278 | // Find a direct waiter who leads to the root | |
| 279 | for abstracted_waiter in abstracted_waiters_of(job_map, query_in_cycle) { | |
| 280 | let Some(parent) = abstracted_waiter.parent else { | |
| 281 | // The query in the cycle is directly connected to root. | |
| 282 | entrypoint = true; | |
| 283 | continue; | |
| 284 | }; | |
| 285 | ||
| 286 | // Mark all the other queries in the cycle as already visited, | |
| 287 | // so paths to the root through the cycle itself won't count. | |
| 288 | let mut visited = FxHashSet::from_iter(stack.iter().map(|q| q.1)); | |
| 289 | ||
| 290 | if connected_to_root(job_map, parent, &mut visited) { | |
| 291 | query_waiting_on_cycle = Some((abstracted_waiter.span, parent)); | |
| 292 | entrypoint = true; | |
| 293 | break; | |
| 294 | } | |
| 295 | } | |
| 296 | ||
| 297 | entrypoint.then_some(EntryPoint { query_in_cycle, query_waiting_on_cycle }) | |
| 298 | }) | |
| 299 | .collect::<Vec<EntryPoint>>(); | |
| 300 | ||
| 301 | // Pick an entry point, preferring ones with waiters | |
| 302 | let entry_point = entry_points | |
| 303 | .iter() | |
| 304 | .find(|entry_point| entry_point.query_waiting_on_cycle.is_some()) | |
| 305 | .unwrap_or(&entry_points[0]); | |
| 306 | ||
| 307 | // Shift the stack so that our entry point is first | |
| 308 | let entry_point_pos = | |
| 309 | stack.iter().position(|(_, query)| *query == entry_point.query_in_cycle); | |
| 310 | if let Some(pos) = entry_point_pos { | |
| 311 | stack.rotate_left(pos); | |
| 312 | } | |
| 313 | ||
| 314 | let usage = entry_point | |
| 315 | .query_waiting_on_cycle | |
| 316 | .map(|(span, job)| QueryStackFrame { span, tagged_key: job_map.tagged_key_of(job) }); | |
| 317 | ||
| 318 | 329 | // Create the cycle error |
| 319 | let error = Cycle { | |
| 320 | usage, | |
| 321 | frames: stack | |
| 322 | .iter() | |
| 323 | .map(|&(span, job)| QueryStackFrame { | |
| 324 | span, | |
| 325 | tagged_key: job_map.tagged_key_of(job), | |
| 326 | }) | |
| 327 | .collect(), | |
| 328 | }; | |
| 330 | let error = process_cycle(job_map, stack); | |
| 329 | 331 | |
| 330 | 332 | // We unwrap `resumable` here since there must always be one |
| 331 | 333 | // edge which is resumable / waited using a query latch |
| ... | ... | @@ -481,13 +483,23 @@ pub(crate) fn create_cycle_error<'tcx>( |
| 481 | 483 | usage: usage.tagged_key.description(tcx), |
| 482 | 484 | }); |
| 483 | 485 | |
| 484 | let alias = if frames | |
| 485 | .iter() | |
| 486 | .all(|frame| frame.tagged_key.def_kind(tcx) == Some(DefKind::TyAlias)) | |
| 487 | { | |
| 486 | let is_all_def_kind = |def_kind| { | |
| 487 | // Trivial type alias and trait alias cycles consists of `type_of` and | |
| 488 | // `explicit_implied_predicates_of` queries, so we just check just these here. | |
| 489 | frames.iter().all(|frame| match frame.tagged_key { | |
| 490 | TaggedQueryKey::type_of(def_id) | |
| 491 | | TaggedQueryKey::explicit_implied_predicates_of(def_id) | |
| 492 | if tcx.def_kind(def_id) == def_kind => | |
| 493 | { | |
| 494 | true | |
| 495 | } | |
| 496 | _ => false, | |
| 497 | }) | |
| 498 | }; | |
| 499 | ||
| 500 | let alias = if is_all_def_kind(DefKind::TyAlias) { | |
| 488 | 501 | Some(crate::error::Alias::Ty) |
| 489 | } else if frames.iter().all(|frame| frame.tagged_key.def_kind(tcx) == Some(DefKind::TraitAlias)) | |
| 490 | { | |
| 502 | } else if is_all_def_kind(DefKind::TraitAlias) { | |
| 491 | 503 | Some(crate::error::Alias::Trait) |
| 492 | 504 | } else { |
| 493 | 505 | None |
library/compiler-builtins/compiler-builtins/src/math/mod.rs+4| ... | ... | @@ -144,8 +144,12 @@ pub mod partial_availability { |
| 144 | 144 | libm_intrinsics! { |
| 145 | 145 | fn acos(x: f64) -> f64; |
| 146 | 146 | fn acosf(n: f32) -> f32; |
| 147 | fn acosh(x: f64) -> f64; | |
| 148 | fn acoshf(x: f32) -> f32; | |
| 147 | 149 | fn asin(x: f64) -> f64; |
| 148 | 150 | fn asinf(n: f32) -> f32; |
| 151 | fn asinh(x: f64) -> f64; | |
| 152 | fn asinhf(x: f32) -> f32; | |
| 149 | 153 | fn atan(x: f64) -> f64; |
| 150 | 154 | fn atan2(x: f64, y: f64) -> f64; |
| 151 | 155 | fn atan2f(a: f32, b: f32) -> f32; |
library/core/src/autodiff.md created+157| ... | ... | @@ -0,0 +1,157 @@ |
| 1 | This module provides support for automatic differentiation. For precise information on | |
| 2 | differences between the `autodiff_forward` and `autodiff_reverse` macros and how to | |
| 3 | use them, see their respective documentation. | |
| 4 | ||
| 5 | ## General usage | |
| 6 | ||
| 7 | Autodiff macros can be applied to almost all function definitions, see below for examples. | |
| 8 | They can be applied to functions accepting structs, arrays, slices, vectors, tuples, and more. | |
| 9 | ||
| 10 | It is possible to apply multiple autodiff macros to the same function. As an example, this can | |
| 11 | be helpful to compute the partial derivatives with respect to `x` and `y` independently: | |
| 12 | ```rust,ignore (optional component) | |
| 13 | #[autodiff_forward(dsquare1, Dual, Const, Dual)] | |
| 14 | #[autodiff_forward(dsquare2, Const, Dual, Dual)] | |
| 15 | #[autodiff_forward(dsquare3, Active, Active, Active)] | |
| 16 | fn square(x: f64, y: f64) -> f64 { | |
| 17 | x * x + 2.0 * y | |
| 18 | } | |
| 19 | ``` | |
| 20 | ||
| 21 | We also support autodiff on functions with generic parameters: | |
| 22 | ```rust,ignore (optional component) | |
| 23 | #[autodiff_forward(generic_derivative, Duplicated, Active)] | |
| 24 | fn generic_f<T: std::ops::Mul<Output = T> + Copy>(x: &T) -> T { | |
| 25 | x * x | |
| 26 | } | |
| 27 | ``` | |
| 28 | ||
| 29 | or applying autodiff to nested functions: | |
| 30 | ```rust,ignore (optional component) | |
| 31 | fn outer(x: f64) -> f64 { | |
| 32 | #[autodiff_forward(inner_derivative, Dual, Const)] | |
| 33 | fn inner(y: f64) -> f64 { | |
| 34 | y * y | |
| 35 | } | |
| 36 | inner_derivative(x, 1.0) | |
| 37 | } | |
| 38 | ||
| 39 | fn main() { | |
| 40 | assert_eq!(outer(3.14), 6.28); | |
| 41 | } | |
| 42 | ``` | |
| 43 | The generated function will be available in the same scope as the function differentiated, and | |
| 44 | have the same private/pub usability. | |
| 45 | ||
| 46 | ## Traits and impls | |
| 47 | Autodiff macros can be used in multiple ways in combination with traits: | |
| 48 | ```rust,ignore (optional component) | |
| 49 | struct Foo { | |
| 50 | a: f64, | |
| 51 | } | |
| 52 | ||
| 53 | trait MyTrait { | |
| 54 | #[autodiff_reverse(df, Const, Active, Active)] | |
| 55 | fn f(&self, x: f64) -> f64; | |
| 56 | } | |
| 57 | ||
| 58 | impl MyTrait for Foo { | |
| 59 | fn f(&self, x: f64) -> f64 { | |
| 60 | x.sin() | |
| 61 | } | |
| 62 | } | |
| 63 | ||
| 64 | fn main() { | |
| 65 | let foo = Foo { a: 3.0f64 }; | |
| 66 | assert_eq!(foo.f(2.0), 2.0_f64.sin()); | |
| 67 | assert_eq!(foo.df(2.0, 1.0).1, 2.0_f64.cos()); | |
| 68 | } | |
| 69 | ``` | |
| 70 | In this case `df` will be the default implementation provided by the library who provided the | |
| 71 | trait. A user implementing `MyTrait` could then decide to use the default implementation of | |
| 72 | `df`, or overwrite it with a custom implementation as a form of "custom derivatives". | |
| 73 | ||
| 74 | On the other hand, a function generated by either autodiff macro can also be used to implement a | |
| 75 | trait: | |
| 76 | ```rust,ignore (optional component) | |
| 77 | struct Foo { | |
| 78 | a: f64, | |
| 79 | } | |
| 80 | ||
| 81 | trait MyTrait { | |
| 82 | fn f(&self, x: f64) -> f64; | |
| 83 | fn df(&self, x: f64, seed: f64) -> (f64, f64); | |
| 84 | } | |
| 85 | ||
| 86 | impl MyTrait for Foo { | |
| 87 | #[autodiff_reverse(df, Const, Active, Active)] | |
| 88 | fn f(&self, x: f64) -> f64 { | |
| 89 | self.a * 0.25 * (x * x - 1.0 - 2.0 * x.ln()) | |
| 90 | } | |
| 91 | } | |
| 92 | ``` | |
| 93 | ||
| 94 | Simple `impl` blocks without traits are also supported. Differentiating with respect to the | |
| 95 | implemented struct will then require the use of a "shadow struct" to hold the derivatives of the | |
| 96 | struct fields: | |
| 97 | ||
| 98 | ```rust,ignore (optional component) | |
| 99 | struct OptProblem { | |
| 100 | a: f64, | |
| 101 | b: f64, | |
| 102 | } | |
| 103 | ||
| 104 | impl OptProblem { | |
| 105 | #[autodiff_reverse(d_objective, Duplicated, Duplicated, Duplicated)] | |
| 106 | fn objective(&self, x: &[f64], out: &mut f64) { | |
| 107 | *out = self.a + x[0].sqrt() * self.b | |
| 108 | } | |
| 109 | } | |
| 110 | fn main() { | |
| 111 | let p = OptProblem { a: 1., b: 2. }; | |
| 112 | let mut p_shadow = OptProblem { a: 0., b: 0. }; | |
| 113 | let mut dx = [0.0]; | |
| 114 | let mut out = 0.0; | |
| 115 | let mut dout = 1.0; | |
| 116 | ||
| 117 | p.d_objective(&mut p_shadow, &x, &mut dx, &mut out, &mut dout); | |
| 118 | } | |
| 119 | ``` | |
| 120 | ||
| 121 | ## Higher-order derivatives | |
| 122 | Finally, it is possible to generate higher-order derivatives (e.g. Hessian) by applying an | |
| 123 | autodiff macro to a function that is already generated by an autodiff macro, via a thin wrapper. | |
| 124 | The following example uses Forward mode over Reverse mode | |
| 125 | ||
| 126 | ```rust,ignore (optional component) | |
| 127 | #[autodiff_reverse(df, Duplicated, Duplicated)] | |
| 128 | fn f(x: &[f64;2], y: &mut f64) { | |
| 129 | *y = x[0] * x[0] + x[1] * x[0] | |
| 130 | } | |
| 131 | ||
| 132 | #[autodiff_forward(h, Dual, Dual, Dual, Dual)] | |
| 133 | fn wrapper(x: &[f64;2], dx: &mut [f64;2], y: &mut f64, dy: &mut f64) { | |
| 134 | df(x, dx, y, dy); | |
| 135 | } | |
| 136 | ||
| 137 | fn main() { | |
| 138 | let mut y = 0.0; | |
| 139 | let x = [2.0, 2.0]; | |
| 140 | ||
| 141 | let mut dy = 0.0; | |
| 142 | let mut dx = [1.0, 0.0]; | |
| 143 | ||
| 144 | let mut bx = [0.0, 0.0]; | |
| 145 | let mut by = 1.0; | |
| 146 | let mut dbx = [0.0, 0.0]; | |
| 147 | let mut dby = 0.0; | |
| 148 | h(&x, &mut dx, &mut bx, &mut dbx, &mut y, &mut dy, &mut by, &mut dby); | |
| 149 | assert_eq!(&dbx, [2.0, 1.0]); | |
| 150 | } | |
| 151 | ``` | |
| 152 | ||
| 153 | ## Current limitations: | |
| 154 | ||
| 155 | - Differentiating a function which accepts a `dyn Trait` is currently not supported. | |
| 156 | - Builds without `lto="fat"` are not yet supported. | |
| 157 | - Builds in debug mode are currently more likely to fail compilation. |
library/core/src/intrinsics/simd/scalable.rs-6| ... | ... | @@ -19,7 +19,6 @@ |
| 19 | 19 | /// * Not be `NaN` |
| 20 | 20 | /// * Not be infinite |
| 21 | 21 | /// * Be representable in the return type, after truncating off its fractional part |
| 22 | #[cfg(target_arch = "aarch64")] | |
| 23 | 22 | #[rustc_intrinsic] |
| 24 | 23 | #[rustc_nounwind] |
| 25 | 24 | pub unsafe fn sve_cast<T, U>(x: T) -> U; |
| ... | ... | @@ -31,7 +30,6 @@ pub unsafe fn sve_cast<T, U>(x: T) -> U; |
| 31 | 30 | /// type `SVec`. |
| 32 | 31 | /// |
| 33 | 32 | /// Corresponds to Clang's `__builtin_sve_svcreate2*` builtins. |
| 34 | #[cfg(target_arch = "aarch64")] | |
| 35 | 33 | #[rustc_nounwind] |
| 36 | 34 | #[rustc_intrinsic] |
| 37 | 35 | pub unsafe fn sve_tuple_create2<SVec, SVecTup>(x0: SVec, x1: SVec) -> SVecTup; |
| ... | ... | @@ -43,7 +41,6 @@ pub unsafe fn sve_tuple_create2<SVec, SVecTup>(x0: SVec, x1: SVec) -> SVecTup; |
| 43 | 41 | /// type `SVec`. |
| 44 | 42 | /// |
| 45 | 43 | /// Corresponds to Clang's `__builtin_sve_svcreate3*` builtins. |
| 46 | #[cfg(target_arch = "aarch64")] | |
| 47 | 44 | #[rustc_intrinsic] |
| 48 | 45 | #[rustc_nounwind] |
| 49 | 46 | pub unsafe fn sve_tuple_create3<SVec, SVecTup>(x0: SVec, x1: SVec, x2: SVec) -> SVecTup; |
| ... | ... | @@ -55,7 +52,6 @@ pub unsafe fn sve_tuple_create3<SVec, SVecTup>(x0: SVec, x1: SVec, x2: SVec) -> |
| 55 | 52 | /// type `SVec`. |
| 56 | 53 | /// |
| 57 | 54 | /// Corresponds to Clang's `__builtin_sve_svcreate4*` builtins. |
| 58 | #[cfg(target_arch = "aarch64")] | |
| 59 | 55 | #[rustc_intrinsic] |
| 60 | 56 | #[rustc_nounwind] |
| 61 | 57 | pub unsafe fn sve_tuple_create4<SVec, SVecTup>(x0: SVec, x1: SVec, x2: SVec, x3: SVec) -> SVecTup; |
| ... | ... | @@ -71,7 +67,6 @@ pub unsafe fn sve_tuple_create4<SVec, SVecTup>(x0: SVec, x1: SVec, x2: SVec, x3: |
| 71 | 67 | /// # Safety |
| 72 | 68 | /// |
| 73 | 69 | /// `IDX` must be in-bounds of the tuple. |
| 74 | #[cfg(target_arch = "aarch64")] | |
| 75 | 70 | #[rustc_intrinsic] |
| 76 | 71 | #[rustc_nounwind] |
| 77 | 72 | pub unsafe fn sve_tuple_get<SVecTup, SVec, const IDX: i32>(tuple: SVecTup) -> SVec; |
| ... | ... | @@ -87,7 +82,6 @@ pub unsafe fn sve_tuple_get<SVecTup, SVec, const IDX: i32>(tuple: SVecTup) -> SV |
| 87 | 82 | /// # Safety |
| 88 | 83 | /// |
| 89 | 84 | /// `IDX` must be in-bounds of the tuple. |
| 90 | #[cfg(target_arch = "aarch64")] | |
| 91 | 85 | #[rustc_intrinsic] |
| 92 | 86 | #[rustc_nounwind] |
| 93 | 87 | pub unsafe fn sve_tuple_set<SVecTup, SVec, const IDX: i32>(tuple: SVecTup, x: SVec) -> SVecTup; |
library/core/src/iter/range.rs+4-2| ... | ... | @@ -513,7 +513,8 @@ macro_rules! step_nonzero_impls { |
| 513 | 513 | $( |
| 514 | 514 | #[allow(unreachable_patterns)] |
| 515 | 515 | #[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")] |
| 516 | impl Step for NonZero<$narrower> { | |
| 516 | #[rustc_const_unstable(feature = "step_trait", issue = "42168")] | |
| 517 | impl const Step for NonZero<$narrower> { | |
| 517 | 518 | step_nonzero_identical_methods!($narrower); |
| 518 | 519 | |
| 519 | 520 | #[inline] |
| ... | ... | @@ -538,7 +539,8 @@ macro_rules! step_nonzero_impls { |
| 538 | 539 | $( |
| 539 | 540 | #[allow(unreachable_patterns)] |
| 540 | 541 | #[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")] |
| 541 | impl Step for NonZero<$wider> { | |
| 542 | #[rustc_const_unstable(feature = "step_trait", issue = "42168")] | |
| 543 | impl const Step for NonZero<$wider> { | |
| 542 | 544 | step_nonzero_identical_methods!($wider); |
| 543 | 545 | |
| 544 | 546 | #[inline] |
library/core/src/lib.rs+1-1| ... | ... | @@ -227,7 +227,7 @@ mod sealed { |
| 227 | 227 | |
| 228 | 228 | // We don't export this through #[macro_export] for now, to avoid breakage. |
| 229 | 229 | #[unstable(feature = "autodiff", issue = "124509")] |
| 230 | /// Unstable module containing the unstable `autodiff` macro. | |
| 230 | #[doc = include_str!("../../core/src/autodiff.md")] | |
| 231 | 231 | pub mod autodiff { |
| 232 | 232 | #[unstable(feature = "autodiff", issue = "124509")] |
| 233 | 233 | pub use crate::macros::builtin::{autodiff_forward, autodiff_reverse}; |
library/core/src/num/nonzero.rs+4-2| ... | ... | @@ -184,7 +184,8 @@ impl_nonzero_auto_trait!(Unpin); |
| 184 | 184 | impl_nonzero_auto_trait!(UnwindSafe); |
| 185 | 185 | |
| 186 | 186 | #[stable(feature = "nonzero", since = "1.28.0")] |
| 187 | impl<T> Clone for NonZero<T> | |
| 187 | #[rustc_const_unstable(feature = "const_clone", issue = "142757")] | |
| 188 | impl<T> const Clone for NonZero<T> | |
| 188 | 189 | where |
| 189 | 190 | T: ZeroablePrimitive, |
| 190 | 191 | { |
| ... | ... | @@ -202,7 +203,8 @@ impl<T> Copy for NonZero<T> where T: ZeroablePrimitive {} |
| 202 | 203 | |
| 203 | 204 | #[doc(hidden)] |
| 204 | 205 | #[unstable(feature = "trivial_clone", issue = "none")] |
| 205 | unsafe impl<T> TrivialClone for NonZero<T> where T: ZeroablePrimitive {} | |
| 206 | #[rustc_const_unstable(feature = "const_clone", issue = "142757")] | |
| 207 | unsafe impl<T> const TrivialClone for NonZero<T> where T: ZeroablePrimitive {} | |
| 206 | 208 | |
| 207 | 209 | #[stable(feature = "nonzero", since = "1.28.0")] |
| 208 | 210 | #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] |
library/core/src/pin.rs+3-3| ... | ... | @@ -474,9 +474,9 @@ |
| 474 | 474 | //! |
| 475 | 475 | //! In an intrusive doubly-linked list, the collection itself does not own the memory in which |
| 476 | 476 | //! each of its elements is stored. Instead, each client is free to allocate space for elements it |
| 477 | //! adds to the list in whichever manner it likes, including on the stack! Elements can live on a | |
| 478 | //! stack frame that lives shorter than the collection does provided the elements that live in a | |
| 479 | //! given stack frame are removed from the list before going out of scope. | |
| 477 | //! adds to the list in whichever manner it likes, including on the stack! Elements can be stored | |
| 478 | //! in a stack frame shorter-lived than the collection, provided they are removed from the list | |
| 479 | //! before that frame goes out of scope. | |
| 480 | 480 | //! |
| 481 | 481 | //! To make such an intrusive data structure work, every element stores pointers to its predecessor |
| 482 | 482 | //! and successor within its own data, rather than having the list structure itself managing those |
library/coretests/tests/cmp.rs+31| ... | ... | @@ -48,6 +48,37 @@ fn test_ord_min_max_by() { |
| 48 | 48 | assert_eq!(cmp::max_by(2, -1, f), 2); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | // Regression test for #136307 / #139357: ensure compare() receives (v1, v2), not (v2, v1). | |
| 52 | #[test] | |
| 53 | fn min_by_compare_argument_order() { | |
| 54 | let mut order = vec![]; | |
| 55 | let _ = cmp::min_by(1i32, 2, |a, b| { | |
| 56 | order.push((*a, *b)); | |
| 57 | a.cmp(b) | |
| 58 | }); | |
| 59 | assert_eq!(order, [(1, 2)]); | |
| 60 | } | |
| 61 | ||
| 62 | #[test] | |
| 63 | fn max_by_compare_argument_order() { | |
| 64 | let mut order = vec![]; | |
| 65 | let _ = cmp::max_by(1i32, 2, |a, b| { | |
| 66 | order.push((*a, *b)); | |
| 67 | a.cmp(b) | |
| 68 | }); | |
| 69 | assert_eq!(order, [(1, 2)]); | |
| 70 | } | |
| 71 | ||
| 72 | #[test] | |
| 73 | fn minmax_by_compare_argument_order() { | |
| 74 | let mut order = vec![]; | |
| 75 | let _ = cmp::minmax_by(1i32, 2, |a, b| { | |
| 76 | order.push((*a, *b)); | |
| 77 | a.cmp(b) | |
| 78 | }); | |
| 79 | assert_eq!(order, [(1, 2)]); | |
| 80 | } | |
| 81 | ||
| 51 | 82 | #[test] |
| 52 | 83 | fn test_ord_min_max_by_key() { |
| 53 | 84 | let f = |x: &i32| x.abs(); |
library/coretests/tests/lib.rs+1| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | #![feature(char_internals)] |
| 15 | 15 | #![feature(char_max_len)] |
| 16 | 16 | #![feature(clone_to_uninit)] |
| 17 | #![feature(cmp_minmax)] | |
| 17 | 18 | #![feature(const_array)] |
| 18 | 19 | #![feature(const_bool)] |
| 19 | 20 | #![feature(const_cell_traits)] |
library/std/src/lib.rs+1-1| ... | ... | @@ -637,7 +637,7 @@ pub mod simd { |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | #[unstable(feature = "autodiff", issue = "124509")] |
| 640 | /// This module provides support for automatic differentiation. | |
| 640 | #[doc = include_str!("../../core/src/autodiff.md")] | |
| 641 | 641 | pub mod autodiff { |
| 642 | 642 | /// This macro handles automatic differentiation. |
| 643 | 643 | pub use core::autodiff::{autodiff_forward, autodiff_reverse}; |
library/std/src/sys/pal/motor/mod.rs+1-1| ... | ... | @@ -42,5 +42,5 @@ pub fn unsupported_err() -> io::Error { |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | pub fn abort_internal() -> ! { |
| 45 | core::intrinsics::abort(); | |
| 45 | moto_rt::process::exit(-1) | |
| 46 | 46 | } |
license-metadata.json+1-1| ... | ... | @@ -114,10 +114,10 @@ |
| 114 | 114 | { |
| 115 | 115 | "directories": [], |
| 116 | 116 | "files": [ |
| 117 | "Fira-LICENSE.txt", | |
| 117 | 118 | "FiraMono-Medium.woff2", |
| 118 | 119 | "FiraMono-Regular.woff2", |
| 119 | 120 | "FiraSans-Italic.woff2", |
| 120 | "FiraSans-LICENSE.txt", | |
| 121 | 121 | "FiraSans-Medium.woff2", |
| 122 | 122 | "FiraSans-MediumItalic.woff2", |
| 123 | 123 | "FiraSans-Regular.woff2" |
src/bootstrap/src/core/config/config.rs+20-5| ... | ... | @@ -78,6 +78,7 @@ pub const RUSTC_IF_UNCHANGED_ALLOWED_PATHS: &[&str] = &[ |
| 78 | 78 | ":!src/rustdoc-json-types", |
| 79 | 79 | ":!tests", |
| 80 | 80 | ":!triagebot.toml", |
| 81 | ":!src/bootstrap/defaults", | |
| 81 | 82 | ]; |
| 82 | 83 | |
| 83 | 84 | /// Global configuration for the entire build and/or bootstrap. |
| ... | ... | @@ -2237,11 +2238,7 @@ pub fn download_ci_rustc_commit<'a>( |
| 2237 | 2238 | }); |
| 2238 | 2239 | match freshness { |
| 2239 | 2240 | PathFreshness::LastModifiedUpstream { upstream } => upstream, |
| 2240 | PathFreshness::HasLocalModifications { upstream } => { | |
| 2241 | if if_unchanged { | |
| 2242 | return None; | |
| 2243 | } | |
| 2244 | ||
| 2241 | PathFreshness::HasLocalModifications { upstream, modifications } => { | |
| 2245 | 2242 | if dwn_ctx.is_running_on_ci() { |
| 2246 | 2243 | eprintln!("CI rustc commit matches with HEAD and we are in CI."); |
| 2247 | 2244 | eprintln!( |
| ... | ... | @@ -2250,6 +2247,24 @@ pub fn download_ci_rustc_commit<'a>( |
| 2250 | 2247 | return None; |
| 2251 | 2248 | } |
| 2252 | 2249 | |
| 2250 | eprintln!( | |
| 2251 | "NOTE: detected {} modifications that could affect a build of rustc", | |
| 2252 | modifications.len() | |
| 2253 | ); | |
| 2254 | for file in modifications.iter().take(10) { | |
| 2255 | eprintln!("- {}", file.display()); | |
| 2256 | } | |
| 2257 | if modifications.len() > 10 { | |
| 2258 | eprintln!("- ... and {} more", modifications.len() - 10); | |
| 2259 | } | |
| 2260 | ||
| 2261 | if if_unchanged { | |
| 2262 | eprintln!("skipping rustc download due to `download-rustc = 'if-unchanged'`"); | |
| 2263 | return None; | |
| 2264 | } else { | |
| 2265 | eprintln!("downloading unconditionally due to `download-rustc = true`"); | |
| 2266 | } | |
| 2267 | ||
| 2253 | 2268 | upstream |
| 2254 | 2269 | } |
| 2255 | 2270 | PathFreshness::MissingUpstream => { |
src/bootstrap/src/core/config/tests.rs+14-16| ... | ... | @@ -32,6 +32,13 @@ fn get_toml(file: &Path) -> Result<TomlConfig, toml::de::Error> { |
| 32 | 32 | toml::from_str(&contents).and_then(|table: toml::Value| TomlConfig::deserialize(table)) |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | fn modified(upstream: impl Into<String>, changes: &[&str]) -> PathFreshness { | |
| 36 | PathFreshness::HasLocalModifications { | |
| 37 | upstream: upstream.into(), | |
| 38 | modifications: changes.iter().copied().map(PathBuf::from).collect(), | |
| 39 | } | |
| 40 | } | |
| 41 | ||
| 35 | 42 | #[test] |
| 36 | 43 | fn download_ci_llvm() { |
| 37 | 44 | let config = TestCtx::new().config("check").create_config(); |
| ... | ... | @@ -692,7 +699,7 @@ fn test_pr_ci_changed_in_pr() { |
| 692 | 699 | let sha = ctx.create_upstream_merge(&["a"]); |
| 693 | 700 | ctx.create_nonupstream_merge(&["b"]); |
| 694 | 701 | let src = ctx.check_modifications(&["b"], CiEnv::GitHubActions); |
| 695 | assert_eq!(src, PathFreshness::HasLocalModifications { upstream: sha }); | |
| 702 | assert_eq!(src, modified(sha, &["b"])); | |
| 696 | 703 | }); |
| 697 | 704 | } |
| 698 | 705 | |
| ... | ... | @@ -712,7 +719,7 @@ fn test_auto_ci_changed_in_pr() { |
| 712 | 719 | let sha = ctx.create_upstream_merge(&["a"]); |
| 713 | 720 | ctx.create_upstream_merge(&["b", "c"]); |
| 714 | 721 | let src = ctx.check_modifications(&["c", "d"], CiEnv::GitHubActions); |
| 715 | assert_eq!(src, PathFreshness::HasLocalModifications { upstream: sha }); | |
| 722 | assert_eq!(src, modified(sha, &["c"])); | |
| 716 | 723 | }); |
| 717 | 724 | } |
| 718 | 725 | |
| ... | ... | @@ -723,10 +730,7 @@ fn test_local_uncommitted_modifications() { |
| 723 | 730 | ctx.create_branch("feature"); |
| 724 | 731 | ctx.modify("a"); |
| 725 | 732 | |
| 726 | assert_eq!( | |
| 727 | ctx.check_modifications(&["a", "d"], CiEnv::None), | |
| 728 | PathFreshness::HasLocalModifications { upstream: sha } | |
| 729 | ); | |
| 733 | assert_eq!(ctx.check_modifications(&["a", "d"], CiEnv::None), modified(sha, &["a"]),); | |
| 730 | 734 | }); |
| 731 | 735 | } |
| 732 | 736 | |
| ... | ... | @@ -741,10 +745,7 @@ fn test_local_committed_modifications() { |
| 741 | 745 | ctx.modify("a"); |
| 742 | 746 | ctx.commit(); |
| 743 | 747 | |
| 744 | assert_eq!( | |
| 745 | ctx.check_modifications(&["a", "d"], CiEnv::None), | |
| 746 | PathFreshness::HasLocalModifications { upstream: sha } | |
| 747 | ); | |
| 748 | assert_eq!(ctx.check_modifications(&["a", "d"], CiEnv::None), modified(sha, &["a"]),); | |
| 748 | 749 | }); |
| 749 | 750 | } |
| 750 | 751 | |
| ... | ... | @@ -757,10 +758,7 @@ fn test_local_committed_modifications_subdirectory() { |
| 757 | 758 | ctx.modify("a/b/d"); |
| 758 | 759 | ctx.commit(); |
| 759 | 760 | |
| 760 | assert_eq!( | |
| 761 | ctx.check_modifications(&["a/b"], CiEnv::None), | |
| 762 | PathFreshness::HasLocalModifications { upstream: sha } | |
| 763 | ); | |
| 761 | assert_eq!(ctx.check_modifications(&["a/b"], CiEnv::None), modified(sha, &["a/b/d"]),); | |
| 764 | 762 | }); |
| 765 | 763 | } |
| 766 | 764 | |
| ... | ... | @@ -836,11 +834,11 @@ fn test_local_changes_negative_path() { |
| 836 | 834 | ); |
| 837 | 835 | assert_eq!( |
| 838 | 836 | ctx.check_modifications(&[":!c"], CiEnv::None), |
| 839 | PathFreshness::HasLocalModifications { upstream: upstream.clone() } | |
| 837 | modified(&upstream, &["b", "d"]), | |
| 840 | 838 | ); |
| 841 | 839 | assert_eq!( |
| 842 | 840 | ctx.check_modifications(&[":!d", ":!x"], CiEnv::None), |
| 843 | PathFreshness::HasLocalModifications { upstream } | |
| 841 | modified(&upstream, &["b"]), | |
| 844 | 842 | ); |
| 845 | 843 | }); |
| 846 | 844 | } |
src/bootstrap/src/core/download.rs+1-1| ... | ... | @@ -266,7 +266,7 @@ impl Config { |
| 266 | 266 | }); |
| 267 | 267 | let llvm_sha = match llvm_freshness { |
| 268 | 268 | PathFreshness::LastModifiedUpstream { upstream } => upstream, |
| 269 | PathFreshness::HasLocalModifications { upstream } => upstream, | |
| 269 | PathFreshness::HasLocalModifications { upstream, modifications: _ } => upstream, | |
| 270 | 270 | PathFreshness::MissingUpstream => { |
| 271 | 271 | eprintln!("error: could not find commit hash for downloading LLVM"); |
| 272 | 272 | eprintln!("HELP: maybe your repository history is too shallow?"); |
src/build_helper/src/git.rs+22-9| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | use std::path::Path; | |
| 1 | use std::path::{Path, PathBuf}; | |
| 2 | 2 | use std::process::{Command, Stdio}; |
| 3 | 3 | |
| 4 | 4 | use crate::ci::CiEnv; |
| ... | ... | @@ -38,7 +38,7 @@ pub enum PathFreshness { |
| 38 | 38 | /// "Local" essentially means "not-upstream" here. |
| 39 | 39 | /// `upstream` is the latest upstream merge commit that made modifications to the |
| 40 | 40 | /// set of paths. |
| 41 | HasLocalModifications { upstream: String }, | |
| 41 | HasLocalModifications { upstream: String, modifications: Vec<PathBuf> }, | |
| 42 | 42 | /// No upstream commit was found. |
| 43 | 43 | /// This should not happen in most reasonable circumstances, but one never knows. |
| 44 | 44 | MissingUpstream, |
| ... | ... | @@ -134,21 +134,34 @@ pub fn check_path_modifications( |
| 134 | 134 | // However, that should be equivalent to checking if something has changed |
| 135 | 135 | // from the latest upstream commit *that modified `target_paths`*, and |
| 136 | 136 | // with this approach we do not need to invoke git an additional time. |
| 137 | if has_changed_since(git_dir, &upstream_sha, target_paths) { | |
| 138 | Ok(PathFreshness::HasLocalModifications { upstream: upstream_sha }) | |
| 137 | let modifications = changes_since(git_dir, &upstream_sha, target_paths)?; | |
| 138 | if !modifications.is_empty() { | |
| 139 | Ok(PathFreshness::HasLocalModifications { upstream: upstream_sha, modifications }) | |
| 139 | 140 | } else { |
| 140 | 141 | Ok(PathFreshness::LastModifiedUpstream { upstream: upstream_sha }) |
| 141 | 142 | } |
| 142 | 143 | } |
| 143 | 144 | |
| 144 | 145 | /// Returns true if any of the passed `paths` have changed since the `base` commit. |
| 145 | pub fn has_changed_since(git_dir: &Path, base: &str, paths: &[&str]) -> bool { | |
| 146 | pub fn changes_since(git_dir: &Path, base: &str, paths: &[&str]) -> Result<Vec<PathBuf>, String> { | |
| 147 | use std::io::BufRead; | |
| 148 | ||
| 146 | 149 | run_git_diff_index(Some(git_dir), |cmd| { |
| 147 | cmd.args(["--quiet", base, "--"]).args(paths); | |
| 150 | cmd.args([base, "--name-only", "--"]).args(paths); | |
| 151 | ||
| 152 | let output = cmd.stderr(Stdio::inherit()).output().expect("cannot run git diff-index"); | |
| 153 | if !output.status.success() { | |
| 154 | return Err(format!("failed to run: {cmd:?}: {:?}", output.status)); | |
| 155 | } | |
| 148 | 156 | |
| 149 | // Exit code 0 => no changes | |
| 150 | // Exit code 1 => some changes were detected | |
| 151 | !cmd.status().expect("cannot run git diff-index").success() | |
| 157 | output | |
| 158 | .stdout | |
| 159 | .lines() | |
| 160 | .map(|res| match res { | |
| 161 | Ok(line) => Ok(PathBuf::from(line)), | |
| 162 | Err(e) => Err(format!("invalid UTF-8 in diff-index: {e:?}")), | |
| 163 | }) | |
| 164 | .collect() | |
| 152 | 165 | }) |
| 153 | 166 | } |
| 154 | 167 |
src/ci/github-actions/jobs.yml+2| ... | ... | @@ -94,6 +94,7 @@ jobs: |
| 94 | 94 | dist-x86_64-linux: &job-dist-x86_64-linux |
| 95 | 95 | name: dist-x86_64-linux |
| 96 | 96 | env: |
| 97 | IMAGE: dist-x86_64-linux | |
| 97 | 98 | CODEGEN_BACKENDS: llvm,cranelift |
| 98 | 99 | DOCKER_SCRIPT: dist.sh |
| 99 | 100 | <<: *job-linux-36c-codebuild |
| ... | ... | @@ -150,6 +151,7 @@ pr: |
| 150 | 151 | # it in each job definition. |
| 151 | 152 | try: |
| 152 | 153 | - <<: *job-dist-x86_64-linux |
| 154 | name: dist-x86_64-linux-quick | |
| 153 | 155 | |
| 154 | 156 | # Jobs that only run when explicitly invoked in one of the following ways: |
| 155 | 157 | # - comment `@bors try jobs=<job-name>` |
src/doc/rustc-dev-guide/src/tests/ci.md+4-1| ... | ... | @@ -150,7 +150,10 @@ Such a try build will not execute any tests, and it will allow compilation warni |
| 150 | 150 | It is useful when you want to |
| 151 | 151 | get an optimized toolchain as fast as possible, for a Crater run or performance benchmarks, |
| 152 | 152 | even if it might not be working fully correctly. |
| 153 | If you want to do a full build for the default try job, | |
| 153 | ||
| 154 | The CI job executed in fast try builds has a special suffix (`-quick`), | |
| 155 | to distinguish it from a full build of the default try job. | |
| 156 | If you want to do the full build instead, | |
| 154 | 157 | specify its job name in a job pattern (explained below). |
| 155 | 158 | |
| 156 | 159 | If you want to run custom CI jobs in a try build and make sure that they pass all tests and do |
src/librustdoc/build.rs+1-1| ... | ... | @@ -27,7 +27,7 @@ fn main() { |
| 27 | 27 | "static/fonts/FiraSans-MediumItalic.woff2", |
| 28 | 28 | "static/fonts/FiraMono-Regular.woff2", |
| 29 | 29 | "static/fonts/FiraMono-Medium.woff2", |
| 30 | "static/fonts/FiraSans-LICENSE.txt", | |
| 30 | "static/fonts/Fira-LICENSE.txt", | |
| 31 | 31 | "static/fonts/SourceSerif4-Regular.ttf.woff2", |
| 32 | 32 | "static/fonts/SourceSerif4-Semibold.ttf.woff2", |
| 33 | 33 | "static/fonts/SourceSerif4-Bold.ttf.woff2", |
src/librustdoc/html/static/COPYRIGHT.txt+4-3| ... | ... | @@ -4,15 +4,16 @@ These documentation pages include resources by third parties. This copyright |
| 4 | 4 | file applies only to those resources. The following third party resources are |
| 5 | 5 | included, and carry their own copyright notices and license terms: |
| 6 | 6 | |
| 7 | * Fira Sans (FiraSans-Regular.woff2, FiraSans-Medium.woff2): | |
| 7 | * Fira (FiraSans-Regular.woff2, FiraSans-Medium.woff2, | |
| 8 | FiraMono-Regular.woff2, FiraMono-Medium.woff2): | |
| 8 | 9 | |
| 9 | 10 | Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ |
| 10 | with Reserved Font Name Fira Sans. | |
| 11 | with Reserved Font Name < Fira >. | |
| 11 | 12 | |
| 12 | 13 | Copyright (c) 2014, Telefonica S.A. |
| 13 | 14 | |
| 14 | 15 | Licensed under the SIL Open Font License, Version 1.1. |
| 15 | See FiraSans-LICENSE.txt. | |
| 16 | See Fira-LICENSE.txt. | |
| 16 | 17 | |
| 17 | 18 | * rustdoc.css, main.js, and playpen.js: |
| 18 | 19 |
src/librustdoc/html/static/fonts/Fira-LICENSE.txt created+98| ... | ... | @@ -0,0 +1,98 @@ |
| 1 | // REUSE-IgnoreStart | |
| 2 | ||
| 3 | Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A. | |
| 4 | with Reserved Font Name < Fira >, | |
| 5 | ||
| 6 | This Font Software is licensed under the SIL Open Font License, Version 1.1. | |
| 7 | This license is copied below, and is also available with a FAQ at: | |
| 8 | http://scripts.sil.org/OFL | |
| 9 | ||
| 10 | ||
| 11 | ----------------------------------------------------------- | |
| 12 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 | |
| 13 | ----------------------------------------------------------- | |
| 14 | ||
| 15 | PREAMBLE | |
| 16 | The goals of the Open Font License (OFL) are to stimulate worldwide | |
| 17 | development of collaborative font projects, to support the font creation | |
| 18 | efforts of academic and linguistic communities, and to provide a free and | |
| 19 | open framework in which fonts may be shared and improved in partnership | |
| 20 | with others. | |
| 21 | ||
| 22 | The OFL allows the licensed fonts to be used, studied, modified and | |
| 23 | redistributed freely as long as they are not sold by themselves. The | |
| 24 | fonts, including any derivative works, can be bundled, embedded, | |
| 25 | redistributed and/or sold with any software provided that any reserved | |
| 26 | names are not used by derivative works. The fonts and derivatives, | |
| 27 | however, cannot be released under any other type of license. The | |
| 28 | requirement for fonts to remain under this license does not apply | |
| 29 | to any document created using the fonts or their derivatives. | |
| 30 | ||
| 31 | DEFINITIONS | |
| 32 | "Font Software" refers to the set of files released by the Copyright | |
| 33 | Holder(s) under this license and clearly marked as such. This may | |
| 34 | include source files, build scripts and documentation. | |
| 35 | ||
| 36 | "Reserved Font Name" refers to any names specified as such after the | |
| 37 | copyright statement(s). | |
| 38 | ||
| 39 | "Original Version" refers to the collection of Font Software components as | |
| 40 | distributed by the Copyright Holder(s). | |
| 41 | ||
| 42 | "Modified Version" refers to any derivative made by adding to, deleting, | |
| 43 | or substituting -- in part or in whole -- any of the components of the | |
| 44 | Original Version, by changing formats or by porting the Font Software to a | |
| 45 | new environment. | |
| 46 | ||
| 47 | "Author" refers to any designer, engineer, programmer, technical | |
| 48 | writer or other person who contributed to the Font Software. | |
| 49 | ||
| 50 | PERMISSION & CONDITIONS | |
| 51 | Permission is hereby granted, free of charge, to any person obtaining | |
| 52 | a copy of the Font Software, to use, study, copy, merge, embed, modify, | |
| 53 | redistribute, and sell modified and unmodified copies of the Font | |
| 54 | Software, subject to the following conditions: | |
| 55 | ||
| 56 | 1) Neither the Font Software nor any of its individual components, | |
| 57 | in Original or Modified Versions, may be sold by itself. | |
| 58 | ||
| 59 | 2) Original or Modified Versions of the Font Software may be bundled, | |
| 60 | redistributed and/or sold with any software, provided that each copy | |
| 61 | contains the above copyright notice and this license. These can be | |
| 62 | included either as stand-alone text files, human-readable headers or | |
| 63 | in the appropriate machine-readable metadata fields within text or | |
| 64 | binary files as long as those fields can be easily viewed by the user. | |
| 65 | ||
| 66 | 3) No Modified Version of the Font Software may use the Reserved Font | |
| 67 | Name(s) unless explicit written permission is granted by the corresponding | |
| 68 | Copyright Holder. This restriction only applies to the primary font name as | |
| 69 | presented to the users. | |
| 70 | ||
| 71 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font | |
| 72 | Software shall not be used to promote, endorse or advertise any | |
| 73 | Modified Version, except to acknowledge the contribution(s) of the | |
| 74 | Copyright Holder(s) and the Author(s) or with their explicit written | |
| 75 | permission. | |
| 76 | ||
| 77 | 5) The Font Software, modified or unmodified, in part or in whole, | |
| 78 | must be distributed entirely under this license, and must not be | |
| 79 | distributed under any other license. The requirement for fonts to | |
| 80 | remain under this license does not apply to any document created | |
| 81 | using the Font Software. | |
| 82 | ||
| 83 | TERMINATION | |
| 84 | This license becomes null and void if any of the above conditions are | |
| 85 | not met. | |
| 86 | ||
| 87 | DISCLAIMER | |
| 88 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
| 89 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF | |
| 90 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT | |
| 91 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE | |
| 92 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
| 93 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL | |
| 94 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| 95 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM | |
| 96 | OTHER DEALINGS IN THE FONT SOFTWARE. | |
| 97 | ||
| 98 | // REUSE-IgnoreEnd |
src/librustdoc/html/static/fonts/FiraSans-LICENSE.txt deleted-98| ... | ... | @@ -1,98 +0,0 @@ |
| 1 | // REUSE-IgnoreStart | |
| 2 | ||
| 3 | Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A. | |
| 4 | with Reserved Font Name < Fira >, | |
| 5 | ||
| 6 | This Font Software is licensed under the SIL Open Font License, Version 1.1. | |
| 7 | This license is copied below, and is also available with a FAQ at: | |
| 8 | http://scripts.sil.org/OFL | |
| 9 | ||
| 10 | ||
| 11 | ----------------------------------------------------------- | |
| 12 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 | |
| 13 | ----------------------------------------------------------- | |
| 14 | ||
| 15 | PREAMBLE | |
| 16 | The goals of the Open Font License (OFL) are to stimulate worldwide | |
| 17 | development of collaborative font projects, to support the font creation | |
| 18 | efforts of academic and linguistic communities, and to provide a free and | |
| 19 | open framework in which fonts may be shared and improved in partnership | |
| 20 | with others. | |
| 21 | ||
| 22 | The OFL allows the licensed fonts to be used, studied, modified and | |
| 23 | redistributed freely as long as they are not sold by themselves. The | |
| 24 | fonts, including any derivative works, can be bundled, embedded, | |
| 25 | redistributed and/or sold with any software provided that any reserved | |
| 26 | names are not used by derivative works. The fonts and derivatives, | |
| 27 | however, cannot be released under any other type of license. The | |
| 28 | requirement for fonts to remain under this license does not apply | |
| 29 | to any document created using the fonts or their derivatives. | |
| 30 | ||
| 31 | DEFINITIONS | |
| 32 | "Font Software" refers to the set of files released by the Copyright | |
| 33 | Holder(s) under this license and clearly marked as such. This may | |
| 34 | include source files, build scripts and documentation. | |
| 35 | ||
| 36 | "Reserved Font Name" refers to any names specified as such after the | |
| 37 | copyright statement(s). | |
| 38 | ||
| 39 | "Original Version" refers to the collection of Font Software components as | |
| 40 | distributed by the Copyright Holder(s). | |
| 41 | ||
| 42 | "Modified Version" refers to any derivative made by adding to, deleting, | |
| 43 | or substituting -- in part or in whole -- any of the components of the | |
| 44 | Original Version, by changing formats or by porting the Font Software to a | |
| 45 | new environment. | |
| 46 | ||
| 47 | "Author" refers to any designer, engineer, programmer, technical | |
| 48 | writer or other person who contributed to the Font Software. | |
| 49 | ||
| 50 | PERMISSION & CONDITIONS | |
| 51 | Permission is hereby granted, free of charge, to any person obtaining | |
| 52 | a copy of the Font Software, to use, study, copy, merge, embed, modify, | |
| 53 | redistribute, and sell modified and unmodified copies of the Font | |
| 54 | Software, subject to the following conditions: | |
| 55 | ||
| 56 | 1) Neither the Font Software nor any of its individual components, | |
| 57 | in Original or Modified Versions, may be sold by itself. | |
| 58 | ||
| 59 | 2) Original or Modified Versions of the Font Software may be bundled, | |
| 60 | redistributed and/or sold with any software, provided that each copy | |
| 61 | contains the above copyright notice and this license. These can be | |
| 62 | included either as stand-alone text files, human-readable headers or | |
| 63 | in the appropriate machine-readable metadata fields within text or | |
| 64 | binary files as long as those fields can be easily viewed by the user. | |
| 65 | ||
| 66 | 3) No Modified Version of the Font Software may use the Reserved Font | |
| 67 | Name(s) unless explicit written permission is granted by the corresponding | |
| 68 | Copyright Holder. This restriction only applies to the primary font name as | |
| 69 | presented to the users. | |
| 70 | ||
| 71 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font | |
| 72 | Software shall not be used to promote, endorse or advertise any | |
| 73 | Modified Version, except to acknowledge the contribution(s) of the | |
| 74 | Copyright Holder(s) and the Author(s) or with their explicit written | |
| 75 | permission. | |
| 76 | ||
| 77 | 5) The Font Software, modified or unmodified, in part or in whole, | |
| 78 | must be distributed entirely under this license, and must not be | |
| 79 | distributed under any other license. The requirement for fonts to | |
| 80 | remain under this license does not apply to any document created | |
| 81 | using the Font Software. | |
| 82 | ||
| 83 | TERMINATION | |
| 84 | This license becomes null and void if any of the above conditions are | |
| 85 | not met. | |
| 86 | ||
| 87 | DISCLAIMER | |
| 88 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
| 89 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF | |
| 90 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT | |
| 91 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE | |
| 92 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
| 93 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL | |
| 94 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| 95 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM | |
| 96 | OTHER DEALINGS IN THE FONT SOFTWARE. | |
| 97 | ||
| 98 | // REUSE-IgnoreEnd |
src/librustdoc/html/static/js/search.js+13-10| ... | ... | @@ -4749,11 +4749,16 @@ class DocSearch { |
| 4749 | 4749 | })(), |
| 4750 | 4750 | "query": parsedQuery, |
| 4751 | 4751 | }; |
| 4752 | } else if (parsedQuery.error !== null) { | |
| 4752 | } else if (parsedQuery.error !== null || parsedQuery.foundElems === 0) { | |
| 4753 | // Symbol-only queries like `==` do not parse into type elements, | |
| 4754 | // but can still match exact item names or doc aliases. | |
| 4755 | const others = parsedQuery.userQuery.length === 0 ? | |
| 4756 | (async function*() {})() : | |
| 4757 | innerRunNameQuery(currentCrate); | |
| 4753 | 4758 | return { |
| 4754 | 4759 | "in_args": (async function*() {})(), |
| 4755 | 4760 | "returned": (async function*() {})(), |
| 4756 | "others": innerRunNameQuery(currentCrate), | |
| 4761 | "others": others, | |
| 4757 | 4762 | "query": parsedQuery, |
| 4758 | 4763 | }; |
| 4759 | 4764 | } else { |
| ... | ... | @@ -4764,14 +4769,12 @@ class DocSearch { |
| 4764 | 4769 | return { |
| 4765 | 4770 | "in_args": (async function*() {})(), |
| 4766 | 4771 | "returned": (async function*() {})(), |
| 4767 | "others": parsedQuery.foundElems === 0 ? | |
| 4768 | (async function*() {})() : | |
| 4769 | innerRunTypeQuery( | |
| 4770 | parsedQuery.elems, | |
| 4771 | parsedQuery.returned, | |
| 4772 | typeInfo, | |
| 4773 | currentCrate, | |
| 4774 | ), | |
| 4772 | "others": innerRunTypeQuery( | |
| 4773 | parsedQuery.elems, | |
| 4774 | parsedQuery.returned, | |
| 4775 | typeInfo, | |
| 4776 | currentCrate, | |
| 4777 | ), | |
| 4775 | 4778 | "query": parsedQuery, |
| 4776 | 4779 | }; |
| 4777 | 4780 | } |
src/librustdoc/html/static_files.rs+1-1| ... | ... | @@ -97,7 +97,7 @@ static_files! { |
| 97 | 97 | fira_sans_medium_italic => "static/fonts/FiraSans-MediumItalic.woff2", |
| 98 | 98 | fira_mono_regular => "static/fonts/FiraMono-Regular.woff2", |
| 99 | 99 | fira_mono_medium => "static/fonts/FiraMono-Medium.woff2", |
| 100 | fira_sans_license => "static/fonts/FiraSans-LICENSE.txt", | |
| 100 | fira_license => "static/fonts/Fira-LICENSE.txt", | |
| 101 | 101 | source_serif_4_regular => "static/fonts/SourceSerif4-Regular.ttf.woff2", |
| 102 | 102 | source_serif_4_semibold => "static/fonts/SourceSerif4-Semibold.ttf.woff2", |
| 103 | 103 | source_serif_4_bold => "static/fonts/SourceSerif4-Bold.ttf.woff2", |
src/tools/wasm-component-ld/Cargo.toml+1-1| ... | ... | @@ -10,4 +10,4 @@ name = "wasm-component-ld" |
| 10 | 10 | path = "src/main.rs" |
| 11 | 11 | |
| 12 | 12 | [dependencies] |
| 13 | wasm-component-ld = "0.5.21" | |
| 13 | wasm-component-ld = "0.5.22" |
tests/codegen-llvm/dont_codegen_private_const_fn_only_used_in_const_eval.rs deleted-27| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | //! This test checks that we do not monomorphize functions that are only | |
| 2 | //! used to evaluate static items, but never used in runtime code. | |
| 3 | ||
| 4 | //@compile-flags: --crate-type=lib -Copt-level=0 | |
| 5 | ||
| 6 | #![feature(generic_const_items)] | |
| 7 | ||
| 8 | const fn foo() {} | |
| 9 | ||
| 10 | pub static FOO: () = foo(); | |
| 11 | ||
| 12 | // CHECK-NOT: define{{.*}}foo{{.*}} | |
| 13 | ||
| 14 | const fn bar() {} | |
| 15 | ||
| 16 | pub const BAR: () = bar(); | |
| 17 | ||
| 18 | // CHECK-NOT: define{{.*}}bar{{.*}} | |
| 19 | ||
| 20 | const fn baz() {} | |
| 21 | ||
| 22 | #[rustfmt::skip] | |
| 23 | pub const BAZ<const C: bool>: () = if C { | |
| 24 | baz() | |
| 25 | }; | |
| 26 | ||
| 27 | // CHECK: define{{.*}}baz{{.*}} |
tests/codegen-llvm/private-const-fn-only-used-in-const-eval.rs created+38| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | // Check that we — where possible — don't codegen functions that are only used to evaluate | |
| 2 | // static / const items, but never used in runtime code. | |
| 3 | ||
| 4 | //@ compile-flags: --crate-type=lib -Copt-level=0 | |
| 5 | ||
| 6 | #![feature(generic_const_items)] // only used in the last few test cases | |
| 7 | ||
| 8 | pub static STATIC: () = func0(); | |
| 9 | const fn func0() {} | |
| 10 | // CHECK-NOT: define{{.*}}func0{{.*}} | |
| 11 | ||
| 12 | pub const CONSTANT: () = func1(); | |
| 13 | const fn func1() {} | |
| 14 | // CHECK-NOT: define{{.*}}func1{{.*}} | |
| 15 | ||
| 16 | // We generally don't want to evaluate the initializer of free const items if they have | |
| 17 | // non-region params (and even if we did, const eval would fail anyway with "too polymorphic" | |
| 18 | // if the initializer actually referenced such a param). | |
| 19 | // | |
| 20 | // As a result of not being able to look at the final value, during reachability analysis we | |
| 21 | // can't tell for sure if for example certain functions end up in the final value or if they're | |
| 22 | // only used during const eval. We fall back to a conservative HIR-based approach. | |
| 23 | ||
| 24 | // `func2` isn't needed at runtime but the compiler can't tell for the reason mentioned above. | |
| 25 | pub const POLY_CONST_0<const C: bool>: () = func2(); | |
| 26 | const fn func2() {} | |
| 27 | // CHECK: define{{.*}}func2{{.*}} | |
| 28 | ||
| 29 | // `func3` isn't needed at runtime but the compiler can't tell for the reason mentioned above. | |
| 30 | pub const POLY_CONST_1<const C: bool>: () = if C { func3() }; | |
| 31 | const fn func3() {} | |
| 32 | // CHECK: define{{.*}}func3{{.*}} | |
| 33 | ||
| 34 | // `func4` *is* needed at runtime (here, the HIR-based approach gets it right). | |
| 35 | pub const POLY_CONST_2<const C: bool>: Option<fn() /* or a TAIT */> = | |
| 36 | if C { Some(func4) } else { None }; | |
| 37 | const fn func4() {} | |
| 38 | // CHECK: define{{.*}}func4{{.*}} |
tests/run-make/raw-dylib-elf-extern-types/bin.rs created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | #![feature(extern_types)] | |
| 2 | #![feature(raw_dylib_elf)] | |
| 3 | ||
| 4 | use std::ffi::c_char; | |
| 5 | ||
| 6 | #[link(name = "extern", kind = "raw-dylib")] | |
| 7 | unsafe extern "C" { | |
| 8 | type FOO; | |
| 9 | fn create_foo() -> *const FOO; | |
| 10 | fn get_foo(foo: *const FOO) -> c_char; | |
| 11 | fn set_foo(foo: *const FOO, value: c_char); | |
| 12 | } | |
| 13 | ||
| 14 | pub fn main() { | |
| 15 | let value = unsafe { | |
| 16 | let foo = create_foo(); | |
| 17 | set_foo(foo, 42); | |
| 18 | get_foo(foo) | |
| 19 | }; | |
| 20 | println!("{}", value); | |
| 21 | } |
tests/run-make/raw-dylib-elf-extern-types/extern.c created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | typedef struct FOO { | |
| 2 | char val; | |
| 3 | } FOO; | |
| 4 | ||
| 5 | FOO* create_foo() { | |
| 6 | static FOO foo; | |
| 7 | return &foo; | |
| 8 | } | |
| 9 | ||
| 10 | void set_foo(FOO* foo, char val) { | |
| 11 | foo->val = val; | |
| 12 | } | |
| 13 | ||
| 14 | char get_foo(FOO* foo) { | |
| 15 | return foo->val; | |
| 16 | } |
tests/run-make/raw-dylib-elf-extern-types/output.txt created+1| ... | ... | @@ -0,0 +1 @@ |
| 1 | 42 |
tests/run-make/raw-dylib-elf-extern-types/rmake.rs created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | //@ only-elf | |
| 2 | //@ ignore-cross-compile: Runs a binary. | |
| 3 | //@ needs-dynamic-linking | |
| 4 | // FIXME(raw_dylib_elf): Debug the failures on other targets. | |
| 5 | //@ only-gnu | |
| 6 | //@ only-x86_64 | |
| 7 | ||
| 8 | //@ ignore-rustc-debug-assertions | |
| 9 | ||
| 10 | use run_make_support::{build_native_dynamic_lib, diff, run, rustc}; | |
| 11 | ||
| 12 | fn main() { | |
| 13 | rustc().crate_type("bin").crate_name("raw_dylib_test").input("bin.rs").run(); | |
| 14 | build_native_dynamic_lib("extern"); | |
| 15 | ||
| 16 | let out_raw = run("raw_dylib_test").stdout_utf8(); | |
| 17 | diff().expected_file("output.txt").actual_text("actual", out_raw).normalize(r#"\r"#, "").run(); | |
| 18 | } |
tests/rustdoc-js-std/doc-alias-symbols-150921.js created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | // exact-check | |
| 2 | // Regression test for <https://github.com/rust-lang/rust/issues/150921>. | |
| 3 | ||
| 4 | const EXPECTED = [ | |
| 5 | { | |
| 6 | 'query': '==', | |
| 7 | 'others': [ | |
| 8 | { | |
| 9 | 'path': 'std::cmp', | |
| 10 | 'name': 'Eq', | |
| 11 | 'alias': '==', | |
| 12 | 'href': '../std/cmp/trait.Eq.html', | |
| 13 | 'is_alias': true, | |
| 14 | }, | |
| 15 | { | |
| 16 | 'path': 'std::cmp', | |
| 17 | 'name': 'PartialEq', | |
| 18 | 'alias': '==', | |
| 19 | 'href': '../std/cmp/trait.PartialEq.html', | |
| 20 | 'is_alias': true, | |
| 21 | }, | |
| 22 | ], | |
| 23 | }, | |
| 24 | ]; |
tests/rustdoc-js/doc-alias-symbols-150921.js created+29| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | // exact-check | |
| 2 | // Regression test for <https://github.com/rust-lang/rust/issues/150921>. | |
| 3 | ||
| 4 | const EXPECTED = [ | |
| 5 | { | |
| 6 | 'query': '==', | |
| 7 | 'others': [ | |
| 8 | { | |
| 9 | 'path': 'doc_alias_symbols_150921', | |
| 10 | 'name': 'OperatorEqEqAlias', | |
| 11 | 'alias': '==', | |
| 12 | 'href': '../doc_alias_symbols_150921/struct.OperatorEqEqAlias.html', | |
| 13 | 'is_alias': true, | |
| 14 | }, | |
| 15 | ], | |
| 16 | }, | |
| 17 | { | |
| 18 | 'query': '!=', | |
| 19 | 'others': [ | |
| 20 | { | |
| 21 | 'path': 'doc_alias_symbols_150921', | |
| 22 | 'name': 'OperatorNotEqAlias', | |
| 23 | 'alias': '!=', | |
| 24 | 'href': '../doc_alias_symbols_150921/struct.OperatorNotEqAlias.html', | |
| 25 | 'is_alias': true, | |
| 26 | }, | |
| 27 | ], | |
| 28 | }, | |
| 29 | ]; |
tests/rustdoc-js/doc-alias-symbols-150921.rs created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | // Regression test for <https://github.com/rust-lang/rust/issues/150921>. | |
| 2 | ||
| 3 | #[doc(alias = "==")] | |
| 4 | pub struct OperatorEqEqAlias; | |
| 5 | ||
| 6 | #[doc(alias = "!=")] | |
| 7 | pub struct OperatorNotEqAlias; |
tests/ui/cfg/suggest-alternative-name-on-target.rs+1-1| ... | ... | @@ -32,8 +32,8 @@ struct D; |
| 32 | 32 | #[cfg(target_abi = "windows")] |
| 33 | 33 | //~^ ERROR unexpected `cfg` condition value: |
| 34 | 34 | //~| NOTE see <https://doc.rust-lang.org |
| 35 | //~| HELP `windows` is an expected value for `target_os` | |
| 36 | 35 | //~| HELP `windows` is an expected value for `target_family` |
| 36 | //~| HELP `windows` is an expected value for `target_os` | |
| 37 | 37 | struct E; |
| 38 | 38 | |
| 39 | 39 | fn main() {} |
tests/ui/cfg/suggest-alternative-name-on-target.stderr+4-4| ... | ... | @@ -62,15 +62,15 @@ LL | #[cfg(target_abi = "windows")] |
| 62 | 62 | | ^^^^^^^^^^^^^^^^^^^^^^ |
| 63 | 63 | | |
| 64 | 64 | = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration |
| 65 | help: `windows` is an expected value for `target_os` | |
| 65 | help: `windows` is an expected value for `target_family` | |
| 66 | 66 | | |
| 67 | 67 | LL - #[cfg(target_abi = "windows")] |
| 68 | LL + #[cfg(target_os = "windows")] | |
| 68 | LL + #[cfg(target_family = "windows")] | |
| 69 | 69 | | |
| 70 | help: `windows` is an expected value for `target_family` | |
| 70 | help: `windows` is an expected value for `target_os` | |
| 71 | 71 | | |
| 72 | 72 | LL - #[cfg(target_abi = "windows")] |
| 73 | LL + #[cfg(target_family = "windows")] | |
| 73 | LL + #[cfg(target_os = "windows")] | |
| 74 | 74 | | |
| 75 | 75 | |
| 76 | 76 | error: aborting due to 5 previous errors |
tests/ui/delegation/duplicate-definition-inside-trait-impl.rs+2| ... | ... | @@ -18,6 +18,8 @@ impl Trait for S { |
| 18 | 18 | reuse to_reuse::foo { self } |
| 19 | 19 | reuse Trait::foo; |
| 20 | 20 | //~^ ERROR duplicate definitions with name `foo` |
| 21 | //~| ERROR: this function takes 1 argument but 0 arguments were supplied | |
| 22 | //~| ERROR: mismatched types | |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | 25 | fn main() {} |
tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr+28-2| ... | ... | @@ -9,6 +9,32 @@ LL | reuse to_reuse::foo { self } |
| 9 | 9 | LL | reuse Trait::foo; |
| 10 | 10 | | ^^^^^^^^^^^^^^^^^ duplicate definition |
| 11 | 11 | |
| 12 | error: aborting due to 1 previous error | |
| 12 | error[E0061]: this function takes 1 argument but 0 arguments were supplied | |
| 13 | --> $DIR/duplicate-definition-inside-trait-impl.rs:19:18 | |
| 14 | | | |
| 15 | LL | reuse Trait::foo; | |
| 16 | | ^^^ argument #1 of type `&_` is missing | |
| 17 | | | |
| 18 | note: method defined here | |
| 19 | --> $DIR/duplicate-definition-inside-trait-impl.rs:5:8 | |
| 20 | | | |
| 21 | LL | fn foo(&self) -> u32 { 0 } | |
| 22 | | ^^^ ----- | |
| 23 | help: provide the argument | |
| 24 | | | |
| 25 | LL | reuse Trait::foo(/* value */); | |
| 26 | | +++++++++++++ | |
| 27 | ||
| 28 | error[E0308]: mismatched types | |
| 29 | --> $DIR/duplicate-definition-inside-trait-impl.rs:19:18 | |
| 30 | | | |
| 31 | LL | reuse Trait::foo; | |
| 32 | | ^^^- help: consider using a semicolon here: `;` | |
| 33 | | | | |
| 34 | | expected `()`, found `u32` | |
| 35 | | expected `()` because of default return type | |
| 36 | ||
| 37 | error: aborting due to 3 previous errors | |
| 13 | 38 | |
| 14 | For more information about this error, try `rustc --explain E0201`. | |
| 39 | Some errors have detailed explanations: E0061, E0201, E0308. | |
| 40 | For more information about an error, try `rustc --explain E0061`. |
tests/ui/delegation/glob-glob-conflict.rs+4| ... | ... | @@ -3,9 +3,13 @@ |
| 3 | 3 | |
| 4 | 4 | trait Trait1 { |
| 5 | 5 | fn method(&self) -> u8; |
| 6 | //~^ ERROR: this function takes 1 argument but 0 arguments were supplied | |
| 7 | //~| ERROR: mismatched types | |
| 6 | 8 | } |
| 7 | 9 | trait Trait2 { |
| 8 | 10 | fn method(&self) -> u8; |
| 11 | //~^ ERROR: this function takes 1 argument but 0 arguments were supplied | |
| 12 | //~| ERROR: mismatched types | |
| 9 | 13 | } |
| 10 | 14 | trait Trait { |
| 11 | 15 | fn method(&self) -> u8; |
tests/ui/delegation/glob-glob-conflict.stderr+55-4| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | error[E0201]: duplicate definitions with name `method`: |
| 2 | --> $DIR/glob-glob-conflict.rs:26:5 | |
| 2 | --> $DIR/glob-glob-conflict.rs:30:5 | |
| 3 | 3 | | |
| 4 | 4 | LL | fn method(&self) -> u8; |
| 5 | 5 | | ----------------------- item in trait |
| ... | ... | @@ -10,7 +10,7 @@ LL | reuse Trait2::*; |
| 10 | 10 | | ^^^^^^^^^^^^^^^^ duplicate definition |
| 11 | 11 | |
| 12 | 12 | error[E0201]: duplicate definitions with name `method`: |
| 13 | --> $DIR/glob-glob-conflict.rs:30:5 | |
| 13 | --> $DIR/glob-glob-conflict.rs:34:5 | |
| 14 | 14 | | |
| 15 | 15 | LL | fn method(&self) -> u8; |
| 16 | 16 | | ----------------------- item in trait |
| ... | ... | @@ -20,6 +20,57 @@ LL | reuse Trait1::*; |
| 20 | 20 | LL | reuse Trait1::*; |
| 21 | 21 | | ^^^^^^^^^^^^^^^^ duplicate definition |
| 22 | 22 | |
| 23 | error: aborting due to 2 previous errors | |
| 23 | error[E0061]: this function takes 1 argument but 0 arguments were supplied | |
| 24 | --> $DIR/glob-glob-conflict.rs:10:8 | |
| 25 | | | |
| 26 | LL | fn method(&self) -> u8; | |
| 27 | | ^^^^^^ argument #1 of type `&_` is missing | |
| 28 | | | |
| 29 | note: method defined here | |
| 30 | --> $DIR/glob-glob-conflict.rs:10:8 | |
| 31 | | | |
| 32 | LL | fn method(&self) -> u8; | |
| 33 | | ^^^^^^ ---- | |
| 34 | help: provide the argument | |
| 35 | | | |
| 36 | LL | fn method(/* value */)(&self) -> u8; | |
| 37 | | +++++++++++++ | |
| 38 | ||
| 39 | error[E0308]: mismatched types | |
| 40 | --> $DIR/glob-glob-conflict.rs:10:8 | |
| 41 | | | |
| 42 | LL | fn method(&self) -> u8; | |
| 43 | | ^^^^^^- help: consider using a semicolon here: `;` | |
| 44 | | | | |
| 45 | | expected `()`, found `u8` | |
| 46 | | expected `()` because of default return type | |
| 47 | ||
| 48 | error[E0061]: this function takes 1 argument but 0 arguments were supplied | |
| 49 | --> $DIR/glob-glob-conflict.rs:5:8 | |
| 50 | | | |
| 51 | LL | fn method(&self) -> u8; | |
| 52 | | ^^^^^^ argument #1 of type `&_` is missing | |
| 53 | | | |
| 54 | note: method defined here | |
| 55 | --> $DIR/glob-glob-conflict.rs:5:8 | |
| 56 | | | |
| 57 | LL | fn method(&self) -> u8; | |
| 58 | | ^^^^^^ ---- | |
| 59 | help: provide the argument | |
| 60 | | | |
| 61 | LL | fn method(/* value */)(&self) -> u8; | |
| 62 | | +++++++++++++ | |
| 63 | ||
| 64 | error[E0308]: mismatched types | |
| 65 | --> $DIR/glob-glob-conflict.rs:5:8 | |
| 66 | | | |
| 67 | LL | fn method(&self) -> u8; | |
| 68 | | ^^^^^^- help: consider using a semicolon here: `;` | |
| 69 | | | | |
| 70 | | expected `()`, found `u8` | |
| 71 | | expected `()` because of default return type | |
| 72 | ||
| 73 | error: aborting due to 6 previous errors | |
| 24 | 74 | |
| 25 | For more information about this error, try `rustc --explain E0201`. | |
| 75 | Some errors have detailed explanations: E0061, E0201, E0308. | |
| 76 | For more information about an error, try `rustc --explain E0061`. |
tests/ui/delegation/ice-issue-124347.rs+2| ... | ... | @@ -4,9 +4,11 @@ |
| 4 | 4 | trait Trait { |
| 5 | 5 | reuse Trait::foo { &self.0 } |
| 6 | 6 | //~^ ERROR failed to resolve delegation callee |
| 7 | //~| ERROR: this function takes 0 arguments but 1 argument was supplied | |
| 7 | 8 | } |
| 8 | 9 | |
| 9 | 10 | reuse foo; |
| 10 | 11 | //~^ ERROR failed to resolve delegation callee |
| 12 | //~| WARN: function cannot return without recursing | |
| 11 | 13 | |
| 12 | 14 | fn main() {} |
tests/ui/delegation/ice-issue-124347.stderr+32-2| ... | ... | @@ -5,10 +5,40 @@ LL | reuse Trait::foo { &self.0 } |
| 5 | 5 | | ^^^ |
| 6 | 6 | |
| 7 | 7 | error: failed to resolve delegation callee |
| 8 | --> $DIR/ice-issue-124347.rs:9:7 | |
| 8 | --> $DIR/ice-issue-124347.rs:10:7 | |
| 9 | 9 | | |
| 10 | 10 | LL | reuse foo; |
| 11 | 11 | | ^^^ |
| 12 | 12 | |
| 13 | error: aborting due to 2 previous errors | |
| 13 | error[E0061]: this function takes 0 arguments but 1 argument was supplied | |
| 14 | --> $DIR/ice-issue-124347.rs:5:18 | |
| 15 | | | |
| 16 | LL | reuse Trait::foo { &self.0 } | |
| 17 | | ^^^ ------- unexpected argument | |
| 18 | | | |
| 19 | note: associated function defined here | |
| 20 | --> $DIR/ice-issue-124347.rs:5:18 | |
| 21 | | | |
| 22 | LL | reuse Trait::foo { &self.0 } | |
| 23 | | ^^^ | |
| 24 | help: remove the extra argument | |
| 25 | | | |
| 26 | LL - reuse Trait::foo { &self.0 } | |
| 27 | LL + reuse Trait::fo&self.0 } | |
| 28 | | | |
| 29 | ||
| 30 | warning: function cannot return without recursing | |
| 31 | --> $DIR/ice-issue-124347.rs:10:7 | |
| 32 | | | |
| 33 | LL | reuse foo; | |
| 34 | | ^^^ | |
| 35 | | | | |
| 36 | | cannot return without recursing | |
| 37 | | recursive call site | |
| 38 | | | |
| 39 | = help: a `loop` may express intention better if this is on purpose | |
| 40 | = note: `#[warn(unconditional_recursion)]` on by default | |
| 41 | ||
| 42 | error: aborting due to 3 previous errors; 1 warning emitted | |
| 14 | 43 | |
| 44 | For more information about this error, try `rustc --explain E0061`. |
tests/ui/delegation/recursive-delegation-errors.rs+6| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | mod first_mod { |
| 6 | 6 | reuse foo; |
| 7 | 7 | //~^ ERROR failed to resolve delegation callee |
| 8 | //~| WARN: function cannot return without recursing | |
| 8 | 9 | } |
| 9 | 10 | |
| 10 | 11 | mod second_mod { |
| ... | ... | @@ -33,8 +34,10 @@ mod fourth_mod { |
| 33 | 34 | trait Trait { |
| 34 | 35 | reuse Trait::foo as bar; |
| 35 | 36 | //~^ ERROR encountered a cycle during delegation signature resolution |
| 37 | //~| ERROR: type annotations needed | |
| 36 | 38 | reuse Trait::bar as foo; |
| 37 | 39 | //~^ ERROR encountered a cycle during delegation signature resolution |
| 40 | //~| ERROR: type annotations needed | |
| 38 | 41 | } |
| 39 | 42 | } |
| 40 | 43 | |
| ... | ... | @@ -48,6 +51,9 @@ mod fifth_mod { |
| 48 | 51 | //~^ ERROR encountered a cycle during delegation signature resolution |
| 49 | 52 | //~| ERROR encountered a cycle during delegation signature resolution |
| 50 | 53 | //~| ERROR encountered a cycle during delegation signature resolution |
| 54 | //~| ERROR: type annotations needed | |
| 55 | //~| ERROR: type annotations needed | |
| 56 | //~| ERROR: type annotations needed | |
| 51 | 57 | } |
| 52 | 58 | } |
| 53 | 59 |
tests/ui/delegation/recursive-delegation-errors.stderr+69-16| ... | ... | @@ -5,94 +5,147 @@ LL | reuse foo; |
| 5 | 5 | | ^^^ |
| 6 | 6 | |
| 7 | 7 | error: encountered a cycle during delegation signature resolution |
| 8 | --> $DIR/recursive-delegation-errors.rs:11:11 | |
| 8 | --> $DIR/recursive-delegation-errors.rs:12:11 | |
| 9 | 9 | | |
| 10 | 10 | LL | reuse foo as bar; |
| 11 | 11 | | ^^^ |
| 12 | 12 | |
| 13 | 13 | error: encountered a cycle during delegation signature resolution |
| 14 | --> $DIR/recursive-delegation-errors.rs:13:11 | |
| 14 | --> $DIR/recursive-delegation-errors.rs:14:11 | |
| 15 | 15 | | |
| 16 | 16 | LL | reuse bar as foo; |
| 17 | 17 | | ^^^ |
| 18 | 18 | |
| 19 | 19 | error: encountered a cycle during delegation signature resolution |
| 20 | --> $DIR/recursive-delegation-errors.rs:18:11 | |
| 20 | --> $DIR/recursive-delegation-errors.rs:19:11 | |
| 21 | 21 | | |
| 22 | 22 | LL | reuse foo as foo1; |
| 23 | 23 | | ^^^ |
| 24 | 24 | |
| 25 | 25 | error: encountered a cycle during delegation signature resolution |
| 26 | --> $DIR/recursive-delegation-errors.rs:20:11 | |
| 26 | --> $DIR/recursive-delegation-errors.rs:21:11 | |
| 27 | 27 | | |
| 28 | 28 | LL | reuse foo1 as foo2; |
| 29 | 29 | | ^^^^ |
| 30 | 30 | |
| 31 | 31 | error: encountered a cycle during delegation signature resolution |
| 32 | --> $DIR/recursive-delegation-errors.rs:22:11 | |
| 32 | --> $DIR/recursive-delegation-errors.rs:23:11 | |
| 33 | 33 | | |
| 34 | 34 | LL | reuse foo2 as foo3; |
| 35 | 35 | | ^^^^ |
| 36 | 36 | |
| 37 | 37 | error: encountered a cycle during delegation signature resolution |
| 38 | --> $DIR/recursive-delegation-errors.rs:24:11 | |
| 38 | --> $DIR/recursive-delegation-errors.rs:25:11 | |
| 39 | 39 | | |
| 40 | 40 | LL | reuse foo3 as foo4; |
| 41 | 41 | | ^^^^ |
| 42 | 42 | |
| 43 | 43 | error: encountered a cycle during delegation signature resolution |
| 44 | --> $DIR/recursive-delegation-errors.rs:26:11 | |
| 44 | --> $DIR/recursive-delegation-errors.rs:27:11 | |
| 45 | 45 | | |
| 46 | 46 | LL | reuse foo4 as foo5; |
| 47 | 47 | | ^^^^ |
| 48 | 48 | |
| 49 | 49 | error: encountered a cycle during delegation signature resolution |
| 50 | --> $DIR/recursive-delegation-errors.rs:28:11 | |
| 50 | --> $DIR/recursive-delegation-errors.rs:29:11 | |
| 51 | 51 | | |
| 52 | 52 | LL | reuse foo5 as foo; |
| 53 | 53 | | ^^^^ |
| 54 | 54 | |
| 55 | 55 | error: encountered a cycle during delegation signature resolution |
| 56 | --> $DIR/recursive-delegation-errors.rs:34:22 | |
| 56 | --> $DIR/recursive-delegation-errors.rs:35:22 | |
| 57 | 57 | | |
| 58 | 58 | LL | reuse Trait::foo as bar; |
| 59 | 59 | | ^^^ |
| 60 | 60 | |
| 61 | 61 | error: encountered a cycle during delegation signature resolution |
| 62 | --> $DIR/recursive-delegation-errors.rs:36:22 | |
| 62 | --> $DIR/recursive-delegation-errors.rs:38:22 | |
| 63 | 63 | | |
| 64 | 64 | LL | reuse Trait::bar as foo; |
| 65 | 65 | | ^^^ |
| 66 | 66 | |
| 67 | 67 | error: encountered a cycle during delegation signature resolution |
| 68 | --> $DIR/recursive-delegation-errors.rs:42:30 | |
| 68 | --> $DIR/recursive-delegation-errors.rs:45:30 | |
| 69 | 69 | | |
| 70 | 70 | LL | reuse super::fifth_mod::{bar as foo, foo as bar}; |
| 71 | 71 | | ^^^ |
| 72 | 72 | |
| 73 | 73 | error: encountered a cycle during delegation signature resolution |
| 74 | --> $DIR/recursive-delegation-errors.rs:42:42 | |
| 74 | --> $DIR/recursive-delegation-errors.rs:45:42 | |
| 75 | 75 | | |
| 76 | 76 | LL | reuse super::fifth_mod::{bar as foo, foo as bar}; |
| 77 | 77 | | ^^^ |
| 78 | 78 | |
| 79 | 79 | error: encountered a cycle during delegation signature resolution |
| 80 | --> $DIR/recursive-delegation-errors.rs:47:27 | |
| 80 | --> $DIR/recursive-delegation-errors.rs:50:27 | |
| 81 | 81 | | |
| 82 | 82 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; |
| 83 | 83 | | ^^^ |
| 84 | 84 | |
| 85 | 85 | error: encountered a cycle during delegation signature resolution |
| 86 | --> $DIR/recursive-delegation-errors.rs:47:39 | |
| 86 | --> $DIR/recursive-delegation-errors.rs:50:39 | |
| 87 | 87 | | |
| 88 | 88 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; |
| 89 | 89 | | ^^^ |
| 90 | 90 | |
| 91 | 91 | error: encountered a cycle during delegation signature resolution |
| 92 | --> $DIR/recursive-delegation-errors.rs:47:51 | |
| 92 | --> $DIR/recursive-delegation-errors.rs:50:51 | |
| 93 | 93 | | |
| 94 | 94 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; |
| 95 | 95 | | ^^^ |
| 96 | 96 | |
| 97 | error: aborting due to 16 previous errors | |
| 97 | error[E0283]: type annotations needed | |
| 98 | --> $DIR/recursive-delegation-errors.rs:35:22 | |
| 99 | | | |
| 100 | LL | reuse Trait::foo as bar; | |
| 101 | | ^^^ cannot infer type | |
| 102 | | | |
| 103 | = note: the type must implement `fourth_mod::Trait` | |
| 104 | ||
| 105 | error[E0283]: type annotations needed | |
| 106 | --> $DIR/recursive-delegation-errors.rs:38:22 | |
| 107 | | | |
| 108 | LL | reuse Trait::bar as foo; | |
| 109 | | ^^^ cannot infer type | |
| 110 | | | |
| 111 | = note: the type must implement `fourth_mod::Trait` | |
| 112 | ||
| 113 | error[E0283]: type annotations needed | |
| 114 | --> $DIR/recursive-delegation-errors.rs:50:27 | |
| 115 | | | |
| 116 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; | |
| 117 | | ^^^ cannot infer type | |
| 118 | | | |
| 119 | = note: the type must implement `GlobReuse` | |
| 120 | ||
| 121 | error[E0283]: type annotations needed | |
| 122 | --> $DIR/recursive-delegation-errors.rs:50:39 | |
| 123 | | | |
| 124 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; | |
| 125 | | ^^^ cannot infer type | |
| 126 | | | |
| 127 | = note: the type must implement `GlobReuse` | |
| 128 | ||
| 129 | error[E0283]: type annotations needed | |
| 130 | --> $DIR/recursive-delegation-errors.rs:50:51 | |
| 131 | | | |
| 132 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; | |
| 133 | | ^^^ cannot infer type | |
| 134 | | | |
| 135 | = note: the type must implement `GlobReuse` | |
| 136 | ||
| 137 | warning: function cannot return without recursing | |
| 138 | --> $DIR/recursive-delegation-errors.rs:6:11 | |
| 139 | | | |
| 140 | LL | reuse foo; | |
| 141 | | ^^^ | |
| 142 | | | | |
| 143 | | cannot return without recursing | |
| 144 | | recursive call site | |
| 145 | | | |
| 146 | = help: a `loop` may express intention better if this is on purpose | |
| 147 | = note: `#[warn(unconditional_recursion)]` on by default | |
| 148 | ||
| 149 | error: aborting due to 21 previous errors; 1 warning emitted | |
| 98 | 150 | |
| 151 | For more information about this error, try `rustc --explain E0283`. |
tests/ui/delegation/unlowered-path-ice-154820.rs created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | #![feature(fn_delegation)] | |
| 2 | #![allow(incomplete_features)] | |
| 3 | ||
| 4 | reuse foo:: < { //~ ERROR: failed to resolve delegation callee | |
| 5 | //~^ ERROR: function takes 0 generic arguments but 1 generic argument was supplied | |
| 6 | fn foo() {} | |
| 7 | reuse foo; | |
| 8 | //~^ ERROR: the name `foo` is defined multiple times | |
| 9 | } | |
| 10 | >; | |
| 11 | ||
| 12 | fn main() {} |
tests/ui/delegation/unlowered-path-ice-154820.stderr created+40| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | error[E0428]: the name `foo` is defined multiple times | |
| 2 | --> $DIR/unlowered-path-ice-154820.rs:7:5 | |
| 3 | | | |
| 4 | LL | fn foo() {} | |
| 5 | | -------- previous definition of the value `foo` here | |
| 6 | LL | reuse foo; | |
| 7 | | ^^^^^^^^^^ `foo` redefined here | |
| 8 | | | |
| 9 | = note: `foo` must be defined only once in the value namespace of this block | |
| 10 | ||
| 11 | error: failed to resolve delegation callee | |
| 12 | --> $DIR/unlowered-path-ice-154820.rs:4:7 | |
| 13 | | | |
| 14 | LL | reuse foo:: < { | |
| 15 | | ^^^ | |
| 16 | ||
| 17 | error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied | |
| 18 | --> $DIR/unlowered-path-ice-154820.rs:4:7 | |
| 19 | | | |
| 20 | LL | reuse foo:: < { | |
| 21 | | _______^^^- | |
| 22 | | | | | |
| 23 | | | expected 0 generic arguments | |
| 24 | LL | | | |
| 25 | LL | | fn foo() {} | |
| 26 | LL | | reuse foo; | |
| 27 | ... | | |
| 28 | LL | | >; | |
| 29 | | |___- help: remove the unnecessary generics | |
| 30 | | | |
| 31 | note: function defined here, with 0 generic parameters | |
| 32 | --> $DIR/unlowered-path-ice-154820.rs:4:7 | |
| 33 | | | |
| 34 | LL | reuse foo:: < { | |
| 35 | | ^^^ | |
| 36 | ||
| 37 | error: aborting due to 3 previous errors | |
| 38 | ||
| 39 | Some errors have detailed explanations: E0107, E0428. | |
| 40 | For more information about an error, try `rustc --explain E0107`. |
tests/ui/generic-const-items/def-site-eval.fail.stderr+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | error[E0080]: evaluation panicked: explicit panic |
| 2 | --> $DIR/def-site-eval.rs:13:20 | |
| 2 | --> $DIR/def-site-eval.rs:32:20 | |
| 3 | 3 | | |
| 4 | 4 | LL | const _<'_a>: () = panic!(); |
| 5 | 5 | | ^^^^^^^^ evaluation of `_` failed here |
tests/ui/generic-const-items/def-site-eval.rs+23-6| ... | ... | @@ -1,15 +1,32 @@ |
| 1 | //! Test that we only evaluate free const items (their def site to be clear) | |
| 2 | //! whose generics don't require monomorphization. | |
| 1 | // Test that we don't evaluate the initializer of free const items if they have | |
| 2 | // non-region generic parameters (i.e., ones that "require monomorphization"). | |
| 3 | // | |
| 4 | // To peek behind the curtains for a bit, at the time of writing there are three places where we | |
| 5 | // usually evaluate the initializer: "analysis", mono item collection & reachability analysis. | |
| 6 | // We must ensure that all of them take the generics into account. | |
| 7 | // | |
| 8 | //@ revisions: fail pass | |
| 9 | //@[pass] check-pass | |
| 10 | ||
| 3 | 11 | #![feature(generic_const_items)] |
| 4 | 12 | #![expect(incomplete_features)] |
| 13 | #![crate_type = "lib"] // (*) | |
| 5 | 14 | |
| 6 | //@ revisions: fail pass | |
| 7 | //@[pass] check-pass | |
| 15 | // All of these constants are intentionally unused since we want to test the | |
| 16 | // behavior at the def site, not at use sites. | |
| 8 | 17 | |
| 9 | 18 | const _<_T>: () = panic!(); |
| 10 | 19 | const _<const _N: usize>: () = panic!(); |
| 11 | 20 | |
| 21 | // Check *public* const items specifically to exercise reachability analysis which normally | |
| 22 | // evaluates const initializers to look for function pointers in the final const value. | |
| 23 | // | |
| 24 | // (*): While reachability analysis also runs for purely binary crates (to find e.g., extern items) | |
| 25 | // setting the crate type to library (1) makes the case below 'more realistic' since | |
| 26 | // hypothetical downstream crates that require runtime MIR could actually exist. | |
| 27 | // (2) It ensures that we exercise the relevant part of the compiler under test. | |
| 28 | pub const K<_T>: () = panic!(); | |
| 29 | pub const Q<const _N: usize>: () = loop {}; | |
| 30 | ||
| 12 | 31 | #[cfg(fail)] |
| 13 | 32 | const _<'_a>: () = panic!(); //[fail]~ ERROR evaluation panicked: explicit panic |
| 14 | ||
| 15 | fn main() {} |
tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | #![feature(generic_const_items, trivial_bounds)] | |
| 2 | #![allow(incomplete_features)] | |
| 3 | ||
| 4 | // Ensure that we check if trivial bounds on const items hold or not. | |
| 5 | ||
| 6 | const UNUSABLE: () = () //~ ERROR entering unreachable code | |
| 7 | where | |
| 8 | String: Copy; | |
| 9 | ||
| 10 | fn main() { | |
| 11 | let _ = UNUSABLE; //~ ERROR the trait bound `String: Copy` is not satisfied | |
| 12 | } |
tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr deleted-27| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | error[E0080]: entering unreachable code | |
| 2 | --> $DIR/trivially-unsatisfied-bounds-0.rs:6:1 | |
| 3 | | | |
| 4 | LL | / const UNUSABLE: () = () | |
| 5 | LL | | where | |
| 6 | LL | | String: Copy; | |
| 7 | | |_________________^ evaluation of `UNUSABLE` failed here | |
| 8 | ||
| 9 | error[E0277]: the trait bound `String: Copy` is not satisfied | |
| 10 | --> $DIR/trivially-unsatisfied-bounds-0.rs:11:13 | |
| 11 | | | |
| 12 | LL | let _ = UNUSABLE; | |
| 13 | | ^^^^^^^^ the trait `Copy` is not implemented for `String` | |
| 14 | | | |
| 15 | note: required by a bound in `UNUSABLE` | |
| 16 | --> $DIR/trivially-unsatisfied-bounds-0.rs:8:13 | |
| 17 | | | |
| 18 | LL | const UNUSABLE: () = () | |
| 19 | | -------- required by a bound in this constant | |
| 20 | LL | where | |
| 21 | LL | String: Copy; | |
| 22 | | ^^^^ required by this bound in `UNUSABLE` | |
| 23 | ||
| 24 | error: aborting due to 2 previous errors | |
| 25 | ||
| 26 | Some errors have detailed explanations: E0080, E0277. | |
| 27 | For more information about an error, try `rustc --explain E0080`. |
tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | #![feature(generic_const_items, trivial_bounds)] | |
| 2 | #![allow(incomplete_features, dead_code, trivial_bounds)] | |
| 3 | ||
| 4 | // FIXME(generic_const_items): This looks like a bug to me. I expected that we wouldn't emit any | |
| 5 | // errors. I thought we'd skip the evaluation of consts whose bounds don't hold. | |
| 6 | ||
| 7 | const UNUSED: () = () | |
| 8 | where | |
| 9 | String: Copy; | |
| 10 | //~^^^ ERROR unreachable code | |
| 11 | ||
| 12 | fn main() {} |
tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | error[E0080]: entering unreachable code | |
| 2 | --> $DIR/trivially-unsatisfied-bounds-1.rs:7:1 | |
| 3 | | | |
| 4 | LL | / const UNUSED: () = () | |
| 5 | LL | | where | |
| 6 | LL | | String: Copy; | |
| 7 | | |_________________^ evaluation of `UNUSED` failed here | |
| 8 | ||
| 9 | error: aborting due to 1 previous error | |
| 10 | ||
| 11 | For more information about this error, try `rustc --explain E0080`. |
tests/ui/generic-const-items/trivially-unsatisfied-bounds.mentioned.stderr created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | error[E0080]: entering unreachable code | |
| 2 | --> $DIR/trivially-unsatisfied-bounds.rs:17:1 | |
| 3 | | | |
| 4 | LL | / const UNUSABLE: () = () | |
| 5 | LL | | where | |
| 6 | LL | | for<'_delay> String: Copy; | |
| 7 | | |______________________________^ evaluation of `UNUSABLE` failed here | |
| 8 | ||
| 9 | error[E0277]: the trait bound `String: Copy` is not satisfied | |
| 10 | --> $DIR/trivially-unsatisfied-bounds.rs:24:13 | |
| 11 | | | |
| 12 | LL | let _ = UNUSABLE; | |
| 13 | | ^^^^^^^^ the trait `Copy` is not implemented for `String` | |
| 14 | | | |
| 15 | note: required by a bound in `UNUSABLE` | |
| 16 | --> $DIR/trivially-unsatisfied-bounds.rs:19:26 | |
| 17 | | | |
| 18 | LL | const UNUSABLE: () = () | |
| 19 | | -------- required by a bound in this constant | |
| 20 | LL | where | |
| 21 | LL | for<'_delay> String: Copy; | |
| 22 | | ^^^^ required by this bound in `UNUSABLE` | |
| 23 | ||
| 24 | error: aborting due to 2 previous errors | |
| 25 | ||
| 26 | Some errors have detailed explanations: E0080, E0277. | |
| 27 | For more information about an error, try `rustc --explain E0080`. |
tests/ui/generic-const-items/trivially-unsatisfied-bounds.rs created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | // Exercise trivially unsatisfied bounds on free const items. | |
| 2 | // Their interaction with the evaluation of the initializer is interesting. | |
| 3 | // | |
| 4 | //@ revisions: mentioned unmentioned | |
| 5 | ||
| 6 | #![feature(generic_const_items)] | |
| 7 | ||
| 8 | // FIXME(generic_const_items): Try to get rid of error "entering unreachable error", it's | |
| 9 | // unnecessary and actually caused by MIR pass `ImpossiblePredicates` replacing the body with the | |
| 10 | // terminator `Unreachable` due to the unsatisfied bound which is subsequently reached. | |
| 11 | // | |
| 12 | // NOTE(#142293): However, don't think about suppressing the evaluation of the initializer if the | |
| 13 | // bounds are "impossible". That'd be a SemVer hazard since it could cause downstream to fail to | |
| 14 | // compile if upstream added a new trait impl which is undesirable[^1]. | |
| 15 | // [^1]: Strictly speaking that's already possible due to the one-impl rule. | |
| 16 | ||
| 17 | const UNUSABLE: () = () //~ ERROR entering unreachable code | |
| 18 | where | |
| 19 | for<'_delay> String: Copy; | |
| 20 | ||
| 21 | fn scope() { | |
| 22 | // Ensure that we successfully reject references of consts with trivially unsatisfied bounds. | |
| 23 | #[cfg(mentioned)] | |
| 24 | let _ = UNUSABLE; //[mentioned]~ ERROR the trait bound `String: Copy` is not satisfied | |
| 25 | } | |
| 26 | ||
| 27 | const _BAD: () = <() as Unimplemented>::CT | |
| 28 | where | |
| 29 | for<'_delay> (): Unimplemented; | |
| 30 | ||
| 31 | trait Unimplemented { const CT: (); } | |
| 32 | ||
| 33 | fn main() {} |
tests/ui/generic-const-items/trivially-unsatisfied-bounds.unmentioned.stderr created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | error[E0080]: entering unreachable code | |
| 2 | --> $DIR/trivially-unsatisfied-bounds.rs:17:1 | |
| 3 | | | |
| 4 | LL | / const UNUSABLE: () = () | |
| 5 | LL | | where | |
| 6 | LL | | for<'_delay> String: Copy; | |
| 7 | | |______________________________^ evaluation of `UNUSABLE` failed here | |
| 8 | ||
| 9 | error: aborting due to 1 previous error | |
| 10 | ||
| 11 | For more information about this error, try `rustc --explain E0080`. |
tests/ui/impl-trait/associated-impl-trait-type-into-emplacable.rs created+52| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | //! add regression test for <https://github.com/rust-lang/rust/issues/146514>. | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | ||
| 5 | #![feature(impl_trait_in_assoc_type)] | |
| 6 | ||
| 7 | use std::marker::PhantomData; | |
| 8 | ||
| 9 | struct Emp<T, F> { | |
| 10 | phantom: PhantomData<(*const T, F)>, | |
| 11 | } | |
| 12 | ||
| 13 | impl<T, F> Emp<T, F> { | |
| 14 | fn from_fn(_: F) -> Emp<T, F> { | |
| 15 | loop {} | |
| 16 | } | |
| 17 | ||
| 18 | fn unsize(self) -> Emp<Slice, impl Sized> { | |
| 19 | Emp::from_fn(|| ()) | |
| 20 | } | |
| 21 | } | |
| 22 | ||
| 23 | trait IntoEmplacable { | |
| 24 | type Closure; | |
| 25 | ||
| 26 | fn into_emplacable(self) -> Emp<Slice, Self::Closure>; | |
| 27 | } | |
| 28 | ||
| 29 | impl<F> IntoEmplacable for Emp<Arr, F> { | |
| 30 | type Closure = impl Sized; | |
| 31 | ||
| 32 | fn into_emplacable(self) -> Emp<Slice, Self::Closure> { | |
| 33 | self.unsize() | |
| 34 | } | |
| 35 | } | |
| 36 | ||
| 37 | impl<F> Into<Emp<Slice, <Emp<Arr, F> as IntoEmplacable>::Closure>> for Emp<Arr, F> { | |
| 38 | fn into(self) -> Emp<Slice, <Emp<Arr, F> as IntoEmplacable>::Closure> { | |
| 39 | self.into_emplacable() | |
| 40 | } | |
| 41 | } | |
| 42 | ||
| 43 | fn box_new_with(_: Emp<Slice, impl Sized>) {} | |
| 44 | ||
| 45 | pub struct Arr; | |
| 46 | pub struct Slice; | |
| 47 | ||
| 48 | pub fn foo() { | |
| 49 | let e: Emp<Arr, ()> = Emp { phantom: PhantomData }; | |
| 50 | box_new_with(e.into()); | |
| 51 | } | |
| 52 | fn main() {} |
tests/ui/intrinsics/transmute-phantomdata-generic-unequal-size.rs created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | //! regression test for <https://github.com/rust-lang/rust/issues/32377> | |
| 2 | //@ normalize-stderr: "\d+ bits" -> "N bits" | |
| 3 | ||
| 4 | use std::mem; | |
| 5 | use std::marker::PhantomData; | |
| 6 | ||
| 7 | trait Foo { | |
| 8 | type Error; | |
| 9 | } | |
| 10 | ||
| 11 | struct Bar<U: Foo> { | |
| 12 | stream: PhantomData<U::Error>, | |
| 13 | } | |
| 14 | ||
| 15 | fn foo<U: Foo>(x: [usize; 2]) -> Bar<U> { | |
| 16 | unsafe { mem::transmute(x) } | |
| 17 | //~^ ERROR cannot transmute between types of different sizes, or dependently-sized types | |
| 18 | } | |
| 19 | ||
| 20 | fn main() {} |
tests/ui/intrinsics/transmute-phantomdata-generic-unequal-size.stderr created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | |
| 2 | --> $DIR/transmute-phantomdata-generic-unequal-size.rs:16:14 | |
| 3 | | | |
| 4 | LL | unsafe { mem::transmute(x) } | |
| 5 | | ^^^^^^^^^^^^^^ | |
| 6 | | | |
| 7 | = note: source type: `[usize; 2]` (N bits) | |
| 8 | = note: target type: `Bar<U>` (N bits) | |
| 9 | ||
| 10 | error: aborting due to 1 previous error | |
| 11 | ||
| 12 | For more information about this error, try `rustc --explain E0512`. |
tests/ui/issues/issue-25746-bool-transmute.rs deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | //@ run-pass | |
| 2 | #![allow(unnecessary_transmutes)] | |
| 3 | use std::mem::transmute; | |
| 4 | ||
| 5 | fn main() { | |
| 6 | unsafe { | |
| 7 | let _: i8 = transmute(false); | |
| 8 | let _: i8 = transmute(true); | |
| 9 | let _: bool = transmute(0u8); | |
| 10 | let _: bool = transmute(1u8); | |
| 11 | } | |
| 12 | } |
tests/ui/issues/issue-32377.rs deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | //@ normalize-stderr: "\d+ bits" -> "N bits" | |
| 2 | ||
| 3 | use std::mem; | |
| 4 | use std::marker::PhantomData; | |
| 5 | ||
| 6 | trait Foo { | |
| 7 | type Error; | |
| 8 | } | |
| 9 | ||
| 10 | struct Bar<U: Foo> { | |
| 11 | stream: PhantomData<U::Error>, | |
| 12 | } | |
| 13 | ||
| 14 | fn foo<U: Foo>(x: [usize; 2]) -> Bar<U> { | |
| 15 | unsafe { mem::transmute(x) } | |
| 16 | //~^ ERROR cannot transmute between types of different sizes, or dependently-sized types | |
| 17 | } | |
| 18 | ||
| 19 | fn main() {} |
tests/ui/issues/issue-32377.stderr deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | |
| 2 | --> $DIR/issue-32377.rs:15:14 | |
| 3 | | | |
| 4 | LL | unsafe { mem::transmute(x) } | |
| 5 | | ^^^^^^^^^^^^^^ | |
| 6 | | | |
| 7 | = note: source type: `[usize; 2]` (N bits) | |
| 8 | = note: target type: `Bar<U>` (N bits) | |
| 9 | ||
| 10 | error: aborting due to 1 previous error | |
| 11 | ||
| 12 | For more information about this error, try `rustc --explain E0512`. |
tests/ui/transmute/transmute-bool-u8.rs created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | //! regression test for <https://github.com/rust-lang/rust/issues/25746> | |
| 2 | //@ build-pass | |
| 3 | #![allow(unnecessary_transmutes)] | |
| 4 | use std::mem::transmute; | |
| 5 | ||
| 6 | fn main() { | |
| 7 | unsafe { | |
| 8 | let _: i8 = transmute(false); | |
| 9 | let _: i8 = transmute(true); | |
| 10 | let _: bool = transmute(0u8); | |
| 11 | let _: bool = transmute(1u8); | |
| 12 | } | |
| 13 | } |