Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #88774

Closed
wants to merge 31 commits into from

Conversation

GuillaumeGomez
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

Sasha Pourcelot and others added 30 commits August 31, 2021 23:24
This commit focuses on emitting clean errors for the following syntax
error:

```
Some(42).map(|a|
    dbg!(a);
    a
);
```

Previous implementation tried to recover after parsing the closure body
(the `dbg` expression) by replacing the next `;` with a `,`, which made
the next expression belong to the next function argument. As such, the
following errors were emitted (among others):
  - the semicolon token was not expected,
  - a is not in scope,
  - Option::map is supposed to take one argument, not two.

This commit allows us to gracefully handle this situation by adding
giving the parser the ability to remember when it has just parsed a
closure body inside a function call. When this happens, we can treat the
unexpected `;` specifically and try to parse as much statements as
possible in order to eat the whole block. When we can't parse statements
anymore, we generate a clean error indicating that the braces are
missing, and return an ExprKind::Err.
It was accidentally changed to use `opts()` in rust-lang#86451.

I also renamed `opts()` to `main_body_opts()` to make this kind of
accidental change less likely.
This fixes odd renderings when these features are used in the first
paragraph of documentation for an item. This is an extension of rust-lang#87270.
this also renders them as `_`, which rustdoc previously did not.
Note that this incorrectly suggests a shared borrow,
but at least we know it's happening.
These were deleted in https://reviews.llvm.org/D108614, and in C++ I
definitely see the argument for their removal. I didn't try and
propagate the changes up into higher layers of rustc in this change
because my initial goal was to get rustc working against LLVM HEAD
promptly, but I'm happy to follow up with some refactoring to make the
API on the Rust side match the LLVM API more directly (though the way
the enum works in Rust makes the API less scary IMO).

r? @nagisa cc @nikic
Otherwise we're kind of reimplementing the inverse of the well-named
methods, and that's not a direction we want to go.
Turns out we can also use Attribute::get*() methods here, and avoid the
AttrBuilder and an extra helper method here.
This usually describes either an error in the compiler itself or some
sort of IO error. Either way, we should report it to the user rather
than just saying "crate not found".

This only gives an error if the crate couldn't be loaded at all - if the
compiler finds another .rlib or .rmeta file which was valid, it will
continue to compile the crate.

Example output:
```
error[E0785]: found invalid metadata files for crate `foo`
 --> bar.rs:3:24
  |
3 |         println!("{}", foo::FOO_11_49[0]);
  |                        ^^^
  |
  = warning: failed to parse rlib '/home/joshua/test-rustdoc/libfoo.rlib': Invalid archive extended name offset
```
 Improve error when an .rlib can't be parsed

This usually describes either an error in the compiler itself or some
sort of IO error. Either way, we should report it to the user rather
than just saying "crate not found".

This only gives an error if the crate couldn't be loaded at all - if the
compiler finds another .rlib or .rmeta file which was valid, it will
continue to compile the crate.

Example output:
```
error[E0785]: found invalid metadata files for crate `foo`
 --> bar.rs:3:24
  |
3 |         println!("{}", foo::FOO_11_49[0]);
  |                        ^^^
  |
  = warning: failed to parse rlib '/home/joshua/test-rustdoc/libfoo.rlib': Invalid archive extended name offset
```

cc `@ehuss`
…races, r=estebank

Emit proper errors when on missing closure braces

This commit focuses on emitting clean errors for the following syntax
error:

```
Some(42).map(|a|
    dbg!(a);
    a
);
```

Previous implementation tried to recover after parsing the closure body
(the `dbg` expression) by replacing the next `;` with a `,`, which made
the next expression belong to the next function argument. As such, the
following errors were emitted (among others):
  - the semicolon token was not expected,
  - a is not in scope,
  - Option::map is supposed to take one argument, not two.

This commit allows us to gracefully handle this situation by adding
giving the parser the ability to remember when it has just parsed a
closure body inside a function call. When this happens, we can treat the
unexpected `;` specifically and try to parse as much statements as
possible in order to eat the whole block. When we can't parse statements
anymore, we generate a clean error indicating that the braces are
missing, and return an ExprKind::Err.

