]> git.lizzy.rs Git - rust.git/log
rust.git
18 months agoMerge commit '4bdfb0741dbcecd5279a2635c3280726db0604b5' into clippyup
Philipp Krones [Sat, 17 Dec 2022 13:12:54 +0000 (14:12 +0100)]
Merge commit '4bdfb0741dbcecd5279a2635c3280726db0604b5' into clippyup

18 months agoRollup merge of #105743 - nnethercote:SimplifiedType-cleanups, r=lcnr
Matthias Krüger [Thu, 15 Dec 2022 21:03:01 +0000 (22:03 +0100)]
Rollup merge of #105743 - nnethercote:SimplifiedType-cleanups, r=lcnr

`SimplifiedType` cleanups

r? `@lcnr`

18 months agoMerge `SimplifiedTypeGen<D>` into `SimplifiedType`.
Nicholas Nethercote [Thu, 15 Dec 2022 04:13:19 +0000 (15:13 +1100)]
Merge `SimplifiedTypeGen<D>` into `SimplifiedType`.

`SimplifiedTypeGen<DefId>` is the only instantiation used, so we don't
need the generic parameter.

18 months agoRemove TraitRef::new
Oli Scherer [Tue, 13 Dec 2022 11:25:31 +0000 (11:25 +0000)]
Remove TraitRef::new

18 months agoEnsure no one constructs `AliasTy`s themselves
Oli Scherer [Tue, 13 Dec 2022 11:07:42 +0000 (11:07 +0000)]
Ensure no one constructs `AliasTy`s themselves

18 months agoCombine projection and opaque into alias
Michael Goulet [Sat, 26 Nov 2022 21:51:55 +0000 (21:51 +0000)]
Combine projection and opaque into alias

18 months agosquash OpaqueTy and ProjectionTy into AliasTy
Michael Goulet [Sat, 26 Nov 2022 21:32:01 +0000 (21:32 +0000)]
squash OpaqueTy and ProjectionTy into AliasTy

18 months agoProjectionTy.item_def_id -> ProjectionTy.def_id
Michael Goulet [Sat, 26 Nov 2022 21:21:20 +0000 (21:21 +0000)]
ProjectionTy.item_def_id -> ProjectionTy.def_id

18 months agoUse ty::OpaqueTy everywhere
Michael Goulet [Sat, 26 Nov 2022 21:09:39 +0000 (21:09 +0000)]
Use ty::OpaqueTy everywhere

18 months agoAuto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkov
bors [Mon, 12 Dec 2022 05:16:50 +0000 (05:16 +0000)]
Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkov

Remove `token::Lit` from `ast::MetaItemLit`.

Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time.

r? `@petrochenkov`

18 months agoRemove unneeded field from `SwitchTargets`
Jakob Degen [Sun, 4 Dec 2022 00:03:27 +0000 (16:03 -0800)]
Remove unneeded field from `SwitchTargets`

18 months agoFix #10021
Samuel Moelius [Sat, 3 Dec 2022 01:41:29 +0000 (20:41 -0500)]
Fix #10021

19 months agoAuto merge of #104963 - petrochenkov:noaddids2, r=cjgillot
bors [Fri, 2 Dec 2022 04:24:57 +0000 (04:24 +0000)]
Auto merge of #104963 - petrochenkov:noaddids2, r=cjgillot

rustc_ast_lowering: Stop lowering imports into multiple items

Lower them into a single item with multiple resolutions instead.
This also allows to remove additional `NodId`s and `DefId`s related to those additional items.

19 months agoAdd `StrStyle` to `ast::LitKind::ByteStr`.
Nicholas Nethercote [Tue, 29 Nov 2022 02:35:44 +0000 (13:35 +1100)]
Add `StrStyle` to `ast::LitKind::ByteStr`.

This is required to distinguish between cooked and raw byte string
literals in an `ast::LitKind`, without referring to an adjacent
`token::Lit`. It's a prerequisite for the next commit.

19 months agoMerge commit 'd822110d3b5625b9dc80ccc442e06fc3cc851d76' into clippyup
Philipp Krones [Thu, 1 Dec 2022 17:29:38 +0000 (18:29 +0100)]
Merge commit 'd822110d3b5625b9dc80ccc442e06fc3cc851d76' into clippyup

19 months agorustc_ast_lowering: Stop lowering imports into multiple items
Vadim Petrochenkov [Thu, 1 Dec 2022 15:51:20 +0000 (18:51 +0300)]
rustc_ast_lowering: Stop lowering imports into multiple items

