Commit Graph

218392 Commits

Author SHA1 Message Date
bors
c5c7d2b377 Auto merge of #108421 - Dylan-DPC:rollup-mpeovxd, r=Dylan-DPC
Rollup of 10 pull requests

Successful merges:

 - #106541 (implement const iterator using `rustc_do_not_const_check`)
 - #106918 (Rebuild BinaryHeap on unwind from retain)
 - #106923 (Restore behavior when primary bundle is missing)
 - #108169 (Make query keys `Copy`)
 - #108287 (Add test for bad cast with deferred projection equality)
 - #108370 (std: time: Avoid to use "was created" in elapsed() description)
 - #108377 (Fix ICE in 'duplicate diagnostic item' diagnostic)
 - #108388 (parser: provide better suggestions and errors on closures with braces missing)
 - #108391 (Fix `is_terminal`'s handling of long paths on Windows.)
 - #108401 (diagnostics: remove inconsistent English article "this" from E0107)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-24 20:49:11 +00:00
David Koloski
6e7902bc3d Update fuchsia-test-runner.py and docs
This updates the test runner to the latest version of the SDK and fixes
debugging support for Rust source code.
2023-02-24 15:39:58 -05:00
Obei Sideg
34966aab55 Migrate rustc_hir_analysis to session diagnostic
Part one, lib.rs file
2023-02-24 23:23:30 +03:00
Michael Goulet
a861b192da Wrap missing provider message correctly 2023-02-24 18:46:29 +00:00
Trevor Gross
4ecf14372f doc: cleanup of doc/index.md
- Add quick link to API docs
- Add marker for external links, to help offline users
- Add information about using 'cargo doc' and the playground
- Clean up some of the wording
- Update body & header style to match rustdoc defaults
2023-02-24 13:21:02 -05:00
klensy
c3749ddf4c test: drop unused deps 2023-02-24 20:45:00 +03:00
Guillaume Gomez
37d4302c25 Add regression test for #107918 2023-02-24 18:15:56 +01:00
Stefan Lankes
af8ee641a8 avoid the usage of libc during the creation of documentation 2023-02-24 15:30:14 +01:00
Stefan Lankes
90162a78a9 remove code duplications 2023-02-24 15:30:14 +01:00
Stefan Lankes
b5fb4f3d9b move IO traits to std/src/os/hermit
By moving the IO traits, the RustyHermit support is harmonized to
of other operating systems.
2023-02-24 15:30:14 +01:00
Stefan Lankes
7143379a52 add support of RustyHermit's BSD socket layer
RustHermit publishs a new kernel interface and supports
a common BSD socket layer. By supporting this interface,
the implementation can be harmonized to other operating systems.

To realize this socket layer, the handling of file descriptors
is also harmonized to other operating systems.
2023-02-24 15:30:14 +01:00
bors
81490e15d4 Auto merge of #2799 - klensy:dep-up, r=RalfJung
cargo-miri: bump `rustc_tools_util` crate

This dedupes crate versions in rust repo.
2023-02-24 13:41:31 +00:00
LevitatingLion
9cb27d2604 CI: Move arm-unknown-linux-gnueabi tests to Windows host 2023-02-24 14:30:11 +01:00
LevitatingLion
e81ebb947c
Use full path to c_char in README
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-02-24 14:27:46 +01:00
klensy
9a32db7e17 use setup_version_info! 2023-02-24 16:14:49 +03:00
klensy
47aeaba8b3 bump rustc_tools_util 2023-02-24 16:05:50 +03:00
Patrik Kårlin
3d34538f5d
rustc_infer: Consolidate obligation elaboration de-duplication 2023-02-24 11:32:41 +01:00
bors
b528cc90bc Auto merge of #10391 - ldm0:ldm0_fix_unwrap_in_tests, r=xFrednet
Fix test function checker in `unwrap_used`, `expect_used`

After #9686 , `unwrap` and `expect` in integration tests and raw test functions won't be allowed.

fixes #10011
fixes #10238
fixes #10264

---

