Commit graph

150937 commits

Author SHA1 Message Date
bors
23c652dfe3 Auto merge of #86866 - nikomatsakis:issue-84841, r=oli-obk
Hack: Ignore inference variables in certain queries

Fixes #84841
Fixes #86753

Some queries are not built to accept types with inference variables, which can lead to ICEs. These queries probably ought to be converted to canonical form, but as a quick workaround, we can return conservative results in the case that inference variables are found.

We should file a follow-up issue (and update the FIXMEs...) to do the proper refactoring.

cc `@arora-aman`

r? `@oli-obk`
2021-07-04 17:39:37 +00:00
Aaron Hill
ff15b5e2c7
Query-ify global limit attribute handling 2021-07-04 12:33:14 -05:00
Guillaume Gomez
f742cde948 Add missing code example for Write::write_vectored 2021-07-04 19:23:29 +02:00
klensy
f6146081ba tidy: update cargo_metadata to 0.12 2021-07-04 19:58:04 +03:00
Niko Matsakis
492ba34a91 revert broken formatting 2021-07-04 12:50:41 -04:00
Niko Matsakis
1c1573d2a3 remove outdated comment 2021-07-04 12:50:35 -04:00
Niko Matsakis
63fbefd359 tag issues with FIXME 2021-07-04 12:50:28 -04:00
Yuki Okushi
2512e9606b
Add a regression test for issue-69323 2021-07-05 01:45:46 +09:00
Niko Matsakis
86a5a6520d
Update compiler/rustc_middle/src/ty/normalize_erasing_regions.rs
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
2021-07-04 12:37:25 -04:00
Yuki Okushi
93882e4396
Convert debug_assert! to assert! in Binder::dummy
This is needed for #85350 not to be passed.
2021-07-05 01:22:33 +09:00
Niko Matsakis
9bdfde0be4 remove some ad-hoc has_infer_types checks that aren't needed anymore 2021-07-04 11:55:09 -04:00
Niko Matsakis
75c172246c be conservative in has_significant_drop 2021-07-04 11:41:40 -04:00
Niko Matsakis
40ee019c17 allow inference vars in type_implements_trait 2021-07-04 11:28:20 -04:00
Niko Matsakis
26f7030b16 remove unused Option 2021-07-04 11:09:32 -04:00
Taylor Yu
92197a551f E0716: clarify that equivalent code example is erroneous
In E0716, there is a code block that is equivalent to the erroneous
code example. Especially when viewed with `rustc --explain`, it's
not obvious that it is also erroneous, and some users have been
confused when they try to change their code to match the erroneous
equivalent.
2021-07-04 10:04:37 -05:00
bors
90442458ac Auto merge of #86048 - nbdd0121:no_floating_point, r=Amanieu
core: add unstable no_fp_fmt_parse to disable float formatting code

In some projects (e.g. kernel), floating point is forbidden. They can disable
hardware floating point support and use `+soft-float` to avoid fp instructions
from being generated, but as libcore contains the formatting code for `f32`
and `f64`, some fp intrinsics are depended. One could define stubs for these
intrinsics that just panic [1], but it means that if any formatting functions
are accidentally used, mistake can only be caught during the runtime rather
than during compile-time or link-time, and they consume a lot of space without
LTO.

This patch provides an unstable cfg `no_fp_fmt_parse` to disable these.
A panicking stub is still provided for the `Debug` implementation (unfortunately)
because there are some SIMD types that use `#[derive(Debug)]`.

[1]: https://lkml.org/lkml/2021/4/14/1028
2021-07-04 14:18:57 +00:00
bors
308fc2322b Auto merge of #86213 - jhpratt:stabilize-const-from_utf8_unchecked, r=JohnTitor
Stabilize `str::from_utf8_unchecked` as `const`

This stabilizes `unsafe fn str::from_utf8_unchecked` as `const` pending FCP on #75196. By the time FCP finishes, the beta will have already been cut, so I've set 1.55 as the stable-since version.

