Commit Graph

972 Commits

Author SHA1 Message Date
bors 9b60e6c68f Auto merge of #108312 - michaelwoerister:hash-set-not-hash-stable, r=eholk
Do not implement HashStable for HashSet (MCP 533)

This PR removes all occurrences of `HashSet` in query results, replacing it either with `FxIndexSet` or with `UnordSet`, and then removes the `HashStable` implementation of `HashSet`. This is part of implementing [MCP 533](https://github.com/rust-lang/compiler-team/issues/533), that is, removing the `HashStable` implementations of all collection types with unstable iteration order.

The changes are mostly mechanical. The only place where additional sorting is happening is in Miri's override implementation of the `exported_symbols` query.
2023-03-08 06:07:11 +00:00
Matthias Krüger 9c99a4ca2b
Rollup merge of #107801 - davidtwco:stability-implies-const, r=Nilstrieb
const_eval: `implies_by` in `rustc_const_unstable`

Fixes #107605.

Extend support for `implies_by` (from `#[stable]` and `#[unstable]`) to `#[rustc_const_stable]` and `#[rustc_const_unstable]`.

cc ``@steffahn``
2023-03-06 16:41:56 +01:00
bors 0d439f8181 Auto merge of #108351 - petrochenkov:rmdit, r=cjgillot
rustc_middle: Remove trait `DefIdTree`

This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-05 10:37:02 +00:00
est31 6df5ae4fb0 Match unmatched backticks in comments in compiler/ 2023-03-03 08:39:00 +01:00
est31 ff2c609d66 Match unmatched backticks in compiler/ that are part of rustdoc 2023-03-03 08:39:00 +01:00
Vadim Petrochenkov c83553da31 rustc_middle: Remove trait `DefIdTree`
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-02 23:46:44 +04:00
Michael Woerister 422208ae52 Use UnordSet instead of FxHashSet for names_imported_by_glob_use query. 2023-03-01 10:20:43 +01:00
Michael Woerister b0202d9c2c Use LocalDefIdSet/Map instead of FxHashSet/Map for live_symbols_and_ignored_derived_traits query. 2023-03-01 10:19:26 +01:00
Michael Woerister f0eadbafd4 Use LocalDefIdSet instead of FxHashSet for reachable_set query. 2023-03-01 10:19:25 +01:00
Matthias Krüger abc82484d4
Rollup merge of #108486 - cjgillot:owner-ditem, r=Nilstrieb
Merge diagnostic_items duplicate diagnostics

To deduplicate how we diagnose duplication.
2023-02-27 06:11:53 +01:00
Matthias Krüger 19b8685b06
Rollup merge of #108379 - compiler-errors:hir-error-guaranteed, r=cjgillot
Add `ErrorGuaranteed` to `hir::{Expr,Ty}Kind::Err` variants

First step in making the `Err` variants of `ExprKind` and `TyKind` require an `ErrorGuaranteed` during parsing. Making the corresponding AST versions require `ErrorGuaranteed` is a bit harder, whereas it was pretty easy to do this for HIR, so let's do that first.

The only weird thing about this PR is that `ErrorGuaranteed` is moved to `rustc_span`. This is *certainly* not the right place to put it, but `rustc_hir` cannot depend on `rustc_error` because the latter already depends on the former. Should I just pull out some of the error machinery from `rustc_error` into an even more minimal crate that `rustc_hir` can depend on? Advice would be appreciated.
2023-02-26 12:04:58 +01:00
Camille GILLOT 752ddd028c Merge the two diagnostics. 2023-02-26 10:29:25 +00:00
Camille GILLOT 11fbb57395 Simplify diagnostic_items. 2023-02-26 10:06:03 +00:00
bors 70fd012439 Auto merge of #108473 - matthiaskrgr:rollup-qjyae58, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #107062 (Do some cleanup of doc/index.md)
 - #107890 (Lint against `Iterator::map` receiving a callable that returns `()`)
 - #108431 (Add regression test for #107918)
 - #108432 (test: drop unused deps)
 - #108436 (make "proc macro panicked" translatable)
 - #108444 (docs/test: add UI test and docs for `E0476`)
 - #108449 (Do not lint ineffective unstable trait impl for unresolved trait)
 - #108456 (Complete migrating `ast_passes` to derive diagnostics)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-26 02:04:23 +00:00
Matthias Krüger a223ff7cea
Rollup merge of #108449 - fee1-dead-contrib:do_not_lint_unresolved, r=compiler-errors
Do not lint ineffective unstable trait impl for unresolved trait
2023-02-26 00:46:28 +01:00
Michael Goulet cf049ac2af
Rollup merge of #107911 - blyxyas:issue-107231-fix, r=compiler-errors
Add check for invalid #[macro_export] arguments

Resolves #107231
Sorry if I made something wrong, this is my first contribution to the repo.
2023-02-25 11:53:10 -08:00
Michael Goulet c0e58c3420 Add ErrorGuaranteed to HIR ExprKind::Err 2023-02-25 19:46:36 +00:00
Deadbeef ed34354bfa Do not lint unresolved trait for ineffective unstable trait impl 2023-02-25 10:12:20 +00:00
Dylan DPC 4aff2c5ff8
Rollup merge of #108377 - clubby789:duplicate-diagnostic-ice, r=compiler-errors
Fix ICE in 'duplicate diagnostic item' diagnostic

Not sure how to add this in a test; I found it by mistakenly running `cargo fix --lib -p std` rather than `x fix` at the root.
2023-02-24 12:02:43 +05:30
clubby789 4332a27c2d Fix ICE in 'duplicate diagnostic item' diagnostic 2023-02-23 14:58:48 +00:00
bors 0978711950 Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, r=compiler-errors,davidtwco,estebank,oli-obk
diagnostics: if AssocFn has self argument, describe as method

Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515

This commit also changes the tooltips on rustdoc intra-doc links targeting methods.

For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods>

> Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation.

In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-23 00:19:12 +00:00
blyxyas e39fe374df Add check for invalid \`#[macro_export]\` arguments 2023-02-22 21:53:16 +00:00
Matthias Krüger 783617b5e4
Rollup merge of #108315 - clubby789:dead-code-in-closure, r=compiler-errors
Lint dead code in closures and generators

Fixes #108296

I think this might be a potentially breaking change, but restores the behaviour of pre-1.64.

`@rustbot` label +A-lint
2023-02-22 20:05:58 +01:00
Michael Howell 3d056c3125 diagnostics: if AssocFn has self argument, describe as method
Discussed in
https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515

This commit also changes the tooltips on rustdoc intra-doc links
targeting methods.
2023-02-22 08:40:33 -07:00
clubby789 c7a4f387fd Lint dead code in closures 2023-02-22 15:27:19 +00:00
David Wood d1fcf61117 errors: generate typed identifiers in each crate
Instead of loading the Fluent resources for every crate in
`rustc_error_messages`, each crate generates typed identifiers for its
own diagnostics and creates a static which are pulled together in the
`rustc_driver` crate and provided to the diagnostic emitter.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22 09:15:53 +00:00
bors 21e5b941e0 Auto merge of #108128 - clubby789:builtin-derived-attr, r=jackh726
Properly check for builtin derived code

Fixes #108122
2023-02-19 21:18:07 +00:00
bors 9556b56dbd Auto merge of #107753 - kylematsuda:type-of, r=BoxyUwU
Switch to `EarlyBinder` for `type_of` query

Part of the work to finish #105779 and implement https://github.com/rust-lang/types-team/issues/78.

Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `type_of` query and removes `bound_type_of`.

r? `@lcnr`
2023-02-17 04:45:15 +00:00
Kyle Matsuda c183110cc2 remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata 2023-02-16 17:05:56 -07:00
Kyle Matsuda d822b97a27 change usages of type_of to bound_type_of 2023-02-16 17:01:52 -07:00
Matthias Krüger 089e8c03bc
Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjgillot
Implement partial support for non-lifetime binders

This implements support for non-lifetime binders. It's pretty useless currently, but I wanted to put this up so the implementation can be discussed.

Specifically, this piggybacks off of the late-bound lifetime collection code in `rustc_hir_typeck::collect::lifetimes`. This seems like a necessary step given the fact we don't resolve late-bound regions until this point, and binders are sometimes merged.

Q: I'm not sure if I should go along this route, or try to modify the earlier nameres code to compute the right bound var indices for type and const binders eagerly... If so, I'll need to rename all these queries to something more appropriate (I've done this for `resolve_lifetime::Region` -> `resolve_lifetime::ResolvedArg`)

cc rust-lang/types-team#81

r? `@ghost`
2023-02-17 00:19:34 +01:00
clubby789 90f642bb3d Properly check for builtin derives 2023-02-16 19:44:03 +00:00
Maybe Waffle 5bf6a46032 Replace some `then`s with some `then_some`s 2023-02-16 15:26:03 +00:00
Maybe Waffle 8751fa1a9a `if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)` 2023-02-16 15:26:00 +00:00
Michael Goulet eff2cb7760 Rename some region-specific stuff 2023-02-16 03:39:59 +00:00
bors 2d14db321b Auto merge of #108006 - cjgillot:def-impl, r=oli-obk
Avoid accessing HIR when it can be avoided

Experiment to see if it helps some incremental cases.

Will be rebased once https://github.com/rust-lang/rust/pull/107942 gets merged.

r? `@ghost`
2023-02-15 16:14:10 +00:00
Camille GILLOT e9e12266ce Do not fetch HIR for reachable. 2023-02-14 20:26:01 +00:00
Camille GILLOT 03dff82d59 Add `of_trait` to DefKind::Impl. 2023-02-14 19:55:44 +00:00
lcnr 646e667200 add a `#[rustc_coinductive]` attribute 2023-02-14 11:53:22 +01:00
David Wood 912783402f const_eval: `implies_by` in `rustc_const_unstable`
Extend support for `implies_by` (from `#[stable]` and `#[unstable]`)
to `#[rustc_const_stable]` and `#[rustc_const_unstable]`.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-08 15:09:11 +00:00
est31 a399f0ca84 rustc_passes: remove huge error imports 2023-02-05 03:47:58 +01:00
bors a94b9fd0ac Auto merge of #107569 - petrochenkov:optattr, r=nnethercote
ast: Optimize list and value extraction primitives for attributes

