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 13 pull requests #73876

Closed
wants to merge 33 commits into from

Conversation

Manishearth
Copy link
Member

Successful merges:

Failed merges:

r? @ghost

Keno and others added 30 commits June 23, 2020 22:42
I know very little about rust, so I saw this example and tried to generalize it by writing,
```
    let layout = Layout::new::<T>();
    let new_obj = unsafe {
        let ptr = alloc(layout) as *mut T;
        *ptr = obj;
        Box::from_raw(ptr)
    };
```
for some more complicated `T`, which ended up crashing with SIGSEGV,
because it tried to `drop_in_place` the previous object in `ptr` which is
of course garbage. I also added a comment that explains why `.write`
is used, but I think adding that comment is optional and may be too verbose
here. I do however think that changing this example is a good idea to
suggest the correct generalization. `.write` is also used in most of the rest
of the documentation here, even if the example is `i32`, so it would additionally
be more consistent.
This commit applies the existing 'extra angle bracket recovery' logic
when parsing fields in struct definitions. This allows us to continue
parsing the struct's fields, avoiding spurious 'missing field' errors in
code that tries to use the struct.
Fixes rust-lang#67765

When reporting errors during MIR region inference, we sometimes use
`universal_upper_bound` to obtain a named universal region that we
can display to the user. However, this is not always possible - in a
case like `fn foo<'a, 'b>() { .. }`, the only upper bound for a region
containing `'a` and `'b` is `'static`. When displaying diagnostics, it's
usually better to display *some* named region (even if there are
multiple involved) rather than fall back to a generic error involving
`'static`.

This commit adds a new `approx_universal_upper_bound` method, which
uses the lowest-numbered universal region if the only alternative is to
return `'static`.
linker: Create GNU_EH_FRAME header by default when producing ELFs

Do it in a centralized way in `link.rs` instead of individual target specs.

The opt-out is `-Clink-arg=(-Wl,)--no-eh-frame-hdr` if necessary.

Fixes rust-lang#73451
cc rust-lang#73483
Update Box::from_raw example to generalize better

I know very little about rust, so I saw the example here
```
use std::alloc::{alloc, Layout};

unsafe {
    let ptr = alloc(Layout::new::<i32>()) as *mut i32;
    *ptr = 5;
    let x = Box::from_raw(ptr);
}
```
and tried to generalize it by writing,
```
    let layout = Layout::new::<T>();
    let new_obj = unsafe {
        let ptr = alloc(layout) as *mut T;
        *ptr = obj;
        Box::from_raw(ptr)
    };
```
for some more complicated `T`, which ended up crashing with SIGSEGV,
because it tried to `drop_in_place` the previous object in `ptr` which is
of course garbage. I think that changing this example to use `.write` instead
would be a good idea to suggest the correct generalization. It is also more
consistent with other documentation items in this file, which use `.write`.
I also added a comment to explain it, but I'm not too attached to that,
and can see it being too verbose in this place.
stop taking references in Relate

Adds a `Copy` bound to `Relate` and changes the type signatures to `T` from `&T`. While the `Copy` bound is not strictly necessary (i.e. the `Clone` bound of `TypeRelation` would be good enough), we don't need non `Copy` types and it simplifies the implementation.

Removes the afaict unused impls for `Vec<ty::PolyExistentialProjection<'tcx>>`, `Rc<T>` and `Box<T>`. If they end up being relevant again the bound of `Relate` can be reduced to `T: Clone`.

This also changes signature of `Binder::skip_binder` to `fn skip_binder(self) -> T`.

`TypeError::ProjectionBoundsLength` was never used and is also removed in this PR.

r? @nikomatsakis maybe 🤔 feel free to reassign
…sKalbertodt

Document the static keyword

Partial fix of rust-lang#34601.

This documents the `static` keyword. It's basically a simplified version of the reference with more examples.

@rustbot modify labels: T-doc,C-enhancement
…LukasKalbertodt

Remap Windows ERROR_INVALID_PARAMETER to ErrorKind::InvalidInput from Other

I don't know if this is acceptable or how likely it is to break existing code, but it seem to me ERROR_INVALID_PARAMETER "The parameter is incorrect" should map to ErrorKind::InvalidInput "A parameter was incorrect". Previously this value fell through to ErrorKind::Other.

I can't speak for anyone but myself, but I instinctively thought it would be InvalidInput.
…ery, r=matthewjasper

Recover extra trailing angle brackets in struct definition

This commit applies the existing 'extra angle bracket recovery' logic
when parsing fields in struct definitions. This allows us to continue
parsing the struct's fields, avoiding spurious 'missing field' errors in
code that tries to use the struct.
Document the type keyword

Partial fix of rust-lang#34601.

