]> git.lizzy.rs Git - rust.git/log
rust.git
18 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`.

18 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.

18 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

18 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

18 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

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

18 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

18 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.

18 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.

18 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
```

18 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

18 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.

18 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

19 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

19 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>
19 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
```

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

19 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`

19 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.

19 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.

19 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.

19 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

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

19 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

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

19 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.

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

19 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

20 months agoImplement -Ztrack-diagnostics
mejrs [Tue, 18 Oct 2022 22:08:20 +0000 (00:08 +0200)]
Implement -Ztrack-diagnostics

20 months agoRemove CastCheckResult since it's unused
Michael Goulet [Wed, 14 Sep 2022 23:42:25 +0000 (23:42 +0000)]
Remove CastCheckResult since it's unused

20 months agomerge rustc history
Ralf Jung [Wed, 12 Oct 2022 17:53:57 +0000 (19:53 +0200)]
merge rustc history

20 months agoFix unclosed HTML tag in clippy doc
Guillaume Gomez [Mon, 10 Oct 2022 18:45:04 +0000 (20:45 +0200)]
Fix unclosed HTML tag in clippy doc

20 months agomerge rustc history
Ralf Jung [Mon, 10 Oct 2022 15:50:32 +0000 (17:50 +0200)]
merge rustc history