It's not necessary to convert the whole attribute into a meta item to extract something specific.
2023-02-03 11:19:03 +00:00
Matthias Krüger 230c9e91fd
Rollup merge of #107515 - Swatinem:hirvalidator, r=compiler-errors
Improve pretty-printing of `HirIdValidator` errors

This now uses `node_to_string` for both missing and seen Ids, which includes the snippet of code for which the Id was allocated. Also removes the duplicated printing of `HirId`, as `node_to_string` also includes that.
2023-02-02 17:14:06 +01:00
Arpad Borsos 3a75f10af1
Improve pretty-printing of `HirIdValidator` errors
This now uses `node_to_string` for both missing and seen Ids, which includes
the snippet of code for which the Id was allocated.
Also removes the duplicated printing of `HirId`, as `node_to_string` includes that already.
Similarly, changes all other users of `node_to_string` that do so, and changes the output of `node_to_string`, which is now "$hirid ($what `$span` in $path)".
2023-02-01 20:09:22 +01:00
Vadim Petrochenkov a9c8a5c025 ast: Optimize list and value extraction primitives for attributes
It's not necessary to convert the whole attribute into a meta item to extract something specific
2023-02-01 22:35:02 +04:00
bors 11d96b5930 Auto merge of #107257 - inquisitivecrystal:ffi-attr, r=davidtwco
Strengthen validation of FFI attributes