Lower them into a single item with multiple resolutions instead.
This also allows to remove additional `NodId`s and `DefId`s related to those additional items.

19 months agorustc_hir: Change representation of import paths to support multiple resolutions
Vadim Petrochenkov [Fri, 25 Nov 2022 14:39:38 +0000 (17:39 +0300)]
rustc_hir: Change representation of import paths to support multiple resolutions

19 months agorustc_hir: Relax lifetime requirements on `Visitor::visit_path`
Vadim Petrochenkov [Fri, 25 Nov 2022 08:26:36 +0000 (11:26 +0300)]
rustc_hir: Relax lifetime requirements on `Visitor::visit_path`

19 months agoAuto merge of #104905 - compiler-errors:normalization-changes, r=spastorino
bors [Wed, 30 Nov 2022 11:13:09 +0000 (11:13 +0000)]
Auto merge of #104905 - compiler-errors:normalization-changes, r=spastorino

Some initial normalization method changes

1. Rename `AtExt::normalize` to `QueryNormalizeExt::query_normalize` (using the `QueryNormalizer`)
2. Introduce `NormalizeExt::normalize` to replace `partially_normalize_associated_types_in` (using the `AssocTypeNormalizer`)
3. Rename `FnCtxt::normalize_associated_types_in` to `FnCtxt::normalize`
4. Remove some unused other normalization fns in `Inherited` and `FnCtxt`

Also includes one drive-by where we're no longer creating a `FnCtxt` inside of `check_fn`, but passing it in. This means we don't need such weird `FnCtxt` construction logic.

Stacked on top of #104835 for convenience.

r? types

19 months agoFnCtxt normalization stuff
Michael Goulet [Fri, 25 Nov 2022 17:28:50 +0000 (17:28 +0000)]
FnCtxt normalization stuff

19 months agopartially_normalize_... -> At::normalize
Michael Goulet [Fri, 25 Nov 2022 17:11:15 +0000 (17:11 +0000)]
partially_normalize_... -> At::normalize

19 months agoRollup merge of #104804 - nnethercote:MetaItemLit, r=petrochenkov
Matthias Krüger [Mon, 28 Nov 2022 16:25:46 +0000 (17:25 +0100)]
Rollup merge of #104804 - nnethercote:MetaItemLit, r=petrochenkov

Rename `ast::Lit` as `ast::MetaItemLit`.

And some other literal cleanups.

r? `@petrochenkov`

19 months agofix clippy tests
Esteban Küber [Mon, 28 Nov 2022 08:41:31 +0000 (00:41 -0800)]
fix clippy tests

19 months agoRename `ast::Lit` as `ast::MetaItemLit`.
Nicholas Nethercote [Wed, 23 Nov 2022 04:39:42 +0000 (15:39 +1100)]
Rename `ast::Lit` as `ast::MetaItemLit`.

19 months agoAuto merge of #104048 - cjgillot:split-lifetime, r=compiler-errors
bors [Sun, 27 Nov 2022 14:30:19 +0000 (14:30 +0000)]
Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errors

Separate lifetime ident from lifetime resolution in HIR

Drive-by: change how suggested generic args are computed.
Fixes https://github.com/rust-lang/rust/issues/103815

I recommend reviewing commit-by-commit.

19 months agoAuto merge of #104846 - spastorino:santa-clauses-make-goals-early-christmas-🎄, r...
bors [Fri, 25 Nov 2022 15:59:31 +0000 (15:59 +0000)]
Auto merge of #104846 - spastorino:santa-clauses-make-goals-early-christmas-🎄, r=oli-obk

Branch Clause from Predicate

r? `@oli-obk`

This is part of what's proposed in https://github.com/rust-lang/compiler-team/issues/531

19 months agoRollup merge of #104873 - RalfJung:therefore, r=Dylan-DPC
Matthias Krüger [Fri, 25 Nov 2022 09:44:40 +0000 (10:44 +0100)]
Rollup merge of #104873 - RalfJung:therefore, r=Dylan-DPC

RefCell::get_mut: fix typo

and fix the same typo in a bunch of other places

19 months agoRefCell::get_mut: fix typo
Ralf Jung [Fri, 25 Nov 2022 07:47:59 +0000 (08:47 +0100)]
RefCell::get_mut: fix typo

and fix the same typo in a bunch of other places

19 months agoIntroduce PredicateKind::Clause
Santiago Pastorino [Thu, 24 Nov 2022 21:14:58 +0000 (18:14 -0300)]
Introduce PredicateKind::Clause