20 months agoRollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8Ki
Dylan DPC [Mon, 10 Oct 2022 08:13:43 +0000 (13:43 +0530)]
Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8Ki

Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type`

Thanks `@camsteffen` for catching this in ast too, cc https://github.com/rust-lang/rust/pull/102829#issuecomment-1272649247

20 months agoRollup merge of #99696 - WaffleLapkin:uplift, r=fee1-dead
Dylan DPC [Mon, 10 Oct 2022 08:13:40 +0000 (13:43 +0530)]
Rollup merge of #99696 - WaffleLapkin:uplift, r=fee1-dead

Uplift `clippy::for_loops_over_fallibles` lint into rustc

This PR, as the title suggests, uplifts [`clippy::for_loops_over_fallibles`] lint into rustc. This lint warns for code like this:
```rust
for _ in Some(1) {}
for _ in Ok::<_, ()>(1) {}
```
i.e. directly iterating over `Option` and `Result` using `for` loop.

There are a number of suggestions that this PR adds (on top of what clippy suggested):
1. If the argument (? is there a better name for that expression) of a `for` loop is a `.next()` call, then we can suggest removing it (or rather replacing with `.by_ref()` to allow iterator being used later)
   ```rust
    for _ in iter.next() {}
    // turns into
    for _ in iter.by_ref() {}
    ```
2. (otherwise) We can suggest using `while let`, this is useful for non-iterator, iterator-like things like [async] channels
   ```rust
   for _ in rx.recv() {}
   // turns into
   while let Some(_) = rx.recv() {}
   ```
3. If the argument type is `Result<impl IntoIterator, _>` and the body has a `Result<_, _>` type, we can suggest using `?`
   ```rust
   for _ in f() {}
   // turns into
   for _ in f()? {}
   ```
4. To preserve the original behavior and clear intent, we can suggest using `if let`
   ```rust
   for _ in f() {}
   // turns into
   if let Some(_) = f() {}
   ```
(P.S. `Some` and `Ok` are interchangeable depending on the type)

I still feel that the lint wording/look is somewhat off, so I'll be happy to hear suggestions (on how to improve suggestions :D)!

Resolves #99272

[`clippy::for_loops_over_fallibles`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_fallibles

20 months agoRename AssocItemKind::TyAlias to AssocItemKind::Type
Michael Goulet [Mon, 10 Oct 2022 02:05:24 +0000 (02:05 +0000)]
Rename AssocItemKind::TyAlias to AssocItemKind::Type

20 months agoRollup merge of #102275 - Urgau:stabilize-half_open_range_patterns, r=cjgillot
Yuki Okushi [Mon, 10 Oct 2022 01:23:03 +0000 (10:23 +0900)]
Rollup merge of #102275 - Urgau:stabilize-half_open_range_patterns, r=cjgillot

Stabilize `half_open_range_patterns`

This PR stabilize `feature(half_open_range_patterns)`:
```
Allows using `..=X` as a pattern.
```

And adds a new `feature(half_open_range_patterns_in_slices)` for the slice part, https://github.com/rust-lang/rust/pull/102275#issuecomment-1267422806.

The FCP was completed in https://github.com/rust-lang/rust/issues/67264.

20 months agoRollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki
Yuki Okushi [Sun, 9 Oct 2022 15:09:42 +0000 (00:09 +0900)]
Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki

rename `ImplItemKind::TyAlias` to `ImplItemKind::Type`

The naming of this variant seems inconsistent given that this is not really a "type alias", and the associated type variant for `TraitItemKind` is just called `Type`.

20 months agodeprecate `clippy::for_loops_over_fallibles`
Maybe Waffle [Fri, 7 Oct 2022 17:08:29 +0000 (17:08 +0000)]
deprecate `clippy::for_loops_over_fallibles`

20 months agofixup lint name
Maybe Waffle [Fri, 7 Oct 2022 15:59:39 +0000 (15:59 +0000)]
fixup lint name

20 months agoFix clippy tests that trigger `for_loop_over_fallibles` lint
Maybe Waffle [Thu, 25 Aug 2022 10:03:13 +0000 (14:03 +0400)]
Fix clippy tests that trigger `for_loop_over_fallibles` lint

20 months agomerge rustc history
Ralf Jung [Sun, 9 Oct 2022 10:42:24 +0000 (12:42 +0200)]
merge rustc history

20 months agoImplItemKind::TyAlias => ImplItemKind::Type
Michael Goulet [Sun, 9 Oct 2022 07:09:57 +0000 (07:09 +0000)]
ImplItemKind::TyAlias => ImplItemKind::Type

20 months agoRollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obk
Matthias Krüger [Sat, 8 Oct 2022 12:38:18 +0000 (14:38 +0200)]
Rollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obk

Remove `mir::CastKind::Misc`

As discussed in #97649 `mir::CastKind::Misc` is not clear, this PR addresses that by creating a new enum variant for every valid cast.

r? ````@oli-obk````

20 months agoStabilize half_open_range_patterns
Urgau [Sat, 24 Sep 2022 15:22:04 +0000 (17:22 +0200)]
Stabilize half_open_range_patterns

20 months agoAuto merge of #2583 - RalfJung:rustup, r=oli-obk
bors [Sat, 8 Oct 2022 08:53:29 +0000 (08:53 +0000)]
Auto merge of #2583 - RalfJung:rustup, r=oli-obk

initial josh subtree sync

This demonstrates what a josh-based rustup would look like with my patched josh. To create it I did
```
git fetch http://localhost:8000/rust-lang/rust.git:start=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/tools/miri]:/src/tools/miri.git master
git merge FETCH_HEAD
./rustup-toolchain HEAD && ./miri fmt
git commit -am rustup
```
Unlike the [previous attempt](https://github.com/rust-lang/miri/pull/2554), this does not add a new root commit to the repo.

Once we merge this, we committed to using josh for subtree syncing, and in particular a version of josh that includes https://github.com/josh-project/josh/pull/961 (or something compatible).

20 months agoAuto merge of #102091 - RalfJung:const_err, r=oli-obk
bors [Fri, 7 Oct 2022 20:50:51 +0000 (20:50 +0000)]
Auto merge of #102091 - RalfJung:const_err, r=oli-obk

make const_err a hard error

This lint has been deny-by-default with future incompat wording since [Rust 1.51](https://github.com/rust-lang/rust/pull/80394) and the stable release of this week starts showing it in cargo's future compat reports. I can't wait to finally get rid of at least some of the mess in our const-err-reporting-code. ;)

r? `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/71800
Fixes https://github.com/rust-lang/rust/issues/100114

20 months agomake const_err a hard error
Ralf Jung [Wed, 21 Sep 2022 11:05:20 +0000 (13:05 +0200)]
make const_err a hard error

20 months agoChange InferCtxtBuilder from enter to build
Cameron Steffen [Tue, 20 Sep 2022 03:03:59 +0000 (22:03 -0500)]
Change InferCtxtBuilder from enter to build

20 months agoIntroduce TypeErrCtxt
Cameron Steffen [Fri, 9 Sep 2022 20:08:06 +0000 (15:08 -0500)]
Introduce TypeErrCtxt

TypeErrCtxt optionally has a TypeckResults so that InferCtxt doesn't
need to.

20 months agoMerge commit '8f1ebdd18bdecc621f16baaf779898cc08cc2766' into clippyup
Philipp Krones [Thu, 6 Oct 2022 15:41:53 +0000 (17:41 +0200)]
Merge commit '8f1ebdd18bdecc621f16baaf779898cc08cc2766' into clippyup