Closes rust-lang#88065.

r? `@estebank`
…erence-to-for-loop-iter, r=nagisa

fix(rustc): suggest `items` be borrowed in `for i in items[x..]`

Fixes rust-lang#87994
Fix issues with Markdown summary options

- Use `summary_opts()` for Markdown summaries
- Enable all main body Markdown options for summaries
…aumeGomez

rustdoc: Fix ICE with `doc(hidden)` on tuple variant fields

Fixes rust-lang#88600.

```rust
pub struct H;
pub struct S;

pub enum FooEnum {
    HiddenTupleItem(#[doc(hidden)] H),
    MultipleHidden(#[doc(hidden)] H, #[doc(hidden)] H),
    MixedHiddenFirst(#[doc(hidden)] H, S),
    MixedHiddenLast(S, #[doc(hidden)] H),
    HiddenStruct {
        #[doc(hidden)]
        h: H,
        s: S,
    },
}
```

Generates
![image](https://user-images.githubusercontent.com/1502855/132259152-382f9517-c2a0-41d8-acd0-64e5993931fc.png)
RustWrapper: avoid deleted unclear attribute methods

These were deleted in https://reviews.llvm.org/D108614, and in C++ I
definitely see the argument for their removal. I didn't try and
propagate the changes up into higher layers of rustc in this change
because my initial goal was to get rustc working against LLVM HEAD
promptly, but I'm happy to follow up with some refactoring to make the
API on the Rust side match the LLVM API more directly (though the way
the enum works in Rust makes the API less scary IMO).

r? `@nagisa` cc `@nikic`
… r=GuillaumeGomez

Allow missing code examples in trait impls.

Excludes Trait implementations from the items that need to have doc code examples when using the `rustdoc::missing_doc_code_examples` lint.

For details see rust-lang#88741

fixes rust-lang#88741

r? `@jyn514`
@rustbot rustbot added the rollup A PR which is a rollup label Sep 9, 2021
@GuillaumeGomez
Copy link
Member Author

@bors: r+ p=7 rollup=never

@bors
Copy link
Contributor

bors commented Sep 9, 2021

📌 Commit 26a98a7 has been approved by GuillaumeGomez

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 9, 2021
@bors
Copy link
Contributor

bors commented Sep 9, 2021

⌛ Testing commit 26a98a7 with merge 9dde3d1a820fe0ee4658ceeef81cbea90b6d95da...

@Emilgardis
Copy link
Contributor

Doesnt #88546 contain a merge commit?

@rust-log-analyzer
Copy link
Collaborator

The job test-various failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [ui] ui/expr-if-unique.rs ... ok
test [ui] ui/ext-nonexistent.rs ... ok
test [ui] ui/extenv/extenv-arg-2-not-string-literal.rs ... ok
test [ui] ui/extenv/extenv-not-defined-default.rs ... ok
test [ui] ui/expr/malformed_closure/ruby_style_closure.rs ... ok
test [ui] ui/extern-flag/empty-extern-arg.rs ... ok
test [ui] ui/extenv/extenv-not-defined-custom.rs ... ok
test [ui] ui/expr/if/expr-if-panic-pass.rs ... ok
test [ui] ui/extenv/extenv-too-many-args.rs ... ok
test [ui] ui/extenv/extenv-too-many-args.rs ... ok
test [ui] ui/expr/if/attrs/gate-whole-expr.rs ... ok
test [ui] ui/extenv/extenv-not-string-literal.rs ... ok
test [ui] ui/extern/extern-const.rs ... ignored
test [ui] ui/expr/malformed_closure/missing_braces_around_block.rs ... ok
test [ui] ui/expr/if/if-ret.rs ... ok
test [ui] ui/expr/if/if-check.rs ... ok
test [ui] ui/extern/extern-ffi-fn-with-body.rs ... ok
test [ui] ui/expr/compound-assignment/eval-order.rs ... ok
---
test [ui] ui/wrong-hashset-issue-42918.rs ... ok

failures:

---- [ui] ui/crate-loading/invalid-so.rs stdout ----


- error[E0786]: found invalid metadata files for crate `bar`
+ error[E0463]: can't find crate for `bar`
2   --> $DIR/invalid-so.rs:3:7
3    |
4 LL | use ::bar;
-    |       ^^^
+    |       ^^^ can't find crate
6    |
6    |
-    = note: invalid metadata version found: $DIR/auxiliary/libbar.so
+    = note: extern location for bar is of an unknown type: $DIR/auxiliary/libbar.so
+    = help: file name should be lib*.rlib or *..wasm
9 error: aborting due to previous error
10 

- For more information about this error, try `rustc --explain E0786`.
- For more information about this error, try `rustc --explain E0786`.
+ For more information about this error, try `rustc --explain E0463`.
12 


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/crate-loading/invalid-so/invalid-so.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args crate-loading/invalid-so.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/crate-loading/invalid-so.rs" "-Zthreads=1" "--target=wasm32-unknown-unknown" "--error-format" "json" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "--emit" "metadata" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/crate-loading/invalid-so" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/wasm32-unknown-unknown/native/rust-test-helpers" "--crate-type" "lib" "--extern" "bar=/checkout/src/test/ui/crate-loading/auxiliary/libbar.so" "--edition=2018" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/crate-loading/invalid-so/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
error[E0463]: can't find crate for `bar`
  --> /checkout/src/test/ui/crate-loading/invalid-so.rs:3:7
   |
LL | use ::bar; //~ ERROR invalid metadata files for crate `bar`
   |
   |
   = note: extern location for bar is of an unknown type: /checkout/src/test/ui/crate-loading/auxiliary/libbar.so
   = help: file name should be lib*.rlib or *..wasm
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

---

Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=wasm32-unknown-unknown


command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/wasm32-unknown-unknown/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-wasm32-unknown-unknown" "--suite" "ui" "--mode" "ui" "--target" "wasm32-unknown-unknown" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--nodejs" "/node-v15.14.0-linux-x64/bin/node" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0  -Lnative=/checkout/obj/build/wasm32-unknown-unknown/native/rust-test-helpers" "--docck-python" "/usr/bin/python3" "--lldb-python" "/usr/bin/python3" "--gdb" "/usr/bin/gdb" "--llvm-version" "13.0.0-rust-1.57.0-nightly" "--llvm-components" "aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo cfguard codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfogsym debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker dwp engine executionengine extensions filecheck frontendopenacc frontendopenmp fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interfacestub interpreter ipo irreader jitlink libdriver lineeditor linker lto mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcjit orcshared orctargetprocess passes powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo runtimedyld scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target textapi transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo webassemblyutils windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info xray" "--cc" "" "--cxx" "" "--cflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--channel" "nightly" "--color" "always"


Build completed unsuccessfully in 0:16:37

@GuillaumeGomez
Copy link
Member Author

Well, it failed CI so that resolves the problem. :)

@GuillaumeGomez
Copy link
Member Author

@bors: r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 9, 2021
@scrabsha
Copy link
Contributor

scrabsha commented Sep 9, 2021

Doesnt #88546 contain a merge commit?

Yes, sorry for that. I'll rebase and squash my work as soon as possible

@GuillaumeGomez
Copy link
Member Author

@scrabsha Thanks!

@jyn514
Copy link
Member

jyn514 commented Sep 10, 2021

It's strange that this failed test-various when it succeeded on x86_64-gnu-llvm-10 ... maybe it's related to cross-compiling somehow?

@jyn514
Copy link
Member

jyn514 commented Sep 12, 2021

  • = note: extern location for bar is of an unknown type: $DIR/auxiliary/libbar.so
  • = help: file name should be lib*.rlib or *..wasm

Oh, this is the issue - apparently the wasm target doesn't recognize .so files.

@GuillaumeGomez GuillaumeGomez deleted the rollup-qbape3k branch September 12, 2021 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.