(should also be +relnotes but I don't have the permission to do that)

r? `@m-ou-se`

Closes #75196
2021-07-04 11:56:55 +00:00
Tomasz Miąsko
6bbf1e7aad re-export SwitchIntEdgeEffects
This makes it possible to use `switch_int_edge_effects` outside
`rustc_mir::dataflow::impls`.
2021-07-04 13:33:22 +02:00
bors
39e20f1ae5 Auto merge of #86255 - Smittyvb:mir-alloc-oom, r=RalfJung,oli-obk
Support allocation failures when interpreting MIR

This closes #79601 by handling the case where memory allocation fails during MIR interpretation, and translates that failure into an `InterpError`. The error message is "tried to allocate more memory than available to compiler" to make it clear that the memory shortage is happening at compile-time by the compiler itself, and that it is not a runtime issue.

Now that memory allocation can fail, it would be neat if Miri could simulate low-memory devices to make it easy to see how much memory a Rust program needs.

Note that this breaks Miri because it assumes that allocation can never fail.
2021-07-04 09:15:36 +00:00
bors
64ae15ddd3 Auto merge of #86849 - jyn514:rustdoc-group, r=Manishearth
Warn when `rustdoc::` group is omitted from lint names

When rustdoc lints were first made a tool lint, they gave an unconditional warning when you used the original name:
```
warning: lint `broken_intra_doc_links` has been renamed to `rustdoc::broken_intra_doc_links`
  --> $DIR/renamed-lint-still-applies.rs:2:9
   |
LL | #![deny(broken_intra_doc_links)]
   |         ^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rustdoc::broken_intra_doc_links`
   |
   = note: `#[warn(renamed_and_removed_lints)]` on by default
```
That was reverted in https://github.com/rust-lang/rust/pull/83203 because adding `rustdoc::x` lints would cause the code to break on old versions of the compiler (due to https://github.com/rust-lang/rust/issues/66079#issuecomment-788589193, "fixed" in https://github.com/rust-lang/rust/pull/83216 in the sense that you can now opt-in to not breaking on nightly, which is not ideal but `register_tool` is a long way from stabilizing). Since https://github.com/rust-lang/rust/pull/80527 is now on 1.52.0 stable, we can re-enable the warning. For nightly users, they can change immediately and still have their code work on stable; for stable users, they can change their code in 12 weeks and still have it work up to 3 releases back (about 18 weeks). That seems reasonable to me.

r? `@Manishearth` cc `@rust-lang/rustdoc`
2021-07-04 06:34:31 +00:00
Yuki Okushi
ab86df0ce9
Stabilize string_drain_as_str 2021-07-04 14:23:43 +09:00
bors
71a567fae4 Auto merge of #86833 - crlf0710:remove-std-raw-mod, r=SimonSapin
Remove the deprecated `core::raw` and `std::raw` module.

A few months has passed since #84207. I think now it's time for the final removal.

Closes #27751.

r? `@m-ou-se`
2021-07-04 04:04:47 +00:00
Niko Matsakis
6f4b539a62 introduce helper function 2021-07-03 22:15:32 -04:00
Joshua Nelson
fad1b9c3ba Make x.py less verbose on failures
- Don't print the exact command run by rustbuild unless `--verbose` is set.
  This is almost always unhelpful, since it's just cargo with a lot of
  arguments.
- Don't print "Build completed unsuccessfully" unless --verbose is set.
  You can already tell the build failed by the errors above, and the
  time isn't particularly helpful.
- Don't print the full path to bootstrap. This is useless to everyone,
  even including when working on x.py itself. You can still opt-in to
  this being shown with `--verbose`, since it will throw an exception.

Before:

```
error[E0432]: unresolved import `x`
   --> library/std/src/lib.rs:343:5
    |
343 | use x;
    |     ^ no external crate `x`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `std`

To learn more, run the command again with --verbose.
command did not execute successfully: "/home/joshua/rustc4/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "8" "--release" "--features" "panic-unwind backtrace" "--manifest-path" "/home/joshua/rustc4/library/test/Cargo.toml" "--message-format" "json-render-diagnostics"
expected success, got: exit status: 101
failed to run: /home/joshua/rustc4/build/bootstrap/debug/bootstrap check
Build completed unsuccessfully in 0:00:13
```

After:

```
error[E0432]: unresolved import `x`
   --> library/std/src/lib.rs:343:5
    |
343 | use x;
    |     ^ no external crate `x`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `std`

To learn more, run the command again with --verbose.
```
2021-07-03 21:45:47 -04:00
bors
1540711946 Auto merge of #85270 - ChrisDenton:win-env-case, r=m-ou-se
When using `process::Command` on Windows, environment variable names must be case-preserving but case-insensitive

When using `Command` to set the environment variables, the key should be compared as uppercase Unicode but when set it should preserve the original case.

Fixes #85242
2021-07-04 01:24:05 +00:00
Noah Lev
7ffec7028a rustc_ast_pretty: Don't print space after $
For example, this code:

    $arg:expr

used to be pretty-printed as:

    $ arg : expr

but is now pretty-printed as:

    $arg : expr
2021-07-03 16:35:18 -07:00
bors
d34a3a401b Auto merge of #85090 - Aaron1011:type-outlives-global, r=matthewjasper,jackh726
Return `EvaluatedToOk` when type in outlives predicate is global

A global type doesn't reference any local regions or types, so it's
guaranteed to outlive any region.
2021-07-03 22:42:58 +00:00
Noah Lev
f82d4845f2 Pretty-print macro matchers instead of using source code
The output is not quite as nice as it used to be, but it does work.
2021-07-03 15:36:32 -07:00
Niko Matsakis
1297cb7f37 add test case 2021-07-03 18:32:26 -04:00
bors
71b8742bbc Auto merge of #86825 - ehuss:update-cargo, r=ehuss
Update cargo

5 commits in 4952979031e2cf1d901c817a32e25a156a19db4c..3ebb5f15a940810f250b68821149387af583a79e
2021-07-01 01:14:50 +0000 to 2021-07-02 20:35:38 +0000
- Adjust the edition2021 resolver diff report. (rust-lang/cargo#9649)
- Include the linker in the fingerprint. (rust-lang/cargo#9647)
- Temporarily disable windows env test. (rust-lang/cargo#9646)
- Handle git deleted files with dirty worktree. (rust-lang/cargo#9645)
- Adjust error message with offline and frozen. (rust-lang/cargo#9644)
2021-07-03 20:21:39 +00:00
Joshua Nelson
7a774a8537 Warn when rustdoc:: group is omitted from lint names 2021-07-03 15:32:09 -04:00
bors
96859dbaf6 Auto merge of #86778 - tmiasko:fast-multiline, r=davidtwco
Avoid byte to char position conversions in `is_multiline`

Converting a byte position into a char position is currently linear in
the number of multibyte characters in the source code. Avoid it when
checking if a range spans across lines.

This makes it feasible to compile source files with a large number of
multibyte characters.
2021-07-03 16:06:35 +00:00
Smittyvb
d83c46ffcc
add note about MAX_ALLOC_LIMIT
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-07-03 11:15:14 -04:00
Smitty
b201b2f65f Make vtable_allocation always succeed 2021-07-03 11:14:19 -04:00
bors
8649737bee Auto merge of #86810 - ojeda:alloc-gate, r=dtolnay
alloc: `no_global_oom_handling`: disable `new()`s, `pin()`s, etc.

They are infallible, and could not be actually used because
they will trigger an error when monomorphized, but it is better
to just remove them.

Link: https://github.com/Rust-for-Linux/linux/pull/402
Suggested-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-07-03 13:23:28 +00:00
bors
a8b8558f08 Auto merge of #86799 - tlyu:stdio-locked, r=joshtriplett
add owned locked stdio handles

Add stderr_locked, stdin_locked, and stdout_locked free functions
to obtain owned locked stdio handles in a single step. Also add
into_lock methods to consume a stdio handle and return an owned
lock. These methods will make it easier to use locked stdio
handles without having to deal with lifetime problems or keeping
bindings to the unlocked handles around.

Fixes #85383; enables #86412.

r? `@joshtriplett`
`@rustbot` label +A-io +C-enhancement +D-newcomer-roadblock +T-libs-api
2021-07-03 10:40:53 +00:00
bors
701496384f Auto merge of #86571 - fee1-dead:const-trait-impl-fix, r=jackh726
deny using default function in impl const Trait

Fixes #79450.

I don't know if my implementation is correct:

 - The check is in `rustc_passes::check_const`, should I put it somewhere else instead?
 - Is my approach (to checking the impl) optimal? It works for the current tests, but it might have some issues or there might be a better way of doing this.
2021-07-03 07:24:24 +00:00
Charles Lew
0d1919c7ab Remove the deprecated core::raw and std::raw module. 2021-07-03 14:03:27 +08:00
bors
fdd9a07147 Auto merge of #79965 - ijackson:moreerrnos, r=joshtriplett
More ErrorKinds for common errnos

From the commit message of the main commit here (as revised):

```
There are a number of IO error situations which it would be very
useful for Rust code to be able to recognise without having to resort
to OS-specific code.  Taking some Unix examples, `ENOTEMPTY` and
`EXDEV` have obvious recovery strategies.  Recently I was surprised to
discover that `ENOSPC` came out as `ErrorKind::Other`.

Since I am familiar with Unix I reviwed the list of errno values in
  https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html

Here, I add those that most clearly seem to be needed.

`@CraftSpider` provided information about Windows, and references, which
I have tried to take into account.

This has to be insta-stable because we can't sensibly have a different
set of ErrorKinds depending on a std feature flag.

I have *not* added these to the mapping tables for any operating
systems other than Unix and Windows.  I hope that it is OK to add them
now for Unix and Windows now, and maybe add them to other OS's mapping
tables as and when someone on that OS is able to consider the
situation.

I adopted the general principle that it was usually a bad idea to map
two distinct error values to the same Rust error code.  I notice that
this principle is already violated in the case of `EACCES` and
`EPERM`, which both map to `PermissionDenied`.  I think this was
probably a mistake but it would be quite hard to change now, so I
don't propose to do anything about that.

However, for Windows, there are sometimes different error codes for
identical situations.  Eg there are WSA* versions of some error
codes as well as ERROR_* ones.  Also Windows seems to have a great
many more erorr codes.  I don't know precisely what best practice
would be for Windows.
```

<strike>

```
Errno values I wasn't sure about so *haven't* included:

EMFILE ENFILE ENOBUFS ENOLCK:

  These are all fairly Unix-specific resource exhaustion situations.
  In practice it seemed not very likely to me that anyone would want
  to handle these differently to `Other`.

ENOMEM ERANGE EDOM EOVERFLOW

  Normally these don't get exposed to the Rust callers I hope.  They
  don't tend to come out of filesystem APIs.

EILSEQ

  Hopefully Rust libraries open files in binary mode and do the
  converstion in Rust.  So Rust code ought not to be exposed to
  EILSEQ.

EIO

  The range of things that could cause this is troublesome.  I found
  it difficult to describe.  I do think it would be useful to add this
  at some point, because EIO on a filesystem operation is much more
  serious than most other errors.

ENETDOWN

  I wasn't sure if this was useful or, indeed, if any modern systems
  use it.

ENOEXEC

  It is not clear to me how a Rust program could respond to this.  It
  seems rather niche.

EPROTO ENETRESET ENODATA ENOMSG ENOPROTOOPT ENOSR ENOSTR ETIME
ENOTRECOVERABLE EOWNERDEAD EBADMSG EPROTONOSUPPORT EPROTOTYPE EIDRM

  These are network or STREAMS related errors which I have never in
  my own Unix programming found the need to do anything with.  I think
  someone who understands these better should be the one to try to
  find good Rust names and descriptions for them.

ENOTTY ENXIO ENODEV EOPNOTSUPP ESRCH EALREADY ECANCELED ECHILD
EINPROGRESS

  These are very hard to get unless you're already doing something
  very Unix-specific, in which case the raw_os_error interface is
  probably more suitable than relying on the Rust ErrorKind mapping.

EFAULT EBADF

  These would seem to be the result of application UB.
```
</strike>
<i>(omitted errnos are discussed below, especially in https://github.com/rust-lang/rust/pull/79965#issuecomment-810468334)
2021-07-03 04:12:36 +00:00
bors
cd48e61c5d Auto merge of #86795 - JohnTitor:fix-bind, r=jackh726
Fix const-generics ICE related to binding

Fixes #83765, fixes #85848
r? `@jackh726` as you're familiar with `Binding`. I'd like to get some views if the current approach is right path.
2021-07-03 01:42:06 +00:00
Guillaume Gomez
d6962ffb31 Only run error code explanation removal check if on CI 2021-07-03 01:01:13 +02:00
Gary Guo
ec7292ad3c core: add unstable no_fp_fmt_parse to disable float fmt/parse code
In some projects (e.g. kernel), floating point is forbidden. They can disable
hardware floating point support and use `+soft-float` to avoid fp instructions
from being generated, but as libcore contains the formatting code for `f32`
and `f64`, some fp intrinsics are depended. One could define stubs for these
intrinsics that just panic [1], but it means that if any formatting functions
are accidentally used, mistake can only be caught during the runtime rather
than during compile-time or link-time, and they consume a lot of space without
LTO.

This patch provides an unstable cfg `no_fp_fmt_parse` to disable these.
A panicking stub is still provided for the `Debug` implementation (unfortunately)
because there are some SIMD types that use `#[derive(Debug)]`.

[1]: https://lkml.org/lkml/2021/4/14/1028
2021-07-02 22:52:37 +01:00
Eric Huss
7cf9825e87 Update cargo 2021-07-02 14:23:30 -07:00
Taylor Yu
c58ceb7a42 stdio_locked: updates based on feedback
Rename methods to `into_locked`. Remove type aliases for owned locks.
2021-07-02 15:56:56 -05:00
Smitty
e9d69d9f8e Allocation failure in constprop panics right away 2021-07-02 16:06:12 -04:00
bors
798baebde1 Auto merge of #86817 - JohnTitor:rollup-rcysc95, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #84029 (add `track_path::path` fn for usage in `proc_macro`s)
 - #85001 (Merge `sys_common::bytestring` back into `os_str_bytes`)
 - #86308 (Docs: clarify that certain intrinsics are not unsafe)
 - #86796 (Add a regression test for issue-70703)
 - #86803 (Remove & from Command::args calls in documentation)
 - #86807 (Fix double import in wasm thread )
 - #86813 (Add a help message to `unused_doc_comments` lint)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-07-02 20:00:51 +00:00
Yuki Okushi
1b136323dc
Rollup merge of #86813 - JohnTitor:unused-doc-comments-help, r=jackh726
Add a help message to `unused_doc_comments` lint

Fixes #83492
This adds a help message to suggest a plain comment like the E0658 error. I've yet to come up with the best message about the doc attribute but the current shouldn't harm anything.
I was thinking of recovering in the `doc_comment_between_if_else` case, but I came to the conclusion that it unlikely happened and was an overkill.
2021-07-03 03:15:14 +09:00
Yuki Okushi
df55204afb
Rollup merge of #86807 - tversteeg:patch-1, r=bjorn3
Fix double import in wasm thread

The `unsupported` type is imported two times, as `super::unsupported` and as `crate::sys::unsupported`, throwing an error. Remove `super::unsupported` in favor of the other.

As reported in #86802.

Fix #86802
2021-07-03 03:15:13 +09:00
Yuki Okushi
6107340483
Rollup merge of #86803 - xfix:remove-unnecessary-ampersand-from-command-args-calls, r=joshtriplett
Remove & from Command::args calls in documentation

Now that arrays implement `IntoIterator`, using `&` is no longer necessary. This makes examples easier to understand.
2021-07-03 03:15:12 +09:00
Yuki Okushi
f6ef2c8cbe
Rollup merge of #86796 - JohnTitor:test-70703, r=jonas-schievink
Add a regression test for issue-70703

Closes #70703
2021-07-03 03:15:11 +09:00