Commit Graph

20717 Commits

Author SHA1 Message Date
yukang
e7a777805a Suggest possible clone when we have &T 2023-01-07 04:43:57 +08:00
Matthias Krüger
a1b3393f5f
Rollup merge of #106542 - sigaloid:master, r=bjorn3
Add default and latest stable edition to --edition in rustc (attempt 2)

Fixes #106041

No longer leaks string like my first attempt PR, #106094 - uses LazyLock to construct a `&'static str`

It will now output the default edition and latest stable edition in the help message for the `--edition` flag.

Going to request the same reviewer as the first attempt for continuity - r? `@Nilstrieb`
2023-01-06 21:26:12 +01:00
Matthias Krüger
9a090edf2e
Rollup merge of #106528 - estebank:quick-fix, r=TaKO8Ki
Tiny formatting fix
2023-01-06 21:26:11 +01:00
Matthias Krüger
498216e9db
Rollup merge of #106341 - Ezrashaw:refactor-error-code-tidy-check, r=mejrs,klensy,GuillaumeGomez
refactor: clean up `errors.rs` and `error_codes_check.rs`

`errors.rs` is basically unused now, `error_codes_check.rs` is useful but not well commented, etc. It also doesn't check certain things which are certainly not correct. For example, `E0505` has a UI test in `src/test/ui/error-codes/` but that test actually outputs `E0504`?! Other issues like these exist. I've implemented these with "warnings" which are a bit rough around the edges but should be removed eventually.

r? `@GuillaumeGomez` (again not sure if you want to review but its relevant to you)
2023-01-06 21:26:10 +01:00
Matthias Krüger
7568c49bf0
Rollup merge of #106287 - Nilstrieb:its-bugging-me-how-we-dont-have-docs, r=jyn514
Add some docs to `bug`, `span_bug` and `delay_span_bug`

cc `@mejrs` as you wanted me to do this, does this look good and understandable?
2023-01-06 21:26:09 +01:00
Matthew E
893938f64f
Update compiler/rustc_session/src/config.rs
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2023-01-06 14:36:52 -05:00
Matthew Esposito
5cda0a2f39 Add default and latest stable edition to --edition in rustc 2023-01-06 14:07:12 -05:00
bors
0fb8b72ce4 Auto merge of #106501 - cjgillot:resolved-elided-apit, r=compiler-errors
Correct detection of elided lifetimes in impl-trait.

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

r? `@compiler-errors`
cc `@pnkfelix`
2023-01-06 18:15:56 +00:00
Paul Kirth
c5bde0699f Enable Shadow Call Stack for Fuchsia on AArch64
Fuchsia already uses SCS by default for C/C++ code on ARM hardware.
This patch allows SCS to be used for Rust code as well.
2023-01-06 17:42:20 +00:00
bors
afe8c4537c Auto merge of #106474 - erikdesjardins:noalias, r=bjorn3
cleanup: handle -Zmutable-noalias like -Zbox-noalias

r? `@bjorn3`

cc `@RalfJung` this will conflict with #106180
2023-01-06 15:20:58 +00:00
Takayuki Maeda
804dea9ca6 use smaller spans for missing lifetime/generic args
fix rustdoc ui test
2023-01-06 21:55:23 +09:00
bors
7bbbaabbb6 Auto merge of #105805 - yanchen4791:issue-105227-fix, r=estebank
Suggest adding named lifetime when the return contains value borrowed from more than one lifetimes of function inputs

fix for #105227.

The problem: The suggestion of adding an explicit `'_` lifetime bound is **incorrect** when the function's return type contains a value which could be borrowed from more than one lifetimes of the function's inputs. Instead, a named lifetime parameter can be introduced in such a case.

The solution: Checking the number of elided lifetimes in the function signature. If more than one lifetimes found in the function inputs when the suggestion of adding explicit `'_` lifetime, change it to using named lifetime parameter `'a` instead.
2023-01-06 12:08:49 +00:00
bors
1146560e1a Auto merge of #106529 - Dylan-DPC:rollup-mvncmrk, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #106400 (Point at expressions where inference refines an unexpected type)
 - #106491 (Fix error-index redirect to work with the back button.)
 - #106494 (Add regression test for #58355)
 - #106499 (fix [type error] for error E0029 and E0277)
 - #106502 (rustdoc: remove legacy user-select CSS)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-06 09:17:14 +00:00
Dylan DPC
a8f7ec2c48
Rollup merge of #106499 - lyming2007:issue-105946-fix, r=estebank
fix [type error] for error E0029 and E0277

check explicitly for the type references error
if ty.references_error() is true change the error to be err.delay_as_bug() and prevent the error E0029 and E0277 from emitting out this fix #105946
2023-01-06 11:38:57 +05:30
Dylan DPC
6ae0f08c19
Rollup merge of #106400 - estebank:type-errs, r=compiler-errors
Point at expressions where inference refines an unexpected type

Fix #106355. Fix #14007. (!)

```
error[E0308]: mismatched types
  --> src/test/ui/type/type-check/point-at-inference.rs:12:9
   |
9  |         foo.push(i);
   |                  - this is of type `&{integer}`, which makes `foo` to be inferred as `Vec<&{integer}>`
...
12 |     bar(foo);
   |     --- ^^^ expected `i32`, found `&{integer}`
   |     |
   |     arguments to this function are incorrect
   |
   = note: expected struct `Vec<i32>`
              found struct `Vec<&{integer}>`
note: function defined here
  --> src/test/ui/type/type-check/point-at-inference.rs:2:4
   |
2  | fn bar(_: Vec<i32>) {}
   |    ^^^ -----------
help: consider dereferencing the borrow
   |
9  |         foo.push(*i);
   |                  +
```
2023-01-06 11:38:56 +05:30
bors
ce8fbe7901 Auto merge of #106429 - djkoloski:add_vendor_to_fuchsia_target_triple, r=nagisa
Add vendor to Fuchsia's target triple

Historically, Rust's Fuchsia targets have been labeled x86_64-fuchsia and aarch64-fuchsia. However, they should technically contain vendor information. This CL changes Fuchsia's target triples to include the "unknown" vendor since Clang now does normalization and handles all triple spellings.