Two small examples, one clarifying that `type` only defines an alias, not a completely new type, the other explaining the use in traits.

@rustbot modify labels: T-doc,C-enhancement
…upper, r=estebank

Use an 'approximate' universal upper bound when reporting region errors

Fixes rust-lang#67765

When reporting errors during MIR region inference, we sometimes use
`universal_upper_bound` to obtain a named universal region that we
can display to the user. However, this is not always possible - in a
case like `fn foo<'a, 'b>() { .. }`, the only upper bound for a region
containing `'a` and `'b` is `'static`. When displaying diagnostics, it's
usually better to display *some* named region (even if there are
multiple involved) rather than fall back to a generic error involving
`'static`.

This commit adds a new `approx_universal_upper_bound` method, which
uses the lowest-numbered universal region if the only alternative is to
return `'static`.
ast_pretty: Pass some token streams and trees by reference

Salvaged from an intermediate version of rust-lang#73345.
…bank

Fix wording for anonymous parameter name help

```
 --> exercises/functions/functions2.rs:8:15
  |
8 | fn call_me(num) {
  |               ^ expected one of `:`, `@`, or `|`
  |
  = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
help: if this is a `self` type, give it a parameter name
  |
8 | fn call_me(self: num) {
  |            ^^^^^^^^^
help: if this was a parameter name, give it a type
  |
8 | fn call_me(num: TypeName) {
  |            ^^^^^^^^^^^^^
help: if this is a type, explicitly ignore the parameter name
  |
8 | fn call_me(_: num) {
  |
```
This commit changes "if this was a parameter name" to "if this is a parameter name" to match the wording of similar errors.
…-morse

Some refactoring around intrinsic type checking

So... This PR went a bit overboard. I wanted to make the `rustc_peek` intrinsic safe (cc @ecstatic-morse ), and remembered a long-standing itch of mine. So I made that huge `&str` match for the intrinsic name a match on `Symbol`s (so basically `u32`s). This is unlikely to have a positive perf effect, even if it likely has better codegen (intrinsics are used rarely, mostly once in their wrapper), so it's mostly a consistency thing since other places actually match on the symbol name of the intrinsics.
…nishearth

Split and expand nonstandard-style lints unicode unit test.

RFC 2457 requested that the `nonstandard_style` series of linted be adjusted to cover the non_ascii_identifier case. However when i read the code of those implementations, it seems they're already supporting non_ascii_identifiers. But the exact rules is a little different than what's proposed in RFC 2457.

So I splitted and expanded the existing test case to try to exercise every branch in the code. I think it'll also be easier to examine the cases in these unit tests to see whether it's ok to just leave them as is, or some adjustments are needed.

r? @Manishearth
…Simulacrum

Remove defunct `-Z print-region-graph`
@Manishearth
Copy link
Member Author

@rustbot modify labels: +rollup
@bors r+ rollup=never p=5

@bors
Copy link
Contributor

bors commented Jun 29, 2020

📌 Commit 89bc5a4 has been approved by Manishearth

@rustbot rustbot added the rollup A PR which is a rollup label Jun 29, 2020
@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 Jun 29, 2020
@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
##[section]Starting: Linux mingw-check
##[section]Starting: Initialize job
Agent name: 'Hosted Agent'
Agent machine name: 'fv-az578'
Current agent version: '2.171.1'
##[group]Operating System
16.04.6
LTS
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-16.04
Version: 20200621.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200621.1/images/linux/Ubuntu1604-README.md
##[endgroup]
Agent running as: 'vsts'
Prepare build directory.
Set build variables.
Download all required tasks.
Download all required tasks.
Downloading task: Bash (3.171.1)
Checking job knob settings.
   Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY} 
   Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG} 
Start tracking orphan processes.
##[section]Finishing: Initialize job
##[section]Starting: Configure Job Name
==============================================================================
---
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /home/vsts/work/_temp/c15f487b-6082-4598-b754-269ca11d3ec5.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/73876/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
---
##[command]git remote add origin https://github.com/rust-lang/rust
##[command]git config gc.auto 0
##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
##[command]git config --get-all http.proxy
##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/73876/merge:refs/remotes/pull/73876/merge
---
 ---> a9ec21d337b3
Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
 ---> Using cache
 ---> 5ff2c13d8dba
Step 7/7 : ENV SCRIPT python3 ../x.py test src/tools/expand-yaml-anchors &&            python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu &&            python3 ../x.py build --stage 0 src/tools/build-manifest &&            python3 ../x.py test --stage 0 src/tools/compiletest &&            python3 ../x.py test src/tools/tidy &&            python3 ../x.py doc --stage 0 src/libstd &&            /scripts/validate-toolstate.sh
 ---> 6b931e755c7e