19 months agoSimplify a bunch of trait ref obligation creations
Oli Scherer [Fri, 18 Nov 2022 21:29:26 +0000 (21:29 +0000)]
Simplify a bunch of trait ref obligation creations

19 months agoAuto merge of #103693 - HKalbasi:master, r=oli-obk
bors [Thu, 24 Nov 2022 20:29:13 +0000 (20:29 +0000)]
Auto merge of #103693 - HKalbasi:master, r=oli-obk

Make rustc_target usable outside of rustc

I'm working on showing type size in rust-analyzer (https://github.com/rust-lang/rust-analyzer/pull/13490) and I currently copied rustc code inside rust-analyzer, which works, but is bad. With this change, I would become able to use `rustc_target` and `rustc_index` directly in r-a, reducing the amount of copy needed.

This PR contains some feature flag to put nightly features behind them to make crates buildable on the stable compiler + makes layout related types generic over index type + removes interning of nested layouts.

19 months agoUse kw::Empty for elided lifetimes in path.
Camille GILLOT [Sun, 6 Nov 2022 11:40:31 +0000 (11:40 +0000)]
Use kw::Empty for elided lifetimes in path.

19 months agoAuto merge of #104321 - Swatinem:async-gen, r=oli-obk
bors [Thu, 24 Nov 2022 17:14:42 +0000 (17:14 +0000)]
Auto merge of #104321 - Swatinem:async-gen, r=oli-obk

Avoid `GenFuture` shim when compiling async constructs

Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`.

The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim.

The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.

---

Given this demo code:

```rust
pub async fn a(arg: u32) -> Backtrace {
    let bt = b().await;
    let _arg = arg;
    bt
}

pub async fn b() -> Backtrace {
    Backtrace::force_capture()
}
```

I would get the following with the latest stable compiler (on Windows):

```
   4: async_codegen::b::async_fn$0
             at .\src\lib.rs:10
   5: core::future::from_generator::impl$1::poll<enum2$<async_codegen::b::async_fn_env$0> >
             at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91
   6: async_codegen::a::async_fn$0
             at .\src\lib.rs:4
   7: core::future::from_generator::impl$1::poll<enum2$<async_codegen::a::async_fn_env$0> >
             at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91
```

whereas now I get a much cleaner stack trace:

```
   3: async_codegen::b::async_fn$0
             at .\src\lib.rs:10
   4: async_codegen::a::async_fn$0
             at .\src\lib.rs:4
