Commit Graph

167847 Commits

Author SHA1 Message Date
bors
9add63257b Auto merge of #96353 - estebank:issue-95413, r=compiler-errors
When suggesting to import an item, also suggest changing the path if appropriate

When we don't find an item we search all of them for an appropriate
import and suggest `use`ing it. This is sometimes done for expressions
that have paths with more than one segment. We now also suggest changing
that path to work with the `use`.

Fix #95413
2022-05-04 01:58:23 +00:00
Yuki Okushi
81a4f4bd69
Add some TAIT-related tests 2022-05-04 09:17:47 +09:00
Nicholas Nethercote
5022d764cf Show invisible delimeters (within comments) when pretty printing. 2022-05-04 10:06:06 +10:00
bors
1b2e0b60cc Auto merge of #95380 - compiler-errors:unit-destructure-assign, r=nikomatsakis
Fix unit struct/enum variant in destructuring assignment

See https://github.com/rust-lang/rfcs/blob/master/text/2909-destructuring-assignment.md#guide-level-explanation, "including **unit** and tuple structs"

Fixes #94319
2022-05-03 22:29:58 +00:00
bors
a10fe902d2 Auto merge of #8779 - binggh:easier-needless-late-init, r=llogiq
Easier readability for `needless_late_init` message

Closes #8530

Updated the lint to use a `MultiSpan`, showing where the `let` statement was first used and where the initialisation statement was done, as in the format described, for easier readability.

Was wondering why, when pushing the span label for the initialisation statement, that sometimes the prior statement above the initialisation statement gets pulled into the output as well - any insight is appreciated!

---

changelog: [`needless_late_init`]: Now shows the `let` statement where it was first initialized
2022-05-03 20:42:35 +00:00
Tomasz Miąsko
a63d414031 Update ProjectionElem::Downcast documentation
`ProjectionElem:::Downcast` is used when downcasting to a variant of
an enum or a generator, regardless of the number of variants.
2022-05-03 22:29:51 +02:00
ricked-twice
574bee35fb
Taking review hints into account. 2022-05-03 22:23:30 +02:00
Nicholas Nethercote
1d2e172935 Remove unnecessary NtIdent in Token::is_whole_expr.
The comment on this function explains that it's a specialized version of
`maybe_whole_expr`. But `maybe_whole_expr` doesn't do anything with
`NtIdent`, so `is_whole_expr` also doesn't need to.
2022-05-04 06:15:36 +10:00
Nicholas Nethercote
bbef9756ea Fix spelling of an identifier. 2022-05-04 06:15:36 +10:00
Nicholas Nethercote
637a93cb5d Speed up Token::{ident,lifetime}.
They're hot enough that the repeated matching done by `uninterpolate`
has a measurable effect.
2022-05-04 06:15:29 +10:00
bors
e1b71feb59 Auto merge of #96558 - bjorn3:librarify_parse_format, r=davidtwco
Make rustc_parse_format compile on stable

This allows it to be used by lightweight formatting systems and may allow it to be used by rust-analyzer.
2022-05-03 20:03:54 +00:00
bors
8be86fcf35 Auto merge of #96558 - bjorn3:librarify_parse_format, r=davidtwco
Make rustc_parse_format compile on stable

This allows it to be used by lightweight formatting systems and may allow it to be used by rust-analyzer.
2022-05-03 20:03:54 +00:00
ricked-twice
bfcd191905
Quick fix for #96223. 2022-05-03 21:16:03 +02:00
Joshua Nelson
cd63b22e80 Add more tests for label-break-value 2022-05-03 14:09:52 -05:00
Guillaume Gomez
56c2769de3 Fix flaky rustdoc-ui test because it did not replace time result 2022-05-03 20:46:02 +02:00
bors
38b7a041cc Auto merge of #8783 - flip1995:ouir-nursery, r=llogiq
Move only_used_in_recursion to nursery

r? `@llogiq`

I still think this is the right thing to do for this lint. See: #8782

I want to get this merged before the sync on Thursday, because I want to backport this and the last fix #8691 to beta.

changelog: Move [`only_used_in_recursion`] to nursery
2022-05-03 18:06:52 +00:00
ridwanabdillahi
175a4eab84 Add support for a new attribute #[debugger_visualizer] to support embedding debugger visualizers into a generated PDB.
Cleanup `DebuggerVisualizerFile` type and other minor cleanup of queries.

Merge the queries for debugger visualizers into a single query.

Revert move of `resolve_path` to `rustc_builtin_macros`. Update dependencies in Cargo.toml for `rustc_passes`.

Respond to PR comments. Load visualizer files into opaque bytes `Vec<u8>`. Debugger visualizers for dynamically linked crates should not be embedded in the current crate.

