Commit graph

6377 commits

Author SHA1 Message Date
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
7fb3c29dc6
Rollup merge of #86308 - bstrie:intrinsafe, r=JohnTitor
Docs: clarify that certain intrinsics are not unsafe

As determined by the hardcoded list at 003b8eadd7/compiler/rustc_typeck/src/check/intrinsic.rs (L59-L92)
2021-07-03 03:15:10 +09:00
Yuki Okushi
45470a3bcd
Rollup merge of #84029 - drahnr:master, r=petrochenkov
add `track_path::path` fn for usage in `proc_macro`s

Adds a way to declare a dependency on external files without including them, to either re-trigger the build of a file as well as covering the use case of including dependencies within the `rustc` invocation, such that tools like `sccache`/`cachepot` are able to handle references to external files which are not included.

Ref #73921
2021-07-03 03:15:07 +09:00
Yuki Okushi
086eb4764a
Add a help message to unused_doc_comments lint 2021-07-03 01:00:08 +09:00
Guillaume Gomez
c02c26e393
Rollup merge of #86776 - tmiasko:v0-skip-layout-query, r=petrochenkov
Skip layout query when computing integer type size during mangling
2021-07-02 11:35:30 +02:00
bors
1aa6c7cbc6 Auto merge of #80182 - in42:stack_trace, r=tmandry
Implement printing of stack traces on LLVM segfaults and aborts

Implement #79153

Based on discussion, try to extend the rust_backtrace=1 feature to handle segfault or aborts in the llvm backend
2021-07-02 05:40:51 +00:00
Bernhard Schuster
67e6a81315 add track_path::path fn for proc-macro usage
Ref #73921
2021-07-02 07:13:19 +02:00
Tyler Mandry
162ed4d7da Use signal handler only on supported platforms 2021-07-02 01:23:25 +00:00
bors
7a9ff746fe Auto merge of #86777 - tmiasko:estimate-terminators, r=estebank
Include terminators in instance size estimate

For example, drop glue generated for struct below, doesn't have any
statements, only terminators. Previously it received an estimate of 0,
the new estimate is 13 (6+5 drop terminators, +1 resume, +1 return).

```rust
struct S {
    a: String,
    b: String,
    c: String,
    d: String,
    e: String,
    f: String,
}
```

Originally reported in https://github.com/rust-lang/rust/issues/69382#issue-569392141
2021-07-02 00:15:58 +00:00
bors
56dee7c49e Auto merge of #86791 - JohnTitor:rollup-96ltzpz, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #86148 (Check the number of generic lifetime and const parameters of intrinsics)
 - #86659 (fix(rustdoc): generics search)
 - #86768 (Add myself to mailmap)
 - #86775 (Test for const trait impls behind feature gates)
 - #86779 (Allow anyone to add or remove any label starting with perf-)
 - #86783 (Move Mutex::unlock to T: ?Sized)
 - #86785 (proc_macro/bridge: Remove dead code Slice type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-07-01 21:45:19 +00:00
Yuki Okushi
ab4d16fe7a
Rollup merge of #86148 - FabianWolff:issue-85855, r=varkor
Check the number of generic lifetime and const parameters of intrinsics

This pull request fixes #85855. The current code for type checking intrinsics only checks the number of generic _type_ parameters, but does not check for an incorrect number of lifetime or const parameters, which can cause problems later on, such as the ICE in #85855, where the code thought that it was looking at a type parameter but found a lifetime parameter:
```
error: internal compiler error: compiler/rustc_middle/src/ty/generics.rs:188:18:
    expected type parameter, but found another generic parameter
```

The changes in this PR add checks for the number of lifetime and const parameters, expand the scope of `E0094` to also apply to these cases, and improve the error message by properly pluralizing the number of expected generic parameters.
2021-07-02 06:20:28 +09:00
bors
7100b311df Auto merge of #86749 - bjorn3:link_info_refactor_part1, r=petrochenkov
Rename all_crate_nums query to crates and remove useless wrapper

Split out of https://github.com/rust-lang/rust/pull/86105