This was previously attempted in #90510, which was closed due to inactivity.
2023-01-06 06:05:40 +00:00
Esteban Küber
0edca66a90 Tiny formatting fix 2023-01-06 05:34:56 +00:00
Yiming Lei
10dbcf0630 fix [type error] for error E0029 and E0277
check explicitly for the type references error
if ty.references_error() is true change the error to be err.delay_as_bug()
and prevent the error E0029 and E0277 from emitting out
this fix #105946
2023-01-05 21:21:13 -08:00
yanchen4791
523fe7a121 Suggests adding named lifetime when the return contains value borrowed from more than one lifetimes of the function's inputs 2023-01-05 21:09:27 -08:00
Esteban Küber
031e085450 Tweak output 2023-01-06 04:37:29 +00:00
Michael Goulet
a9d093bd6b Report WF error for new solver too 2023-01-06 04:09:44 +00:00
bors
0853d9677c Auto merge of #105890 - Nilstrieb:inline-fmt-part-1, r=jackh726
Fix `uninlined_format_args` in compiler crates with the diagnostic migration completed

Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).

Some of them have been reviewed by myself and they were all correct (though I still recommend going over all of them again for review).
2023-01-06 02:58:40 +00:00
Esteban Küber
1fa6ada9dd Detect bindings assigned blocks without tail expressions in trait errors
Address  #44173 for trait errors.
2023-01-06 02:43:16 +00:00
Esteban Küber
1983a627b3 Detect bindings assigned blocks without tail expressions
Address  #44173 for type check errors.
2023-01-06 00:45:10 +00:00
Esteban Küber
ce6b7179af Detect closures assigned to binding in block
Fix #58497.
2023-01-05 21:29:36 +00:00
Nilstrieb
5112f0281d Shrink ParseResult in the hot path.
A recent PR increased the size, which caused regressions. This uses the
existing generic infrastructure to differentiate between the hot path
and the diagnostics path.
2023-01-05 20:42:26 +01:00
nils
fd7a159710 Fix uninlined_format_args for some compiler crates
Convert all the crates that have had their diagnostic migration
completed (except save_analysis because that will be deleted soon and
apfloat because of the licensing problem).
2023-01-05 19:01:12 +01:00
Camille GILLOT
de1859fc32 Correct detection of elided lifetimes in impl-trait. 2023-01-05 18:00:45 +00:00
Esteban Küber
f98f2fcb5e fix rebase 2023-01-05 17:09:41 +00:00
clubby789
23c3a30730 Explain error with &mut self for unsized trait impls 2023-01-05 16:51:30 +00:00
Esteban Küber
b182259d39 review comments: reword 2023-01-05 16:51:17 +00:00
Esteban Küber
98f3936aa7 review comment: potentially produce more suggestions for arg type mismatch 2023-01-05 16:51:17 +00:00
Esteban Küber
c905f5e1b0 Account for type error on method arg caused by earlier inference
```rust
fn main() {
    let v = Vec::new();
    v.push(0);
    v.push(0);
    v.push("");
}
```

now produces

```
error[E0308]: mismatched types
  --> $DIR/point-at-inference-3.rs:6:12
   |
LL |     v.push(0);
   |            - this is of type `{integer}`, which makes `v` to be inferred as `Vec<{integer}>`
...
LL |     v.push("");
   |       ---- ^^ expected integer, found `&str`
   |       |
   |       arguments to this function are incorrect
   |
note: associated function defined here
  --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
```
2023-01-05 16:51:17 +00:00
Esteban Küber
ad82eedfa1 Use BottomUpFolder 2023-01-05 16:51:16 +00:00
Esteban Küber
4ac7d1c3ab Formatting 2023-01-05 16:51:16 +00:00
Esteban Küber
9cc8d86190 Tweak output
- Only point at a the single expression where the found type was first
  inferred.
- Find method call argument that might have caused the found type to be
  inferred.
- Provide structured suggestion.
- Apply some review comments.
- Tweak wording.
2023-01-05 16:51:16 +00:00
Esteban Küber
6b0cce4b50 review comments: do not always point at init expr 2023-01-05 16:51:16 +00:00
Esteban Küber
48094a4a6f More eagerly resolve expr tys before writing them
This allows the expressions to have more accurate types
when showing inference steps.
2023-01-05 16:51:16 +00:00
Esteban Küber
05c30b0ca5 Skip macros to avoid talking about bindings the user can't see 2023-01-05 16:51:16 +00:00
Esteban Küber
ea43eb3721 Point at expressions where inference refines an unexpected type
Address #106355.
2023-01-05 16:51:16 +00:00
David Koloski
f6ef039775 Add vendor to Fuchsia's target triple
Historically, Rust's Fuchsia targets have been labeled x86_64-fuchsia
and aarch64-fuchsia. However, they should technically contain vendor
information. This CL changes Fuchsia's target triples to include the
"unknown" vendor since Clang now does normalization and handles all
triple spellings.

This was previously attempted in #90510, which was closed due to
inactivity.
2023-01-05 09:34:22 -05:00
bors
e94fab69d0 Auto merge of #106404 - tmiasko:dedup-box-derefs, r=wesleywiser
Remove duplicated elaborate box derefs pass

The pass runs earlier as a part of `run_runtime_lowering_passes`.

The duplicate was added in #99102.
2023-01-05 09:50:05 +00:00
bors
1429899700 Auto merge of #106482 - compiler-errors:rollup-g7n1p39, r=compiler-errors
Rollup of 6 pull requests

Successful merges:

 - #105846 (Account for return-position `impl Trait` in trait in `opt_suggest_box_span`)
 - #106385 (Split `-Zchalk` flag into `-Ztrait-solver=(classic|chalk|next)` flag)
 - #106403 (Rename `hir::Map::{get_,find_}parent_node` to `hir::Map::{,opt_}parent_id`, and add `hir::Map::{get,find}_parent`)
 - #106462 (rustdoc: remove unnecessary wrapper around sidebar and mobile logos)
 - #106464 (Update Fuchsia walkthrough with new configs)
 - #106478 (Tweak wording of fn call with wrong number of args)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-05 06:47:02 +00:00
Michael Goulet
e048ee2ac1
Rollup merge of #106478 - estebank:tweak-fn-mismatch, r=compiler-errors
Tweak wording of fn call with wrong number of args
2023-01-04 20:36:29 -08:00
Michael Goulet
5ce6311f34
Rollup merge of #106403 - compiler-errors:rename-hir-methods, r=cjgillot
Rename `hir::Map::{get_,find_}parent_node` to `hir::Map::{,opt_}parent_id`, and add `hir::Map::{get,find}_parent`

The `hir::Map::get_parent_node` function doesn't return a `Node`, and I think that's quite confusing. Let's rename it to something that sounds more like something that gets the parent hir id => `hir::Map::parent_id`. Same with `find_parent_node` => `opt_parent_id`.