Successfully built 6b931e755c7e
Successfully tagged rust-ci:latest
Built container sha256:6b931e755c7ea1f69816640eb9df74fafd40a545d0e5aa8341d35009dabb0f3c
---
    Checking rustc_span v0.0.0 (/checkout/src/librustc_span)
    Checking rustc_errors v0.0.0 (/checkout/src/librustc_errors)
    Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature)
    Checking rustc_parse_format v0.0.0 (/checkout/src/librustc_parse_format)
    Checking tracing v0.1.15
    Checking rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
    Checking rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
    Checking rustc_session v0.0.0 (/checkout/src/librustc_session)
    Checking rustc_hir v0.0.0 (/checkout/src/librustc_hir)
    Checking chalk-solve v0.14.0
---
    Checking rustc_mir v0.0.0 (/checkout/src/librustc_mir)
error[E0053]: method `relate_with_variance` has an incompatible type for trait
  --> src/librustc_mir/transform/validate.rs:74:9
   |
74 | /         fn relate_with_variance<T: Relate<'tcx>>(
76 | |             _: ty::Variance,
77 | |             a: &T,
...  |
...  |
81 | |             self.relate(a, b)
   | |_________^ expected type parameter `T`, found `&T`
   |
   |
   = note: expected fn pointer `fn(&mut transform::validate::equal_up_to_regions::LifetimeIgnoreRelation<'tcx>, rustc_middle::ty::Variance, T, T) -> std::result::Result<_, _>`
              found fn pointer `fn(&mut transform::validate::equal_up_to_regions::LifetimeIgnoreRelation<'tcx>, rustc_middle::ty::Variance, &T, &T) -> std::result::Result<_, _>`
error[E0053]: method `binders` has an incompatible type for trait
   --> src/librustc_mir/transform/validate.rs:109:9
    |
109 | /         fn binders<T>(
---
118 | |             Ok(a.clone())
119 | |         }
    | |_________^ expected struct `rustc_middle::ty::Binder`, found reference
    |
    = note: expected fn pointer `fn(&mut transform::validate::equal_up_to_regions::LifetimeIgnoreRelation<'tcx>, rustc_middle::ty::Binder<T>, rustc_middle::ty::Binder<T>) -> std::result::Result<_, _>`
               found fn pointer `fn(&mut transform::validate::equal_up_to_regions::LifetimeIgnoreRelation<'tcx>, &rustc_middle::ty::Binder<T>, &rustc_middle::ty::Binder<T>) -> std::result::Result<_, _>`
    Checking rustc_passes v0.0.0 (/checkout/src/librustc_passes)
    Checking rustc_passes v0.0.0 (/checkout/src/librustc_passes)
error[E0277]: the trait bound `&&rustc_middle::ty::TyS<'_>: rustc_middle::ty::relate::Relate<'_>` is not satisfied
   --> src/librustc_mir/transform/validate.rs:124:13
    |
124 |     relator.relate(&src, &dest).is_ok()
    |             ^^^^^^ the trait `rustc_middle::ty::relate::Relate<'_>` is not implemented for `&&rustc_middle::ty::TyS<'_>`
    = help: the following implementations were found:
    = help: the following implementations were found:
              <&'tcx rustc_middle::ty::TyS<'tcx> as rustc_middle::ty::relate::Relate<'tcx>>
error[E0308]: mismatched types
  --> src/librustc_mir/transform/validate.rs:81:25
   |
   |
74 |         fn relate_with_variance<T: Relate<'tcx>>(
...
...
81 |             self.relate(a, b)
   |                         |
   |                         expected type parameter `T`, found `&T`
   |                         help: consider dereferencing the borrow: `*a`
   |
   |
   = note: expected type parameter `T`
                   found reference `&T`

error[E0308]: mismatched types
  --> src/librustc_mir/transform/validate.rs:81:28
   |
74 |         fn relate_with_variance<T: Relate<'tcx>>(
...
...
81 |             self.relate(a, b)
   |                            |
   |                            expected type parameter `T`, found `&T`
   |                            help: consider dereferencing the borrow: `*b`
   |
---

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "2" "--release" "--color" "always" "--features" " llvm" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json-render-diagnostics"
failed to run: /checkout/obj/build/bootstrap/debug/bootstrap check
Build completed unsuccessfully in 0:05:56
== clock drift check ==
  local time: Mon Jun 29 23:57:30 UTC 2020
  local time: Mon Jun 29 23:57:30 UTC 2020
  network time: Mon, 29 Jun 2020 23:57:30 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/73876/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
Author       : Microsoft
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Cleaning any cached credential from repository: rust-lang/rust (GitHub)
##[section]Finishing: Checkout rust-lang/rust@refs/pull/73876/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (4048) (python)
##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@Manishearth Manishearth deleted the rollup-dtgro2f branch July 18, 2020 01:15
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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.