about summary refs log tree commit diff
path: root/compiler/rustc_hir/src
AgeCommit message (Collapse)AuthorLines
2022-04-15Rollup merge of #95194 - kckeiks:update-algo-in-find-use-placement, r=pnkfelixDylan DPC-4/+10
remove find_use_placement A more robust solution to finding where to place use suggestions was added in #94584. The algorithm uses the AST to find the span for the suggestion so we pass this span down to the HIR during lowering and use it instead of calling `find_use_placement` Fixes #94941
2022-04-14library: Move `CStr` to libcore, and `CString` to liballocVadim Petrochenkov-0/+2
2022-04-14Reimplement lowering of sym operands for asm! so that it also works with ↵Amanieu d'Antras-11/+20
global_asm!
2022-04-13Auto merge of #95656 - cjgillot:no-id-hashing-mode, r=Aaron1011bors-114/+14
Remove NodeIdHashingMode. r? `@ghost`
2022-04-12Rollup merge of #95970 - WaffleLapkin:nicer_trait_suggestions, r=compiler-errorsDylan DPC-1/+35
Fix suggestions in case of `T:` bounds This PR fixes a corner case in `suggest_constraining_type_params` that was causing incorrect suggestions. For the following functions: ```rust fn a<T:>(t: T) { [t, t]; } fn b<T>(t: T) where T: { [t, t]; } ``` We previously suggested the following: ```text ... help: consider restricting type parameter `T` | 1 | fn a<T: Copy:>(t: T) { [t, t]; } | ++++++ ... help: consider further restricting this bound | 2 | fn b<T>(t: T) where T: + Copy { [t, t]; } | ++++++ ``` Note that neither `T: Copy:` not `where T: + Copy` is a correct bound. With this commit the suggestions are correct: ```text ... help: consider restricting type parameter `T` | 1 | fn a<T: Copy>(t: T) { [t, t]; } | ++++ ... help: consider further restricting this bound | 2 | fn b<T>(t: T) where T: Copy { [t, t]; } | ++++ ``` r? `@compiler-errors` I've tried fixing #95898 here too, but got too confused with how `suggest_traits_to_import` works and what it does :sweat_smile:
2022-04-12Remove NodeIdHashingMode.Camille GILLOT-114/+14
2022-04-12Fix wrong suggestions for `T:`Maybe Waffle-1/+35
This commit fixes a corner case in `suggest_constraining_type_params` that was causing incorrect suggestions. For the following functions: ```rust fn a<T:>(t: T) { [t, t]; } fn b<T>(t: T) where T: { [t, t]; } ``` We previously suggested the following: ```text ... help: consider restricting type parameter `T` | 1 | fn a<T: Copy:>(t: T) { [t, t]; } | ++++++ ... help: consider further restricting this bound | 2 | fn b<T>(t: T) where T: + Copy { [t, t]; } | ++++++ ``` Note that neither `T: Copy:` not `where T: + Copy` is a correct bound. With this commit the suggestions are correct: ```text ... help: consider restricting type parameter `T` | 1 | fn a<T: Copy>(t: T) { [t, t]; } | ++++ ... help: consider further restricting this bound | 2 | fn b<T>(t: T) where T: Copy { [t, t]; } | ++++ ```
2022-04-10Avoid accessing HIR from MIR queries.Camille GILLOT-0/+8
2022-04-09add comment about restriction of Target::from_def_kindMiguel Guarniz-0/+1
2022-04-09Use def_key in `tcx.item_name` when possible.Camille GILLOT-0/+5
2022-04-08add mapping from DefKind to Target and remove more ItemLikeVisitor implsMiguel Guarniz-0/+24
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-06Fix unit struct/enum variant in destructuring assignmentMichael Goulet-0/+5
2022-04-05span: move `MultiSpan`David Wood-1/+2
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-03-31remove find_use_placementFausto-4/+10
A more robust solution to finding where to place use suggestions was added. The algorithm uses the AST to find the span for the suggestion so we pass this span down to the HIR during lowering and use it. Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-03-31Store next_disambiguator in Definitions.Camille GILLOT-2/+9
2022-03-30Auto merge of #95436 - cjgillot:static-mut, r=oli-obkbors-4/+4
Remember mutability in `DefKind::Static`. This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-30Auto merge of #94963 - lcnr:inherent-impls-std, r=oli-obk,m-ou-sebors-30/+0
allow arbitrary inherent impls for builtin types in core Part of https://github.com/rust-lang/compiler-team/issues/487. Slightly adjusted after some talks with `@m-ou-se` about the requirements of `t-libs-api`. This adds a crate attribute `#![rustc_coherence_is_core]` which allows arbitrary impls for builtin types in core. For other library crates impls for builtin types should be avoided if possible. We do have to allow the existing stable impls however. To prevent us from accidentally adding more of these in the future, there is a second attribute `#[rustc_allow_incoherent_impl]` which has to be added to **all impl items**. This only supports impls for builtin types but can easily be extended to additional types in a future PR. This implementation does not check for overlaps in these impls. Perfectly checking that requires us to check the coherence of these incoherent impls in every crate, as two distinct dependencies may add overlapping methods. It should be easy enough to detect if it goes wrong and the attribute is only intended for use inside of std. The first two commits are mostly unrelated cleanups.
2022-03-30remove now unnecessary lang itemslcnr-30/+0
2022-03-30Rollup merge of #95461 - nyurik:spelling, r=lcnrDylan DPC-2/+2
Spellchecking some comments This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30Spellchecking compiler codeYuri Astrakhan-1/+1
Address some spelling mistakes in strings, private function names, and function params.
2022-03-30Spellchecking some commentsYuri Astrakhan-2/+2
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-4/+4
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-21Rename `~const Drop` to `~const Destruct`Deadbeef-1/+1
2022-03-21Add `Destructible` for replacing `~const Drop`Deadbeef-0/+1
2022-03-19Give more details in `Display` for `hir::Target`Scott McMurray-1/+5
Made because I was making a code change and got a very confusing "should be applied to a method, not a method" error. ``` error[E0718]: `into_try_type` language item must be applied to a method --> library\core\src\ops\try_trait.rs:352:32 | 352 | #[cfg_attr(not(bootstrap), lang = "into_try_type")] | ^^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a method, not a method ```
2022-03-12Identify anonymous lifetimes by their DefId in HIR.Camille GILLOT-2/+2
2022-03-08add `#[rustc_pass_by_value]` to more typeslcnr-0/+2
2022-03-01compiler: fix some typoscuishuang-1/+1
2022-02-24Remove in-band lifetimesMichael Goulet-5/+0
2022-02-24resolve: Fix incorrect results of `opt_def_kind` query for some built-in macrosVadim Petrochenkov-2/+3
Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
2022-02-24Auto merge of #93438 - spastorino:node_id_to_hir_id_refactor, r=oli-obkbors-0/+13
Node id to hir id refactor Related to #89278 r? `@oli-obk`
2022-02-23Rollup merge of #94137 - aDotInTheVoid:abi-enum, r=CraftSpiderMatthias Krüger-0/+4
rustdoc-json: Better Header Type - Make ABI an enum, instead of being stringly typed - Replace Qualifier HashSet with 3 bools - Merge ABI field into header, as they always occor together r? ``@CraftSpider`` ``@rustbot`` modify labels: +A-rustdoc-json +T-rustdoc
2022-02-20Make node_id_to_hir_id owner-local.Camille GILLOT-0/+13
2022-02-19Adopt let else in more placesest31-3/+3
2022-02-18rustdoc-json: Better Header TypeNixon Enraght-Moony-0/+4
- Make ABI an enum, instead of being stringly typed - Replace Qualifier HashSet with 3 bools - Merge ABI field into header, as they always occor together
2022-02-14Auto merge of #93938 - BoxyUwU:fix_res_self_ty, r=lcnrbors-36/+43
Make `Res::SelfTy` a struct variant and update docs I found pattern matching on a `(Option<DefId>, Option<(DefId, bool)>)` to not be super readable, additionally the doc comments on the types in a tuple variant aren't visible anywhere at use sites as far as I can tell (using rust analyzer + vscode) The docs incorrectly assumed that the `DefId` in `Option<(DefId, bool)>` would only ever be for an impl item and I also found the code examples to be somewhat unclear about which `DefId` was being talked about. r? `@lcnr` since you reviewed the last PR changing these docs
2022-02-12trailing whitespaceEllen-6/+6
2022-02-12change docs on `Res::SelfTy`Ellen-27/+35
2022-02-12change to a struct variantEllen-12/+11
2022-02-12Rebased and improved errorsDeadbeef-2/+3
2022-02-12Improve error messages even moreDeadbeef-5/+6
2022-02-11Rollup merge of #93910 - rosehuds:master, r=cjgillotMatthias Krüger-4/+4
fix mention of moved function in `rustc_hir` docs The function was moved from `Crate` to `Map` in db9fea508a6d but these docs weren't updated
2022-02-11fix mention of moved function in `rustc_hir` docsRose Hudson-4/+4
the function was moved from `Crate` to `Map` in db9fea508a6d but the docs weren't updated
2022-02-11Rollup merge of #93853 - steffahn:map_by_value, r=wesleywiserMatthias Krüger-6/+6
Make all `hir::Map` methods consistently by-value `hir::Map` only consists of a single reference (as part of the contained `TyCtxt`) anyways, so copying is literally zero overhead compared to passing a reference
2022-02-11Rollup merge of #93443 - spastorino:add-stable-hash-impl-doc, r=cjgillotMatthias Krüger-0/+3
Add comment on stable_hash_impl for OwnerNodes r? `@cjgillot` cc `@oli-obk` `@bors` rollup=always
2022-02-10Make all hir::Map methods consistently by-valueFrank Steffahn-6/+6
(hir::Map only consists of a single reference anyways)
2022-02-09Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakisYuki Okushi-8/+3
Remove defaultness from ImplItem. This information is not really used anywhere, except HIR pretty-printing. This makes ImplItem and TraitItem more similar.
2022-02-07Auto merge of #93179 - Urgau:unreachable-2021, r=m-ou-se,oli-obkbors-1/+0
Fix invalid special casing of the unreachable! macro This pull-request fix an invalid special casing of the `unreachable!` macro in the same way the `panic!` macro was solved, by adding two new internal only macros `unreachable_2015` and `unreachable_2021` edition dependent and turn `unreachable!` into a built-in macro that do dispatching. This logic is stolen from the `panic!` macro. ~~This pull-request also adds an internal feature `format_args_capture_non_literal` that allows capturing arguments from formatted string that expanded from macros. The original RFC #2795 mentioned this as a future possibility. This feature is [required](https://github.com/rust-lang/rust/issues/92137#issuecomment-1018630522) because of concatenation that needs to be done inside the macro:~~ ```rust $crate::concat!("internal error: entered unreachable code: ", $fmt) ``` **In summary** the new behavior for the `unreachable!` macro with this pr is: Edition 2021: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is 5 ``` Edition <= 2018: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is {x} ``` Also note that the change in this PR are **insta-stable** and **breaking changes** but this a considered as being a [bug](https://github.com/rust-lang/rust/issues/92137#issuecomment-998441613). If someone could start a perf run and then a crater run this would be appreciated. Fixes https://github.com/rust-lang/rust/issues/92137
2022-02-03Remove defaultness from ImplItem.Camille GILLOT-8/+3
2022-02-01Auto merge of #93285 - JulianKnodt:const_eq_2, r=oli-obkbors-0/+6
Continue work on associated const equality This actually implements some more complex logic for assigning associated consts to values. Inside of projection candidates, it now defers to a separate function for either consts or types. To reduce amount of code, projections are now generic over T, where T is either a Type or a Const. I can add some comments back later, but this was the fastest way to implement it. It also now finds the correct type of consts in type_of. --- The current main TODO is finding the const of the def id for the LeafDef. Right now it works if the function isn't called, but once you use the trait impl with the bound it fails inside projection. I was hoping to get some help in getting the `&'tcx ty::Const<'tcx>`, in addition to a bunch of other `todo!()`s which I think may not be hit. r? `@oli-obk` Updates #92827