Update the unstable book with the new feature. Add the tracking issue for the debugger_visualizer feature.

Respond to PR comments and minor cleanups.
2022-05-03 10:53:54 -07:00
bors
086bf7a8ff Auto merge of #96280 - lygstate:ffi-fixes, r=joshtriplett
library/core: Fixes implement of c_uint, c_long, c_ulong

Fixes: aa67016624 ("make memcmp return a value of c_int_width instead of i32")
Introduce c_num_definition to getting the cfg_if logic easier to maintain
Add newlines for easier code reading

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
2022-05-03 17:22:58 +00:00
Yoshiki Matsuda
4698a3fb8a ignore the doctest for map 2022-05-04 00:53:46 +09:00
flip1995
1834f326c4
Move only_used_in_recursion to nursery 2022-05-03 16:41:12 +01:00
Gary Guo
6baaa527ce Allow inline consts to reference generic params 2022-05-03 15:22:03 +01:00
Oli Scherer
efc6a6f1bd Report that opaque types are not allowed in impls even in the presence of other errors 2022-05-03 13:53:53 +00:00
Gary Guo
bf4d7fa43f Hide InlineConst's generic arg during print
The generic arg is for type inference only and shouldn't be exposed
to users.
2022-05-03 14:37:16 +01:00
Alex Macleod
d53293d52a Ignore type aliases in init_numbered_fields 2022-05-03 14:28:27 +01:00
Martin Geisler
9a1dc2a0a2 Remove hard links from env::current_exe security example
The security example shows that `env::current_exe` will return the
path used when the program was started. This is not really surprising
considering how hard links work: after `ln foo bar`, the two files are
_equivalent_. It is _not_ the case that `bar` is a “link” to `foo`,
nor is `foo` a link to `bar`. They are simply two names for the same
underlying data.

The security vulnerability linked to seems to be different: there an
attacker would start a SUID binary from a directory under the control
of the attacker. The binary would respawn itself by executing the
program found at `/proc/self/exe` (which the attacker can control).
This is a real problem. In my opinion, the example given here doesn’t
really show the same problem, it just shows a misunderstanding of what
hard links are.

I looked through the history a bit and found that the example was
introduced in #33526. That PR actually has two commits, and the
first (8478d48dad) explains the race
condition at the root of the linked security vulnerability. The second
commit proceeds to replace the explanation with the example we have
today.

This commit reverts most of the second commit from #33526.
2022-05-03 14:49:04 +02:00
Loïc BRANSTETT
81d2cba36f Enable cfg checking of cargo features for everything but std 2022-05-03 14:27:15 +02:00
bors
e1df625306 Auto merge of #96601 - tmiasko:ssa-rpo, r=davidtwco
Use reverse postorder in `non_ssa_locals`

The reverse postorder, unlike preorder, is now cached inside the MIR
body. Code generation uses reverse postorder anyway, so it might be
a small perf improvement to use it here as well.
2022-05-03 12:16:00 +00:00
Mara Bos
9299e6915d Round timeouts up to infinite in futex_wait on DragonFlyBSD. 2022-05-03 12:37:52 +02:00
Mara Bos
8ee9b93c4f Add #[cfg] in cfg_if for linux in unix/futex. 2022-05-03 12:37:52 +02:00
Mara Bos
7b7d1d6c48 Don't use futexes on netbsd.
The latest NetBSD release doesn't include the futex syscall yet.
2022-05-03 12:26:17 +02:00
binggh
7017eb102d cargo dev bless 2022-05-03 17:51:34 +08:00
binggh
f505cc9f72 Easier readability for needless_late_init 2022-05-03 17:51:23 +08:00
Oli Scherer
52de679c19 Add regression test 2022-05-03 09:50:17 +00:00
Yoshiki Matsuda
3d12fd0faf ignore a doctest for the non-exported macro 2022-05-03 18:33:56 +09:00
bors
ea5fa17998 Auto merge of #96666 - lnicola:rust-analyzer-2022-05-03, r=lnicola
⬆️ rust-analyzer

r? `@ghost`
2022-05-03 09:27:59 +00:00
bjorn3
d33140d2dc Make rustc_parse_format compile on stable
This allows it to be used by lightweight formatting systems and may
allow it to be used by rust-analyzer.
2022-05-03 11:26:58 +02:00
bjorn3
34760560ed Make rustc_parse_format compile on stable
This allows it to be used by lightweight formatting systems and may
allow it to be used by rust-analyzer.
2022-05-03 11:26:58 +02:00
Laurențiu Nicola
2535893594 ⬆️ rust-analyzer 2022-05-03 12:13:22 +03:00
bors
0ceacbe185 Auto merge of #8730 - tamaroning:fix8724, r=Alexendoo
[FP] identity_op in front of if