```

19 months agomove some layout logic to rustc_target::abi::layout
hkalbasi [Tue, 1 Nov 2022 16:20:30 +0000 (19:50 +0330)]
move some layout logic to rustc_target::abi::layout

19 months agoAvoid `GenFuture` shim when compiling async constructs
Arpad Borsos [Fri, 18 Nov 2022 21:56:22 +0000 (22:56 +0100)]
Avoid `GenFuture` shim when compiling async constructs

Previously, async constructs would be lowered to "normal" generators,
with an additional `from_generator` / `GenFuture` shim in between to
convert from `Generator` to `Future`.

The compiler will now special-case these generators internally so that
async constructs will *directly* implement `Future` without the need
to go through the `from_generator` / `GenFuture` shim.

The primary motivation for this change was hiding this implementation
detail in stack traces and debuginfo, but it can in theory also help
the optimizer as there is less abstractions to see through.

19 months agoRollup merge of #104742 - WaffleLapkin:forbidden-SUPER-deref, r=compiler-errors
Matthias Krüger [Thu, 24 Nov 2022 07:42:34 +0000 (08:42 +0100)]
Rollup merge of #104742 - WaffleLapkin:forbidden-SUPER-deref, r=compiler-errors

Make `deref_into_dyn_supertrait` lint the impl and not the usage

Proposed by ``@compiler-errors`` in https://github.com/rust-lang/rust/issues/89460#issuecomment-1320806785
r? ``@crlf0710``

19 months agoFix clippy code
Esteban Küber [Thu, 3 Nov 2022 16:19:23 +0000 (09:19 -0700)]
Fix clippy code

19 months agoSeparate lifetime ident from resolution in HIR.
Camille GILLOT [Sat, 5 Nov 2022 22:41:07 +0000 (22:41 +0000)]
Separate lifetime ident from resolution in HIR.

19 months agoMove `get_associated_type` from `clippy` to `rustc_lint`
Maybe Waffle [Tue, 22 Nov 2022 19:52:46 +0000 (19:52 +0000)]
Move `get_associated_type` from `clippy` to `rustc_lint`

19 months agoRollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnr
Manish Goregaokar [Wed, 23 Nov 2022 03:54:38 +0000 (22:54 -0500)]
Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnr

Allow opaque types in trait impl headers and rely on coherence to reject unsound cases

r? ````@lcnr````

fixes #99840

19 months agoAuto merge of #104688 - flip1995:clippyup, r=Manishearth,flip1995
bors [Tue, 22 Nov 2022 17:09:06 +0000 (17:09 +0000)]
Auto merge of #104688 - flip1995:clippyup, r=Manishearth,flip1995

Update Clippy

r? `@Manishearth`

Sorry for taking so long. There were so many blockers and so little time. This situation should be mitigated with #104007 in the future.

19 months agoClippy: Workaround for let_chains issue
Philipp Krones [Tue, 22 Nov 2022 13:30:29 +0000 (14:30 +0100)]
Clippy: Workaround for let_chains issue

19 months agoAuto merge of #103578 - petrochenkov:nofict, r=nagisa
bors [Tue, 22 Nov 2022 10:17:09 +0000 (10:17 +0000)]
Auto merge of #103578 - petrochenkov:nofict, r=nagisa

Unreserve braced enum variants in value namespace

With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed.

Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.

19 months agoAuto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgr
bors [Tue, 22 Nov 2022 01:35:57 +0000 (01:35 +0000)]
Auto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgr

Rollup of 11 pull requests

Successful merges:

 - #103396 (Pin::new_unchecked: discuss pinning closure captures)
 - #104416 (Fix using `include_bytes` in pattern position)
 - #104557 (Add a test case for async dyn* traits)
 - #104559 (Split `MacArgs` in two.)
 - #104597 (Probe + better error messsage for `need_migrate_deref_output_trait_object`)
 - #104656 (Move tests)
 - #104657 (Do not check transmute if has non region infer)
 - #104663 (rustdoc: factor out common button CSS)
 - #104666 (Migrate alias search result to CSS variables)
 - #104674 (Make negative_impl and negative_impl_exists take the right types)
 - #104692 (Update test's cfg-if dependency to 1.0)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

19 months agoSplit `MacArgs` in two.
Nicholas Nethercote [Fri, 18 Nov 2022 00:24:21 +0000 (11:24 +1100)]
Split `MacArgs` in two.

`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's
used in two ways:
- For representing attribute macro arguments (e.g. in `AttrItem`), where all
  three variants are used.
- For representing function-like macros (e.g. in `MacCall` and `MacroDef`),
  where only the `Delimited` variant is used.

In other words, `MacArgs` is used in two quite different places due to them
having partial overlap. I find this makes the code hard to read. It also leads
to various unreachable code paths, and allows invalid values (such as
accidentally using `MacArgs::Empty` in a `MacCall`).

This commit splits `MacArgs` in two:
- `DelimArgs` is a new struct just for the "delimited arguments" case. It is
  now used in `MacCall` and `MacroDef`.
