Commit Graph

227141 Commits

Author SHA1 Message Date
bors
dcd31550e2 Auto merge of #14932 - HKalbasi:dev, r=HKalbasi
Lower const params with a bad id

cc #7434

This PR adds an `InTypeConstId` which is a `DefWithBodyId` and lower const generic parameters into bodies using it, and evaluate them with the mir interpreter. I think this is the last unimplemented const generic feature relative to rustc stable.

But there is a problem: The id used in the `InTypeConstId` is the raw `FileAstId`, which changes frequently. So these ids and their bodies will be invalidated very frequently, which is bad for incremental analysis.

Due this problem, I disabled lowering for local crates (in library crate the id is stable since files won't be changed). This might be overreacting (const generic expressions are usually small, maybe it would be better enabled with bad performance than disabled) but it makes motivation for doing it in the correct way, and it splits the potential panic and breakages that usually comes with const generic PRs in two steps.

Other than the id, I think (at least I hope) other parts are in the right direction.
2023-06-12 08:49:02 +00:00
aticu
e3a1a11ed2 Implement TryFrom<&OsStr> for &str 2023-06-12 10:46:49 +02:00
Pietro Albini
4668123945
bless mir-opt
To reproduce the changes in this commit locally:

- Run `./x test tidy` and remove all the output files not associated
  with a test file anymore, as reported by tidy.
- Run `./x test tests/mir-opt --bless` to generate the new outputs.
2023-06-12 09:34:17 +02:00
Pietro Albini
070cc836e9
properly mark tests that require panic=abort 2023-06-12 09:34:15 +02:00
Pietro Albini
a4e8904ce8
add way to split mir-opt into panic=abort and panic=unwind 2023-06-12 09:34:14 +02:00
Pietro Albini
6fd0d1ba14
make sure the standard library compiles properly with synthetic targets
It might happen that a synthetic target name does not match one of the
hardcoded ones in std's build script, causing std to fail to build. This
commit changes the std build script avoid including the restricted-std
feature unconditionally when a synthetic target is being built.
2023-06-12 09:34:13 +02:00
Pietro Albini
9de3c29319
add support for blessing panic=abort mir-opt tests 2023-06-12 09:34:12 +02:00
Pietro Albini
9ec370d40c
bless both 32bit and 64bit variants of mir-opt when available 2023-06-12 09:34:10 +02:00
Pietro Albini
1c26f1b48f
split finding the cc for a single target into a separate fn 2023-06-12 09:34:09 +02:00
Pietro Albini
c6707dc15a
return dummy cc and friends during dry runs
Some targets are added to these hashmaps at runtime, and are not present
during dry runs. To avoid errors, this commit changes all the related
functions to always return empty strings/paths during dry runs.
2023-06-12 09:34:06 +02:00
Pietro Albini
68d458bb40
allow mutating the c compilers detected by bootstrap
This will be needed to create synthetic targets in future commits.
2023-06-12 09:33:33 +02:00
Pietro Albini
1b5143ae13
stop using a macro for the mir-opt test suite 2023-06-12 09:32:36 +02:00
许杰友 Jieyou Xu (Joe)
72421bfb0c
Fix debug ICE for extern type with where clauses 2023-06-12 15:15:45 +08:00
bors
fd0a3313f7 Auto merge of #112261 - jieyouxu:c-like-ptr-arithmetics-diagnostics, r=WaffleLapkin
Add help for trying to do C-like pointer arithmetics

This PR adds help messages for these cases:

```rust
fn main() {
    let ptr1: *const u32 = std::ptr::null();
    let ptr2: *const u32 = std::ptr::null();
    let a = ptr1 + 5;
    let b = ptr1 - 5;
    let c = ptr2 - ptr1;
    let d = ptr1[5];
}
```

### Current Output

```
error[E0369]: cannot add `{integer}` to `*const u32`
 --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:4:18
  |
4 |     let a = ptr1 + 5; //~ ERROR cannot add
  |             ---- ^ - {integer}
  |             |
  |             *const u32

error[E0369]: cannot subtract `{integer}` from `*const u32`
 --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:5:18
  |
5 |     let b = ptr1 - 5; //~ ERROR cannot subtract
  |             ---- ^ - {integer}
  |             |
  |             *const u32

error[E0369]: cannot subtract `*const u32` from `*const u32`
 --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:6:18
  |
6 |     let c = ptr2 - ptr1; //~ ERROR cannot subtract
  |             ---- ^ ---- *const u32
  |             |
  |             *const u32

error[E0608]: cannot index into a value of type `*const u32`
 --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:7:13
  |
7 |     let d = ptr1[5]; //~ ERROR cannot index
  |             ^^^^^^^

error: aborting due to 4 previous errors
```

### Output After This PR

```
error[E0369]: cannot add `{integer}` to `*const u32`
  --> $DIR/issue-112252-ptr-arithmetics-help.rs:6:20
   |
LL |     let _a = _ptr1 + 5;
   |              ------^--
   |              |       |
   |              |       {integer}
   |              *const u32
   |              help: consider using `wrapping_add` or `add` for pointer + {integer}: `_ptr1.wrapping_add(5)`

error[E0369]: cannot subtract `{integer}` from `*const u32`
  --> $DIR/issue-112252-ptr-arithmetics-help.rs:7:20
   |
LL |     let _b = _ptr1 - 5;
   |              ------^--
   |              |       |
   |              |       {integer}
   |              *const u32
   |              help: consider using `offset` for pointer - {integer}: `unsafe { _ptr1.offset(-5) }`

error[E0369]: cannot subtract `*const u32` from `*const u32`
  --> $DIR/issue-112252-ptr-arithmetics-help.rs:8:20
   |
LL |     let _c = _ptr2 - _ptr1;
   |              ------^------
   |              |       |
   |              |       *const u32
   |              *const u32
   |              help: consider using `offset_from` for pointer - pointer if the pointers point to the same allocation: `_ptr2.offset_from(_ptr1)`

error[E0608]: cannot index into a value of type `*const u32`
  --> $DIR/issue-112252-ptr-arithmetics-help.rs:9:14
   |
LL |     let _d = _ptr1[5];
   |              ^^^^^^^^
   |
help: consider using `wrapping_add` or `add` for indexing into raw pointer
   |
LL |     let _d = _ptr1.wrapping_add(5);
   |              ~~~~~~~~~~~~~~~~~~~~~

error: aborting due to 4 previous errors
```

Closes #112252.
2023-06-12 07:15:19 +00:00
bors
38c47dfe30 Auto merge of #15032 - AndreasBackx:fix/vscode-markdown, r=lnicola
fix: exclude Markdown injection grammar from .vscodeignore.

Enables Markdown injection introduced in #14866 but wasn't included in release due to the grammar file being ignored by `.vscodeignore`. I verified the fix by doing `vsce package` and installing it manually:

<img width="779" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/1593486/bb3da211-a017-45bf-ba7b-4122335aa6e8">

<img width="780" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/1593486/aa0c4025-e72c-4b0c-9d40-44c33e7d45e6">
2023-06-12 06:14:02 +00:00
Andreas Backx
942b392150
Exclude Markdown injection grammar from .vscodeignore.
Enables Markdown injection introduced in #14866 but wasn't included in release due to it being ignored.
2023-06-11 22:53:58 -07:00
Michael Howell
94badbe599 rustdoc-search: fix order-independence bug 2023-06-11 18:57:33 -07:00
Michael Howell
c897deddb8 rustdoc-search: add test case for bufread -> result<u8> 2023-06-11 18:19:41 -07:00
Michael Howell
9946d67579 rustdoc-search: build args, return, and generics on one unifier
This enhances generics with the "unboxing" behavior where A<T>
matches T. It makes this unboxing transitive over generics.
2023-06-11 18:19:37 -07:00
Michael Goulet
696cd98e6b Don't record adjustments twice in note_source_of_type_mismatch_constraint 2023-06-12 00:35:30 +00:00
Michael Howell
04f4493722 rustdoc-search: simplify JS in checkGenerics 2023-06-11 17:34:35 -07:00
bors
77dba225c1 Auto merge of #111801 - Bryanskiy:lints1, r=petrochenkov
Private-in-public lints implementation

Next part of RFC https://github.com/rust-lang/rust/issues/48054.

r? `@petrochenkov`
2023-06-11 22:18:23 +00:00
Bryanskiy
6d46382f6f Private-in-public lints implementation 2023-06-12 01:02:19 +03:00
hkalbasi
a4695788ca Add a bunch of fixme comments 2023-06-12 00:37:11 +03:30
yanchith
e0e355dd25 Impl allocator function for iterators 2023-06-11 22:56:16 +02:00
yanchith
d9b6181d2f Remove explicit lifetimes 2023-06-11 22:42:50 +02:00
Ralf Jung
3b9b4e5e3d reorder attributes to make miri-test-libstd work again 2023-06-11 22:15:46 +02:00
bors
d567091f47 Auto merge of #15028 - Veykril:rustfmt-thread, r=Veykril
internal: Give rustfmt jobs a separate thread

Some light testing suggests that this fixes the waiting on formatting popup in vscode when the project is still building (which is usually the way for me to encounter it, as r-a is either waiting or getting little resources causing the tasks to block formatting)
2023-06-11 18:14:54 +00:00
Lukas Wirth
179b8d7efc
Formatting
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2023-06-11 20:11:26 +02:00
Lukas Wirth
52bb94d697 internal: Give rustfmt jobs a separate thread 2023-06-11 19:56:24 +02:00
bors
37998ab508 Auto merge of #112530 - matthiaskrgr:rollup-qee1kc1, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #112487 (Update documentation for `tools` defaults)
 - #112513 (Dont compute `opt_suggest_box_span` span for TAIT)
 - #112528 (bootstrap: Don't override `debuginfo-level = 1` to mean `line-tables-only`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-11 17:33:51 +00:00
Matthias Krüger
c1f2da5683
Rollup merge of #112528 - jyn514:fix-debuginfo-level, r=Mark-Simulacrum
bootstrap: Don't override `debuginfo-level = 1` to mean `line-tables-only`

This has real differences in the effective debuginfo: in particular, it omits the module-level information and makes perf less useful (it can't distinguish "self" from "child" time anymore).

Allow passing `line-tables-only` directly in config.toml instead.

See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/debuginfo.20in.20try.20builds/near/365090631 and https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bsteering.5D.202023-06-09/near/364883519 for more discussion. This effectively reverts the cargo half of https://github.com/rust-lang/rust/pull/110221 to avoid regressing https://github.com/rust-lang/rust/issues/60020 again in 1.72.
2023-06-11 18:38:29 +02:00
Matthias Krüger
d9ae7180e4
Rollup merge of #112513 - compiler-errors:dont-compute-box-span-for-tait, r=cjgillot
Dont compute `opt_suggest_box_span` span for TAIT

Fixes #112434

Also a couple more commits on top, pruning some dead code and fixing another weird suggestion encountered in the above issue.
2023-06-11 18:38:28 +02:00
Matthias Krüger
733617bd16
Rollup merge of #112487 - zwhiteley:improve-docs, r=Mark-Simulacrum
Update documentation for `tools` defaults

This PR alters the information in the tools profile config to mention that `download-rustc` uses the stage2 toolchain and not the stage1 toolchain (see https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Unable.20to.20compile.20rustc.20MSVC and rust-lang/rustc-dev-guide#1694).
2023-06-11 18:38:28 +02:00
jyn
123693953f Don't override debuginfo-level = 1 to mean line-tables-only
This has real differences in the effective debuginfo: in particular, it omits the module-level information and breaks perf.

Allow passing `line-tables-only` directly in config.toml instead.
2023-06-11 10:14:37 -05:00
bors
81c02da94e Auto merge of #111958 - notriddle:notriddle/type-search-slice-array, r=GuillaumeGomez
rustdoc: search for slices and arrays by type with `[]`

This feature extends rustdoc to support the syntax that most users will naturally attempt to use to search for slices and arrays. Part of #60485

Function signature searches already support arrays and slices. The explicit name `primitive:slice<u8>` and `primitive:array<u8>` can be used to match a slice or array of bytes, while square brackets `[u8]` will match either one. Empty square brackets, `[]`, will match any slice regardless of what it contains.

Preview:

* [`option -> []`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=option%20-%3E%20%5B%5D)
* [`[u8] -> str`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=%5Bu8%5D%20-%3E%20str)
* [`Box<[u8]> -> str`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=Box%3C%5Bu8%5D%3E%20-%3E%20str)

Motivation:

When type-based search was first landed, it was directly described as "incomplete". Here's [a comment] from the discussion thread:

[a comment]: https://github.com/rust-lang/rust/pull/23289#issuecomment-79437386

> This is looking really great, nice work! I can think of a number of cases that aren't quite covered by this, but I feel like this is a great improvement regardless and it can always be iterated on so I'm fine landing with a few known cases where it may not work :)

Filling out the missing functionality is going to mean adding support for more of Rust's [type expression] syntax, such as slices (in this PR), tuples, references, raw pointers, function pointers, and generics.

[type expression]: https://doc.rust-lang.org/reference/types.html#type-expressions

There does seem to be demand for this sort of thing, such as [this Discord message](https://discord.com/channels/442252698964721669/443150878111694848/1042145740065099796) expressing regret at rustdoc not supporting tuples in search queries.
2023-06-11 14:48:58 +00:00
Guillaume Gomez
5894193996 Migrate GUI colors test to original CSS color format 2023-06-11 14:40:12 +02:00
bors
7b6093ee08 Auto merge of #112202 - nicklimmm:item-template-derive-macro, r=GuillaumeGomez
rustdoc: Add `item_template` macro

Closes #112021

This change removes the use of `self.borrows()` in Askama templates, removes code duplication from `item_and_mut_cx()`, and improved readability by eliminating the prefix `item_template_` when calling from the template.

References:
- Discussion issue: https://github.com/rust-lang/rust/issues/112021
- `ItemTemplate` PR: https://github.com/rust-lang/rust/pull/111946

r? `@GuillaumeGomez`
2023-06-11 11:53:35 +00:00
Ryo Yoshida
42eab5e100
Deduplicate field names for completion 2023-06-11 19:34:27 +09:00
Ryo Yoshida
b4795507e3
autoderef: completely resolve and deduplicate types 2023-06-11 19:34:22 +09:00
Nicky Lim
211376927d Update ui test 2023-06-11 18:27:26 +08:00
Nicky Lim
6033895ec2 Add subdiagnostic and suggestion for overflowing bin hex with sign bits 2023-06-11 18:27:26 +08:00
Nicky Lim
e240dab0c8 Add item_template macro 2023-06-11 18:06:34 +08:00
bors
b7497fcdfa Auto merge of #15025 - lowr:fix/nested-macro-in-assoc-item-panic, r=lnicola
minor: remove commented out conflicts

Follow-up to #14989 🤦‍♂️
2023-06-11 09:00:00 +00:00
Ryo Yoshida
ed8c58a3b1
Remove commented out conflicts 2023-06-11 17:14:36 +09:00
yukang
b133841bfc Fix the overflow issue for transmute_generic_consts 2023-06-11 16:12:59 +08:00
bors
c3bab96b80 Auto merge of #14989 - lowr:fix/nested-macro-in-assoc-item-panic, r=Veykril
fix: derive source scope from syntax node to be transformed

Fixes #14534

When we use `PathTransform` for associated items of a trait, we have been feeding `SemanticsScope` for the trait definition to it as source scope. `PathTransform` uses the source scope to resolve paths in associated items to find which path to transform. In the course of path resolution, the scope is responsible for lowering `ast::MacroType`s (because they can be written within a path) using `AstIdMap` for the scope's `HirFileId`.

The problem here is that when an associated item is generated by a macro, the scope for the trait is different from the scope for that associated item. The former can only resolve the top-level macros within the trait definition but not the macro calls generated by those top-level macros. We need the latter to resolve such nested macros.

This PR makes sure that we pass `SemanticsScope` for each associated item we're applying path transformation to.
2023-06-11 07:10:27 +00:00
Ryo Yoshida
d091991491
fix(completion): derive source scope from syntax node to be transformed 2023-06-11 15:25:43 +09:00
Ryo Yoshida
008f5065d1
fix(assist): derive source scope from syntax node to be transformed 2023-06-11 15:25:36 +09:00
Deadbeef
1e36f7e9ae suspicious_double_ref_op: don't lint on .borrow() 2023-06-11 06:08:44 +00:00