Previously, `codegen_attrs` validated the attributes `#[ffi_pure]`, `#[ffi_const]`, and `#[ffi_returns_twice]` to make sure that they were only used on foreign functions. However, this validation was insufficient in two ways:

1. `codegen_attrs` only sees items for which code must be generated, so it was unable to raise errors when the attribute was incorrectly applied to macros and the like.
2. the validation code only checked that the item with the attr was foreign, but not that it was a foreign function, allowing these attributes to be applied to foreign statics as well.

This PR moves the validation to `check_attr`, which sees all items. It additionally changes the validation to ensure that the attribute's target is `Target::ForeignFunction`, only allowing the attributes on foreign functions and not foreign statics. Because these attributes are unstable, there is no risk for backwards compatibility. The changes also ending up making the code much easier to read.

This PR is best reviewed commit by commit. Additionally, I was considering moving the tests to the `attribute` subdirectory, to get them out of the general UI directory. I could do that as part of this PR or a follow-up, as the reviewer prefers.

CC: #58328, #58329
2023-02-01 11:37:24 +00:00
Guillaume Gomez 53bb6322db
Rollup merge of #107467 - WaffleLapkin:uneq, r=oli-obk
Improve enum checks

Some light refactoring.
2023-01-31 23:38:52 +01:00
bors a64ef7d07d Auto merge of #100754 - davidtwco:translation-incremental, r=compiler-errors
incremental: migrate diagnostics

- Apply the diagnostic migration lints to more functions on `Session`, namely: `span_warn`, `span_warn_with_code`, `warn` `note_without_error`, `span_note_without_error`, `struct_note_without_error`.
- Add impls of `IntoDiagnosticArg` for `std::io::Error`, `std::path::Path` and `std::path::PathBuf`.
- Migrate the `rustc_incremental` crate's diagnostics to translatable diagnostic structs.

r? `@compiler-errors`
cc #100717
2023-01-31 10:20:58 +00:00
David Wood 2575b1abc9 session: diagnostic migration lint on more fns
Apply the diagnostic migration lint to more functions on `Session`.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-30 17:11:35 +00:00
Maybe Waffle f1d273cbfb Replace some `_ == _ || _ == _`s with `matches!(_, _ | _)`s 2023-01-30 12:26:26 +00:00