Commit graph

155478 commits

Author SHA1 Message Date
Manish Goregaokar
13834e6ad2 fmt 2021-09-27 22:33:45 -07:00
Manish Goregaokar
17155c8dca Add renamed lint 2021-09-27 22:26:14 -07:00
Manish Goregaokar
baec67e9de Use a single if_chain 2021-09-27 22:23:17 -07:00
Andrew Pollack
b6ffb29315 Adjusting changelog 2021-09-27 22:23:17 -07:00
Andrew Pollack
9a3ccd8547 Removed value from changelog to get pass 2021-09-27 22:23:17 -07:00
Andrew Pollack
b7d40bc103 Adding new linting 2021-09-27 22:23:17 -07:00
Tomoaki Kawada
da9ca41c31 Add SOLID targets
SOLID[1] is an embedded development platform provided by Kyoto
Microcomputer Co., Ltd. This commit introduces a basic Tier 3 support
for SOLID.

# New Targets

The following targets are added:

 - `aarch64-kmc-solid_asp3`
 - `armv7a-kmc-solid_asp3-eabi`
 - `armv7a-kmc-solid_asp3-eabihf`

SOLID's target software system can be divided into two parts: an
RTOS kernel, which is responsible for threading and synchronization,
and Core Services, which provides filesystems, networking, and other
things. The RTOS kernel is a μITRON4.0[2][3]-derived kernel based on
the open-source TOPPERS RTOS kernels[4]. For uniprocessor systems
(more precisely, systems where only one processor core is allocated for
SOLID), this will be the TOPPERS/ASP3 kernel. As μITRON is
traditionally only specified at the source-code level, the ABI is
unique to each implementation, which is why `asp3` is included in the
target names.

More targets could be added later, as we support other base kernels
(there are at least three at the point of writing) and are interested
in supporting other processor architectures in the future.

# C Compiler

Although SOLID provides its own supported C/C++ build toolchain, GNU Arm
Embedded Toolchain seems to work for the purpose of building Rust.

# Unresolved Questions

A μITRON4 kernel can support `Thread::unpark` natively, but it's not
used by this commit's implementation because the underlying kernel
feature is also used to implement `Condvar`, and it's unclear whether
`std` should guarantee that parking tokens are not clobbered by other
synchronization primitives.

# Unsupported or Unimplemented Features

Most features are implemented. The following features are not
implemented due to the lack of native support:

- `fs::File::{file_attr, truncate, duplicate, set_permissions}`
- `fs::{symlink, link, canonicalize}`
- Process creation
- Command-line arguments

Backtrace generation is not really a good fit for embedded targets, so
it's intentionally left unimplemented. Unwinding is functional, however.

## Dynamic Linking

Dynamic linking is not supported. The target platform supports dynamic
linking, but enabling this in Rust causes several problems.

 - The linker invocation used to build the shared object of `std` is
   too long for the platform-provided linker to handle.

 - A linker script with specific requirements is required for the
   compiled shared object to be actually loadable.

As such, we decided to disable dynamic linking for now. Regardless, the
users can try to create shared objects by manually invoking the linker.

## Executable

Building an executable is not supported as the notion of "executable
files" isn't well-defined for these targets.

