Commit Graph

16554 Commits

Author SHA1 Message Date
Nathan Stocks
0d65819d52 respond to review feedback: mainly eliminate as many conversions as possible...
- ... when creating diagnostics in rustc_metadata
-  use the error_code! macro
- pass macro output to diag.code()
- use fluent from within manual implementation of SessionDiagnostic
- emit the untested errors in case they occur in the wild
- stop panicking in the probably-not-dead code, add fixme to write test
2022-08-31 10:56:42 -06:00
Nathan Stocks
d0ba1fbaa4 port of locator.rs to SessionDiagnostics, fix some of the errors
revealed by tests, manually add a panic to test for dead code
2022-08-31 10:56:42 -06:00
Nathan Stocks
bd8e312d73 port fs.rs to SessionDiagnostics 2022-08-31 10:56:42 -06:00
Nathan Stocks
32e1823b22 port creader.rs to SessionDiagnostics 2022-08-31 10:56:42 -06:00
Nathan Stocks
f7e462a6c7 port encoder.rs to SessionDiagnostics 2022-08-31 10:56:42 -06:00
Nathan Stocks
3ed93107ff port native_libs.rs to SessionDiagnostics 2022-08-31 10:56:42 -06:00
Nathan Stocks
54645e880f set up rustc_metadata for SessionDiagnostics, port dependency_format.rs 2022-08-31 10:56:38 -06:00
Ralf Jung
59d2c1917a
Rollup merge of #100831 - JhonnyBillM:migrate-symbol-mangling-to-diagnostics-structs, r=davidtwco
Migrate `symbol_mangling` module to new diagnostics structs
2022-08-31 14:29:53 +02:00
Ralf Jung
24922b7a82
Rollup merge of #100753 - LuisCardosoOliveira:translation-migrate-session, r=davidtwco
translations(rustc_session): migrates `rustc_session` to use `SessionDiagnostic` - Pt. 1

## Description

