about summary refs log tree commit diff
path: root/compiler/rustc_hir/src
AgeCommit message (Collapse)AuthorLines
2022-09-05Rollup merge of #101420 - kraktus:doc_hir_local, r=cjgillotDylan DPC-1/+1
Fix `hir::Local` doc to match with the variable name used: `init`
2022-09-05Rollup merge of #101142 - nnethercote:improve-hir-stats, r=davidtwcoDylan DPC-20/+36
Improve HIR stats #100398 improve the AST stats collection done by `-Zhir-stats`. This PR does the same for HIR stats collection. r? `@davidtwco`
2022-09-05Address review comments.Nicholas Nethercote-4/+2
2022-09-05Make `hir::PathSegment::hir_id` non-optional.Nicholas Nethercote-5/+8
2022-09-05Make `hir::PathSegment::res` non-optional.Nicholas Nethercote-9/+6
2022-09-05Add some blank lines to the definition of `Res`.Nicholas Nethercote-1/+5
To make the spacing consistent. Also shorten an overly long comment line.
2022-09-04Fix `hir::Local` doc to match with the variable name used: `init`kraktus-1/+1
2022-09-04Make `const_eval_select` a real intrinsicDeadbeef-2/+0
2022-09-04Auto merge of #100726 - jswrenn:transmute, r=oli-obkbors-1/+2
safe transmute: use `Assume` struct to provide analysis options This task was left as a TODO in #92268; resolving it brings [`BikeshedIntrinsicFrom`](https://doc.rust-lang.org/nightly/core/mem/trait.BikeshedIntrinsicFrom.html) more in line with the API defined in [MCP411](https://github.com/rust-lang/compiler-team/issues/411). **Before:** ```rust pub unsafe trait BikeshedIntrinsicFrom< Src, Context, const ASSUME_ALIGNMENT: bool, const ASSUME_LIFETIMES: bool, const ASSUME_VALIDITY: bool, const ASSUME_VISIBILITY: bool, > where Src: ?Sized, {} ``` **After:** ```rust pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }> where Src: ?Sized, {} ``` `Assume::visibility` has also been renamed to `Assume::safety`, as library safety invariants are what's actually being assumed; visibility is just the mechanism by which it is currently checked (and that may change). r? `@oli-obk` --- Related: - https://github.com/rust-lang/compiler-team/issues/411 - https://github.com/rust-lang/rust/issues/99571
2022-09-02Refactor and re-use BindingAnnotationCameron Steffen-34/+5
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+3
by module
2022-08-31Rollup merge of #100730 - CleanCut:diagnostics-rustc_monomorphize, r=davidtwcoRalf Jung-3/+15
Migrate rustc_monomorphize to use SessionDiagnostic ### Description - Migrates diagnostics in `rustc_monomorphize` to use `SessionDiagnostic` - Adds an `impl IntoDiagnosticArg for PathBuf` ### TODO / Help! - [x] I'm having trouble figuring out how to apply an optional note. 😕 Help!? - Resolved. It was bad docs. Fixed in https://github.com/rust-lang/rustc-dev-guide/pull/1437/files - [x] `errors:RecursionLimit` should be `#[fatal ...]`, but that doesn't exist so it's `#[error ...]` at the moment. - Maybe I can switch after this is merged in? --> https://github.com/rust-lang/rust/pull/100694 - Or maybe I need to manually implement `SessionDiagnostic` instead of deriving it? - [x] How does one go about converting an error inside of [a call to struct_span_lint_hir](https://github.com/rust-lang/rust/blob/8064a495086c2e63c0ef77e8e82fe3b9b5dc535f/compiler/rustc_monomorphize/src/collector.rs#L917-L927)? - [x] ~What placeholder do you use in the fluent template to refer to the value in a vector? It seems like [this code](https://github.com/rust-lang/rust/blob/0b79f758c9aa6646606662a6d623a0752286cd17/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs#L83-L114) ought to have the answer (or something near it)...but I can't figure it out.~ You can't. Punted.
2022-08-29Rename `GenericArg::id` as `GenericArg::hir_id`.Nicholas Nethercote-1/+1
Because `hir_id` is the standard name for methods that return a `HirId` from a HIR node.
2022-08-29Use `&'hir Mod` everywhere.Nicholas Nethercote-1/+1
For consistency, and because it makes HIR measurement simpler and more accurate.
2022-08-29Use `&'hir Ty` everywhere.Nicholas Nethercote-2/+2
For consistency, and because it makes HIR measurement simpler and more accurate.
2022-08-29Use `&'hir Expr` everywhere.Nicholas Nethercote-7/+7
For consistency, and because it makes HIR measurement simpler and more accurate.
2022-08-29Expand the HIR (and AST) size assertions.Nicholas Nethercote-11/+27
2022-08-28Remove `register_attr` featureYuki Okushi-8/+2
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-08-26Merge implementations of HIR fn_decl and fn_sig.Camille GILLOT-4/+5
2022-08-25have LangItemError derive everything LangItem doesNathan Stocks-0/+1
2022-08-25allow non-monomorphize modules to access hard-coded error message through ↵Nathan Stocks-3/+14
new struct, use fluent message in monomorphize
2022-08-22safe transmute: use `Assume` struct to provide analysis optionsJack Wrenn-1/+2
This was left as a TODO in #92268, and brings the trait more in line with what was defined in MCP411. `Assume::visibility` has been renamed to `Assume::safety`, as library safety is what's actually being assumed; visibility is just the mechanism by which it is currently checked (this may change). ref: https://github.com/rust-lang/compiler-team/issues/411 ref: https://github.com/rust-lang/rust/issues/99571
2022-08-18Add diagnostic translation lints to crates that don't emit them5225225-0/+2
2022-08-16Rollup merge of #100610 - nnethercote:ast-and-parser-tweaks, r=spastorinoDylan DPC-5/+1
Ast and parser tweaks r? `@spastorino`
2022-08-16Auto merge of #100237 - cjgillot:no-special-hash-hir, r=nagisabors-18/+3
Remove manual implementations of HashStable for hir::Expr and hir::Ty. We do not need to force hashing HIR bodies inside those nodes. The contents of bodies are not accessible from the `hir_owner` query which used `hash_without_bodies`. When the content of a body is required, the access is still done using `hir_owner_nodes`, which continues hashing HIR bodies.
2022-08-16Remove `{ast,hir}::WhereEqPredicate::id`.Nicholas Nethercote-5/+1
These fields are unused.
2022-08-11Add visitors for PatField and ExprField.Eric Huss-10/+20
This helps simplify the code. It also fixes it to use the correct parent when lowering. One consequence is the `non_snake_case` lint needed to change the way it looked for parent nodes in a struct pattern. This also includes a small fix to use the correct `Target` for expression field attribute validation.
2022-08-11Check attributes on struct expression fields.Eric Huss-0/+4
Attributes on struct expression fields were not being checked for validity. This adds the fields as HIR nodes so that `CheckAttrVisitor` can visit those nodes to check their attributes.
2022-08-11Check attributes on pattern fields.Eric Huss-0/+4
Attributes on pattern struct fields were not being checked for validity. This adds the fields as HIR nodes so that the `CheckAttrVisitor` can visit those nodes to check their attributes.
2022-08-11Rollup merge of #100392 - nnethercote:simplify-visitors, r=cjgillotMatthias Krüger-41/+10
Simplify visitors By removing some unused arguments. r? `@cjgillot`
2022-08-11Simplify `rustc_hir::intravisit::Visitor::visit_enum_def`.Nicholas Nethercote-2/+2
It is passed an argument that is never used.
2022-08-11Simplify `rustc_hir::intravisit::Visitor::visit_variant_data`.Nicholas Nethercote-41/+10
It has four arguments that are never used. This avoids lots of argument passing in functions that feed into `visit_variant_data`.
2022-08-10Avoid repeating qualifiers on `static_assert_size` calls.Nicholas Nethercote-12/+12
Some of these don't need a `use` statement because there is already a `#[macro_use] extern crate rustc_data_structures` item in the crate.
2022-08-07Add Tuple marker traitMichael Goulet-0/+2
2022-08-07Derive HashStable for HIR Expr and Ty.Camille GILLOT-18/+3
2022-08-03Rollup merge of #100029 - hdelc:master, r=cjgillotMatthias Krüger-45/+45
Prevent ICE for `doc_alias` on match arm, statement, expression Fixes #99777. This is a pretty minimal fix that should be safe, since rustdoc doesn't generate documentation for match arms, statements, or expressions. I mentioned in the linked issue that the `doc_alias` target checking should probably be improved to avoid future ICEs, but as a new contributor, I'm not confident enough with the HIR types to make a larger change.
2022-08-02Add items to `DocAliasBadLocation` check error match armhdelc-1/+1
- Added `Impl`, `Closure`, ForeignMod` targets - `Target::name` changed for `Target::Impl` - Error output for `Target::ForeignMod` changed to "foreign module"
2022-08-02Auto merge of #92268 - jswrenn:transmute, r=oli-obkbors-0/+3
Initial implementation of transmutability trait. *T'was the night before Christmas and all through the codebase, not a miri was stirring — no hint of `unsafe`!* This PR provides an initial, **incomplete** implementation of *[MCP 411: Lang Item for Transmutability](https://github.com/rust-lang/compiler-team/issues/411)*. The `core::mem::BikeshedIntrinsicFrom` trait provided by this PR is implemented on-the-fly by the compiler for types `Src` and `Dst` when the bits of all possible values of type `Src` are safely reinterpretable as a value of type `Dst`. What this PR provides is: - [x] [support for transmutations involving primitives](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/primitives) - [x] [support for transmutations involving arrays](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/arrays) - [x] [support for transmutations involving structs](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/structs) - [x] [support for transmutations involving enums](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/enums) - [x] [support for transmutations involving unions](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/unions) - [x] [support for weaker validity checks](https://github.com/jswrenn/rust/blob/transmute/src/test/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs) (i.e., `Assume::VALIDITY`) - [x] visibility checking What isn't yet implemented: - [ ] transmutability options passed using the `Assume` struct - [ ] [support for references](https://github.com/jswrenn/rust/blob/transmute/src/test/ui/transmutability/references.rs) - [ ] smarter error messages These features will be implemented in future PRs.
2022-08-02Make `Target::name` method pass by copyhdelc-3/+3
2022-08-02Refactor `Display` impl for `Target` to `Target::name` methodhdelc-45/+45
2022-08-01Match on TraitItem exhaustively.Camille GILLOT-14/+11
2022-08-01Store associated item defaultness in impl_defaultness.Camille GILLOT-10/+17
2022-08-01Rollup merge of #100003 - nnethercote:improve-size-assertions, r=lqdMatthias Krüger-13/+14
Improve size assertions. - For any file with four or more size assertions, move them into a separate module (as is already done for `hir.rs`). - Add some more for AST nodes and THIR nodes. - Put the `hir.rs` ones in alphabetical order. r? `@lqd`
2022-08-01fix ICE in Definitions::create_defGoldstein-1/+6
2022-08-01Improve size assertions.Nicholas Nethercote-13/+14
- For any file with four or more size assertions, move them into a separate module (as is already done for `hir.rs`). - Add some more for AST nodes and THIR nodes. - Put the `hir.rs` ones in alphabetical order.
2022-07-27Initial (incomplete) implementation of transmutability trait.Jack Wrenn-0/+3
This initial implementation handles transmutations between types with specified layouts, except when references are involved. Co-authored-by: Igor null <m1el.2027@gmail.com>
2022-07-26Replace LifetimeRes::Anonymous by LifetimeRes::Infer.Camille GILLOT-10/+8
2022-07-26Remove the distinction between LifetimeName::Implicit and ↵Camille GILLOT-14/+3
LifetimeName::Underscore.
2022-07-25Auto merge of #97313 - cjgillot:ast-lifetimes-anon, r=petrochenkovbors-1/+1
Resolve function lifetime elision on the AST ~Based on https://github.com/rust-lang/rust/pull/97720~ Lifetime elision for functions is purely syntactic in nature, so can be resolved on the AST. This PR replicates the elision logic and diagnostics on the AST, and replaces HIR-based resolution by a `delay_span_bug`. This refactor allows for more consistent diagnostics, which don't have to guess the original code from HIR. r? `@petrochenkov`
2022-07-25Report elision failures on the AST.Camille GILLOT-1/+1