Commit Graph

241831 Commits

Author SHA1 Message Date
Nicholas Nethercote
824667f753 Improve some names.
Lots of vectors of messages called `message` or `msg`. This commit
pluralizes them.

Note that `emit_message_default` and `emit_messages_default` both
already existed, and both process a vector, so I renamed the former
`emit_messages_default_inner` because it's called by the latter.
2023-12-23 13:23:28 +11:00
Nicholas Nethercote
d7a3b6291c Remove Diagnostic::new_with_code.
Its single use can be replaced with `Diagnostic::new_with_messages`.
2023-12-23 13:23:28 +11:00
Nicholas Nethercote
3a1b8e643a Rename EarlyDiagCtxt methods to match DiagCtxt.
- `early_error_no_abort` -> `early_err`
- `early_error` -> `early_fatal`
- `early_struct_error` -> `early_struct_fatal`
2023-12-23 13:23:28 +11:00
Nicholas Nethercote
1f08bfa383 Remove DiagCtxtInner::span_bug.
`DiagCtxt::span_bug` is different to the other `DiagCtxt::span_*`
methods. This commit makes it the same, which requires changing
`DiagCtxt::span_delayed_bug` to not do everything within the
`inner.borrow_mut()`.
2023-12-23 13:23:28 +11:00
Nicholas Nethercote
1502596ca2 Introduce DiagCtxt::treat_next_err_as_bug.
To fix a FIXME.
2023-12-23 13:23:28 +11:00
Nicholas Nethercote
6f147afea9 Remove unnecessary line breaks from two string literals. 2023-12-23 13:23:28 +11:00
Nicholas Nethercote
a108a3bd8e Tweak flush_delayed.
- Take a `Vec` instead of an iterator, because that's all that is
  needed.
- Do an early return for the "no bugs" case.
- Use `enumerate` and an `i == 0` test to identify the first bug.

Those changes mean the `no_bug` variable can be removed, which I found
hard to read.
2023-12-23 13:23:28 +11:00
Nicholas Nethercote
757d6f6ef8 Give DiagnosticBuilder a default type.
`IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the
most common diagnostic level. It makes sense to do likewise for the
closely-related (and much more widely used) `DiagnosticBuilder` type,
letting us write `DiagnosticBuilder<'a, ErrorGuaranteed>` as just
`DiagnosticBuilder<'a>`. This cuts over 200 lines of code due to many
multi-line things becoming single line things.
2023-12-23 13:23:10 +11:00
Nicholas Nethercote
6257f3bf1f Use IntoDiagnostic default.
`IntoDiagnostic` defaults to `G = ErrorGuaranteed`. Take advantage of
this in one place that currently doesn't.
2023-12-23 13:18:50 +11:00
Nicholas Nethercote
aec78dd695 Fix a couple of left-over references to Handler. 2023-12-23 13:18:50 +11:00
Nicholas Nethercote
1b3695887f Improve use items in compiler/rustc_errors/src/lib.rs.
There are a bunch of them about 400 lines down, which is weird and
annoying. This commit moves them up and puts them in a more sensible
order.
2023-12-23 13:18:50 +11:00
Nicholas Nethercote
de303b87c9 Streamline struct_lint_level.
We can just get the error level in the `match` and then use
`DiagnosticBuilder::new`. This then means a number of `DiagCtxt`
functions are no longer needed, because this was the one place that used
them.

Note: the commit changes the treatment of spans for `Expect`, which was
different to all the other cases, but this has no apparent effect.
2023-12-23 13:18:50 +11:00
Nicholas Nethercote
c8c1615df0 Add comments to Level.
There is room for improvement on some of these, but something is better
than nothing.
2023-12-23 13:18:50 +11:00
bors
467d1d97d4 Auto merge of #119227 - weihanglo:update-cargo, r=weihanglo
Update cargo