- `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro
  case. Its `Delimited` variant now contains a `DelimArgs`.

Various other related things are renamed as well.

These changes make the code clearer, avoids several unreachable paths, and
disallows the invalid values.

19 months agoUse `as_closure` helper method
Oli Scherer [Mon, 21 Nov 2022 15:52:01 +0000 (16:52 +0100)]
Use `as_closure` helper method

Co-authored-by: lcnr <rust@lcnr.de>
19 months agoStop passing the self-type as a separate argument.
Oli Scherer [Mon, 21 Nov 2022 12:24:53 +0000 (12:24 +0000)]
Stop passing the self-type as a separate argument.

19 months agoFix clippy's missing substs
Oli Scherer [Fri, 18 Nov 2022 19:58:07 +0000 (19:58 +0000)]
Fix clippy's missing substs

19 months agoAllow iterators instead of requiring slices that will get turned into iterators
Oli Scherer [Thu, 17 Nov 2022 13:00:35 +0000 (13:00 +0000)]
Allow iterators instead of requiring slices that will get turned into iterators

19 months agoClippy: Don't import GenericParamDefKind
Philipp Krones [Mon, 21 Nov 2022 20:04:59 +0000 (21:04 +0100)]
Clippy: Don't import GenericParamDefKind

19 months agoFix declare_clippy_lint crate
Philipp Krones [Mon, 21 Nov 2022 19:52:12 +0000 (20:52 +0100)]
Fix declare_clippy_lint crate

19 months agoMerge commit 'f4850f7292efa33759b4f7f9b7621268979e9914' into clippyup
Philipp Krones [Mon, 21 Nov 2022 19:34:47 +0000 (20:34 +0100)]
Merge commit 'f4850f7292efa33759b4f7f9b7621268979e9914' into clippyup

19 months agoUnreserve braced enum variants in value namespace
Vadim Petrochenkov [Tue, 25 Oct 2022 16:15:15 +0000 (20:15 +0400)]
Unreserve braced enum variants in value namespace

19 months agoAdd an always-ambiguous predicate to make sure that we don't accidentlally allow...
Oli Scherer [Wed, 2 Nov 2022 15:10:05 +0000 (15:10 +0000)]
Add an always-ambiguous predicate to make sure that we don't accidentlally allow trait resolution to prove false things during coherence

19 months agoRollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnr
Matthias Krüger [Mon, 21 Nov 2022 13:11:11 +0000 (14:11 +0100)]
Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnr

Add `PolyExistentialPredicate` type alias

Wrapping `ExistentialPredicate`s in a binder is very common, and this alias already exists for the `PolyExistential{TraitRef,Projection}` types.

19 months agoAuto merge of #98914 - fee1-dead-contrib:min-deref-patterns, r=compiler-errors
bors [Sun, 20 Nov 2022 07:16:42 +0000 (07:16 +0000)]
Auto merge of #98914 - fee1-dead-contrib:min-deref-patterns, r=compiler-errors

Minimal implementation of implicit deref patterns for Strings

cc `@compiler-errors` `@BoxyUwU` https://github.com/rust-lang/lang-team/issues/88 #87121

~~I forgot to add a feature gate, will do so in a minute~~ Done

19 months agoRollup merge of #104593 - compiler-errors:rpitit-object-safety-spans, r=fee1-dead
Matthias Krüger [Sat, 19 Nov 2022 14:35:23 +0000 (15:35 +0100)]
Rollup merge of #104593 - compiler-errors:rpitit-object-safety-spans, r=fee1-dead

Improve spans for RPITIT object-safety errors

No reason why we can't point at the `impl Trait` that causes the object-safety violation.

Also [drive-by: Add is_async fn to hir::IsAsync](https://github.com/rust-lang/rust/pull/104593/commits/c4165f3a965e258531928180195637455299c6f3), which touches clippy too.

19 months agodrive-by: PolyExistentialPredicate
Michael Goulet [Sat, 19 Nov 2022 03:28:56 +0000 (03:28 +0000)]
drive-by: PolyExistentialPredicate

19 months agodrive-by: Add is_async fn to hir::IsAsync
Michael Goulet [Sat, 19 Nov 2022 02:22:24 +0000 (02:22 +0000)]
drive-by: Add is_async fn to hir::IsAsync

19 months agoAuto merge of #104573 - matthiaskrgr:rollup-k36ybtp, r=matthiaskrgr
bors [Fri, 18 Nov 2022 20:26:58 +0000 (20:26 +0000)]
Auto merge of #104573 - matthiaskrgr:rollup-k36ybtp, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #101162 (Migrate rustc_resolve to use SessionDiagnostic, part # 1)
 - #103386 (Don't allow `CoerceUnsized` into `dyn*` (except for trait upcasting))
 - #103405 (Detect incorrect chaining of if and if let conditions and recover)
 - #103594 (Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targets)
 - #104006 (Add variant_name function to `LangItem`)
 - #104494 (Migrate GUI test to use functions)
 - #104516 (rustdoc: clean up sidebar width CSS)
 - #104550 (fix a typo)

Failed merges:

 - #104554 (Use `ErrorGuaranteed::unchecked_claim_error_was_emitted` less)

r? `@ghost`
`@rustbot` modify labels: rollup

19 months agoAuto merge of #101562 - nnethercote:shrink-ast-Expr-harder, r=petrochenkov
bors [Fri, 18 Nov 2022 16:56:12 +0000 (16:56 +0000)]
Auto merge of #101562 - nnethercote:shrink-ast-Expr-harder, r=petrochenkov

Shrink `ast::Expr` harder

r? `@ghost`

19 months agoRollup merge of #104006 - flip1995:lang-items-clippy, r=oli-obk
Matthias Krüger [Fri, 18 Nov 2022 13:13:37 +0000 (14:13 +0100)]
Rollup merge of #104006 - flip1995:lang-items-clippy, r=oli-obk

Add variant_name function to `LangItem`

Clippy has an internal lint that checks for the usage of hardcoded def paths and suggests to replace them with a lang or diagnostic item, if possible. This was implemented with a hack, by getting all the variants of the `LangItem` enum and then index into it with the position of the `LangItem` in the `items` list. This is no longer possible, because the `items` list can't be accessed anymore.

Follow up to #103603

cc `@camsteffen`
r? `@oli-obk`

This is blocking the sync between Clippy and Rust. I'm not sure if this is the best solution here, or if I should add a method `items()` to `LanguageItems` and keep the code in Clippy unchanged.

19 months agoRm diagnostic item, use lang item
Deadbeef [Tue, 5 Jul 2022 16:56:16 +0000 (16:56 +0000)]
Rm diagnostic item, use lang item

19 months agoRollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errors
Matthias Krüger [Thu, 17 Nov 2022 21:33:19 +0000 (22:33 +0100)]
Rollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errors

Convert predicates into Predicate in the Obligation constructor

instead of having almost all callers do that.

This reduces a bit of boilerplate, and also paves the way for my work towards https://github.com/rust-lang/compiler-team/issues/531 (as it makes it easier to accept both goals and clauses where right now it only accepts predicates).

19 months agoAdd variant_name function to `LangItem`
Philipp Krones [Sat, 5 Nov 2022 14:08:37 +0000 (15:08 +0100)]
Add variant_name function to `LangItem`

Clippy has an internal lint that checks for the usage of hardcoded def
paths and suggests to replace them with a lang or diagnostic item, if
possible. This was implemented with a hack, by getting all the variants
of the `LangItem` enum and then index into it with the position of the
`LangItem` in the `items` list. This is no longer possible, because the
`items` list can't be accessed anymore.

19 months agoAuto merge of #104170 - cjgillot:hir-def-id, r=fee1-dead
bors [Thu, 17 Nov 2022 07:42:27 +0000 (07:42 +0000)]
Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-dead

Record `LocalDefId` in HIR nodes instead of a side table

This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR.
This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed.

This first part adds the information to HIR nodes themselves instead of a table.
The second part is https://github.com/rust-lang/rust/pull/103902
The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter.
The fourth part will be to completely remove the side table.

19 months agoBox `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and patterns.
Nicholas Nethercote [Thu, 8 Sep 2022 00:52:51 +0000 (10:52 +1000)]
Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and patterns.

