about summary refs log tree commit diff
path: root/compiler/rustc_hir/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-11-20Remove unused feature.Nicholas Nethercote-1/+0
2023-08-23Bump cfg(bootstrap)Mark Rousskov-1/+1
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-05-16Remove `LangItems::require`Nilstrieb-1/+0
It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
2022-11-23Separate lifetime ident from resolution in HIR.Camille GILLOT-0/+1
2022-10-29Cleanup weak lang itemsCameron Steffen-1/+0
2022-10-29Use an array in LanguageItemsCameron Steffen-0/+1
2022-09-26remove cfg(bootstrap)Pietro Albini-1/+0
2022-09-23Stabilize const `BTree{Map,Set}::new`Nilstrieb-1/+1
Since `len` and `is_empty` are not const stable yet, this also creates a new feature for them since they previously used the same `const_btree_new` feature.
2022-09-15Only enable the let_else feature on bootstrapest31-1/+1
On later stages, the feature is already stable. Result of running: rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-0/+3
by module
2022-08-25allow non-monomorphize modules to access hard-coded error message through ↵Nathan Stocks-0/+1
new struct, use fluent message in monomorphize
2022-08-18Add diagnostic translation lints to crates that don't emit them5225225-0/+2
2022-07-06Make AST lowering a query.Camille GILLOT-0/+4
2022-06-21Only keep a single well-formed query.Camille GILLOT-1/+0
2022-05-31Apply track_caller to closure on `expect_non_local()`Yuki Okushi-0/+1
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-1/+0
2022-03-08add `#[rustc_pass_by_value]` to more typeslcnr-0/+1
2022-02-19Adopt let else in more placesest31-0/+1
2022-01-16Replace NestedVisitorMap with NestedFilterCameron Steffen-0/+1
2021-12-13Remove `in_band_lifetimes` from `rustc_hir`Peter Jaszkowiak-1/+0
2021-10-10Directly use AttributeMap inside OwnerInfo.Camille GILLOT-0/+1
2021-10-09Perform indexing during lowering.Camille GILLOT-0/+1
Do not access DefId<->HirId maps before they are initialized.
2021-10-06Introduce get_diagnostic_nameCameron Steffen-0/+1
2021-09-14Use on-disk-hash-table format for DefPathHashMap in hir::definitions.Michael Woerister-0/+1
2021-06-28Update to new bootstrap compilerMark Rousskov-1/+0
2021-05-31Remove unused feature gatesbjorn3-2/+0
2021-05-26Specialize implementationsJacob Pratt-0/+2
Implementations in stdlib are now optimized as they were before.
2021-05-24remove cfg(bootstrap)Pietro Albini-1/+0
2021-05-18Stabilize extended_key_value_attributesJoshua Nelson-1/+1
# Stabilization report ## Summary This stabilizes using macro expansion in key-value attributes, like so: ```rust #[doc = include_str!("my_doc.md")] struct S; #[path = concat!(env!("OUT_DIR"), "/generated.rs")] mod m; ``` See the changes to the reference for details on what macros are allowed; see Petrochenkov's excellent blog post [on internals](https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455) for alternatives that were considered and rejected ("why accept no more and no less?") This has been available on nightly since 1.50 with no major issues. ## Notes ### Accepted syntax The parser accepts arbitrary Rust expressions in this position, but any expression other than a macro invocation will ultimately lead to an error because it is not expected by the built-in expression forms (e.g., `#[doc]`). Note that decorators and the like may be able to observe other expression forms. ### Expansion ordering Expansion of macro expressions in "inert" attributes occurs after decorators have executed, analogously to macro expressions appearing in the function body or other parts of decorator input. There is currently no way for decorators to accept macros in key-value position if macro expansion must be performed before the decorator executes (if the macro can simply be copied into the output for later expansion, that can work). ## Test cases - https://github.com/rust-lang/rust/blob/master/src/test/ui/attributes/key-value-expansion-on-mac.rs - https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/external-doc.rs The feature has also been dogfooded extensively in the compiler and standard library: - https://github.com/rust-lang/rust/pull/83329 - https://github.com/rust-lang/rust/pull/83230 - https://github.com/rust-lang/rust/pull/82641 - https://github.com/rust-lang/rust/pull/80534 ## Implementation history - Initial proposal: https://github.com/rust-lang/rust/issues/55414#issuecomment-554005412 - Experiment to see how much code it would break: https://github.com/rust-lang/rust/pull/67121 - Preliminary work to restrict expansion that would conflict with this feature: https://github.com/rust-lang/rust/pull/77271 - Initial implementation: https://github.com/rust-lang/rust/pull/78837 - Fix for an ICE: https://github.com/rust-lang/rust/pull/80563 ## Unresolved Questions ~~https://github.com/rust-lang/rust/pull/83366#issuecomment-805180738 listed some concerns, but they have been resolved as of this final report.~~ ## Additional Information There are two workarounds that have a similar effect for `#[doc]` attributes on nightly. One is to emulate this behavior by using a limited version of this feature that was stabilized for historical reasons: ```rust macro_rules! forward_inner_docs { ($e:expr => $i:item) => { #[doc = $e] $i }; } forward_inner_docs!(include_str!("lib.rs") => struct S {}); ``` This also works for other attributes (like `#[path = concat!(...)]`). The other is to use `doc(include)`: ```rust #![feature(external_doc)] #[doc(include = "lib.rs")] struct S {} ``` The first works, but is non-trivial for people to discover, and difficult to read and maintain. The second is a strange special-case for a particular use of the macro. This generalizes it to work for any use case, not just including files. I plan to remove `doc(include)` when this is stabilized. The `forward_inner_docs` workaround will still compile without warnings, but I expect it to be used less once it's no longer necessary.
2021-04-18fix feature use in rustc libsRalf Jung-1/+0
2021-03-19stabilize or_patternsmark-1/+1
2021-03-11Auto merge of #82641 - camelid:lang-item-docs, r=jyn514bors-0/+1
Improve lang item generated docs cc https://rust-lang.zulipchat.com/#narrow/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F/near/226738260 r? `@jyn514`
2021-03-07Auto merge of #81635 - michaelwoerister:structured_def_path_hash, r=pnkfelixbors-0/+3
Let a portion of DefPathHash uniquely identify the DefPath's crate. This allows to directly map from a `DefPathHash` to the crate it originates from, without constructing side tables to do that mapping -- something that is useful for incremental compilation where we deal with `DefPathHash` instead of `DefId` a lot. It also allows to reliably and cheaply check for `DefPathHash` collisions which allows the compiler to gracefully abort compilation instead of running into a subsequent ICE at some random place in the code. The following new piece of documentation describes the most interesting aspects of the changes: ```rust /// A `DefPathHash` is a fixed-size representation of a `DefPath` that is /// stable across crate and compilation session boundaries. It consists of two /// separate 64-bit hashes. The first uniquely identifies the crate this /// `DefPathHash` originates from (see [StableCrateId]), and the second /// uniquely identifies the corresponding `DefPath` within that crate. Together /// they form a unique identifier within an entire crate graph. /// /// There is a very small chance of hash collisions, which would mean that two /// different `DefPath`s map to the same `DefPathHash`. Proceeding compilation /// with such a hash collision would very probably lead to an ICE and, in the /// worst case, to a silent mis-compilation. The compiler therefore actively /// and exhaustively checks for such hash collisions and aborts compilation if /// it finds one. /// /// `DefPathHash` uses 64-bit hashes for both the crate-id part and the /// crate-internal part, even though it is likely that there are many more /// `LocalDefId`s in a single crate than there are individual crates in a crate /// graph. Since we use the same number of bits in both cases, the collision /// probability for the crate-local part will be quite a bit higher (though /// still very small). /// /// This imbalance is not by accident: A hash collision in the /// crate-local part of a `DefPathHash` will be detected and reported while /// compiling the crate in question. Such a collision does not depend on /// outside factors and can be easily fixed by the crate maintainer (e.g. by /// renaming the item in question or by bumping the crate version in a harmless /// way). /// /// A collision between crate-id hashes on the other hand is harder to fix /// because it depends on the set of crates in the entire crate graph of a /// compilation session. Again, using the same crate with a different version /// number would fix the issue with a high probability -- but that might be /// easier said then done if the crates in questions are dependencies of /// third-party crates. /// /// That being said, given a high quality hash function, the collision /// probabilities in question are very small. For example, for a big crate like /// `rustc_middle` (with ~50000 `LocalDefId`s as of the time of writing) there /// is a probability of roughly 1 in 14,750,000,000 of a crate-internal /// collision occurring. For a big crate graph with 1000 crates in it, there is /// a probability of 1 in 36,890,000,000,000 of a `StableCrateId` collision. ``` Given the probabilities involved I hope that no one will ever actually see the error messages. Nonetheless, I'd be glad about some feedback on how to improve them. Should we create a GH issue describing the problem and possible solutions to point to? Or a page in the rustc book? r? `@pnkfelix` (feel free to re-assign)
2021-02-28Enable `extended_key_value_attributes` in `rustc_hir`Camelid-0/+1
2021-02-04Add unit test to ensure that both parts of a DefPathHash depend on the ↵Michael Woerister-0/+3
defining crate's ID.
2021-02-04Stabilize feature(iterator_fold_self): Iterator::reduceMara Bos-1/+0
2021-01-31Rollup merge of #80470 - SimonSapin:array-intoiter-type, r=m-ou-seJonas Schievink-1/+0
Stabilize by-value `[T; N]` iterator `core::array::IntoIter` Tracking issue: https://github.com/rust-lang/rust/issues/65798 This is unblocked now that `min_const_generics` has been stabilized in https://github.com/rust-lang/rust/pull/79135. This PR does *not* include the corresponding `IntoIterator` impl, which is https://github.com/rust-lang/rust/pull/65819. Instead, an iterator can be constructed through the `new` method. `new` would become unnecessary when `IntoIterator` is implemented and might be deprecated then, although it will stay stable.
2021-01-10Rework diagnostics for wrong number of generic argsPatryk Wychowaniec-0/+1
2020-12-29Stabilize by-value `[T; N]` iterator `core::array::IntoIter`Simon Sapin-1/+0
Tracking issue: https://github.com/rust-lang/rust/issues/65798 This is unblocked now that `min_const_generics` has been stabilized in https://github.com/rust-lang/rust/pull/79135. This PR does *not* include the corresponding `IntoIterator` impl, which is https://github.com/rust-lang/rust/pull/65819. Instead, an iterator can be constructed through the `new` method. `new` would become unnecessary when `IntoIterator` is implemented and might be deprecated then, although it will stay stable.
2020-09-05[WIP] give better errors for broken intra doc linksJoshua Nelson-0/+1
2020-09-01hir: replace `lazy_static` by `SyncLazy` from stdmarmeladema-0/+1
2020-08-30mv compiler to compiler/mark-0/+36