changelog: Fix: [`expect_used`], [`unwrap_used`], [`dbg_macro`], [`print_stdout`], [`print_stderr`]: No longer lint in test functions, if the related configuration is set
[#10391](https://github.com/rust-lang/rust-clippy/pull/10391)
<!-- changelog_checked -->
2023-02-24 09:24:41 +00:00
yukang
34813e2051 Test that the compiler/library builds with -Zmir-opt-level=3 -Zvalidate-mir 2023-02-24 08:07:43 +00:00
Dylan DPC
c77cf40df0
Rollup merge of #108401 - notriddle:notriddle/diagnostics-article, r=compiler-errors
diagnostics: remove inconsistent English article "this" from E0107

Consider [`tests/ui/const-generics/generic_const_exprs/issue-102768.stderr`][issue-102768.stderr], the error message where it gives additional notes about where the associated type is defined, and how the dead code lint doesn't have an article, like in [`tests/ui/lint/dead-code/issue-85255.stderr`][issue-85255.stderr]. They don't have articles, so it seems unnecessary to have one here.

[issue-102768.stderr]: 07c993eba8/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr
[issue-85255.stderr]: 07c993eba8/tests/ui/lint/dead-code/issue-85255.stderr
2023-02-24 12:02:45 +05:30
Dylan DPC
353827a044
Rollup merge of #108391 - sunfishcode:sunfishcode/is-terminal-file-length, r=ChrisDenton
Fix `is_terminal`'s handling of long paths on Windows.

As reported in sunfishcode/is-terminal#18, there are situations where `GetFileInformationByHandleEx` can write a file name length that is longer than the provided buffer. To avoid deferencing memory past the end of the buffer, use a bounds-checked function to form a slice to the buffer and handle the out-of-bounds case.

This ports the fix from sunfishcode/is-terminal#19 to std's `is_terminal` implementation.
2023-02-24 12:02:45 +05:30
Dylan DPC
8acbfe27d6
Rollup merge of #108388 - ohno418:better-suggestion-on-malformed-closure, r=davidtwco
parser: provide better suggestions and errors on closures with braces missing

We currently provide wrong suggestions and unhelpful errors on closure bodies with braces missing.

For example, given the following code:

```rust
fn main() {
    let _x = Box::new(|x|x+1;);
}
```

the current output is:

```
error: expected expression, found `)`
 --> ./main.rs:2:30
  |
2 |     let _x = Box::new(|x|x+1;);
  |                              ^ expected expression

error: closure bodies that contain statements must be surrounded by braces
 --> ./main.rs:2:25
  |
2 |     let _x = Box::new(|x|x+1;);
  |                         ^
3 | }
  | ^
  |
note: statement found outside of a block
 --> ./main.rs:2:29
  |
2 |     let _x = Box::new(|x|x+1;);
  |                          ---^ this `;` turns the preceding closure into a statement
  |                          |
  |                          this expression is a statement because of the trailing semicolon
note: the closure body may be incorrectly delimited
 --> ./main.rs:2:23
  |
2 |     let _x = Box::new(|x|x+1;);
  |                       ^^^^^^ this is the parsed closure...
3 | }
  | - ...but likely you meant the closure to end here
help: try adding braces
  |
2 ~     let _x = Box::new(|x| {x+1;);
3 ~ }}
  |

error: expected `;`, found `}`
 --> ./main.rs:2:32
  |
2 |     let _x = Box::new(|x|x+1;);
  |                                ^ help: add `;` here
3 | }
  | - unexpected token

error: aborting due to 3 previous errors
```

We got 3 errors, but all but the second are unnecessary or just wrong.

This commit allows outputting correct suggestions and errors. The above code would output like this:

```
error: closure bodies that contain statements must be surrounded by braces
 --> ./main.rs:2:25
  |
2 |     let _x = Box::new(|x|x+1;);
  |                         ^    ^
  |
note: statement found outside of a block
 --> ./main.rs:2:29
  |
2 |     let _x = Box::new(|x|x+1;);
  |                          ---^ this `;` turns the preceding closure into a statement
  |                          |
  |                          this expression is a statement because of the trailing semicolon
note: the closure body may be incorrectly delimited
 --> ./main.rs:2:23
  |
2 |     let _x = Box::new(|x|x+1;);
  |                       ^^^^^^ - ...but likely you meant the closure to end here
  |                       |
  |                       this is the parsed closure...
help: try adding braces
  |
2 |     let _x = Box::new(|x| {x+1;});
  |                           +    +

error: aborting due to previous error
```

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