19 months agoAuto merge of #102944 - nnethercote:ast-Lit-third-time-lucky, r=petrochenkov
bors [Wed, 16 Nov 2022 23:03:14 +0000 (23:03 +0000)]
Auto merge of #102944 - nnethercote:ast-Lit-third-time-lucky, r=petrochenkov

Use `token::Lit` in `ast::ExprKind::Lit`.

Instead of `ast::Lit`.

Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing.

r? `@petrochenkov`

19 months agoConvert predicates into Predicate in the Obligation constructor
Oli Scherer [Wed, 9 Nov 2022 10:49:28 +0000 (10:49 +0000)]
Convert predicates into Predicate in the Obligation constructor

19 months agocleanup and dedupe CTFE and Miri error reporting
Ralf Jung [Tue, 15 Nov 2022 11:06:20 +0000 (12:06 +0100)]
cleanup and dedupe CTFE and Miri error reporting

19 months agoUse `token::Lit` in `ast::ExprKind::Lit`.
Nicholas Nethercote [Mon, 10 Oct 2022 02:40:56 +0000 (13:40 +1100)]
Use `token::Lit` in `ast::ExprKind::Lit`.

Instead of `ast::Lit`.

Literal lowering now happens at two different times. Expression literals
are lowered when HIR is crated. Attribute literals are lowered during
parsing.

This commit changes the language very slightly. Some programs that used
to not compile now will compile. This is because some invalid literals
that are removed by `cfg` or attribute macros will no longer trigger
errors. See this comment for more details:
https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773

19 months agoFix clippy and rustdoc
Maybe Waffle [Sun, 13 Nov 2022 22:58:20 +0000 (22:58 +0000)]
Fix clippy and rustdoc

please, please, don't match on `Symbol::as_str`s, every time you do,
somewhere in the world another waffle becomes sad...

19 months agoStore a LocalDefId in hir::Variant & hir::Field.
Camille GILLOT [Sun, 6 Nov 2022 19:46:55 +0000 (19:46 +0000)]
Store a LocalDefId in hir::Variant & hir::Field.

