about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-08-17Make same_type_modulo_infer a proper TypeRelationMichael Goulet-0/+4
2022-08-17Rollup merge of #100389 - compiler-errors:return-type-suggestion-cycle, ↵Matthias Krüger-0/+1
r=cjgillot Do not report cycle error when inferring return type for suggestion The UI test is a good example of a case where this happens. The cycle is due to needing the value of the return type `-> _` to compute the variances of items in the crate, but then needing the variances of the items in the crate to do typechecking to infer what `-> _`'s real type is. Since we're already gonna emit an error in astconv, just delay the cycle bug as an error.
2022-08-17implied_bounds: clarify our assumptionslcnr-0/+8
2022-08-17add List::as_slicelcnr-0/+4
2022-08-16Do not report cycle error when inferring return type for suggestionMichael Goulet-0/+1
2022-08-16Fix error message with non-tupled bare fn traitMichael Goulet-0/+12
2022-08-15Auto merge of #96745 - ehuss:even-more-attribute-validation, r=cjgillotbors-0/+6
Visit attributes in more places. This adds 3 loosely related changes (I can split PRs if desired): - Attribute checking on pattern struct fields. - Attribute checking on struct expression fields. - Lint level visiting on pattern struct fields, struct expression fields, and generic parameters. There are still some lints which ignore lint levels in various positions. This is a consequence of how the lints themselves are implemented. For example, lint levels on associated consts don't work with `unused_braces`.
2022-08-14TypeError can be CopyMichael Goulet-5/+6
2022-08-12Adjust cfgsMark Rousskov-1/+0
2022-08-11Check attributes on struct expression fields.Eric Huss-0/+3
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/+3
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 #100391 - nnethercote:improve-size-assertions, r=lqdDylan DPC-4/+4
Improve size assertions r? `@lqd`
2022-08-10Rollup merge of #100359 - b-naber:valtrees-pretty-print-ice, r=lcnrMichael Goulet-0/+4
Special-case references to leafs in valtree pretty-printing Fixes https://github.com/rust-lang/rust/issues/100313
2022-08-10Rollup merge of #99573 - tbodt:stabilize-backtrace, r=yaahcMatthias Krüger-1/+0
Stabilize backtrace This PR stabilizes the std::backtrace module. As of #99431, the std::Error::backtrace item has been removed, and so the rest of the backtrace feature is set to be stabilized. Previous discussion can be found in #72981, #3156. Stabilized API summary: ```rust pub mod std { pub mod backtrace { pub struct Backtrace { } pub enum BacktraceStatus { Unsupported, Disabled, Captured, } impl fmt::Debug for Backtrace {} impl Backtrace { pub fn capture() -> Backtrace; pub fn force_capture() -> Backtrace; pub const fn disabled() -> Backtrace; pub fn status(&self) -> BacktraceStatus; } impl fmt::Display for Backtrace {} } } ``` `@yaahc`
2022-08-10Avoid repeating qualifiers on `static_assert_size` calls.Nicholas Nethercote-4/+4
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-09fixb-naber-0/+4
2022-08-09Auto merge of #99217 - lcnr:implied-bounds-pre-norm, r=lcnrbors-0/+23
consider unnormalized types for implied bounds extracted, and slightly modified, from #98900 The idea here is that generally, rustc is split into things which can assume its inputs are well formed[^1], and things which have verify that themselves. Generally most predicates should only deal with well formed inputs, e.g. a `&'a &'b (): Trait` predicate should be able to assume that `'b: 'a` holds. Normalization can loosen wf requirements (see #91068) and must therefore not be used in places which still have to check well formedness. The only such place should hopefully be `WellFormed` predicates fixes #87748 and #98543 r? `@jackh726` cc `@rust-lang/types` [^1]: These places may still encounter non-wf inputs and have to deal with them without causing an ICE as we may check for well formedness out of order.
2022-08-09Auto merge of #100318 - Dylan-DPC:rollup-18tzp6q, r=Dylan-DPCbors-7/+82
Rollup of 7 pull requests Successful merges: - #96478 (Implement `#[rustc_default_body_unstable]`) - #99787 (Rustdoc-Json: Document HRTB's on DynTrait) - #100181 (add method to get the mutability of an AllocId) - #100221 (Don't document impossible to call default trait items on impls) - #100228 (Don't ICE while suggesting updating item path.) - #100301 (Avoid `&str` to `String` conversions) - #100305 (Suggest adding an appropriate missing pattern excluding comments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-09Rollup merge of #100221 - compiler-errors:impossible-trait-items, ↵Dylan DPC-0/+8
r=lcnr,notriddle,camelid Don't document impossible to call default trait items on impls Closes #100176 This only skips documenting _default_ trait items on impls, not ones that are written inside the impl block. This is a conservative approach, since I think we should document all items written in an impl block (I guess unless hidden or whatever), but the existence of this new query I added makes this easy to extend to other rustdoc cases.
2022-08-09Rollup merge of #96478 - WaffleLapkin:rustc_default_body_unstable, r=Aaron1011Dylan DPC-7/+74
Implement `#[rustc_default_body_unstable]` This PR implements a new stability attribute — `#[rustc_default_body_unstable]`. `#[rustc_default_body_unstable]` controls the stability of default bodies in traits. For example: ```rust pub trait Trait { #[rustc_default_body_unstable(feature = "feat", isssue = "none")] fn item() {} } ``` In order to implement `Trait` user needs to either - implement `item` (even though it has a default implementation) - enable `#![feature(feat)]` This is useful in conjunction with [`#[rustc_must_implement_one_of]`](https://github.com/rust-lang/rust/pull/92164), we may want to relax requirements for a trait, for example allowing implementing either of `PartialEq::{eq, ne}`, but do so in a safe way — making implementation of only `PartialEq::ne` unstable. r? `@Aaron1011` cc `@nrc` (iirc you were interested in this wrt `read_buf`), `@danielhenrymantilla` (you were interested in the related `#[rustc_must_implement_one_of]`) P.S. This is my first time working with stability attributes, so I'm not sure if I did everything right 😅
2022-08-09don't normalize wf predicateslcnr-0/+23
this allows us to soundly use unnormalized projections for wf
2022-08-09Add option to `mir::MutVisitor` to not invalidate CFG.Jakob Degen-63/+92
This also applies that option to some uses of the visitor
2022-08-07Don't document impossible to call default trait items on implsMichael Goulet-0/+8
2022-08-07Built-in implementation of Tuple traitMichael Goulet-2/+14
2022-08-07Auto merge of #99983 - RalfJung:more-layout-checks, r=eddybbors-110/+309
More layout sanity checks r? `@eddyb`
2022-08-05Move stability lookup after cross-crate checkMaybe Waffle-11/+11
2022-08-05Auto merge of #99867 - spastorino:refactor-remap-lifetimes, r=nikomatsakisbors-0/+5
Split create_def and lowering of lifetimes for opaque types and bare async fns r? `@cjgillot` This work is kind of half-way, but I think it could be merged anyway. I think we should be able to remove all the vacant arms in `new_named_lifetime_with_res`, if I'm not wrong that requires visiting more nodes. We can do that as a follow up. In follow-up PRs, besides the thing mentioned previously, I'll be trying to remove `LifetimeCaptureContext`, `captured_lifetimes` as a global data structure, global `binders_to_ignore` and all their friends :). Also try to remap in a more general way based on def-ids.
2022-08-04Rollup merge of #100095 - jackh726:early-binder, r=lcnrMatthias Krüger-3/+27
More EarlyBinder cleanups Each commit is independent r? types
2022-08-04Document generics_def_id_map field and record/get methods on itSantiago Pastorino-1/+4
2022-08-04Implement def_id based remappingSantiago Pastorino-0/+2
2022-08-03Remove index from Region::EarlyBound.Camille GILLOT-1/+1
2022-08-03Compute `object_lifetime_default` per parameter.Camille GILLOT-4/+5
2022-08-03Create a specific `ObjectLifetimeDefault` enum.Camille GILLOT-4/+14
2022-08-03Make object_lifetime_defaults a cross-crate query.Camille GILLOT-1/+1
2022-08-03Add bound_impl_subject and bound_return_tyJack Huey-0/+10
2022-08-03Change sized_constraints to return EarlyBinderJack Huey-3/+3
2022-08-02Add bound_predicates_of and bound_explicit_predicates_ofJack Huey-0/+14
2022-08-02Avoid invalidating the CFG in MirPatch.Jakob Degen-35/+30
As a part of this change, we adjust MirPatch to not needlessly create unnecessary resume blocks.
2022-08-02Stabilize backtraceTheodore Dubois-1/+0
2022-08-02Auto merge of #92268 - jswrenn:transmute, r=oli-obkbors-1/+94
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-02remove some unused code and typesRalf Jung-20/+2
2022-08-02Auto merge of #100032 - BoxyUwU:no_ty_in_placeholder_const, r=compiler-errorsbors-4/+4
make `PlaceholderConst` not store the type of the const Currently the `Placeholder` variant on `ConstKind` is 28 bytes when with this PR its 8 bytes, i am not sure this is really useful at all rn since `Unevaluated` and `Value` variants are huge still but eventually it should be possible to get both down to 16 bytes :thinking:. Mostly opening this to see if this change has any perf impact when done before it can make `ConstKind`/`ConstS` smaller
2022-08-02fix a commentRalf Jung-1/+1
2022-08-01Remove trait_of_item query.Camille GILLOT-9/+20
2022-08-01Remove DefId from AssocItemContainer.Camille GILLOT-41/+34
2022-08-01Remove visibility from AssocItem.Camille GILLOT-1/+5
2022-08-01Store associated item defaultness in impl_defaultness.Camille GILLOT-4/+8
2022-08-01fix for unions with scalar layoutRalf Jung-0/+4
2022-08-01Rollup merge of #100003 - nnethercote:improve-size-assertions, r=lqdMatthias Krüger-21/+23
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-01Rollup merge of #99340 - GoldsteinE:fix-localdefid-debug-ice, r=lcnrMatthias Krüger-2/+2
Fix ICE in Definitions::create_def `Debug` implementation for `LocalDefId` uses global `Definitions`. Normally it’s ok, but we can’t do it while holding a mutable reference to `Definitions`, since it causes ICE or deadlock (depending on whether `parallel_compiler` is enabled). This PR effectively copies the `Debug` implementation into the problematic method. I don’t particularly love this solution (since it creates code duplication), but I don’t see any other options. This issue was discovered when running `rustdoc` with `RUSTDOC_LOG=trace` on the following file: ```rust pub struct SomeStruct; fn asdf() { impl SomeStruct { pub fn qwop(&self) { println!("hidden function"); } } } ``` I’m not sure how to create a test for this behavior.