[1] https://solid.kmckk.com/SOLID/
[2] http://ertl.jp/ITRON/SPEC/mitron4-e.html
[3] https://en.wikipedia.org/wiki/ITRON_project
[4] https://toppers.jp/
2021-09-28 11:31:47 +09:00
et342
dd0b5f4815
Clarify that CString::from_vec_unchecked appends 0 byte. 2021-09-28 05:51:52 +05:00
antoyo
11c2023ef5
Fix/count trailing zeroes (#95)
* Fix count trailing zeroes
* Fix pop count
* Fix bit reverse
2021-09-27 20:35:45 -04:00
Fabian Wolff
cd0873b502 Add unit assignment to MIR for asm!() 2021-09-28 01:38:54 +02:00
antoyo
63608ac6b3
Fix/mismatch types (#94)
* Refactor test.sh script

* Fix mismatched types error
2021-09-27 19:31:24 -04:00
Augie Fackler
12c3f50a90 PassWrapper: handle function rename from upstream D36850
thinLTOResolvePrevailingInModule became thinLTOFinalizeInModule and
gained the ability to propagate noRecurse and noUnwind function
attributes. I ran codegen tests with it both on and off, as the upstream
patch uses it in both modes, and the tests pass both ways. Given that,
it seemed reasonable to go ahead and let the propagation be enabled in
rustc, and see what happens. See https://reviews.llvm.org/D36850 for
more examples of how the new version of the function gets used.
2021-09-27 18:11:21 -04:00
Jane Lusby
0911069feb
Apply suggestions from code review
Co-authored-by: kennytm <kennytm@gmail.com>
2021-09-27 14:50:35 -07:00
bors
8a12be7412 Auto merge of #89249 - Aaron1011:higher-ranked-cause, r=estebank
Improve cause information for NLL higher-ranked errors

This PR has several interconnected pieces:

1. In some of the NLL region error code, we now pass
   around an `ObligationCause`, instead of just a plain `Span`.
   This gets forwarded into `fulfill_cx.register_predicate_obligation`
   during error reporting.
2. The general InferCtxt error reporting code is extended to
   handle `ObligationCauseCode::BindingObligation`
3. A new enum variant `ConstraintCategory::Predicate` is added.
   We try to avoid using this as the 'best blame constraint' - instead,
   we use it to enhance the `ObligationCause` of the `BlameConstraint`
   that we do end up choosing.

As a result, several NLL error messages now contain the same
"the lifetime requirement is introduced here" message as non-NLL
errors.

Having an `ObligationCause` available will likely prove useful
for future improvements to NLL error messages.
2021-09-27 21:29:19 +00:00
bors
98c8619502 Auto merge of #89214 - smoelius:register_tool, r=petrochenkov
Pass real crate-level attributes to `pre_expansion_lint`

The PR concerns the unstable feature `register_tool` (#66079).

The feature's implementation requires the attributes of the crate being compiled, so that when attributes like `allow(foo::bar)` are encountered, it can be verified that `register_tool(foo)` appears in the crate root.

However, the crate's attributes are not readily available during early lint passes. Specifically, on this line, `krate.attrs` appears to be the attributes of the current source file, not the attributes of the whole crate: bf642323d6/compiler/rustc_lint/src/context.rs (L815)

Consequently, "unknown tool" errors were being produced when `allow(foo::bar)` appeared in a submodule, even though `register_tool(foo)` appeared in the crate root.

EDITED: The proposed fix is to obtain the real crate-level attributes in `configure_and_expand` and pass them to `pre_expansion_lint`. (See `@petrochenkov's` [comment](https://github.com/rust-lang/rust/pull/89214#issuecomment-926927072) below.)

The original "prosed fix" text follows.

---

The proposed fix is to add an `error_on_unknown_tool` flag to `LintLevelsBuilder`. The flag controls whether "unknown tool" errors are emitted. The flag is set during late passes, but not earlier.

More specifically, this PR contains two commits:

* The first adds a `known-tool-in-submodule` UI test that does not currently pass.
* The second adds the `error_on_unknown_tool` flag. The new test passes with the addition of this flag.

This change has the added benefit of eliminating some errors that were duplicated in existing tests.

To the reviewer: please check that I implemented the UI test correctly.
2021-09-27 18:21:14 +00:00
David Carlier
5d4048b66f thread: implements available_concurrency on haiku 2021-09-27 18:51:52 +01:00
Gus Wynn
4cc3297dc4 #[feature] not required for lint result 2021-09-27 08:49:36 -07:00
Aaron Hill
41ad383e11
Remove DefId from ConstraintCategory::Predicate
This shirnks the size of `ConstraintCategory`, hopefully
fixing a performance regression.
2021-09-27 10:45:34 -05:00
Gus Wynn
0f9c349834 lock types 2021-09-27 08:43:30 -07:00
Aaron Hill
93ab12eeab
Improve cause information for NLL higher-ranked errors
This PR has several interconnected pieces:

1. In some of the NLL region error code, we now pass
   around an `ObligationCause`, instead of just a plain `Span`.
   This gets forwarded into `fulfill_cx.register_predicate_obligation`
   during error reporting.
2. The general InferCtxt error reporting code is extended to
   handle `ObligationCauseCode::BindingObligation`
3. A new enum variant `ConstraintCategory::Predicate` is added.
   We try to avoid using this as the 'best blame constraint' - instead,
   we use it to enhance the `ObligationCause` of the `BlameConstraint`
   that we do end up choosing.

As a result, several NLL error messages now contain the same
"the lifetime requirement is introduced here" message as non-NLL
errors.

Having an `ObligationCause` available will likely prove useful
for future improvements to NLL error messages.
2021-09-27 10:23:45 -05:00
bors
2b6ed3b675 Auto merge of #89285 - jackh726:issue-88862, r=nikomatsakis
Don't normalize opaque types with escaping late-bound regions

Fixes #88862

Turns out, this has some really bad perf implications in large types (issue #88862). While we technically can handle them fine, it doesn't change test output either way. For now, revert with an added benchmark. Future attempts to change this back will have to consider perf.

Needs a perf run once https://github.com/rust-lang/rustc-perf/pull/1033 is merged

r? `@nikomatsakis`
2021-09-27 14:08:13 +00:00
antoyo
ab4ff2dfe0
Cleanup fix for global initialization (#93)
* Cleanup fix for global initialization
* Remove linker script hack
* Use v0 symbol mangling
* Fix warnings
2021-09-27 09:34:06 -04:00
bors
3e8f32e1c5 Auto merge of #89263 - TaKO8Ki:suggest-both-immutable-and-mutable-trait-implementations, r=estebank
Suggest both of immutable and mutable trait implementations

closes #85865
2021-09-27 11:10:40 +00:00
flip1995
46f8aa9c31
Update changelog to 1.56 2021-09-27 11:59:33 +02:00
bors
0c8799da5a Auto merge of #7664 - matthiaskrgr:bump_to_2021, r=flip1995
bump clippy crates to edition 2021

Also helps with dogfooding edition 2021 a bit. :)
Tests passed locally.

---

changelog: bump edition from 2018 to 2021
2021-09-27 09:14:10 +00:00
bors
f100159f8c Auto merge of #7692 - workingjubilee:float-cmp-not-wrong, r=giraffate
Demote float_cmp to pedantic

See this issue: https://github.com/rust-lang/rust-clippy/issues/7666

This is one of the most frequently suppressed lints. It is deny-by-default. It is not actually clearly wrong, as there are many instances where direct float comparison is actually desirable. It is only after operating on floats that they may lose precision, and that depends greatly on the operation. As most correctness lints have a much higher standard of error, being based on hard and fast binary logic, this should not be amongst them.

A linter is not a substitute for observing the math carefully and running tests, and doing the desirable thing is even more likely to lead one to want exact comparisons.

changelog: Demote [`float_cmp`] from correctness to pedantic lints
2021-09-27 09:00:31 +00:00
bors
583437a6dd Auto merge of #89203 - GuillaumeGomez:cleanup-rustdoc-types, r=camelid
Clean up clean/types.rs file by making the implementations follow the type declaration

This PR doesn't change anything, it simply moves things around: when reading the code, I realized a few times that a type declaration and implementations on it might be separated by some other type declarations, which makes the reading much more complicated. I put back impl and declaration together.

r? `@camelid`
2021-09-27 07:54:16 +00:00
Laurențiu Nicola
592d0892aa ⬆️ rust-analyzer 2021-09-27 10:39:05 +03:00
Takayuki Maeda
564cb87e27 suggest path for tuple struct 2021-09-27 16:28:38 +09:00
bors
04006d8e3b Auto merge of #89182 - GuillaumeGomez:boostrap-explicit-request, r=Mark-Simulacrum
Simplify explicit request check and allow to run "doc src/librustdoc" even without config set

Originally I wanted to allow the command `doc src/librustdoc` to work when passed explicitly but then `@Mark-Simulacrum` recommended me to generalize it, so here we are!

r? `@Mark-Simulacrum`
2021-09-27 05:00:59 +00:00
Timothy Maloney
adbb608678 Link stage1 build to toolchain automatically
Fixed types

Add checks for rustup and if toolchain is linked

Fortified rustup/directory checks; made other suggested changes

Added check for output status

Remove output of rustup from console

Made suggested change

Deleted confusing comment

Fixed compiler error; removed extra declaration

Refactored to smaller components; made suggested changes

Automate toolchain linking for stage 1 builds
2021-09-26 21:26:30 -07:00
bors
c81c3ea321 Auto merge of #89145 - rusticstuff:bump_stdarch, r=kennytm
Update stdarch submodule

This is mainly to fix the critical issue of aarch64 store intrinsics overwriting additional memory, see https://github.com/rust-lang/stdarch/issues/1220

Changes:
* aarch64/armv7: additional vld1/vst1 intrinsics + perf fixes for existing ones
  * https://github.com/rust-lang/stdarch/pull/1205
  * https://github.com/rust-lang/stdarch/pull/1207
  * https://github.com/rust-lang/stdarch/pull/1216
* armv7: Make FMA work with vfpv4 and optimize
  * https://github.com/rust-lang/stdarch/pull/1219
* Non-visible changes to the testing framework
  * https://github.com/rust-lang/stdarch/pull/1208
  * https://github.com/rust-lang/stdarch/pull/1211
  * https://github.com/rust-lang/stdarch/pull/1213
  * https://github.com/rust-lang/stdarch/pull/1215
  * https://github.com/rust-lang/stdarch/pull/1218
2021-09-27 02:11:52 +00:00
Roxane
d0e2b607de Fix test 2021-09-26 21:02:21 -04:00
bors
30fe4ba1fb Auto merge of #7722 - dtolnay-contrib:float, r=giraffate
Stop suggesting a float truncation that is not shorter

Fixes #7721.

Previously Clippy would say that a number has excessive precision even if it has the minimum possible precision for the floating point value that it corresponds to.

changelog: Fix [`excessive_precision`] being triggered on floats that are already written in shortest form
2021-09-27 00:49:08 +00:00
bors
b2804655f5 Auto merge of #89092 - bjorn3:sync_cg_clif-2021-09-19, r=bjorn3
Sync rustc_codegen_cranelift

Nothing exciting this time. Mostly internal refactorings.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2021-09-26 23:31:01 +00:00
Samuel Moelius
1e15bbe552 Pass real crate-level attributes to pre_expansion_lint 2021-09-26 21:50:50 +00:00
jackh726
a84e3fab30 Don't normalize opaque types with escaping late-bound regions.
Turns out, this has some really bad perf implications in large types (issue #88862). While we technically can handle them fine, it doesn't change test output either way. For now, revert with an added benchmark. Future attempts to change this back will have to consider perf.
2021-09-26 15:58:24 -04:00
Roxane
87010206ad 2229: Consume IfLet expr 2021-09-26 15:52:02 -04:00
Noah Lev
df687bdae0 Add regression test for issue #83564 2021-09-26 12:39:10 -07:00
bors
05044c2e6c Auto merge of #89144 - sexxi-goose:insig_stdlib, r=nikomatsakis
2229: Mark insignificant dtor in stdlib

I looked at all public [stdlib Drop implementations](https://doc.rust-lang.org/stable/std/ops/trait.Drop.html#implementors) and categorized them into Insigificant/Maybe/Significant Drop.

Reasons are noted here: https://docs.google.com/spreadsheets/d/19edb9r5lo2UqMrCOVjV0fwcSdS-R7qvKNL76q7tO8VA/edit#gid=1838773501

One thing missing from this PR is tagging HashMap as insigificant destructor as that needs some discussion.

r? `@Mark-Simulacrum`

cc `@nikomatsakis`
2021-09-26 19:36:00 +00:00
Fabian Wolff
750018e16e Improve diagnostics for inaccessible items 2021-09-26 19:22:20 +02:00
Esteban Kuber
5c70f25f8c Detect when negative literal indices are used and suggest appropriate code 2021-09-26 16:52:10 +00:00
Fabian Wolff
65eb381dec Do not suggest importing inaccessible items 2021-09-26 18:43:58 +02:00
Joshua Nelson
6f087aedb6 Use the correct edition when syntax highlighting doctests
Previously it would unconditionally use edition 2015, which was
incorrect.
2021-09-26 16:36:33 +00:00
Joshua Nelson
f4aa3b544f Preserve the whole LangSyntax when parsing doctests
Previously, only the raw string and the `is_ignore` field were
preserved, which made it hard to recover anything else.
2021-09-26 16:28:36 +00:00
Loïc BRANSTETT
88ff75c6cc Fix populate of union.impls 2021-09-26 18:22:07 +02:00
antoyo
64c561dc22
Fix global initialization (#91)
* Make define_global() return a RValue directly
* Return LValue in functions declaring a global variable
* Remove useless cast
* Fix bytes_in_context to use an array rvalue
* Remove global_names which is unused
* Make const_struct create a constant struct
* Correctly initialize global in static_addr_of_mut
* Fix global variable initialization
* Remove workaround for ARGV
2021-09-26 12:20:02 -04:00
Takayuki Maeda
3bab36357c test suggesting immutable or mutable trait implementations 2021-09-27 00:59:57 +09:00
Takayuki Maeda
3e41397ef2 fix test error 2021-09-27 00:50:46 +09:00
bors
c09d637432 Auto merge of #88316 - est31:remove_box_tests, r=Mark-Simulacrum
Remove most box syntax uses from the testsuite except for src/test/ui/issues

Removes most box syntax uses from the testsuite outside of the src/test/ui/issues directory. The goal was to only change tests where box syntax is an implementation detail instead of the actual feature being tested. So some tests were left out, like the regression test for #87935, or tests where the obtained error message changed significantly.

Mostly this replaces box syntax with `Box::new`, but there are some minor drive by improvements, like formatting improvements or `assert_eq` instead of `assert!( == )`.

Prior PR that removed box syntax from the compiler and tools: #87781
2021-09-26 15:48:10 +00:00