19 months agoIntroduce `ExprKind::IncludedBytes`
clubby789 [Mon, 31 Oct 2022 18:30:09 +0000 (18:30 +0000)]
Introduce `ExprKind::IncludedBytes`

19 months agobless clippy
yukang [Wed, 9 Nov 2022 11:23:23 +0000 (19:23 +0800)]
bless clippy

20 months agoRollup merge of #103660 - ozkanonur:master, r=jyn514
Dylan DPC [Sat, 5 Nov 2022 06:01:28 +0000 (11:31 +0530)]
Rollup merge of #103660 - ozkanonur:master, r=jyn514

improve `filesearch::get_or_default_sysroot`

`fn get_or_default_sysroot` is now improved and used in `miri` and `clippy`, and tests are still passing as they should. So we no longer need to implement custom workarounds/hacks to find sysroot in tools like miri/clippy.

Resolves https://github.com/rust-lang/rust/issues/98832

re-opened from #103581

20 months agoimprove `filesearch::get_or_default_sysroot` r=ozkanonur
Onur Özkan [Fri, 28 Oct 2022 07:20:51 +0000 (10:20 +0300)]
improve `filesearch::get_or_default_sysroot` r=ozkanonur

Signed-off-by: Onur Özkan <work@onurozkan.dev>
20 months agoAuto merge of #103217 - mejrs:track, r=eholk
bors [Tue, 1 Nov 2022 21:09:45 +0000 (21:09 +0000)]
Auto merge of #103217 - mejrs:track, r=eholk

Track where diagnostics were created.

This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`.

For example, the following code...

```rust
struct A;
struct B;

fn main(){
    let _: A = B;
}
```
...now emits the following error message:

```
error[E0308]: mismatched types
 --> src\main.rs:5:16
  |
5 |     let _: A = B;
  |            -   ^ expected struct `A`, found struct `B`
  |            |
  |            expected due to this
-Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31
```

20 months agoUse LanguageItems::require less
Cameron Steffen [Wed, 26 Oct 2022 22:01:00 +0000 (17:01 -0500)]
Use LanguageItems::require less

20 months agoRollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errors
Guillaume Gomez [Sat, 29 Oct 2022 12:18:03 +0000 (14:18 +0200)]
Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errors

Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions

Functions in answer:

- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`

This allows to remove a lot of useless `.at(DUMMY_SP)`, making the code a bit nicer :3

r? `@compiler-errors`

20 months agoRename some `OwnerId` fields.
Nicholas Nethercote [Thu, 27 Oct 2022 03:02:18 +0000 (14:02 +1100)]
Rename some `OwnerId` fields.

spastorino noticed some silly expressions like `item_id.def_id.def_id`.

This commit renames several `def_id: OwnerId` fields as `owner_id`, so
those expressions become `item_id.owner_id.def_id`.

`item_id.owner_id.local_def_id` would be even clearer, but the use of
`def_id` for values of type `LocalDefId` is *very* widespread, so I left
that alone.

20 months agoAuto merge of #102233 - petrochenkov:effvis, r=jackh726
bors [Sat, 29 Oct 2022 03:08:59 +0000 (03:08 +0000)]
Auto merge of #102233 - petrochenkov:effvis, r=jackh726

privacy: Rename "accessibility levels" to "effective visibilities"

And a couple of other naming and comment tweaks.

Related to https://github.com/rust-lang/rust/issues/48054

For `enum Level` I initially used naming `enum EffectiveVisibilityLevel`, but it was too long and inconvenient because it's used pretty often.
So I shortened it to just `Level`, if it needs to be used from some context where this name would be ambiguous, then it can be imported with renaming like `use rustc_middle::privacy::Level as EffVisLevel` or something.

20 months agoRetain ParamEnv constness when running deferred cast checks
Deadbeef [Fri, 28 Oct 2022 11:46:12 +0000 (11:46 +0000)]
Retain ParamEnv constness when running deferred cast checks

Fixes #103677.

20 months agoMove clippy::uninlined_format_args back to pedantic
Philipp Krones [Thu, 27 Oct 2022 20:24:24 +0000 (22:24 +0200)]
Move clippy::uninlined_format_args back to pedantic

20 months agoUpdate tooling
Maybe Waffle [Thu, 27 Oct 2022 14:32:17 +0000 (18:32 +0400)]
Update tooling