r? `@petrochenkov`
2021-07-01 19:00:08 +00:00
bors
ecef52abeb Auto merge of #86304 - klensy:hex-length, r=jackh726
rustc_mir: calc hex number length without string allocation
2021-07-01 16:16:12 +00:00
Fabian Wolff
fe93349109 Minor adjustments and refactoring 2021-07-01 17:48:19 +02:00
klensy
2b57fc40d8 rustc_mir: calc hex number length without string allocation 2021-07-01 18:01:37 +03:00
bjorn3
c7d2099de0 Rename all_crate_nums query to crates and remove useless wrapper 2021-07-01 16:51:11 +02:00
Tomasz Miąsko
56219870ee Include terminators in instance size estimate
For example, drop glue generated for struct below, doesn't have any
statements, only terminators. Previously it received an estimate of 0,
the new estimate is 13 (6+5 drop terminators, +1 resume, +1 return).

struct S {
    a: String,
    b: String,
    c: String,
    d: String,
    e: String,
    f: String,
}

Originally reported in https://github.com/rust-lang/rust/issues/69382#issue-569392141
2021-07-01 13:31:57 +02:00
Tomasz Miąsko
c99f1b9b7e Skip layout query when computing integer type size during mangling 2021-07-01 12:36:44 +02:00
bors
3cb1c11340 Auto merge of #86774 - GuillaumeGomez:rollup-rkcgvph, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #86558 (Add suggestions for "undefined reference" link errors)
 - #86616 (rustc_span: Explicitly handle crates that differ from package names)
 - #86652 (Add support for leaf function frame pointer elimination)
 - #86666 (Fix misleading "impl Trait" error)
 - #86762 (mailmap: Add my work email address)
 - #86773 (Enable the tests developed with #86594)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-07-01 09:20:38 +00:00
Guillaume Gomez
7e27209ff8
Rollup merge of #86666 - ptrojahn:compare_kinds, r=petrochenkov
Fix misleading "impl Trait" error

The kinds can't be compared directly, as types with references are treated as different because the lifetimes aren't bound in ty, but are in expected.
Closes #84160
2021-07-01 11:15:42 +02:00
Guillaume Gomez
dfd30d7b70
Rollup merge of #86652 - nagisa:nagisa/non-leaf-fp, r=petrochenkov
Add support for leaf function frame pointer elimination

This PR adds ability for the target specifications to specify frame
pointer emission type that's not just “always” or “whatever cg decides”.