Also, combine `hir.get(hir.parent_id(hir_id))` and similar `hir.find(hir.parent_id(hir_id))` function into new functions that actually retrieve the parent node in one call. This last commit is the only one that might need to be looked at closely.
2023-01-04 20:36:28 -08:00
Michael Goulet
13bb8a8b15
Rollup merge of #106385 - compiler-errors:new-solver-flag, r=jackh726
Split `-Zchalk` flag into `-Ztrait-solver=(classic|chalk|next)` flag

We'll eventually need a way to select more than chalk + not-chalk.

Does this need an MCP since it's touching a `-Z` flag? Or perhaps I should preserve `-Zchalk` for the time being... maybe I could make it a warning to use that flag? cc ``@rust-lang/types``

r? types
2023-01-04 20:36:27 -08:00
Michael Goulet
f9ccbf084f
Rollup merge of #105846 - compiler-errors:issue-105838, r=jackh726
Account for return-position `impl Trait` in trait in `opt_suggest_box_span`

RPITITs are the only types where their opaque bounds might normalize to some other self type than the opaque type itself. To avoid needing to do normalization, let's just match on either alias kind.

Ideally, we'd just get rid of `opt_suggest_box_span`. It's kind of a wart on type-checking `if`/`match`. I've recently refactored this expression for being confusing/wrong, but moving it into the error path is pretty hard.

Fixes #105838
2023-01-04 20:36:27 -08:00
bors
03b9e1d154 Auto merge of #105409 - compiler-errors:closure-infer-cycle, r=jackh726
Don't deduce a signature that makes a closure cyclic

Sometimes when elaborating supertrait bounds for closure signature inference, we end up deducing a closure signature that is cyclical because either a parameter or the return type references a projection mentioning `Self` that also has escaping bound vars, which means that it's not eagerly replaced with an inference variable.

Interestingly, this is not *just* related to my PR that elaborates supertrait bounds for closure signature deduction. The committed test `supertrait-hint-cycle-3.rs` shows **stable** code that is fixed by this PR:

```rust
trait Foo<'a> {
    type Input;
}

impl<F: Fn(u32)> Foo<'_> for F {
    type Input = u32;
}

fn needs_super<F: for<'a> Fn(<F as Foo<'a>>::Input) + for<'a> Foo<'a>>(_: F) {}

fn main() {
    needs_super(|_: u32| {});
}
```

Fixes #105401
Fixes #105396

r? types
2023-01-05 03:59:31 +00:00
Esteban Küber
5393c6bbd1 Tweak wording of fn call with wrong number of args 2023-01-05 03:02:10 +00:00
bors
d26242d35f Auto merge of #106472 - matthiaskrgr:rollup-4w4v50e, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #106391 (rustdoc: allow popover child links to work)
 - #106398 (Fix a few clippy lints in libtest)
 - #106412 (Fix link generation for local primitive types in rustdoc JSON output)
 - #106437 (rustdoc: fix buggy JS check for absolute URL)
 - #106451 (Merge borrowck permission checks)
 - #106460 (Move tests)
 - #106461 (docs: fix broken link "search bar")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-05 01:06:05 +00:00
Erik Desjardins
d165a6d708 cleanup: handle -Zmutable-noalias like -Zbox-noalias 2023-01-04 19:24:42 -05:00
Matthias Krüger
6feb1fedbc
Rollup merge of #106451 - Zeegomo:merge-borrowck-access, r=estebank
Merge borrowck permission checks

Merge `check_access_permission` and `check_if_reassignment_to_immutable_state`.
The goal of this commit is twofold:
* simplify the codebase by removing duplicate logic.
* avoid duplicate reporting of illegal reassignment errors by reusing the exiting de-duplicating logic of access_place.
2023-01-04 23:39:51 +01:00
Michael Goulet
21b078a64e Use FxIndexSet when updating obligation causes in adjust_fulfillment_errors_for_expr_obligation 2023-01-04 22:07:04 +00:00
bors
d9e317a176 Auto merge of #106224 - bjorn3:staticlib_fixes, r=wesleywiser
Small fixes for --crate-type staticlib

The first commit doesn't have an effect until we start translating error messages. The second commit fixes potential linker errors when combining `--crate-type staticlib` with another crate type and I think `-Cprefer-dynamic`.
2023-01-04 21:35:15 +00:00
Michael Goulet
8b0f43b19d Rename stock solver to classic 2023-01-04 18:40:02 +00:00
Michael Goulet
a4974fa9c7 Split -Zchalk flag into -Ztrait-solver=(stock|chalk|next) flag 2023-01-04 18:12:42 +00:00
bors
b7cdb635c4 Auto merge of #106382 - tmiasko:sdniwnu-daed, r=wesleywiser
Fix handling of dead unwinds in backward analyses

Dead unwinds set contains a head of an unreachable unwind edge.
2023-01-04 15:48:47 +00:00
Giacomo Pasini
ac4426c093
Merge borrowck permission checks
Merge `check_access_permission` and
`check_if_reassignment_to_immutable_state`.
The goal of this commit is twofold:
First, we simplify the codebase by removing duplicate logic.
Second, we avoid duplicate reporting of illegal reassignment
errors by reusing the exiting de-duplicating logic of
access_place.
2023-01-04 15:25:45 +01:00
bjorn3
7705116708 Fix each_linked_rlib when the current crate has 0 crate types 2023-01-04 13:58:08 +00:00
bors
5c18bc6137 Auto merge of #106442 - matthiaskrgr:rollup-wivf7gh, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #106200 (Suggest `impl Fn*` and `impl Future` in `-> _` return suggestions)
 - #106274 (Add JSON output to -Zdump-mono-stats)
 - #106292 (Add codegen test for `Box::new(uninit)` of big arrays)
 - #106327 (Add tidy check for dbg)
 - #106361 (Note maximum integer literal for `IntLiteralTooLarge`)
 - #106396 (Allow passing a specific date to `bump-stage0`)
 - #106436 (Enable doctests for rustc_query_impl)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-04 09:41:43 +00:00
Matthias Krüger
4e590b3ee9
Rollup merge of #106436 - CarsonV:doctest_query_impl, r=jyn514
Enable doctests for rustc_query_impl

doctests worked out of the box for query_impl on my local machine. Working towards #99144
2023-01-04 07:28:57 +01:00
Matthias Krüger
11020b93b6
Rollup merge of #106361 - clubby789:int-literal-too-large, r=estebank
Note maximum integer literal for `IntLiteralTooLarge`

Closes #105908

`@rustbot` label +A-diagnostics
2023-01-04 07:28:56 +01:00
Matthias Krüger
fbfaeb6795
Rollup merge of #106274 - jyn514:dump-mono-stats, r=lqd
Add JSON output to -Zdump-mono-stats