20 months agoprivacy: Rename "accessibility levels" to "effective visibilities"
Vadim Petrochenkov [Thu, 22 Sep 2022 13:19:53 +0000 (16:19 +0300)]
privacy: Rename "accessibility levels" to "effective visibilities"

And a couple of other naming tweaks

Related to https://github.com/rust-lang/rust/issues/48054

20 months agoAdjust normalization
mejrs [Wed, 26 Oct 2022 11:41:57 +0000 (13:41 +0200)]
Adjust normalization

20 months agoAuto merge of #103392 - RalfJung:miri, r=oli-obk
bors [Tue, 25 Oct 2022 12:33:39 +0000 (12:33 +0000)]
Auto merge of #103392 - RalfJung:miri, r=oli-obk

update Miri

I had to use a hacked version of josh to create this, so let's be careful with merging this and maybe wait a bit to see if the josh issue becomes more clear. But the history looks good to me, we are not adding duplicates of rustc commits that were previously mirrored to Miri.

Also I want to add some cross-testing of Miri in x.py.

20 months agoAdd more normalization and tests
mejrs [Mon, 24 Oct 2022 21:19:48 +0000 (23:19 +0200)]
Add more normalization and tests

20 months agoAddress some comments
mejrs [Mon, 24 Oct 2022 18:52:51 +0000 (20:52 +0200)]
Address some comments

20 months agoMerge commit '4f142aa1058f14f153f8bfd2d82f04ddb9982388' into clippyup
flip1995 [Sun, 23 Oct 2022 13:18:45 +0000 (15:18 +0200)]
Merge commit '4f142aa1058f14f153f8bfd2d82f04ddb9982388' into clippyup

20 months agoIntroduce subst_iter and subst_iter_copied on EarlyBinder
Michael Goulet [Sun, 16 Oct 2022 18:48:28 +0000 (18:48 +0000)]
Introduce subst_iter and subst_iter_copied on EarlyBinder

20 months agoAuto merge of #103344 - Dylan-DPC:rollup-d1rpfvx, r=Dylan-DPC
bors [Fri, 21 Oct 2022 12:41:09 +0000 (12:41 +0000)]
Auto merge of #103344 - Dylan-DPC:rollup-d1rpfvx, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #102287 (Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait`)
 - #102922 (Filtering spans when emitting json)
 - #103051 (translation: doc comments with derives, subdiagnostic-less enum variants, more derive use)
 - #103111 (Account for hygiene in typo suggestions, and use them to point to shadowed names)
 - #103260 (Fixup a few tests needing asm support)
 - #103321 (rustdoc: improve appearance of source page navigation bar)

Failed merges:

 - #103209 (Diagnostic derives: allow specifying multiple alternative suggestions)

r? `@ghost`
`@rustbot` modify labels: rollup

20 months agoRollup merge of #103260 - cuviper:needs-asm-support, r=fee1-dead
Dylan DPC [Fri, 21 Oct 2022 11:59:59 +0000 (17:29 +0530)]
Rollup merge of #103260 - cuviper:needs-asm-support, r=fee1-dead

Fixup a few tests needing asm support

20 months agoRollup merge of #102922 - kper:bugfix/102902-filtering-json, r=oli-obk
Dylan DPC [Fri, 21 Oct 2022 11:59:58 +0000 (17:29 +0530)]
Rollup merge of #102922 - kper:bugfix/102902-filtering-json, r=oli-obk

Filtering spans when emitting json

According to the issue #102902, we shouldn't emit spans which have an empty span and no suggested replacement.

20 months agomerge rustc history
Ralf Jung [Fri, 21 Oct 2022 08:18:54 +0000 (10:18 +0200)]
merge rustc history

20 months agorustc_hir_typeck: fix clippy
lcnr [Thu, 20 Oct 2022 15:51:48 +0000 (17:51 +0200)]
rustc_hir_typeck: fix clippy

20 months agoImplement assertions and fixes to not emit empty spans without suggestions
Kevin Per [Tue, 11 Oct 2022 16:17:59 +0000 (16:17 +0000)]
Implement assertions and fixes to not emit empty spans without suggestions

20 months agoFixup a few tests needing asm support
Josh Stone [Wed, 19 Oct 2022 18:34:00 +0000 (11:34 -0700)]
Fixup a few tests needing asm support

20 months agoAdd testcase for next_point, fix more trivial issues in find_width_of_character_at_span
yukang [Wed, 19 Oct 2022 03:46:26 +0000 (11:46 +0800)]
Add testcase for next_point, fix more trivial issues in find_width_of_character_at_span