In particular there's a new mode that allows omission of the frame
pointer for leaf functions (those that don't call any other functions).

We then set this new mode for Aarch64-based Apple targets.

Fixes #86196
2021-07-01 11:15:41 +02:00
Guillaume Gomez
052e8d5933
Rollup merge of #86616 - joshtriplett:simplify-crate-package-discrepancies, r=varkor
rustc_span: Explicitly handle crates that differ from package names

The sha-1 and md-5 packages contain crates named sha1 and md5,
respectively. This discrepancy makes it somewhat more challenging to
automate detection of unused crates. Explicitly rename the packages to
the names of the crates they contain, to simplify such detection.
2021-07-01 11:15:40 +02:00
Guillaume Gomez
75f2263cf7
Rollup merge of #86558 - Smittyvb:link-error-sugg, r=petrochenkov
Add suggestions for "undefined reference" link errors

This adds a suggestion for "undefined reference to ..." linking errors to install or specify the location to an external library. Since there is no defined error format for linkers, we just check if there was a failure and if that failure contains the string `undefined reference to`. This also makes it impossible to test this, since the output depends on the system linker. The output now looks like:
```
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "linking_failure.linking_failure.7rcbfp3g-cgu.0.rcgu.o" "linking_failure.linking_failure.7rcbfp3g-cgu.1.rcgu.o" "linking_failure.linking_failure.7rcbfp3g-cgu.2.rcgu.o" "linking_failure.linking_failure.7rcbfp3g-cgu.3.rcgu.o" "linking_failure.linking_failure.7rcbfp3g-cgu.4.rcgu.o" "linking_failure.linking_failure.7rcbfp3g-cgu.5.rcgu.o" "linking_failure.linking_failure.7rcbfp3g-cgu.6.rcgu.o" "linking_failure.linking_failure.7rcbfp3g-cgu.7.rcgu.o" "linking_failure.linking_failure.7rcbfp3g-cgu.8.rcgu.o" "linking_failure.53u64zklswtfazes.rcgu.o" "-Wl,--as-needed" "-L" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-01ce3ba5c629d02f.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-f1f2102409186354.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-1e8b6b56a999f838.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-d0e93eb4e14f1d19.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-1d7e39d75d082b43.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-ade42e945045b261.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-1a65064fccf4ebc1.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-4d699c310fdfe72d.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-1cafa68a696ec800.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-e9f1c8c4dab2f046.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-ecc1a743be25c7f7.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-e074031c4b66b6b6.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-9aa6ed9f1d3bfd53.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-7862bf96c2250ca0.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-f02ce0dc7895b5fd.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-3af9c60917570521.rlib" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-ca16fc7bb3645684.rlib" "-Wl,--end-group" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d8e1a5b7299604cc.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/smit/rustc-dev/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "linking_failure" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld: linking_failure.linking_failure.7rcbfp3g-cgu.3.rcgu.o: in function `linking_failure::main':
          linking_failure.7rcbfp3g-cgu.3:(.text._ZN15linking_failure4main17h52b6e3052e444479E+0x3): undefined reference to `doesnt_exist_thiwthwfyl'
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

  = help: some `extern` functions couldn't be found; you may need to install or specify the path to some dependencies
  = note: use the -L flag to specify the library lookup path
  = note: use the cargo:rustc-link-search directive to specify the library lookup path with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-search)

error: aborting due to previous error
```
2021-07-01 11:15:39 +02:00
bors
f8ac8fdacf Auto merge of #86190 - asquared31415:extern-main-86110-fix, r=varkor
Fix ICE when `main` is declared in an `extern` block

Changes in #84401 to implement `imported_main` changed how the crate entry point is found, and a declared `main` in an `extern` block was detected erroneously.  This was causing the ICE described in #86110.

This PR adds a check for this case and emits an error instead.  Previously a `main` declaration in an `extern` block was not detected as an entry point at all, so emitting an error shouldn't break anything that worked previously.  In 1.52.1 stable this is demonstrated, with a `` `main` function not found`` error.

Fixes #86110
2021-07-01 06:39:37 +00:00
bors
1034282bca Auto merge of #86617 - joshtriplett:prune-dependencies, r=Mark-Simulacrum
Remove unused dependencies from compiler crates

Various compiler crates have dependencies that they don't appear to use. I used some scripting to detect such dependencies, filtered them based on some manual review, and removed those that do indeed appear to be entirely unused.
2021-07-01 03:49:47 +00:00
bors
866335b337 Auto merge of #86757 - JohnTitor:rollup-acevhz7, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #85504 (the foundation owns rust trademarks)
 - #85520 (Fix typo and improve documentation for E0632)
 - #86680 (Improve error for missing -Z with debugging option)
 - #86728 (Check node kind to avoid ICE in `check_expr_return()`)
 - #86740 (copy rust-lld as ld in dist)
 - #86746 (Fix rustdoc query type filter)
 - #86750 (Test cross-crate usage of `feature(const_trait_impl)`)
 - #86755 (alloc: `RawVec<T, A>::shrink` can be in `no_global_oom_handling`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-07-01 01:08:46 +00:00
Smitty
ce63d55bc7 Add suggestions for "undefined reference" link errors 2021-06-30 18:07:40 -04:00
Yuki Okushi
7714a9a0e3
Rollup merge of #86750 - fee1-dead:impl-const-test, r=jonas-schievink
Test cross-crate usage of `feature(const_trait_impl)`

This PR does two things:

 - Fixes metadata not encoded properly for functions in const trait impls.
 - Adds tests for using const trait impls cross-crate with the feature gate on the user crate either enabled or disabled.

AFAIK, this means we can now constify some trait impls in the standard library 🎉

See #67792 for the tracking issue, cc `@oli-obk`
2021-07-01 05:21:02 +09:00
Yuki Okushi
dfe05c0ea0
Rollup merge of #86728 - FabianWolff:issue-86721, r=LeSeulArtichaut
Check node kind to avoid ICE in `check_expr_return()`

This PR fixes #86721. The ICE described there is apparently due to a misunderstanding:
e98897e5dc/compiler/rustc_typeck/src/check/expr.rs (L684-L685)

Intuitively, one would think that calling `expect_item()` after `get_parent_item()` should succeed, but as it turns out, `get_parent_item()` can also return foreign, trait, and impl items as well as crates, whereas `expect_item()` specifically expects a `Node::Item`. I have therefore added an extra check to prevent this ICE.
2021-07-01 05:20:58 +09:00
Yuki Okushi
56ddef8ab8
Rollup merge of #86680 - camsteffen:dbg-opt-error, r=petrochenkov
Improve error for missing -Z with debugging option

Before:
```text
❯ rustc --unpretty=hir
error: Unrecognized option: 'unpretty'
```
After:
```text
❯ rustc --unpretty=hir
error: Unrecognized option: 'unpretty'. Did you mean `-Z unpretty`?
```
2021-07-01 05:20:57 +09:00
Yuki Okushi
1823b3f2b3
Rollup merge of #85520 - FabianWolff:issue-85475, r=jackh726
Fix typo and improve documentation for E0632

Edit: After https://github.com/rust-lang/rust/pull/85520#issuecomment-870095546, this PR has been boiled down to just an extended description for `E0632` and a fixed typo.
2021-07-01 05:20:55 +09:00
Camille GILLOT
f69877426a Update comments. 2021-06-30 20:56:49 +02:00
Camille GILLOT
aa1bc5874e Fix AST pretty. 2021-06-30 20:53:10 +02:00
Camille GILLOT
2f28737ebe Move AST crate. 2021-06-30 20:53:10 +02:00
Camille GILLOT
c520cf2253 Arena-allocate Crate during lowering. 2021-06-30 20:31:56 +02:00
Camille GILLOT
e05cd155fe Move lowering to create_global_ctxt. 2021-06-30 20:31:55 +02:00
Camille GILLOT
b80f720a2a Inline lower_to_hir. 2021-06-30 20:31:54 +02:00
Camille GILLOT
18c10fb1a6 Separate resolver creation from expansion. 2021-06-30 20:31:53 +02:00
Camille GILLOT
5f98e5ee56 Simplify DepGraph creation. 2021-06-30 20:31:52 +02:00
Cameron Steffen
2a60f090b9 Add suggestion for missing compile flag group 2021-06-30 13:28:15 -05:00
Simonas Kazlauskas
9b67cba4f6 Add support for leaf fn frame pointer elimination
This PR adds ability for the target specifications to specify frame
pointer emission type that's not just “always” or “whatever cg decides”.

In particular there's a new mode that allows omission of the frame
pointer for leaf functions (those that don't call any other functions).

We then set this new mode for Aarch64-based Apple targets.

Fixes #86196
2021-06-30 19:45:17 +03:00
Fabian Wolff
0c267830d5 Match on hir::TraitFn::Provided instead of using maybe_body_owned_by 2021-06-30 18:27:07 +02:00
Deadbeef
3b9453bfe2
use is_const_fn_raw when encoding constness
this properly encodes cross-crate constness data.
2021-06-30 23:56:43 +08:00
bors
868c702d0c Auto merge of #86695 - sexxi-goose:closure_size, r=nikomatsakis
Introduce -Zprofile-closures to evaluate the impact of 2229

This creates a CSV with name "closure_profile_XXXXX.csv", where the
variable part is the process id of the compiler.

To profile a cargo project you can run one of the following depending on
if you're compiling a library or a binary:

```
cargo +nightly rustc --lib -- -Zprofile-closures
cargo +nightly rustc --bin {binary_name} -- -Zprofile-closures
```

r? `@nikomatsakis`
2021-06-30 13:42:50 +00:00
Fabian Wolff
11fd8579e4 Emit explanatory note for functions in trait and impl items as well 2021-06-30 13:56:26 +02:00
bors
51fd129ac1 Auto merge of #86689 - rylev:future-compat-lint-group, r=nikomatsakis
Only include lint in future_incompatible lint group if not an edition lint

A follow up to #86330 - this only includes lints annotated with `FutureIncompatibleInfo` in the `future_incompatibile` lint group if the future compatibility is not tied to an edition.

We probably want to rename `FutureIncompatibleInfo` to something else since this type is now used to indicate future breakages of all kinds (even those that happen in editions). I'd prefer to do that in a separate PR though.

r? `@nikomatsakis`
2021-06-30 05:02:01 +00:00
Fabian Wolff
2586e962e0 Check node kind to avoid ICE in check_expr_return() 2021-06-29 22:20:06 +02:00
bors
6e0b554619 Auto merge of #86603 - Mark-Simulacrum:stage-step, r=pietroalbini
Update to new bootstrap compiler

r? `@pietroalbini`
2021-06-29 18:33:13 +00:00
bors
e98897e5dc Auto merge of #86475 - crlf0710:miri_vtable_refactor, r=bjorn3
Change vtable memory representation to use tcx allocated allocations.

This fixes https://github.com/rust-lang/rust/issues/86324. However i suspect there's more to change before it can land.

r? `@bjorn3`
cc `@rust-lang/miri`
2021-06-29 15:52:21 +00:00
bors
8971fff984 Auto merge of #86009 - cjgillot:fwarn, r=davidtwco
Make ForceWarn a lint level.

Follow-up to #85788
cc `@rylev`
2021-06-29 13:11:16 +00:00