r? diagnostics
2023-02-24 12:02:44 +05:30
Dylan DPC
4aff2c5ff8
Rollup merge of #108377 - clubby789:duplicate-diagnostic-ice, r=compiler-errors
Fix ICE in 'duplicate diagnostic item' diagnostic

Not sure how to add this in a test; I found it by mistakenly running `cargo fix --lib -p std` rather than `x fix` at the root.
2023-02-24 12:02:43 +05:30
Dylan DPC
f94c3c9da1
Rollup merge of #108370 - fbq:time-doc-fix, r=thomcc
std: time: Avoid to use "was created" in elapsed() description

".. since this instant was created" is inaccurate and misleading, consider the following case:
```rust
	let i1 = Instant::now(); // i1 is created at T1
	let i2 = i1 + Duration::from_nanos(0); // i2 is "created" at T2
	i2.elapsed(); // at T3
```
Per the current description, `elapsed()` at T3 should return T3 - T2?

To avoid the inaccuracy, removes the "was created" in the description of {Instant,SystemTime}::elapsed().
And since these types represent times, it's OK to use prepostions with them, e.g. "since this instant".
2023-02-24 12:02:42 +05:30
Dylan DPC
251293ef5e
Rollup merge of #108287 - compiler-errors:new-solver-bad-cast, r=spastorino
Add test for bad cast with deferred projection equality

1. Unification during coercion (`Coerce::unify`) needs to consider deferred projection obligations (at least pass over them with `predicate_may_hold` or something, to disqualify any totally wrong unifications) -- otherwise, we'll shallowly consider `<u8 as Add>::Output` and `char` as coercible during `FnCtxt::try_coerce`, which will fail later when the nested obligations are registered and processed.

2. Cast checking needs to be able to structurally normalize types so it sees `u8` instead of `<u8 as Add>::Output`. Otherwise it'll always consider the latter as part of a non-primitive cast. Currently `FnCtxt::normalize` doesn't do anything useful here, interestingly.

I tried looking into both of these and it's not immediately clear where to refactor existing typeck code to fix this (at least the latter), but I'm gonna commit a test for it at least so we don't forget. This is one of the issues that's keeping us from building larger projects.
2023-02-24 12:02:42 +05:30
Dylan DPC
440113ddf6
Rollup merge of #108169 - Zoxc:query-key-copy, r=cjgillot
Make query keys `Copy`

This regressed compiler performance locally, so I'm curious what perf will say about it.

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.7566s</td><td align="right">1.7657s</td><td align="right"> 0.52%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2572s</td><td align="right">0.2578s</td><td align="right"> 0.20%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9863s</td><td align="right">0.9900s</td><td align="right"> 0.37%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.6018s</td><td align="right">1.6073s</td><td align="right"> 0.34%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.2493s</td><td align="right">6.2920s</td><td align="right"> 0.68%</td></tr><tr><td>Total</td><td align="right">10.8512s</td><td align="right">10.9127s</td><td align="right"> 0.57%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">1.0042s</td><td align="right"> 0.42%</td></tr></table>
2023-02-24 12:02:41 +05:30
Dylan DPC
6826a96067
Rollup merge of #106923 - mejrs:fluent_err, r=davidtwco
Restore behavior when primary bundle is missing

Fixes https://github.com/rust-lang/rust/issues/106755 by restoring some of the behavior prior to https://github.com/rust-lang/rust/pull/106427

Still, I have no idea how this debug assertion can even hit while using `en-US` as primary  bundle.

r? ```@davidtwco```
2023-02-24 12:02:41 +05:30
Dylan DPC
b3657f92d1
Rollup merge of #106918 - dtolnay:heapretain, r=the8472
Rebuild BinaryHeap on unwind from retain

This closes the hole identified in https://github.com/rust-lang/rust/issues/71503#issuecomment-1383251315 which had made it possible for the caller to end up with a heap in invalid state. As of #105851, heaps in invalid state are not supposed to exist.
2023-02-24 12:02:41 +05:30
Dylan DPC
8c135eecac
Rollup merge of #106541 - fee1-dead-contrib:no-const-check-no, r=thomcc
implement const iterator using `rustc_do_not_const_check`

