Ignore `ExprKind::DropTemps` for some ref suggestions
Introduce `Expr::peel_drop_temps()` to ignore `ExprKind::DropTemps` for suggestions that depend on the `ExprKind` for accuracy.
typeck: prohibit foreign statics w/ generics
Fixes#65035 and fixes#65025.
This PR modifies resolve to disallow foreign statics that have
generics.
`improper_ctypes` is not written to support type parameters, as these
are normally disallowed before the lint is run. Thus, type parameters in
foreign statics must be prohibited before the lint.
The only other case where this *could* have occured is in functions,
but typeck prohibits this with a "foreign items may not have type
parameters" error - a similar error did not exist for statics, because
statics cannot have type parameters, but they can use any
type parameters that are in scope (which isn't the case for functions).
Warn if include macro fails to include entire file
This currently introduces an error, mainly because that was just simpler, and I'm not entirely certain if we can introduce a lint without an RFC and such.
This is primarily to get feedback on the approach and overall aim -- in particular, do we think this is helpful? If so, we probably will need lang-team sign off and decide if it should be an error (as currently introduced by this PR), a lint, or a warning.
r? @petrochenkov
cc https://github.com/rust-lang/rust/issues/35560
Updates LLVM to pick up the cherry-picked support for correctly
handling exception handling with aggregates passed by value. This will
be necessary to continue to support Emscripten's exception handling
once we switch using Emscripten's LLVM backend. See #63649.
This commit modifies resolve to disallow foreign statics that use
parent generics.
`improper_ctypes` is not written to support type parameters, as these
are normally disallowed before the lint is run. Thus, type parameters in
foreign statics must be prohibited before the lint.
The only other case where this *could* have occured is in functions,
but typeck prohibits this with a "foreign items may not have type
parameters" error - a similar error did not exist for statics, because
statics cannot have type parameters, but they can use any
type parameters that are in scope (which isn't the case for functions).
Signed-off-by: David Wood <david@davidtw.co>
Rollup of 8 pull requests
Successful merges:
- #64404 (Add long error explanation for E0495)
- #64918 (Add long error explanation for E0551)
- #65102 (Disable stack probe when thread sanitizer is enabled)
- #65120 (Correctly estimate the required space for string in `StyledBuffer::prepend`)
- #65145 (When suggesting assoc function with type params, include turbofish)
- #65162 (Remove loaded_from_cache map from DepGraph)
- #65176 (Remove query-related macros)
- #65179 (Add long error explanation for E0567)
Failed merges:
r? @ghost
Remove query-related macros
The query system has a few macros that only have one or two call sites, and I find they hurt readability. This PR removes them.
r? @michaelwoerister
Remove loaded_from_cache map from DepGraph
It's now unused, even with -Zquery-dep-graph
From https://github.com/rust-lang/rust/pull/63756/files#r316039379 -- it'll simplify that PR to get this landed separately so we can just remove some of the code that it touches.
r? @Zoxc or @michaelwoerister
Disable stack probe when thread sanitizer is enabled
When thread sanitizer instrumentation is enabled during compilation of
stack probe function, the function will be miscompiled and trigger
segmentation fault at runtime. Disable stack probes when tsan is
enabled.
Currently, when two tokens must be glued together, this function duplicates
large chunks of the existing streams. This can cause quadratic behaviour.
This commit changes the function so that it overwrites the last token with a
glued token, which avoids the quadratic behaviour. This removes the need for
`TokenStreamBuilder::push_all_but_{first,last}_tree`.
The commit also restructures `push` somewhat, by removing
`TokenStream::{first_tree_and_joint,last_tree_if_joint}` in favour of more
pattern matching and some comments. This makes the code shorter, and in my
opinion, more readable.
Currently, this function creates a new empty stream, and then appends
the elements from each given stream onto that stream. This can cause
quadratic behaviour.
This commit changes the function so that it modifies the first stream
(which can be long) by extending it with the elements from the
subsequent streams (which are almost always short), which avoids the
quadratic behaviour.
It's the same as `InferCtxt::commit_unconditionally()` except that it
is passed a snapshot and has a worse name.
The commit also changes `commit_unconditionally()` to receive a
snapshot, for consistency with `commit_if_ok()` and `probe()`.
Rollup of 8 pull requests
Successful merges:
- #64726 (rewrite documentation for unimplemented! to clarify use)
- #65040 (syntax: more cleanups in item and function signature parsing)
- #65046 (Make `Cell::new` method come first in documentation)
- #65098 (Add long error explanation for E0561)
- #65150 (Suggest dereferencing boolean reference when used in 'if' or 'while')
- #65154 (Fix const generic arguments not displaying in types mismatch diagnostic)
- #65181 (fix bug in folding for constants)
- #65187 (use 'invalid argument' for vxWorks)
Failed merges:
- #65179 (Add long error explanation for E0567)
r? @ghost
fix bug in folding for constants
These was a bug in the folding for constants that caused it to overlook bound regions. This branch includes some other little things that I did while trying to track the bug down.
r? @oli-obk
Make `Cell::new` method come first in documentation
Methods to create a thing usually comes first in `std` documentation, and `Cell` has been an exception. Also, `T: Copy` specialized methods should not be on top of the page. (This had led me to miss that most of its methods are not bounded by `Copy`...)