10 commits in 1a2666ddd14cf0a255d4ddb61c63531c259a7b39..363a2d11320faf531f6aacd1ea067c6bc08343b9
2023-12-17 17:53:53 +0000 to 2023-12-22 03:12:42 +0000
- refactor: centralize git checkouts and db paths (rust-lang/cargo#13187)
- Bump to 0.78.0; update changelog (rust-lang/cargo#13192)
- refactor: custom error types for `cargo-util-schemas` (rust-lang/cargo#13186)
- chore(deps): update rust crate handlebars to `v4.5.0` (rust-lang/cargo#13168)
- Hold the mutate exclusive lock when vendoring (rust-lang/cargo#12509)
- refactor: clean up package metadata (rust-lang/cargo#13184)
- ci: check SemVer for cargo-util-schemas on CI (rust-lang/cargo#13185)
- refactor(schemas): Pull out as `cargo-util-schemas` (rust-lang/cargo#13178)
- chore(rustfix): rename Readme.md to README.md (rust-lang/cargo#13181)
- chore(rustfix): remove useless clippy rules and fix a typo (rust-lang/cargo#13182)

r? ghost
2023-12-22 22:27:35 +00:00
Weihang Lo
e6412f277a
bootstrap: build doc for `cargo-util-schemas 2023-12-22 17:13:35 -05:00
Weihang Lo
b94cc35f38
Update cargo 2023-12-22 17:02:31 -05:00
bors
d6d7a93866 Auto merge of #118824 - aliemjay:perf-region-cons, r=compiler-errors
use Vec for region constraints instead of BTreeMap

~1% perf gain

Diagnostic regressions need more investigation.

r? `@ghost`
2023-12-22 20:28:48 +00:00
bors
398fd92e17 Auto merge of #119221 - matthiaskrgr:rollup-dh9exqf, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #117601 (Add support for hexagon-unknown-none-elf as target)
 - #119169 (Rid the AST & HIR pretty printer of cruft)
 - #119194 (Run fuchsia tests only on nightly)
 - #119201 (tests: fix overaligned-constant to not over-specify getelementptr instr)
 - #119215 (Emits error if has bound regions)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-22 18:32:16 +00:00
Matthias Krüger
b24e8784de
Rollup merge of #119215 - mu001999:fix/119209, r=Nilstrieb
Emits error if has bound regions

Fixes #119209
2023-12-22 19:01:28 +01:00
Matthias Krüger
41fbd25b73
Rollup merge of #119201 - durin42:overaligned-constant, r=Mark-Simulacrum
tests: fix overaligned-constant to not over-specify getelementptr instr

On LLVM 18 we get slightly different arguments here, so it's easier to just regex those away. The important details are all still asserted as I understand things.

Fixes #119193.

`@rustbot` label: +llvm-main
2023-12-22 19:01:27 +01:00
Matthias Krüger
c1263be8ea
Rollup merge of #119194 - pietroalbini:pa-disable-fuchsia-non-nightly, r=tmandry
Run fuchsia tests only on nightly

We discovered in https://github.com/rust-lang/rust/pull/119187 that the Fuchsia tests only work on nightly, and so we cannot have the `x86_64-gnu-integration` job run on beta and stable. This PR gates the job to only run in the nightly channel.

r? `@tmandry`
2023-12-22 19:01:27 +01:00
Matthias Krüger
15dc9f5bee
Rollup merge of #119169 - fmease:pretty-yeet-syntactic-cruft, r=compiler-errors
Rid the AST & HIR pretty printer of cruft

Found while working on #119163.

For `trait Trait: ?Sized {}` (semantically malformed), we currently output `trait Trait for ? Sized {}` (sic!) / `trait Trait for ? Sized { }` (sic!) if `-Zunpretty=expanded` / `-Zunpretty=hir` is passed.

`trait Tr for Sized? {}` (#15521) and later also `trait Tr for ?Sized {}` (I guess, #20194) is former Rust syntax. Hence I'm removing these outdated branches.

~~This will conflict with #119163, therefore marking this PR as blocked.~~ Rebased
2023-12-22 19:01:26 +01:00
Matthias Krüger
09684d2d31
Rollup merge of #117601 - androm3da:hexagon_unknown_none_elf, r=petrochenkov
Add support for hexagon-unknown-none-elf as target

Still TODO: document usage details for new target
2023-12-22 19:01:26 +01:00
r0cky
d3f466a3a7 Update test 2023-12-23 00:09:37 +08:00
r0cky
4830325a14 Emits error if has bound regions 2023-12-22 23:25:54 +08:00
bors
208dd2032b Auto merge of #118847 - eholk:for-await, r=compiler-errors
Add support for `for await` loops

This adds support for `for await` loops. This includes parsing, desugaring in AST->HIR lowering, and adding some support functions to the library.

Given a loop like:
```rust
for await i in iter {
    ...
}
```
this is desugared to something like:
```rust
let mut iter = iter.into_async_iter();
while let Some(i) = loop {
    match core::pin::Pin::new(&mut iter).poll_next(cx) {
        Poll::Ready(i) => break i,
        Poll::Pending => yield,
    }
} {
    ...
}
```

This PR also adds a basic `IntoAsyncIterator` trait. This is partly for symmetry with the way `Iterator` and `IntoIterator` work. The other reason is that for async iterators it's helpful to have a place apart from the data structure being iterated over to store state. `IntoAsyncIterator` gives us a good place to do this.

I've gated this feature behind `async_for_loop` and opened #118898 as the feature tracking issue.

r? `@compiler-errors`
2023-12-22 14:17:10 +00:00
León Orell Valerian Liehr
b09889b959
Rid the AST & HIR pretty printers of syntactic cruft 2023-12-22 14:32:40 +01:00
bors
c1fc1d18cd Auto merge of #116821 - Nadrieril:fix-opaque-ice, r=compiler-errors
Exhaustiveness: reveal opaque types properly

Previously, exhaustiveness had no clear policy around opaque types. In this PR I propose the following policy: within the body of an item that defines the hidden type of some opaque type, exhaustiveness checking on a value of that opaque type is performed using the concrete hidden type inferred in this body.

I'm not sure how consistent this is with other operations allowed on opaque types; I believe this will require FCP.

From what I can tell, this doesn't change anything for non-empty types.

The observable changes are:
- when the real type is uninhabited, matches within the defining scopes can now rely on that for exhaustiveness, e.g.:

```rust
#[derive(Copy, Clone)]
enum Void {}
fn return_never_rpit(x: Void) -> impl Copy {
    if false {
        match return_never_rpit(x) {}
    }
    x
}
```
- this properly fixes ICEs like https://github.com/rust-lang/rust/issues/117100 that occurred because a same match could have some patterns where the type is revealed and some where it is not.

Bonus subtle point: if `x` is opaque, a match like `match x { ("", "") => {} ... }` will constrain its type ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=901d715330eac40339b4016ac566d6c3)). This is not the case for `match x {}`: this will not constain the type, and will only compile if something else constrains the type to be empty.

Fixes https://github.com/rust-lang/rust/issues/117100

r? `@oli-obk`

Edited for precision of the wording

[Included](https://github.com/rust-lang/rust/pull/116821#issuecomment-1813171764) in the FCP on this PR is this rule:

> Within the body of an item that defines the hidden type of some opaque type, exhaustiveness checking on a value of that opaque type is performed using the concrete hidden type inferred in this body.
2023-12-22 12:12:12 +00:00
bors
ef1b78eabe Auto merge of #119173 - compiler-errors:direct-coro-kind, r=TaKO8Ki
Encode `CoroutineKind` directly

Probably a quick optimization?

r? `@ghost`
2023-12-22 04:07:40 +00:00
bors
aaef5fe497 Auto merge of #119163 - fmease:refactor-ast-trait-bound-modifiers, r=compiler-errors
Refactor AST trait bound modifiers

Instead of having two types to represent trait bound modifiers in the parser / the AST (`parser::ty::BoundModifiers` & `ast::TraitBoundModifier`), only to map one to the other later, just use `parser::ty::BoundModifiers` (moved & renamed to `ast::TraitBoundModifiers`).

The struct type is more extensible and easier to deal with (see [here](https://github.com/rust-lang/rust/pull/119099/files#r1430749981) and [here](https://github.com/rust-lang/rust/pull/119099/files#r1430752116) for context) since it more closely models what it represents: A compound of two kinds of modifiers, constness and polarity. Modeling this as an enum (the now removed `ast::TraitBoundModifier`) meant one had to add a new variant per *combination* of modifier kind, which simply isn't scalable and which lead to a lot of explicit non-DRY matches.

NB: `hir::TraitBoundModifier` being an enum is fine since HIR doesn't need to worry representing invalid modifier kind combinations as those get rejected during AST validation thereby immensely cutting down the number of possibilities.
2023-12-22 02:00:55 +00:00
bors
cee794ee98 Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errors
Fix `EmissionGuarantee`

There are some problems with the `DiagCtxt` API related to `EmissionGuarantee`. This PR fixes them.

r? `@compiler-errors`
2023-12-22 00:03:57 +00:00
Augie Fackler
58fdbd1479 tests: fix overaligned-constant to not over-specify getelementptr instr
On LLVM 18 we get slightly different arguments here, so it's easier to
just regex those away. The important details are all still asserted as I
understand things.

Fixes #119193.

@rustbot label: +llvm-main
2023-12-21 15:53:28 -05:00
bors
3d0e6bed60 Auto merge of #119190 - matthiaskrgr:rollup-jvl8vkj, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #118729 (Add release notes for 1.75.0)
 - #119124 (don't build `rust-analyzer-proc-macro-srv` on def config )
 - #119154 (Simple modification of `non_lifetime_binders`'s diagnostic information to adapt to type binders)
 - #119176 (Fix name error in aarch64_apple_watchos tier 3 target)
 - #119182 (Update sysinfo version to 0.30.0)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-21 20:50:46 +00:00
Brian Cain
cc34942f12 Add support for hexagon-unknown-none-elf as target
Signed-off-by: Brian Cain <bcain@quicinc.com>
2023-12-21 09:34:29 -08:00
Pietro Albini
12b06ad51b
run fuchsia tests only on nightly 2023-12-21 18:27:24 +01:00
Matthias Krüger
6516e595c0
Rollup merge of #119182 - GuillaumeGomez:update-sysinfo, r=onur-ozkan
Update sysinfo version to 0.30.0

Following last `sysinfo` update. Nothing much needs to be changed here apparently.

r? `@onur-ozkan`
2023-12-21 16:43:08 +01:00
Matthias Krüger
81e5ca4d97
Rollup merge of #119176 - leohowell:fix-apple-watchos-target-name-error, r=lqd
Fix name error in aarch64_apple_watchos tier 3 target

fix llvm_target wrong name `aarch-apple-watchos` to `aarch64-apple-watchos`, sorry for my mistake.

previous pr: https://github.com/rust-lang/rust/pull/119074

r? compiler-team
2023-12-21 16:43:08 +01:00
Matthias Krüger
2b48e7dbcb
Rollup merge of #119154 - surechen:fix_119067, r=fmease
Simple modification of `non_lifetime_binders`'s diagnostic information to adapt to type binders

fixes #119067

Replace diagnostic information "lifetime bounds cannot be used in this context" to "bounds cannot be used in this context".

```rust
#![allow(incomplete_features)]
#![feature(non_lifetime_binders)]

trait Trait {}

trait Trait2
    where for <T: Trait> ():{}
//~^ ERROR bounds cannot be used in this context
```
2023-12-21 16:43:07 +01:00
Matthias Krüger
c644d00285
Rollup merge of #119124 - onur-ozkan:help-118861, r=Mark-Simulacrum
don't build `rust-analyzer-proc-macro-srv` on def config

Should be very easy to understand when reviewing commit-by-commit.

Blocker for #118861
2023-12-21 16:43:07 +01:00
Matthias Krüger
1871f2b4a0
Rollup merge of #118729 - cuviper:relnotes-1.75.0, r=pietroalbini
Add release notes for 1.75.0

cc `@rust-lang/release`
r? `@Mark-Simulacrum`
2023-12-21 16:43:06 +01:00
onur-ozkan
1f141dc0b8 add a new change in change-tracker
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-12-21 16:08:14 +03:00
Pietro Albini
73cd2df422
apply last suggestions from code review 2023-12-21 13:26:15 +01:00
Guillaume Gomez
c3ede70d35 Update sysinfo version to 0.30.0 2023-12-21 12:17:49 +01:00
bors
767453eb7c Auto merge of #119181 - pietroalbini:pa-1.77, r=pietroalbini
Bump version number to 1.77.0
2023-12-21 10:02:26 +00:00
Pietro Albini
a55698a1ac
bump version number to 1.77.0 2023-12-21 10:58:56 +01:00
Leo Howell
d9842a2060
Fix name error in aarch64_apple_watchos tier 3 target 2023-12-21 13:53:11 +08:00
bors
920e0051cf Auto merge of #119056 - cjgillot:codegen-overalign, r=wesleywiser
Tolerate overaligned MIR constants for codegen.

Fixes https://github.com/rust-lang/rust/issues/117761

cc `@saethlin`
2023-12-21 04:01:36 +00:00
surechen
4897d5eccf Simple modification of diagnostic information
fixes #119067
2023-12-21 10:17:11 +08:00
Michael Goulet
828272ad37 Encode CoroutineKind directly 2023-12-21 01:43:31 +00:00
bors
3694a6b20a Auto merge of #119170 - matthiaskrgr:rollup-nllgdf2, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #119135 (Fix crash due to `CrateItem::kind()` not handling constructors)
 - #119141 (Add method to get instance instantiation arguments)
 - #119145 (Give `VariantData::Struct`  named fields, to clairfy `recovered`.)
 - #119167 (E0761: module directory has .rs suffix)
 - #119168 (resolve: Stop feeding visibilities for import list stems)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-21 01:43:07 +00:00