This is the first PR for the migration of the module `rustc_session`. You can follow my progress [here](https://github.com/rust-lang/rust/issues/100717#issuecomment-1220279883).

The PR migrates the files `cgu_reuse_tracker` and `parse.rs` to use `SessionDiagnostic `.
2022-08-31 14:29:52 +02:00
Ralf Jung
6c4bda6de4
Rollup merge of #100730 - CleanCut:diagnostics-rustc_monomorphize, r=davidtwco
Migrate rustc_monomorphize to use SessionDiagnostic

### Description

- Migrates diagnostics in `rustc_monomorphize` to use `SessionDiagnostic`
- Adds an `impl IntoDiagnosticArg for PathBuf`

### TODO / Help!
- [x] I'm having trouble figuring out how to apply an optional note. 😕  Help!?
  - Resolved. It was bad docs. Fixed in https://github.com/rust-lang/rustc-dev-guide/pull/1437/files
- [x] `errors:RecursionLimit` should be `#[fatal ...]`, but that doesn't exist so it's `#[error ...]` at the moment.
  - Maybe I can switch after this is merged in? --> https://github.com/rust-lang/rust/pull/100694
  - Or maybe I need to manually implement `SessionDiagnostic` instead of deriving it?
- [x] How does one go about converting an error inside of [a call to struct_span_lint_hir](8064a49508/compiler/rustc_monomorphize/src/collector.rs (L917-L927))?
- [x] ~What placeholder do you use in the fluent template to refer to the value in a vector? It seems like [this code](0b79f758c9/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs (L83-L114)) ought to have the answer (or something near it)...but I can't figure it out.~ You can't. Punted.
2022-08-31 14:29:51 +02:00
Matthias Krüger
49ed325759
Rollup merge of #101185 - compiler-errors:tweak-wf-locs, r=davidtwco
Tweak `WellFormedLoc`s a bit

Gives a bit tighter spans in returns and generic ty defaults
2022-08-31 07:58:02 +02:00
Matthias Krüger
b8b2f88a04
Rollup merge of #101100 - compiler-errors:generalize-call-suggestions, r=petrochenkov
Make call suggestions more general and more accurate

Cleans up some suggestions that have to do with adding `()` to make typeck happy.

1. Drive-by rename of `expr_t` to `base_ty` since it's the type of the `base_expr`
1. Autoderef until we get to a callable type in `suggest_fn_call`.
1. Don't erroneously suggest calling constructor when a method/field does not exist on it.
1. Suggest calling a method receiver if its function output has a method (e.g. `fn.method()` => `fn().method()`)
1. Extend call suggestions to type parameters, fn pointers, trait objects where possible
1. Suggest calling in operators too (fixes #101054)
1. Use `/* {ty} */` as argument placeholder instead of just `_`, which is confusing and makes suggestions look less like `if let` syntax.
2022-08-31 07:58:00 +02:00
Matthias Krüger
78e5d05ea0
Rollup merge of #101049 - JeanCASPAR:remove-span_fatal-from-ast_lowering, r=davidtwco
Remove span fatal from ast lowering

Now the crate `rustc_ast_lowering` is fully migrated to `SessionDiagnostic`.

r? ``@davidtwco``
2022-08-31 07:57:59 +02:00
Matthias Krüger
0fee731a95
Rollup merge of #101025 - semarie:openbsd-archs, r=petrochenkov
Add tier-3 support for powerpc64 and riscv64 openbsd

# powerpc64
- MCP for [powerpc64-unknown-openbsd tier-3 support](https://github.com/rust-lang/compiler-team/issues/551)
- only need to add spec definition in rustc_target

# riscv64
- MCP for [riscv64-unknown-openbsd tier-3 support](https://github.com/rust-lang/compiler-team/issues/552)
- add spec definition in rustc_target
- follow freebsd about avoiding linking with `libatomic`
2022-08-31 07:57:58 +02:00
Matthias Krüger
ea9c370ffe
Rollup merge of #100970 - Xiretza:derive-multipart-suggestion, r=davidtwco
Allow deriving multipart suggestions

This turned into a bit more of a rewrite than I was initially hoping for... Still, I think the `SessionSubdiagnostic` derive is a little cleaner overall now, and closer to the `SessionDiagnostic` derive to make future code sharing easier.

r? ``@davidtwco``
2022-08-31 07:57:54 +02:00
bors
7f442f8ba1 Auto merge of #101220 - JohnTitor:rollup-ov7upr7, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #100804 (Fix search results color on hover for ayu theme)
 - #100892 (Add `AsFd` implementations for stdio types on WASI.)
 - #100927 (Adding new Fuchsia rustup docs... reworking walkthrough)
 - #101088 (Set DebuginfoKind::Pdb in msvc_base)
 - #101159 (add tracking issue number to const_slice_split_at_not_mut)
 - #101192 (Remove path string)
 - #101193 (Avoid zeroing large stack buffers in stdio on Windows)
 - #101197 (⬆️ rust-analyzer)
 - #101200 (Add test for issue #85872)
 - #101219 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-31 02:24:44 +00:00
Yuki Okushi
42a1901cf4
Rollup merge of #101192 - TaKO8Ki:remove-path-string, r=compiler-errors
Remove path string
2022-08-31 08:47:20 +09:00
Yuki Okushi
9642e4840b
Rollup merge of #101088 - nicholasbishop:bishop-uefi-pdb, r=davidtwco
Set DebuginfoKind::Pdb in msvc_base

This PDB setting was added to `windows_msvc_base` in
https://github.com/rust-lang/rust/pull/98051. It's also needed for the
UEFI targets, and since `uefi_msvc_base` and `windows_msvc_base` are the
only things that inherit from `msvc_base`, just move the PDB setting up
to `mscv_base` to cover both.

Fixes https://github.com/rust-lang/rust/issues/101071
2022-08-31 08:47:18 +09:00
bors
f07d6e8c0a Auto merge of #99102 - JakobDegen:reorder-generators, r=oli-obk
Rework definition of MIR phases to more closely reflect semantic concerns

Implements most of rust-lang/compiler-team#522 .

I tried my best to restrict this PR to the "core" parts of the MCP. In other words, this includes just enough changes to make the new definition of `MirPhase` make sense. That means there are a couple of FIXMEs lying around. Depending on what reviewers prefer, I can either fix them in this PR or send follow up PRs. There are also a couple other refactorings of the `rustc_mir_transform/src/lib.rs` file that I want to do in follow ups that I didn't leave explicit FIXMEs for.
2022-08-30 23:43:33 +00:00
bors
02654a0844 Auto merge of #98919 - 5225225:stricter-invalid-value, r=RalfJung
Strengthen invalid_value lint to forbid uninit primitives, adjust docs to say that's UB

For context: https://github.com/rust-lang/rust/issues/66151#issuecomment-1174477404=

This does not make it a FCW, but it does explicitly state in the docs that uninit integers are UB.

This also doesn't affect any runtime behavior, uninit u32's will still successfully be created through mem::uninitialized.
2022-08-30 20:39:01 +00:00
Jhonny Bill Mena
3ee6946316 UPDATE - to support diag introduced in PR #100765 2022-08-30 14:27:43 -04:00
Jhonny Bill Mena
ef2f6ab55e ADD - diagnostics lints to symbol_mangling module 2022-08-30 14:27:42 -04:00
Jhonny Bill Mena
8f5fada86d ADD - migrate InvalidDefPath to new diagnostics infra 2022-08-30 14:27:42 -04:00
Jhonny Bill Mena
bd83bbc93a UPDATE - accept String instead of unused 'str 2022-08-30 14:27:42 -04:00
Jhonny Bill Mena
359002bbeb ADD - migrate InvalidTraitItem and AltInvalidTraitItem errors
Thought of doing this by having a struct and an enum with Default and Alt cases, but not sure if we wanted to have the text in code instead of having “demangling()” and “demangling-alt()” in the ftl file.

Don’t like the current way of having structs representing the same-ish and using long names to distinguish their expectations, instead of putting this in an enum and handling the different cases inside the type.

I am fine with whichever option the team prefers; also understand having them as separate structs keeps it simple.
2022-08-30 14:27:42 -04:00
Jhonny Bill Mena
86f8c4e8e3 ADD - InvalidSymbolName to migrate symbol-name({}) error to new diagnostics infraestructure
ADD - dependencies needed to port a module to new Diagnostics infra (rustc_macros, rustc_errors, errors file, and fluent file)
2022-08-30 14:27:42 -04:00
bors
fce6a7d66e Auto merge of #101195 - Dylan-DPC:rollup-rhjaz6r, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #99517 (Display raw pointer as *{mut,const} T instead of *-ptr in errors)
 - #99928 (Do not leak type variables from opaque type relation)
 - #100473 (Attempt to normalize `FnDef` signature in `InferCtxt::cmp`)
 - #100653 (Move the cast_float_to_int fallback code to GCC)
 - #100941 (Point at the string inside literal and mention if we need string inte…)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-30 14:52:02 +00:00
JeanCASPAR
79d4f09942
Change fatal diagnostic to an error.
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2022-08-30 14:26:09 +02:00
Dylan DPC
467d2c1833
Rollup merge of #100941 - lyming2007:issue-100584, r=oli-obk
Point at the string inside literal and mention if we need string inte…

…rpolation

	modified:   compiler/rustc_passes/src/liveness.rs
2022-08-30 16:56:10 +05:30
Dylan DPC
c57a932c3f
Rollup merge of #100653 - cuviper:fptoint_sat, r=michaelwoerister,antoyo
Move the cast_float_to_int fallback code to GCC

Now that we require at least LLVM 13, that codegen backend is always
using its intrinsic `fptosi.sat` and `fptoui.sat` conversions, so it
doesn't need the manual implementation. However, the GCC backend still
needs it, so we can move all of that code down there.
2022-08-30 16:56:09 +05:30
Dylan DPC
15e2e5185a
Rollup merge of #100473 - compiler-errors:normalize-the-fn-def-sig-plz, r=lcnr
Attempt to normalize `FnDef` signature in `InferCtxt::cmp`

Stashes a normalization callback in `InferCtxt` so that the signature we get from `tcx.fn_sig(..).subst(..)` in `InferCtxt::cmp` can be properly normalized, since we cannot expect for it to have normalized types since it comes straight from astconv.

This is kind of a hack, but I will say that `@jyn514` found the fact that we present unnormalized types to be very confusing in real life code, and I agree with that feeling. Though altogether I am still a bit unsure about whether this PR is worth the effort, so I'm open to alternatives and/or just closing it outright.

On the other hand, this isn't a ridiculously heavy implementation anyways -- it's less than a hundred lines of changes, and half of that is just miscellaneous cleanup.

This is stacked onto #100471 which is basically unrelated, and it can be rebased off of that when that lands or if needed.

---

The code:
```rust
trait Foo { type Bar; }

impl<T> Foo for T {
    type Bar = i32;
}

fn foo<T>(_: <T as Foo>::Bar) {}

fn needs_i32_ref_fn(f: fn(&'static i32)) {}

fn main() {
    needs_i32_ref_fn(foo::<()>);
}
```

Before:
```
   = note: expected fn pointer `fn(&'static i32)`
                 found fn item `fn(<() as Foo>::Bar) {foo::<()>}`
```

After:
```
   = note: expected fn pointer `fn(&'static i32)`
                 found fn item `fn(i32) {foo::<()>}`
```
2022-08-30 16:56:08 +05:30
Dylan DPC
9cfd161cd5
Rollup merge of #99928 - compiler-errors:issue-99914, r=oli-obk
Do not leak type variables from opaque type relation

The "root cause" is that we call `InferCtxt::resolve_vars_if_possible` (3d9dd681f5) on the types we get back in `TypeError::Sorts` since I added a call to it in `InferCtxt::same_type_modulo_infer`. However if this `TypeError` comes from a `InferCtxt::commit_if_ok`, then it may reference type variables that do not exist anymore, which is problematic.

We avoid this by substituting the `TypeError` with the types we had before being generalized while handling opaques.

This is kinda gross, and I feel like we can get the same issue from other places where we generalize type/const inference variables. Maybe not? I don't know.

Fixes #99914
Fixes #99970
Fixes #100463
2022-08-30 16:56:07 +05:30
Dylan DPC
548ed409af
Rollup merge of #99517 - Nilstrieb:display-raw-ptr, r=compiler-errors
Display raw pointer as *{mut,const} T instead of *-ptr in errors

The `*-ptr` is rather confusing, and we have the full information for properly displaying the information.
2022-08-30 16:56:06 +05:30
bors
230a8ee364 Auto merge of #98100 - bjorn3:use_object_for_bitcode_reading, r=wesleywiser
Use object instead of LLVM for reading bitcode from rlibs

Together with changes I plan to make as part of https://github.com/rust-lang/rust/pull/97485 this will allow entirely removing usage of LLVM's archive reader and thus allow removing `archive_ro.rs` and `ArchiveWrapper.cpp`.
2022-08-30 11:13:58 +00:00
Xiretza
31b939b315 Rework SessionSubdiagnostic derive to support multipart_suggestion 2022-08-30 12:18:43 +02:00
Takayuki Maeda
f6252a4862 remove path string 2022-08-30 19:06:19 +09:00
Jakob Degen
d56751cc34 Simplify pass manager's run_passes logic 2022-08-30 01:40:16 -07:00
Jakob Degen
aad14c701e Refactor MIR phases 2022-08-30 01:40:14 -07:00
bors
0631ea5d73 Auto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #95376 (Add `vec::Drain{,Filter}::keep_rest`)
 - #100092 (Fall back when relating two opaques by substs in MIR typeck)
 - #101019 (Suggest returning closure as `impl Fn`)
 - #101022 (Erase late bound regions before comparing types in `suggest_dereferences`)
 - #101101 (interpret: make read-pointer-as-bytes a CTFE-only error with extra information)
 - #101123 (Remove `register_attr` feature)
 - #101175 (Don't --bless in pre-push hook)
 - #101176 (rustdoc: remove unused CSS selectors for `.table-display`)
 - #101180 (Add another MaybeUninit array test with const)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-30 08:29:42 +00:00
Xiretza
9dc0643744 SessionSubdiagnostic: make #[applicability] optional 2022-08-30 09:48:03 +02:00
Xiretza
6e8dad5c07 Use span_suggestion_with_style in SessionSubdiagnostic derive 2022-08-30 09:48:00 +02:00
Xiretza
8af7f4208a Code deduplication in tool_only_multipart_suggestion 2022-08-30 09:46:42 +02:00
Michael Goulet
5a4f7d4ad3 Tweak WellFormedLocs a bit 2022-08-30 06:19:48 +00:00
Dylan DPC
c18292f6a3
Rollup merge of #101123 - JohnTitor:rm-register-attr, r=TaKO8Ki
Remove `register_attr` feature

Closes #66080

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-08-30 11:26:52 +05:30
Dylan DPC
81f3841cfb
Rollup merge of #101101 - RalfJung:read-pointer-as-bytes, r=oli-obk
interpret: make read-pointer-as-bytes a CTFE-only error with extra information

Next step in the reaction to https://github.com/rust-lang/rust/issues/99923. Also teaches Miri to implicitly strip provenance in more situations when transmuting pointers to integers, which fixes https://github.com/rust-lang/miri/issues/2456.

Pointer-to-int transmutation during CTFE now produces a message like this:
```
   = help: this code performed an operation that depends on the underlying bytes representing a pointer
   = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
```

r? ``@oli-obk``
2022-08-30 11:26:51 +05:30
Dylan DPC
1ea84961e8
Rollup merge of #101022 - compiler-errors:issue-101020, r=jackh726
Erase late bound regions before comparing types in `suggest_dereferences`

Fixes #101020
2022-08-30 11:26:50 +05:30
Dylan DPC
aa9bfdee32
Rollup merge of #101019 - compiler-errors:return-closure-suggestion, r=cjgillot
Suggest returning closure as `impl Fn`

Fixes #100936
2022-08-30 11:26:49 +05:30
Dylan DPC
e63424db19
Rollup merge of #100092 - compiler-errors:issue-100075, r=oli-obk
Fall back when relating two opaques by substs in MIR typeck

This is certainly _one_ way to fix #100075. Not really confident it's the _best_ way to do it, though.

The root cause of this issue is that during MIR type-check, we end up trying to equate an opaque against the same opaque def-id but with different substs. Because of the way that we replace RPITs during (HIR) typeck with an inference variable, we don't end up emitting a type-checking error, so the delayed MIR bug causes an ICE.

See the `src/test/ui/impl-trait/issue-100075-2.rs` test below to make that clear -- in that example, we try to equate `{impl Sized} substs=[T]` and `{impl Sized} substs=[Option<T>]`, which causes an ICE. This new logic will instead cause us to infer `{impl Sized} substs=[Option<T>]` as the hidden type for `{impl Sized} substs=[T]`, which causes a proper error to be emitted later on when we check that an opaque isn't recursive.

I'm open to closing this in favor of something else. Ideally we'd fix this in typeck, but the thing we do to ensure backwards compatibility with weird RPIT cases makes that difficult. Also open to discussing this further.
2022-08-30 11:26:48 +05:30
bors
a0d07093f8 Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrum
Revert let_chains stabilization

This is the revert against master, the beta revert was already done in #100538.

Bumps the stage0 compiler which already has it reverted.
2022-08-30 05:48:22 +00:00
bors
9f4d5d2a28 Auto merge of #101167 - matthiaskrgr:rollup-yt3jdmp, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #100898 (Do not report too many expr field candidates)
 - #101056 (Add the syntax of references to their documentation summary.)
 - #101106 (Rustdoc-Json: Retain Stripped Modules when they are imported, not when they have items)
 - #101131 (CTFE: exposing pointers and calling extern fn is just impossible)
 - #101141 (Simplify `get_trait_ref` fn used for `virtual_function_elimination`)
 - #101146 (Various changes to logging of borrowck-related code)
 - #101156 (Remove `Sync` requirement from lint pass objects)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-29 22:49:04 +00:00