Previous experiment: #102225.

Explanation: rather than making all default methods work under `const` all at once, this uses `rustc_do_not_const_check` as a workaround to "trick" the compiler to not run any checks on those other default methods. Any const implementations are only required to implement the `next` method. Any actual calls to the trait methods other than `next` will either error in compile time (at CTFE runs), or run the methods correctly if they do not have any non-const operations. This is extremely easy to maintain, remove, or improve.
2023-02-24 12:02:40 +05:30
est31
2850116636 Replace parse_[sth]_expr with parse_expr_[sth] function names
This resolves an inconsistency in naming style for functions
on the parser, between functions parsing specific kinds of items
and those for expressions, favoring the parse_item_[sth] style
used by functions for items. There are multiple advantages
of that style:

* functions of both categories are collected in the same place
  in the rustdoc output.
* it helps with autocompletion, as you can narrow down your
  search for a function to those about expressions.
* it mirrors rust's path syntax where less specific things
  come first, then it gets more specific, i.e.
  std::collections::hash_map::Entry

The disadvantage is that it doesn't "read like a sentence"
any more, but I think the advantages weigh more greatly.

This change was mostly application of this command:

sed -i -E 's/(fn |\.)parse_([[:alnum:]_]+)_expr/\1parse_expr_\2/' compiler/rustc_parse/src/parser/*.rs

Plus very minor fixes outside of rustc_parse, and an invocation
of x fmt.
2023-02-24 05:12:03 +01:00
LevitatingLion
04b2aab141 Add ARM targets to CI
Specifically `aarch64-unknown-linux-gnu` and `arm-unknown-linux-gnueabi`
2023-02-24 04:18:38 +01:00
LevitatingLion
d4d7edfdf3 Use pointers to c_char instead of i8 in miri_host_to_target_path
This makes sure that the interface of `miri_host_to_target_path` is compatible with `CStr` for targets where `c_char` is unsigned (such as ARM). This commit changes the signature of `miri_host_to_target_path` in the README and in all test cases.
2023-02-24 04:18:38 +01:00
Michael Goulet
ed30efff3b Comments, another test 2023-02-24 02:53:25 +00:00
Michael Goulet
2540c2b761 Make higher-ranked projections in object types work in new solver 2023-02-24 02:48:44 +00:00
Michael Goulet
98525aeee7 Check object's supertrait and associated type bounds in new solver 2023-02-24 02:45:05 +00:00
LevitatingLion
a80f5272c6 Add shim for llvm.arm.hint
This shim is required for `core::hint::spin_loop` on `arm` targets
2023-02-24 02:59:58 +01:00
Liu Dingming
84ceca852e run cargo collect-metadata 2023-02-24 05:53:58 +08:00
Nicholas Nethercote
d78ca52450 Upgrade ena to 0.14.1.
To get the small performance improvements from
https://github.com/rust-lang/ena/pull/43.
2023-02-24 08:53:27 +11:00
Guillaume Gomez
4ff1c4d3e7 No need for the wait-for anymore to go around browser navigation bug 2023-02-23 22:04:38 +01:00
Guillaume Gomez
b6e0efe655 Update browser-ui-test version 2023-02-23 22:04:19 +01:00
Michael Howell
5a9a3df312 rustdoc: avoid including <li> tags in item table short desc
Fixes a bug seen at https://docs.rs/gl_constants/0.1.1/gl_constants/index.html
2023-02-23 13:53:27 -07:00
Nicholas Nethercote
08f28f9447 Use List::empty() instead of mk_substs(&[]). 2023-02-24 07:33:02 +11:00
Nicholas Nethercote
c09f5b6a6b Add mk_canonical_var_infos_from_iter.
It's missing, and is useful in two places.
2023-02-24 07:33:02 +11:00
Nicholas Nethercote
11c2c596e4 Rename mk_{ty,region} as mk_{ty,region}_from_kind.
To discourage accidental use -- there are more specific `mk_*` functions
for all `Ty` and `Region` kinds.
2023-02-24 07:33:00 +11:00
Nicholas Nethercote
a980683d1f Replace a mk_ty call with mk_bound. 2023-02-24 07:32:27 +11:00
Nicholas Nethercote
2200911616 Rename many interner functions.
(This is a large commit. The changes to
`compiler/rustc_middle/src/ty/context.rs` are the most important ones.)

The current naming scheme is a mess, with a mix of `_intern_`, `intern_`
and `mk_` prefixes, with little consistency. In particular, in many
cases it's easy to use an iterator interner when a (preferable) slice
interner is available.

The guiding principles of the new naming system:
- No `_intern_` prefixes.
- The `intern_` prefix is for internal operations.
- The `mk_` prefix is for external operations.
- For cases where there is a slice interner and an iterator interner,
  the former is `mk_foo` and the latter is `mk_foo_from_iter`.

Also, `slice_interners!` and `direct_interners!` can now be `pub` or
non-`pub`, which helps enforce the internal/external operations
division.

It's not perfect, but I think it's a clear improvement.

The following lists show everything that was renamed.

slice_interners
- const_list
  - mk_const_list -> mk_const_list_from_iter
  - intern_const_list -> mk_const_list
- substs
  - mk_substs -> mk_substs_from_iter
  - intern_substs -> mk_substs
  - check_substs -> check_and_mk_substs (this is a weird one)
- canonical_var_infos
  - intern_canonical_var_infos -> mk_canonical_var_infos
- poly_existential_predicates
  - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter
  - intern_poly_existential_predicates -> mk_poly_existential_predicates
  - _intern_poly_existential_predicates -> intern_poly_existential_predicates
- predicates
  - mk_predicates -> mk_predicates_from_iter
  - intern_predicates -> mk_predicates
  - _intern_predicates -> intern_predicates
- projs
  - intern_projs -> mk_projs
- place_elems
  - mk_place_elems -> mk_place_elems_from_iter
  - intern_place_elems -> mk_place_elems
- bound_variable_kinds
  - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter
  - intern_bound_variable_kinds -> mk_bound_variable_kinds

direct_interners
- region
  - intern_region (unchanged)
- const
  - mk_const_internal -> intern_const
- const_allocation
  - intern_const_alloc -> mk_const_alloc
- layout
  - intern_layout -> mk_layout
- adt_def
  - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid)
  - alloc_adt_def(!) -> mk_adt_def
- external_constraints
  - intern_external_constraints -> mk_external_constraints

Other
- type_list
  - mk_type_list -> mk_type_list_from_iter
  - intern_type_list -> mk_type_list
- tup
  - mk_tup -> mk_tup_from_iter
  - intern_tup -> mk_tup
2023-02-24 07:32:24 +11:00
Nicholas Nethercote
29b51cdff3 Tweak the slice interners.
All the slice interners have a wrapper that handles the empty slice
case. We can instead handle this in the `slice_interners!` macro,
avoiding the need for most of the wrappers, and allowing the interner
functions to be renamed from `_intern_foos` to `intern_foos`.

The two exceptions:
- intern_predicates: I kept this wrapper because there's a FIXME
  comment about a possible future change.
- intern_poly_existential_predicates: I kept this wrapper because it
  asserts that the slice is empty and sorted.
2023-02-24 07:08:40 +11:00
bors
659112ca95 Auto merge of #10369 - nindalf:no_mangle_lint, r=llogiq
Add new lint no_mangle_with_rust_abi

Fixes issue #10347

This PR adds a new lint `no_mangle_with_rust_abi` that suggests converting a function to the C ABI to if the function has the `#[no_mangle]` attribute and `Abi == Abi::Rust`. It will not run for any of the other variants defined in [rustc_target::spec::abi::Abi](https://doc.rust-lang.org/beta/nightly-rustc/rustc_target/spec/abi/enum.Abi.html), nor suggest any conversion other than conversion to the C ABI.

Functions that explicitly opt into the Rust ABI with `extern "Rust"` are ignored by this lint.

---

changelog: [`no_mangle_with_rust_abi`]: add lint that converts Rust ABI functions with the `#[no_mangle]` attribute to C ABI
2023-02-23 19:41:03 +00:00
Michael Howell
a402cb0f9b docs: use intra-doc links for Vec::get(_mut)
Now that #63351 is fixed, there's no reason not to.
2023-02-23 12:26:14 -07:00
Michael Howell
0241e493b1 rustdoc: update UI test for dropping "this" article 2023-02-23 11:59:26 -07:00