Follow-up to https://github.com/rust-lang/rust/pull/105481

r? `@lqd` cc `@wesleywiser`
2023-01-04 07:28:54 +01:00
Matthias Krüger
70468af591
Rollup merge of #106200 - compiler-errors:suggest-impl-trait, r=estebank
Suggest `impl Fn*` and `impl Future` in `-> _` return suggestions

Follow-up to #106172, only the last commit is relevant. Can rebase once that PR is landed for easier review.

Suggests `impl Future` and `impl Fn{,Mut,Once}` in `-> _` return suggestions.

r? `@estebank`
2023-01-04 07:28:54 +01:00
bors
ddad1e1f15 Auto merge of #104376 - compiler-errors:thin-metadata-implies-thin-ptr, r=wesleywiser
layout_of: `T: Thin` implies `sizeof(&T) == sizeof(usize)`

Use the `<T as Pointee>::Metadata` associated type to calculate the layout of a pointee's metadata, instead of hard-coding rules about certain types.

Maybe this approach is overkill -- we could instead hard-code this approach as a fallback, with the matching on `Slice`/`Dynamic`/etc. happening first

Fixes this issue here https://github.com/rust-lang/rust/pull/104338#issuecomment-1312595844 .. But is also useful with transmutes, for example, given the UI test I added below.
2023-01-04 06:28:05 +00:00
bors
c361616c3c Auto merge of #106432 - compiler-errors:rollup-lzj0lnp, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #104748 (Ensure `lld` is supported with `download-ci-llvm`)
 - #105541 (Simplify some iterator combinators)
 - #106045 (default OOM handler: use non-unwinding panic, to match std handler)
 - #106157 (Don't trim path for `unsafe_op_in_unsafe_fn` lints)
 - #106353 (Reduce spans for `unsafe impl` errors)
 - #106381 (Jsondoclint: Add `--verbose` and `--json-output` options)
 - #106411 (rustdoc: remove legacy font-feature-settings CSS)
 - #106414 (Add cuviper to the review rotation for libs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-04 03:37:21 +00:00
CarsonV
f98adb32f5 Enable query_impl doctests 2023-01-03 20:38:28 -06:00
Michael Goulet
5d828d2440
Rollup merge of #106353 - lukas-code:reduce-red-lines-in-my-ide, r=wesleywiser
Reduce spans for `unsafe impl` errors

Because huge spans aren't great for IDEs.

Prior art: https://github.com/rust-lang/rust/pull/103749
2023-01-03 17:19:27 -08:00
Michael Goulet
dc5247bf29
Rollup merge of #106157 - LeSeulArtichaut:106126-thir-unsafeck-good-path-bug-2, r=compiler-errors
Don't trim path for `unsafe_op_in_unsafe_fn` lints

Fixes #106126, alternative to #106127.
r? `@ghost` for now.
2023-01-03 17:19:26 -08:00
Michael Goulet
a5d39cf290 review comment: Deduplicate dyn ty_and_layout_field code 2023-01-04 01:03:04 +00:00
Michael Goulet
2011316e59 Mirror metadata changes in layout sanity check 2023-01-04 00:56:05 +00:00
Michael Goulet
b25da9ce6d layout_of: T: Thin implies sizeof(&T) == sizeof(usize) 2023-01-04 00:56:05 +00:00
Michael Goulet
2baee88bdb Address comments 2023-01-04 00:51:50 +00:00
Michael Goulet
7690fe3bc6 Simplify some iterator combinators 2023-01-04 00:48:07 +00:00
Michael Goulet
b1b19bd851 get_parent and find_parent 2023-01-04 00:43:13 +00:00
Michael Goulet
6af339dbfa rename find_parent_node to opt_parent_id 2023-01-04 00:43:13 +00:00
Michael Goulet
a313ef05a7 rename get_parent_node to parent_id 2023-01-04 00:43:13 +00:00
Michael Goulet
89086f7d36 Restore Fn trait note 2023-01-04 00:37:34 +00:00
Michael Goulet
c104ee9f6d Move check_region_obligations_and_report_errors to TypeErrCtxt 2023-01-03 23:58:12 +00:00
Michael Goulet
a0390463fc Suggest more impl Trait on -> _ 2023-01-03 23:50:31 +00:00
bors
fbe8292872 Auto merge of #105712 - amg98:feat/vita-support, r=wesleywiser
PlayStation Vita support

Just the compiler definitions for no-std projects and std support using newlib

Earlier PR: https://github.com/rust-lang/rust/pull/105606
2023-01-03 23:38:28 +00:00
kadmin
077fae94a1 Add note about wrapping in braces
Previously it was not clear why this errored or if it was even supported, as there was no
diagnostic that suggested wrapping it in braces.

Thus, add a simple diagnostic that suggests wrapping enum variants in braces.
2023-01-03 23:26:57 +00:00
bors
c7572670a1 Auto merge of #105752 - chenyukang:yukang/refactor-method-error, r=compiler-errors
Refactoring report_method_error

While working on #105732, I found it's hard to follow this long function,
so I tried to make it shorter.

It's not easy for code reviewing, since so many lines of code changes,
but only the positions are changed.

Generally, I extract two sub-methods from `report_method_error`:

397b66e77b/compiler/rustc_hir_typeck/src/method/suggest.rs (L117)
to `note_candidates_on_method_error`

And this long block:
397b66e77b/compiler/rustc_hir_typeck/src/method/suggest.rs (L263)

to `report_no_match_method_error`.

r? `@compiler-errors`
2023-01-03 20:44:40 +00:00
bors
ab10908e8c Auto merge of #106409 - matthiaskrgr:rollup-b58z1hz, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #104552 (warn newer available version of the x tool)
 - #105681 (some fixes/improvements to mir::visit module)
 - #106005 (Test the borrowck behavior of if-let guards)
 - #106356 (clean: Remove `ctor_kind` from `VariantStruct`.)
 - #106365 (Grammar : Missing "is" in format specifier diagnostic)
 - #106388 (rustdoc: remove legacy box-sizing CSS)
 - #106392 (`has_overflow` only if value is *not* within limit)
 - #106402 (Fix dupe word typos)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-03 17:08:17 +00:00
Matthias Krüger
e2f7108459
Rollup merge of #106402 - Rageking8:fix_dupe_word_typos, r=Nilstrieb
Fix dupe word typos

r? `@Nilstrieb`
Thanks!
2023-01-03 17:12:13 +01:00
Matthias Krüger
9d1193310f
Rollup merge of #106392 - compiler-errors:new-trait-solver-overflow, r=lcnr
`has_overflow` only if value is *not* within limit