fix #8724

changelog: FP: [`identity_op`]: is now allowed in front of if statements, blocks and other expressions where the suggestion would be invalid.

Resolved simular problems with blocks, mathces, and loops.
identity_op always does NOT suggest reducing `0 + if b { 1 } else { 2 } + 3` into  `if b { 1 } else { 2 } + 3` even in the case that the expression is in `f(expr)` or `let x = expr;` for now.
2022-05-03 07:05:51 +00:00
bors
468492c2af Auto merge of #96663 - JohnTitor:rollup-lthuzdq, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #93097 (Switch settings menu to full js)
 - #96587 (Refactor the WriteBackendMethods and ExtraBackendMethods traits)
 - #96589 (Use source callsite in check_argument_types suggestion)
 - #96599 (Update `RValue::Discriminant` documentation)
 - #96614 (Add a regression test for #92305)
 - #96629 (Fix invalid keyword order for function declarations)
 - #96641 (Use a yes/no enum instead of a bool.)
 - #96646 (Mitigate impact of subtle invalid call suggestion logic)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-03 06:09:57 +00:00
Yuki Okushi
279d80127a
Rollup merge of #96646 - estebank:issue-96638, r=jackh726
Mitigate impact of subtle invalid call suggestion logic

There's some subtle interaction between inferred expressions being
passed as an argument to fn calls with fewer than expected arguments. To
avoid the ICE, I'm changing indexing operations with `.get(idx)`, but
the underlying logic still needs to be audited as it was written with
the assumption that `final_arg_types` and `provided_args` have the right
length.

Address #96638.
2022-05-03 14:59:03 +09:00
Yuki Okushi
1e6b880b84
Rollup merge of #96641 - oli-obk:bool_args, r=wesleywiser
Use a yes/no enum instead of a bool.

The bool's meaning wasn't obvious to me at some call sites.
2022-05-03 14:59:01 +09:00
Yuki Okushi
0340703b78
Rollup merge of #96629 - ken-matsui:fix-invalid-keyword-order-for-function-declarations, r=davidtwco
Fix invalid keyword order for function declarations

Closes: https://github.com/rust-lang/rust/issues/94879
2022-05-03 14:59:01 +09:00
Yuki Okushi
492d403f55
Rollup merge of #96614 - JohnTitor:test-92305, r=oli-obk
Add a regression test for #92305

Closes #92305
r? ``@oli-obk`` as per https://github.com/rust-lang/rust/issues/92305#issuecomment-1114043188
2022-05-03 14:59:00 +09:00
Yuki Okushi
61c687a0db
Rollup merge of #96599 - tmiasko:discriminant-docs, r=estebank
Update `RValue::Discriminant` documentation

`RValue::Discriminant` returns zero for types without discriminant.
This guarantee is already documented for `discriminant_value`
intrinsics which is implemented in terms of `RValue::Discriminant`.
2022-05-03 14:58:59 +09:00
Yuki Okushi
a58703677b
Rollup merge of #96589 - Badel2:source-callsite, r=michaelwoerister
Use source callsite in check_argument_types suggestion

This makes the "remove extra arguement" suggestion valid when the function argument is a macro.

Additionally, this may fix #96225, but the only way I can reproduce that issue is using the playground, so we will need to wait until after this is merged to ensure it's fixed.
2022-05-03 14:58:58 +09:00
Yuki Okushi
329a73dbd6
Rollup merge of #96587 - bjorn3:refactor_backend_write, r=michaelwoerister
Refactor the WriteBackendMethods and ExtraBackendMethods traits

The new interface is slightly less confusing and is easier to implement for non-LLVM backends.
2022-05-03 14:58:57 +09:00
Yuki Okushi
27d7615bb4
Rollup merge of #93097 - GuillaumeGomez:settings-js, r=jsha
Switch settings menu to full js

Since the settings can only be set when the JS is enabled, it's not really a problem. It also fixes a debate we had around the themes not being accessible easily before.

![Screenshot from 2022-01-19 23-06-59](https://user-images.githubusercontent.com/3050060/150221936-fd1a1e76-06b6-4416-a653-dbae111979ed.png)

You can test it [here](https://rustdoc.crud.net/imperio/settings-js/doc/foo/index.html).

r? ``@jsha``
2022-05-03 14:58:56 +09:00
Rock Boynton
77390a152f Fix typo in lint levels doc 2022-05-02 22:33:28 -07:00
Tomasz Miąsko
e62663492b Collect function instance used in global_asm! sym operand
The constants used in SymFn operands have FnDef type,
so the type of the constant identifies the function.
2022-05-03 07:12:43 +02:00