about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
AgeCommit message (Collapse)AuthorLines
2023-09-12Fix formattingChinedu Francis Nwafili-12/+8
2023-09-12Tests passingChinedu Francis Nwafili-14/+20
2023-09-11Disentangle `Debug` and `Display` for `Ty`.Nicholas Nethercote-1/+3
The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This is surprising and annoying. In particular, it means `Debug` doesn't show as much information as `Debug` for `TyKind` does. And `Debug` is used in some user-facing error messages, which seems bad. This commit changes the `Debug` impl for `Ty` to call the `Debug` impl for `TyKind`. It also does a number of follow-up changes to preserve existing output, many of which involve inserting `with_no_trimmed_paths!` calls. It also adds `Display` impls for `UserType` and `Canonical`. Some tests have changes to expected output: - Those that use the `rustc_abi(debug)` attribute. - Those that use the `EMIT_MIR` annotation. In each case the output is slightly uglier than before. This isn't ideal, but it's pretty weird (particularly for the attribute) that the output is using `Debug` in the first place. They're fairly obscure attributes (I hadn't heard of them) so I'm not worried by this. For `async-is-unwindsafe.stderr`, there is one line that now lacks a full path. This is a consistency improvement, because all the other mentions of `Context` in this test lack a path.
2023-09-10Encode only MIR that can be used by other cratesTomasz Miąsko-0/+4
Only reachable items might participate in the code generation in the downstream crates. Omit redundant optimized MIR of unreachable items from a crate metadata. Additionally, include reachable closures in reachable set, so that unreachable closures can be omitted on the same basis.
2023-09-09better spans for WF errorsRalf Jung-3/+8
2023-09-09use hir_crate_items(()).definitions() instead of hir().items()Ralf Jung-41/+18
2023-09-09rustc_layout, rustc_abi: make sure the types are well-formedRalf Jung-27/+47
2023-09-08Rework no_coverage to coverage(off)Andy Caldwell-22/+16
2023-09-08turns out Layout has some more things to worry about -- move ABI comparison ↵Ralf Jung-17/+3
into helper function like is_bool, and some special magic extra fields
2023-09-08also ensure that size and alignment are the sameRalf Jung-3/+7
2023-09-08accept some differences for rustc_abi(assert_eq), so that we can test more ↵Ralf Jung-3/+1
things to be compatible
2023-09-07add support for rustc_abi(assert_eq) and use it to test some ↵Ralf Jung-2/+85
repr(transparent) cases
2023-09-06rustc_layout/abi: error when attribute is applied to the wrong thingRalf Jung-32/+64
2023-09-06rustc_abi: also support debugging function pointersRalf Jung-37/+87
2023-08-27add rustc_abi debugging attributeRalf Jung-9/+113
2023-08-25Auto merge of #114201 - Centri3:explicit-repr-rust, r=WaffleLapkinbors-0/+1
Allow explicit `#[repr(Rust)]` This is identical to no `repr()` at all. For `Rust, packed` and `Rust, align(x)`, it should be the same as no `Rust` at all (as, afaik, `#[repr(align(16))]` uses the Rust ABI.) The main use case for this is being able to explicitly say "I want to use the Rust ABI" in very very rare circumstances where the first obvious choice would be the C ABI yet is undesirable, which is already possible with functions as `extern "Rust"`. This would be useful for silencing https://github.com/rust-lang/rust-clippy/pull/11253. It's also more consistent with `extern`. The lack of this also tripped me up a bit when I was new to Rust, as I expected this to be possible.
2023-08-24Auto merge of #115131 - frank-king:feature/unnamed-fields-lite, r=petrochenkovbors-0/+2
Parse unnamed fields and anonymous structs or unions (no-recovery) It is part of #114782 which implements #49804. Only parse anonymous structs or unions in struct field definition positions. r? `@petrochenkov`
2023-08-24Parse unnamed fields and anonymous structs or unionsFrank King-0/+2
Anonymous structs or unions are only allowed in struct field definitions. Co-authored-by: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com>
2023-08-22Contents of reachable statics is reachableTomasz Miąsko-7/+3
2023-08-19remove redundant var rebindingsMatthias Krüger-2/+0
2023-08-15Rollup merge of #114819 - estebank:issue-78124, r=compiler-errorsMatthias Krüger-1/+1
Point at return type when it influences non-first `match` arm When encountering code like ```rust fn foo() -> i32 { match 0 { 1 => return 0, 2 => "", _ => 1, } } ``` Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`. Fix #78124.
2023-08-15Misc progressChinedu Francis Nwafili-15/+25
2023-08-15Rollup merge of #114772 - fee1-dead-contrib:typed-did, r=b-naberGuillaume Gomez-14/+14
Add `{Local}ModDefId` to more strongly type DefIds` Based on #110862 by `@Nilstrieb`
2023-08-14Move scrutinee `HirId` into `MatchSource::TryDesugar`Esteban Küber-1/+1
2023-08-14Use `{Local}ModDefId` in many queriesNilstrieb-14/+14
2023-08-13Remove reached_eof from ParseSessbjorn3-6/+0
It was only ever set in a function which isn't called anywhere.
2023-08-13Auto merge of #114723 - petrochenkov:noplugin2, r=davidtwcobors-1/+1
rustc: Move `features` from `Session` to `GlobalCtxt` Removes one more piece of mutable state. Follow up to #114622. The rule I used for passing feature in function signatures: - if a crate already depends on `rustc_middle`, then `Session` is replaced with `TyCtxt` - otherwise session and features are passed as a pair `sess: &Session, features: &Features` The code in `rustc_lint` is ultimately used for implementing a trait from `rustc_expand`, so it also doesn't use tcx despite the dependency on `rustc_middle`.
2023-08-12Auto merge of #114710 - Urgau:fix-expect-dead_code-114557, r=cjgillotbors-33/+93
Respect `#[expect]` the same way `#[allow]` is with the `dead_code` lint This PR makes the `#[expect]` attribute being respected in the same way the `#[allow]` attribute is with the `dead_code` lint. The fix is much more involved than I would have liked (and it's not because I didn't tried!), because the implementation took advantage of the fact that firing a lint in a allow context is a nop (for the user, as the lint is suppressed) to not fire-it at all. And will it's fine for `#[allow]`, it definitively isn't for `#[expect]`, as the presence and absence of the lint is significant. So a big part of the PR is just adding the context information of whenever an item is on the worklist because of an `[allow]`/`#[expect]` or not. Fixes https://github.com/rust-lang/rust/issues/114557
2023-08-11rustc: Move `features` from `Session` to `GlobalCtxt`Vadim Petrochenkov-1/+1
Removes two pieces of mutable state. Follow up to #114622.
2023-08-10Respect `#[expect]` the same way `#[allow]` is with the `dead_code` lintUrgau-33/+93
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-6/+6
Removes a piece of mutable state. Follow up to #114578.
2023-08-08Auto merge of #114545 - fee1-dead-contrib:lower-impl-effect, r=oli-obkbors-8/+2
correctly lower `impl const` to bind to host effect param r? `@oli-obk`
2023-08-08Fix multiple `expect` attribs in impl blockChinedu Francis Nwafili-0/+7
Closes #114416
2023-08-08Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, ↵Matthias Krüger-3/+3
r=oli-obk Store the laziness of type aliases in their `DefKind` Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not. With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*: Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates. As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions. --- This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold. `@rustbot` label F-lazy_type_alias r? `@oli-obk`
2023-08-07check_attrs: Warn when #[macro_export] is used on macros 2.0Arthur Cohen-0/+18
The compiler should emit a more specific error when the `#[macro_export]` attribute is present on a decl macro, instead of silently ignoring it. This commit adds the required error message in rustc_passes/messages.ftl, as well as a note. A new variant is added to the `errors::MacroExport` enum, specifically for the case where the attribute is added to a macro 2.0.
2023-08-07Store the laziness of type aliases in the DefKindLeón Orell Valerian Liehr-3/+3
2023-08-06lower impl const to bind to host effect paramDeadbeef-8/+2
2023-08-05Add #[rustc_never_returns_null_ptr]est31-0/+3
And look for it in the useless_ptr_null_checks lint
2023-08-04Improve spans for indexing expressionsNilstrieb-1/+1
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-07-29Allow explicit `#[repr(Rust)]`Catherine Flores-0/+1
2023-07-28Lower generic const items to HIRLeón Orell Valerian Liehr-1/+1
2023-07-25inline format!() args from rustc_codegen_llvm to the end (4)Matthias Krüger-12/+9
r? @WaffleLapkin
2023-07-24validate `doc(masked)`Lukas Markeffsky-0/+68
2023-07-16Add infrastructure `#[rustc_confusables]` attribute to allow targeted许杰友 Jieyou Xu (Joe)-0/+73
"no method" errors on standard library types The standard library developer can annotate methods on e.g. `BTreeSet::push` with `#[rustc_confusables("insert")]`. When the user mistypes `btreeset.push()`, `BTreeSet::insert` will be suggested if there are no other candidates to suggest.
2023-07-14Rollup merge of #113698 - compiler-errors:rpitit-check, r=spastorinoMatthias Krüger-1/+1
Make it clearer that we're just checking for an RPITIT Tiny nit to use `is_impl_trait_in_trait` more, to make it clearer that we're just checking whether a def-id is an RPITIT, rather than doing something meaningful with the `opt_rpitit_info`. r? `@spastorino`
2023-07-14Make it clearer that we're just checking for an RPITITMichael Goulet-1/+1
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-7/+7
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-8/+18
2023-07-08Replace RPITIT current impl with new strategy that lowers as a GATSantiago Pastorino-1/+0
2023-07-01Put `LayoutError` behind reference to shrink resultNilstrieb-0/+1
`LayoutError` is 24 bytes, which is bigger than the `Ok` types, so let's shrink that.