New solver forgot a not operator, I think.
2023-01-03 17:12:13 +01:00
Matthias Krüger
01d99f6569
Rollup merge of #106365 - gimbles:patch-1, r=jyn514
Grammar : Missing "is" in format specifier diagnostic
2023-01-03 17:12:12 +01:00
Matthias Krüger
da07053ee1
Rollup merge of #105681 - tshepang:doc-mir-visit, r=Nilstrieb
some fixes/improvements to mir::visit module
2023-01-03 17:12:10 +01:00
bors
312c9a37f2 Auto merge of #101792 - lqd:rust-lld, r=petrochenkov
Only specify `--target` by default for `-Zgcc-ld=lld` on wasm

On macOS, it's not yet clear which cases of clang/OS/target/SDK version impact how to find ld/lld/rust-lld. The `--target` argument is not needed on our current targets with a vanilla config to do so, but may be in some cases ?

That is, things look to be different and more subtle than suggested in https://github.com/rust-lang/rust/issues/97402#issuecomment-1147404520.

Specifying this argument unconditionally currently breaks `-Zgcc-ld=lld` on the 10.7+ targets on x64 macOS. Vanilla configs on x64 and aarch64 don't seem to need it to be able to find `rust-lld`.

This fixes #101653 on macOS (I've tried on x64 and aarch64: vanilla installs with the most recent command line tools available for each of the OS versions I have access to, `run-make/issue-71519` passes).

I didn't expect the previous PRs to fail because of the existing tests, but CI does not actually run those tests yet, which explains the regressions. I was hoping to fix those in this PR but it's more involved (building lld is required for the tests to run, llvm/lld is not built on the test builders but on the dist builders, the dist builders don't run tests). This PR is just to unblock current users on macOS who have reported issues, but a regression could happen in the future by mistake until then.

r? `@petrochenkov`
2023-01-03 14:05:44 +00:00
bors
3b1c8a94a4 Auto merge of #105609 - bjorn3:shrink_rustc_dev, r=jyn514
Only include metadata for non-dynamic libraries in rustc-dev

The actual object code should be linked from librustc_driver.so, which is still included in rustc-dev. This saves on download time and disk usage.

Fixes https://github.com/rust-lang/rust/issues/103538
2023-01-03 08:05:54 +00:00
Rageking8
e808a69911 fix dupe word typos 2023-01-03 15:48:16 +08:00
bors
442f997f98 Auto merge of #106371 - RalfJung:no-ret-position-noalias, r=nikic
do not add noalias in return position

`noalias` as a return attribute in LLVM indicates that the returned pointer does not alias anything else that is reachable from the caller, *including things reachable before this function call*. This is clearly not the case with a function like `fn id(Box<T>) -> Box<T>`, so we cannot use this attribute.

Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/385 (including an actual miscompilation that `@comex` managed to produce).
2023-01-03 04:54:03 +00:00
bors
481c9bad80 Auto merge of #106386 - compiler-errors:rollup-dxjv18b, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #95985 (Add PhantomData marker to Context to make Context !Send and !Sync)
 - #104298 (Add notes and examples about non-intuitive `PathBuf::set_extension` behavior)
 - #105558 (Reduce HIR debug output)
 - #106315 (Cleanup `mingw-tidy` docker job)
 - #106354 (Rustdoc-Json: Report discriminant on all kinds of enum variant.)
 - #106366 (Fix rustdoc ICE on bad typedef with mismatching types)
 - #106376 (Update books)
 - #106383 (Document some of the AST nodes)

Failed merges:

 - #106356 (clean: Remove `ctor_kind` from `VariantStruct`.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-03 01:45:33 +00:00
Michael Goulet
50ab306015 Simplify some canonical type alias names 2023-01-03 01:16:10 +00:00
Michael Goulet
b2317a642d has_overflow only if value is *not* within limit 2023-01-03 01:09:08 +00:00
Tomasz Miąsko
3eabea9e2c Remove duplicated elaborate box derefs pass
The pass runs earlier as a part of `run_runtime_lowering_passes`.
2023-01-03 00:00:00 +00:00
Michael Goulet
d4cf00f03d
Rollup merge of #106383 - Manishearth:ast-docs, r=compiler-errors
Document some of the AST nodes

Someone was confused about some of this on Zulip, added some docs

We probably should make sure every last field/variant in the AST/HIR is documented at some point

`@bors` rollup
2023-01-02 15:39:19 -08:00
Michael Goulet
fbffaa91ad
Rollup merge of #105558 - Nilstrieb:less-spam-hir-tree, r=cjgillot
Reduce HIR debug output

HIR debug output is currently very verbose, especially when used with the alternate (`#`) flag. This commit reduces the amount of noisy newlines by forcing a few small key types to stay on one line, which makes the output easier to read and scroll by.

```
$ rustc +after hello_world.rs -Zunpretty=hir-tree | wc -l
582
$ rustc +before hello_world.rs -Zunpretty=hir-tree | wc -l
932
```
2023-01-02 15:39:17 -08:00
Rémy Rakic
7770b06b06 only specify --target by default for -Zgcc-ld=lld on wasm
On macOS, it's not yet clear which cases of clang/OS/target/SDK version impact
how to find ld/lld/rust-lld. The --target is not needed on our current targets with
a vanilla config, but may be in some cases. Specifying it all the time breaks the 10.7+
targets on x64 macOS.

We try to only specify it on macOS if the linker flavors are different,
for possible cases of cross-compilation with `-Zgcc-ld=lld` but the
expectation is that it should be passed manually when needed in these
situations.
2023-01-02 23:30:07 +00:00
Léo Lanteri Thauvin
2a7d559970 Don't trim path for unsafe_op_in_unsafe_fn lints 2023-01-03 00:28:54 +01:00
Joshua Nelson
5c79624bfa Fix unknown_crate when --crate-name isn't passed on the CLI 2023-01-02 23:02:58 +00:00
Joshua Nelson
eb53eea609 Add json output to -Zdump-mono-stats
This allows analyzing the output programatically; for example, finding
the item with the highest `total_estimate`.

I also took the liberty of adding `untracked` tests to `rustc_session` and documentation to the unstable book for `dump-mono-items`.
2023-01-02 23:02:58 +00:00
bors
67d16171d7 Auto merge of #106364 - JakobDegen:top-down-inlining, r=cjgillot
Reenable limited top-down MIR inlining

Reverts most of #105119 and uses an alternative strategy to prevent exponential blowup. Specifically, we allow doing top-down inlining up to depth at most five, and for at most one call site per nested body.

r? `@cjgillot`
2023-01-02 22:52:58 +00:00
Manish Goregaokar
157211ff2f Document rustc_ast::FnHeader fields 2023-01-02 14:42:27 -08:00
Manish Goregaokar
3c7c694e73 Document rustc_ast::Extern variants 2023-01-02 14:42:27 -08:00
Tomasz Miąsko
357c3cf72c Fix handling of dead unwinds in backward analyses
Dead unwinds set contains a head of an unreachable unwind edge.
2023-01-02 22:24:01 +01:00
bors
d6f99e535a Auto merge of #106307 - Nilstrieb:dynamic->static, r=cjgillot
Abolish `QueryVTable` in favour of more assoc items on `QueryConfig`

This may introduce additional mono _but_ may help const fold things better and especially may help not constructing a `QueryVTable` anymore which is cheap but not free.
2023-01-02 20:12:16 +00:00
Nilstrieb
9fe4efe115 Abolish QueryVTable in favour of more assoc items on QueryConfig
This may introduce additional mono _but_ may help const fold things
better and especially may help not constructing a `QueryVTable` anymore
which is cheap but not free.
2023-01-02 20:22:19 +01:00
Nilstrieb
e1787f5572 Reduce HIR debug output
HIR debug output is currently very verbose, especially when used with
the alternate (`#`) flag. This commit reduces the amount of noisy
newlines by forcing a few small key types to stay on one line, which
makes the output easier to read and scroll by.

```
$ rustc +after hello_world.rs -Zunpretty=hir-tree | wc -l
582
$ rustc +before hello_world.rs -Zunpretty=hir-tree | wc -l
932
```
2023-01-02 20:15:48 +01:00
Ralf Jung
e7cad62257 do not add noalias in return position 2023-01-02 15:11:19 +01:00
bors
fb9dfa8cef Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov
Encode spans relative to the enclosing item -- enable on nightly

Follow-up to #84373 with the flag `-Zincremental-relative-spans` set by default.

This PR seeks to remove one of the main shortcomings of incremental: the handling of spans.
Changing the contents of a function may require redoing part of the compilation process for another function in another file because of span information is changed.
Within one file: all the spans in HIR change, so typechecking had to be re-done.
Between files: spans of associated types/consts/functions change, so type-based resolution needs to be re-done (hygiene information is stored in the span).

The flag `-Zincremental-relative-spans` encodes local spans relative to the span of an item, stored inside the `source_span` query.

Trap: stashed diagnostics are referenced by the "raw" span, so stealing them requires to remove the span's parent.

In order to avoid too much traffic in the span interner, span encoding uses the `ctxt_or_tag` field to encode:
- the parent when the `SyntaxContext` is 0;
- the `SyntaxContext` when the parent is `None`.
Even with this, the PR creates a lot of traffic to the Span interner, when a Span has both a LocalDefId parent and a non-root SyntaxContext. They appear in lowering, when we add a parent to all spans, including those which come from macros, and during inlining when we mark inlined spans.

The last commit changes how queries of `LocalDefId` manage their cache. I can put this in a separate PR if required.

Possible future directions:
- validate that all spans are marked in HIR validation;
- mark macro-expanded spans relative to the def-site and not the use-site.
2023-01-02 13:10:16 +00:00
clubby789
537c7f4fa9 Print correct base for too-large literals
Also update tests
2023-01-02 11:43:07 +00:00
Gimbles
32ab2d95f1
Update format.rs 2023-01-02 15:51:54 +05:30
bors
d5a7ddd99f Auto merge of #106284 - estebank:merge-mut-errors, r=jyn514
Merge multiple mutable borrows of immutable binding errors

Fix #53466.
2023-01-02 07:30:23 +00:00
Jakob Degen
ee6503a706 Reenable limited top-down MIR inlining 2023-01-01 22:01:29 -08:00
Esteban Küber
545406528a Verbose suggestions 2023-01-01 21:33:23 -08:00
Ben Kimock
82f0973dd5 Always take advantage of arithmetic identities 2023-01-01 23:12:29 -05:00
clubby789
cafdd2f7bb Note maximum integer literal for IntLiteralTooLarge 2023-01-02 03:52:29 +00:00
Troy Neubauer
4cb9030a66
Implement fix for #67535 2023-01-01 18:26:28 -08:00
yukang
93e62a4bf6 resolve merge conflict 2023-01-02 09:14:18 +08:00
yukang
74cdf93307 code refactor report_method_error 2023-01-02 09:14:15 +08:00
Ezra Shaw
9618f646b3
docs: revert removal of E0729 2023-01-02 09:11:36 +13:00
Léo Lanteri Thauvin
6289fe2cf1 Use the correct tracking issue for dyn_star 2023-01-01 19:56:10 +01:00
Esteban Küber
5bfcfeee2a Merge multiple mutable borrows of immutable binding errors
Fix #53466.
2023-01-01 10:09:26 -08:00
Lukas Markeffsky
035d854947 reduce spans for unsafe impl errors 2023-01-01 18:48:57 +01:00
Ezra Shaw
04b9038610
refactor: clean up errors.rs and error_codes_check.rs
Move them into new `error_codes.rs` tidy check.
2023-01-01 15:22:01 +13:00
bors
574b64a97f Auto merge of #106282 - Ezrashaw:merge-e0465, r=estebank
refactor: merge error code `E0465` into `E0464`

`E0465` is an undocumented and untested error code that is functionally identical to `E0464`. This PR merges `E0465` into `E0464`, thus documenting and testing another error code (#61137).

r? `@GuillaumeGomez` (not sure if you want to review this but it's relevant to my other PRs that you have reviewed)
2022-12-31 20:10:02 +00:00
bjorn3
7837058073 Add help for the error message when missing rustc_driver 2022-12-31 17:20:13 +00:00
bors
726bbfc8f0 Auto merge of #106302 - compiler-errors:terr-coerce-w-infer, r=estebank
Suppress errors due to TypeError not coercing with inference variables

Fixes #75331
Fixes #68507
Fixes #82323

cc `@estebank`
2022-12-31 11:32:15 +00:00
bors
96c1f338bb Auto merge of #106245 - estebank:mutability-suggestions, r=jyn514
Use verbose suggestions for mutability errors
2022-12-31 08:43:24 +00:00
Ezra Shaw
24b39ece2f
refactor: merge E0465 into E0464 2022-12-31 20:44:54 +13:00
Michael Goulet
d798e228ea
Rollup merge of #106317 - compiler-errors:restore-the-backtraces, r=jyn514
Only deduplicate stack traces for good path bugs

Fixes #106267

Restores backtraces for `bug!` and `delay_span_bug` after #106056. Only `delay_good_path_bug` needed its backtraces to be deduplicated, since it spits out the backtrace where it was created when it's being emitted.

Before:

```
error: internal compiler error: /home/ubuntu/rust2/compiler/rustc_middle/src/ty/relate.rs:638:13: var types encountered in super_relate_consts: Const { ty: usize, kind: Infer(Var(_#0c)) } Const { ty: usize, kind: Param(N/#1) }

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.68.0-dev running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `<impl at /home/ubuntu/test.rs:7:1: 7:34>::trigger`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors
```

Hmm... that's a little bare.

After:

```
error: internal compiler error: /home/ubuntu/rust2/compiler/rustc_middle/src/ty/relate.rs:638:13: var types encountered in super_relate_consts: Const { ty: usize, kind: Infer(Var(_#0c)) } Const { ty: usize, kind: Param(N/#1) }

thread 'rustc' panicked at 'Box<dyn Any>', /home/ubuntu/rust2/compiler/rustc_errors/src/lib.rs:1599:9
stack backtrace:
   0:     0x7ffb5b41bdd1 - std::backtrace_rs::backtrace::libunwind::trace::h26056f81198c6594
                               at /home/ubuntu/rust2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7ffb5b41bdd1 - std::backtrace_rs::backtrace::trace_unsynchronized::hacfb345a0c6d5bb1
                               at /home/ubuntu/rust2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ffb5b41bdd1 - std::sys_common::backtrace::_print_fmt::h18ea6016ac8030f3
                               at /home/ubuntu/rust2/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7ffb5b41bdd1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he35dde201d0c2d09
                               at /home/ubuntu/rust2/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ffb5b4a0308 - core::fmt::write::h094ad263467a053c
                               at /home/ubuntu/rust2/library/core/src/fmt/mod.rs:1208:17
   5:     0x7ffb5b43caf1 - std::io::Write::write_fmt::hd47b4e2324b4d9b7
                               at /home/ubuntu/rust2/library/std/src/io/mod.rs:1682:15
   6:     0x7ffb5b41bbfa - std::sys_common::backtrace::_print::h43044162653a17fc
                               at /home/ubuntu/rust2/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7ffb5b41bbfa - std::sys_common::backtrace::print::hc8605da258fa5aeb
                               at /home/ubuntu/rust2/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7ffb5b3ffb87 - std::panicking::default_hook::{{closure}}::h9e37f23f75122a15
   9:     0x7ffb5b3ff97b - std::panicking::default_hook::h602873a063f84da2
                               at /home/ubuntu/rust2/library/std/src/panicking.rs:286:9
  10:     0x7ffb5be192b2 - <alloc[48d7b30605060536]::boxed::Box<dyn for<'a, 'b> core[672e3947e150d6c6]::ops::function::Fn<(&'a core[672e3947e150d6c6]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[672e3947e150d6c6]::marker::Send + core[672e3947e150d6c6]::marker::Sync> as core[672e3947e150d6c6]::ops::function::Fn<(&core[672e3947e150d6c6]::panic::panic_info::PanicInfo,)>>::call
                               at /home/ubuntu/rust2/library/alloc/src/boxed.rs:2002:9
  11:     0x7ffb5be192b2 - rustc_driver[f5b6d32d8905ecdd]::DEFAULT_HOOK::{closure#0}::{closure#0}
                               at /home/ubuntu/rust2/compiler/rustc_driver/src/lib.rs:1204:17
  12:     0x7ffb5b4000d3 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hfd13333ca953ae8e
                               at /home/ubuntu/rust2/library/alloc/src/boxed.rs:2002:9
  13:     0x7ffb5b4000d3 - std::panicking::rust_panic_with_hook::h45753e10264ebe7e
                               at /home/ubuntu/rust2/library/std/src/panicking.rs:692:13
  14:     0x7ffb5e8b3a63 - std[3330b4673efabfce]::panicking::begin_panic::<rustc_errors[1b15f4e7e49d1fd5]::ExplicitBug>::{closure#0}

[... FRAMES INTENTIONALLY OMITTED BECAUSE GITHUB GOT ANGRY ...]

 186:     0x7ffb5bea5554 - <std[3330b4673efabfce]:🧵:Builder>::spawn_unchecked_::<rustc_interface[947706ead88047d0]::util::run_in_thread_pool_with_globals<rustc_interface[947706ead88047d0]::interface::run_compiler<core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>, rustc_driver[f5b6d32d8905ecdd]::run_compiler::{closure#1}>::{closure#0}, core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>>::{closure#1}
                               at /home/ubuntu/rust2/library/std/src/thread/mod.rs:549:30
 187:     0x7ffb5bea5554 - <<std[3330b4673efabfce]:🧵:Builder>::spawn_unchecked_<rustc_interface[947706ead88047d0]::util::run_in_thread_pool_with_globals<rustc_interface[947706ead88047d0]::interface::run_compiler<core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>, rustc_driver[f5b6d32d8905ecdd]::run_compiler::{closure#1}>::{closure#0}, core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[672e3947e150d6c6]::result::Result<(), rustc_errors[1b15f4e7e49d1fd5]::ErrorGuaranteed>>::{closure#1} as core[672e3947e150d6c6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
                               at /home/ubuntu/rust2/library/core/src/ops/function.rs:250:5
 188:     0x7ffb5b433968 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he8b26fc22c6f51ec
                               at /home/ubuntu/rust2/library/alloc/src/boxed.rs:1988:9
 189:     0x7ffb5b433968 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5cf9cbe75a8c3ddc
                               at /home/ubuntu/rust2/library/alloc/src/boxed.rs:1988:9
 190:     0x7ffb5b41199c - std::sys::unix:🧵:Thread:🆕:thread_start::h2d6dd4455e97d031
                               at /home/ubuntu/rust2/library/std/src/sys/unix/thread.rs:108:17
 191:     0x7ffb5441b609 - start_thread
 192:     0x7ffb5b282133 - clone
 193:                0x0 - <unknown>

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.68.0-dev running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `<impl at /home/ubuntu/test.rs:7:1: 7:34>::trigger`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0601`.
```
2022-12-30 21:26:36 -08:00
Michael Goulet
5b74a33b8d
Rollup merge of #106248 - dtolnay:revertupcastlint, r=jackh726
Revert "Implement allow-by-default `multiple_supertrait_upcastable` lint"

This is a clean revert of #105484.

I confirmed that reverting that PR fixes the regression reported in #106247. ~~I can't say I understand what this code is doing, but maybe it can be re-landed with a different implementation.~~ **Edit:** https://github.com/rust-lang/rust/issues/106247#issuecomment-1367174384 has an explanation of why #105484 ends up surfacing spurious `where_clause_object_safety` errors. The implementation of `where_clause_object_safety` assumes we only check whether a trait is object safe when somebody actually uses that trait with `dyn`. However the implementation of `multiple_supertrait_upcastable` added in the problematic PR involves checking *every* trait for whether it is object-safe.

FYI `@nbdd0121` `@compiler-errors`
2022-12-30 21:26:34 -08:00
Michael Goulet
fad73392dc
Rollup merge of #106232 - maurer:transparent-subst, r=rcvalle
CFI: Monomorphize transparent ADTs before typeid

Monomorphise `#[repr(transparent)]` parameterized ADTs before turning them into an Itanium mangled String.

`#[repr(transparent)]` ADTs currently use the single field to represent them in their CFI type ID to ensure that they are compatible. However, if that type involves a type parameter instantiated at the ADT level, as in `ManuallyDrop`, this will currently ICE as the `Parameter` type cannot be mangled. Since this happens at lowering time, it should always be concrete after substitution.

Fixes #106230
2022-12-30 21:26:33 -08:00
Michael Goulet
5d62a737d7 Only deduplicate stack traces for good path bugs 2022-12-31 02:14:26 +00:00
Obei Sideg
cc1dee148d Fix incorrect suggestion for extra & in pattern
see #106182
2022-12-30 23:08:01 +03:00
Michael Goulet
f6b45e399e Suppress errors due to TypeError not coercing with inference variables 2022-12-30 19:53:34 +00:00
Nilstrieb
0047e25090 Add some docs to bug, span_bug and delay_span_bug 2022-12-30 16:47:56 +01:00
bors
e5e5fcb0b7 Auto merge of #106268 - kraktus:patch-2, r=Nilstrieb
fix comment for `TokenCursor::desugar`

the hashes of the text were forgotten.
2022-12-30 06:59:13 +00:00
bors
973a4db8d5 Auto merge of #106210 - fee1-dead-contrib:const-closure-trait-method, r=compiler-errors
Allow trait method paths to satisfy const Fn bounds

r? `@oli-obk`
2022-12-30 01:09:31 +00:00
bors
ad8ae0504c Auto merge of #106266 - matthiaskrgr:rollup-cxrdbzy, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #104531 (Provide a better error and a suggestion for `Fn` traits with lifetime params)
 - #105899 (`./x doc library --open` opens `std`)
 - #106190 (Account for multiple multiline spans with empty padding)
 - #106202 (Trim more paths in obligation types)
 - #106234 (rustdoc: simplify settings, help, and copy button CSS by not reusing)
 - #106236 (docs/test: add docs and a UI test for `E0514` and `E0519`)
 - #106259 (Update Clippy)
 - #106260 (Fix index out of bounds issues in rustdoc)
 - #106263 (Formatter should not try to format non-Rust files)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-29 19:40:06 +00:00
kraktus
d08134f1d2
fix comment for TokenCursor::desugar
the hashes of the text were forgotten.
2022-12-29 19:45:31 +01:00
Matthew Maurer
fb2c27d73f CFI: Monomorphize transparent ADTs before typeid
Monomorphise `#[repr(transparent)]` parameterized ADTs before turning
them into an Itanium mangled String.

`#[repr(transparent)]` ADTs currently use the single field to represent
them in their CFI type ID to ensure that they are compatible. However,
if that type involves a type parameter instantiated at the ADT level, as
in `ManuallyDrop`, this will currently ICE as the `Parameter` type
cannot be mangled. Since this happens at lowering time, it should always
be concrete after substitution.

Fixes #106230
2022-12-29 10:21:07 -08:00
Matthias Krüger
51534b897e
Rollup merge of #106236 - Ezrashaw:add-test+docs-e0519-e0514, r=GuillaumeGomez
docs/test: add docs and a UI test for `E0514` and `E0519`

No UI test on `E0514`, it would need to compile with a different `rustc` version.

r? `@GuillaumeGomez`
2022-12-29 18:24:32 +01:00
Matthias Krüger
6b792e9178
Rollup merge of #106202 - estebank:trim-paths, r=Nilstrieb
Trim more paths in obligation types
2022-12-29 18:24:31 +01:00
Matthias Krüger
be56dc037f
Rollup merge of #106190 - estebank:multiline-start-tweak, r=jackh726
Account for multiple multiline spans with empty padding

Instead of

```
LL |    fn oom(
   |  __^
   | | _|
   | ||
LL | || ) {
   | ||_-
LL | |  }
   | |__^
```

emit

```
LL | // fn oom(
LL | || ) {
   | ||_-
LL | |  }
   | |__^
   ```
2022-12-29 18:24:30 +01:00
Matthias Krüger
81c2b7280f
Rollup merge of #104531 - ohno418:recover-fn-traits-with-lifetime-params, r=estebank
Provide a better error and a suggestion for `Fn` traits with lifetime params

Given `Fn`-family traits with lifetime params in trait bounds like `fn f(_: impl Fn<'a>(&'a str) -> bool)`, we currently produce many unhelpful errors.

This PR allows these situations to suggest simply using Higher-Rank Trait Bounds like `for<'a> Fn(&'a str) -> bool`.

Fixes https://github.com/rust-lang/rust/issues/103490.
2022-12-29 18:24:29 +01:00
Esteban Küber
af74ca0666 Account for multiple multiline spans with empty padding
Instead of

```
LL |    fn oom(
   |  __^
   | | _|
   | ||
LL | || ) {
   | ||_-
LL | |  }
   | |__^
```

emit

```
LL | // fn oom(
LL | || ) {
   | ||_-
LL | |  }
   | |__^
   ```
2022-12-29 09:13:40 -08:00
bors
e37ff7e71a Auto merge of #106256 - matthiaskrgr:rollup-g1ovcqq, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #106208 (Make trait/impl `where` clause mismatch on region error a bit more actionable)
 - #106216 (Powershell: Use `WaitForExit` instead of `-Wait`)
 - #106217 (rustdoc: remove unnecessary `.tooltip::after { text-align: center }`)
 - #106218 (Migrate css var scraped examples)
 - #106221 (Rename `Rptr` to `Ref` in AST and HIR)
 - #106223 (On unsized locals with explicit types suggest `&`)
 - #106225 (Remove CraftSpider from review rotation)
 - #106229 (update Miri)
 - #106242 (Detect diff markers in the parser)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-29 16:46:08 +00:00
Matthias Krüger
031a2143f0
Rollup merge of #106242 - estebank:diff-markers, r=jyn514
Detect diff markers in the parser

Partly address #32059.
2022-12-29 13:16:06 +01:00