mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Auto merge of #69950 - Centril:rollup-xh0hmvx, r=Centril
Rollup of 10 pull requests Successful merges: - #68899 (Add Display and Error impls for proc_macro::LexError) - #69011 (Document unsafe blocks in core::fmt) - #69674 (Rename DefKind::Method and TraitItemKind::Method ) - #69705 (Toolstate: remove redundant beta-week check.) - #69722 (Tweak output for invalid negative impl AST errors) - #69747 (Rename rustc guide) - #69792 (Implement Error for TryReserveError) - #69830 (miri: ICE on invalid terminators) - #69921 (rustdoc: remove unused import) - #69945 (update outdated comment) Failed merges: r? @ghost
This commit is contained in:
commit
54b7d21f59
8
.github/ISSUE_TEMPLATE/tracking_issue.md
vendored
8
.github/ISSUE_TEMPLATE/tracking_issue.md
vendored
@ -36,11 +36,11 @@ for larger features an implementation could be broken up into multiple PRs.
|
||||
|
||||
- [ ] Implement the RFC (cc @rust-lang/XXX -- can anyone write up mentoring
|
||||
instructions?)
|
||||
- [ ] Adjust documentation ([see instructions on rustc-guide][doc-guide])
|
||||
- [ ] Stabilization PR ([see instructions on rustc-guide][stabilization-guide])
|
||||
- [ ] Adjust documentation ([see instructions on rustc-dev-guide][doc-guide])
|
||||
- [ ] Stabilization PR ([see instructions on rustc-dev-guide][stabilization-guide])
|
||||
|
||||
[stabilization-guide]: https://rust-lang.github.io/rustc-guide/stabilization_guide.html#stabilization-pr
|
||||
[doc-guide]: https://rust-lang.github.io/rustc-guide/stabilization_guide.html#documentation-prs
|
||||
[stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr
|
||||
[doc-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#documentation-prs
|
||||
|
||||
### Unresolved Questions
|
||||
<!--
|
||||
|
@ -19,7 +19,7 @@ hop on the [Rust Discord server][rust-discord] or [Rust Zulip server][rust-zulip
|
||||
|
||||
As a reminder, all contributors are expected to follow our [Code of Conduct][coc].
|
||||
|
||||
The [rustc-guide] is your friend! It describes how the compiler works and how
|
||||
The [rustc-dev-guide] is your friend! It describes how the compiler works and how
|
||||
to contribute to it in more detail than this document.
|
||||
|
||||
If this is your first time contributing, the [walkthrough] chapter of the guide
|
||||
@ -29,8 +29,8 @@ can give you a good example of how a typical contribution would go.
|
||||
[rust-discord]: http://discord.gg/rust-lang
|
||||
[rust-zulip]: https://rust-lang.zulipchat.com
|
||||
[coc]: https://www.rust-lang.org/conduct.html
|
||||
[rustc-guide]: https://rust-lang.github.io/rustc-guide/
|
||||
[walkthrough]: https://rust-lang.github.io/rustc-guide/walkthrough.html
|
||||
[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/
|
||||
[walkthrough]: https://rustc-dev-guide.rust-lang.org/walkthrough.html
|
||||
|
||||
## Feature Requests
|
||||
[feature-requests]: #feature-requests
|
||||
@ -103,12 +103,12 @@ $ RUST_BACKTRACE=1 rustc ...
|
||||
## The Build System
|
||||
|
||||
For info on how to configure and build the compiler, please see [this
|
||||
chapter][rustcguidebuild] of the rustc-guide. This chapter contains info for
|
||||
chapter][rustcguidebuild] of the rustc-dev-guide. This chapter contains info for
|
||||
contributions to the compiler and the standard library. It also lists some
|
||||
really useful commands to the build system (`./x.py`), which could save you a
|
||||
lot of time.
|
||||
|
||||
[rustcguidebuild]: https://rust-lang.github.io/rustc-guide/building/how-to-build-and-run.html
|
||||
[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html
|
||||
|
||||
## Pull Requests
|
||||
[pull-requests]: #pull-requests
|
||||
@ -336,9 +336,9 @@ to check small fixes. For example, `rustdoc src/doc/reference.md` will render
|
||||
reference to `doc/reference.html`. The CSS might be messed up, but you can
|
||||
verify that the HTML is right.
|
||||
|
||||
Additionally, contributions to the [rustc-guide] are always welcome. Contributions
|
||||
Additionally, contributions to the [rustc-dev-guide] are always welcome. Contributions
|
||||
can be made directly at [the
|
||||
rust-lang/rustc-guide](https://github.com/rust-lang/rustc-guide) repo. The issue
|
||||
rust-lang/rustc-dev-guide](https://github.com/rust-lang/rustc-dev-guide) repo. The issue
|
||||
tracker in that repo is also a great way to find things that need doing. There
|
||||
are issues for beginners and advanced compiler devs alike!
|
||||
|
||||
@ -434,7 +434,7 @@ For people new to Rust, and just starting to contribute, or even for
|
||||
more seasoned developers, some useful places to look for information
|
||||
are:
|
||||
|
||||
* The [rustc guide] contains information about how various parts of the compiler work and how to contribute to the compiler
|
||||
* The [rustc dev guide] contains information about how various parts of the compiler work and how to contribute to the compiler
|
||||
* [Rust Forge][rustforge] contains additional documentation, including write-ups of how to achieve common tasks
|
||||
* The [Rust Internals forum][rif], a place to ask questions and
|
||||
discuss Rust's internals
|
||||
@ -448,7 +448,7 @@ are:
|
||||
* **Google!** ([search only in Rust Documentation][gsearchdocs] to find types, traits, etc. quickly)
|
||||
* Don't be afraid to ask! The Rust community is friendly and helpful.
|
||||
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/about-this-guide.html
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/about-this-guide.html
|
||||
[gdfrustc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/
|
||||
[gsearchdocs]: https://www.google.com/search?q=site:doc.rust-lang.org+your+query+here
|
||||
[rif]: http://internals.rust-lang.org
|
||||
@ -456,5 +456,5 @@ are:
|
||||
[rustforge]: https://forge.rust-lang.org/
|
||||
[tlgba]: http://tomlee.co/2014/04/a-more-detailed-tour-of-the-rust-compiler/
|
||||
[ro]: http://www.rustaceans.org/
|
||||
[rctd]: https://rust-lang.github.io/rustc-guide/tests/intro.html
|
||||
[rctd]: https://rustc-dev-guide.rust-lang.org/tests/intro.html
|
||||
[cheatsheet]: https://buildbot2.rust-lang.org/homu/
|
||||
|
10
README.md
10
README.md
@ -15,13 +15,13 @@ Read ["Installation"] from [The Book].
|
||||
## Installing from Source
|
||||
|
||||
_Note: If you wish to contribute to the compiler, you should read [this
|
||||
chapter][rustcguidebuild] of the rustc-guide instead of this section._
|
||||
chapter][rustcguidebuild] of the rustc-dev-guide instead of this section._
|
||||
|
||||
The Rust build system has a Python script called `x.py` to bootstrap building
|
||||
the compiler. More information about it may be found by running `./x.py --help`
|
||||
or reading the [rustc guide][rustcguidebuild].
|
||||
or reading the [rustc dev guide][rustcguidebuild].
|
||||
|
||||
[rustcguidebuild]: https://rust-lang.github.io/rustc-guide/building/how-to-build-and-run.html
|
||||
[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html
|
||||
|
||||
### Building on *nix
|
||||
1. Make sure you have installed the dependencies:
|
||||
@ -249,13 +249,13 @@ Most real-time collaboration happens in a variety of channels on the
|
||||
community, documentation, and all major contribution areas in the Rust ecosystem.
|
||||
A good place to ask for help would be the #help channel.
|
||||
|
||||
The [rustc guide] might be a good place to start if you want to find out how
|
||||
The [rustc dev guide] might be a good place to start if you want to find out how
|
||||
various parts of the compiler work.
|
||||
|
||||
Also, you may find the [rustdocs for the compiler itself][rustdocs] useful.
|
||||
|
||||
[rust-discord]: https://discord.gg/rust-lang
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/about-this-guide.html
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/about-this-guide.html
|
||||
[rustdocs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/
|
||||
|
||||
## License
|
||||
|
@ -3,6 +3,6 @@ This directory contains the source code of the rust project, including:
|
||||
- `libstd`
|
||||
- Various submodules for tools, like rustdoc, rls, etc.
|
||||
|
||||
For more information on how various parts of the compiler work, see the [rustc guide].
|
||||
For more information on how various parts of the compiler work, see the [rustc dev guide].
|
||||
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/about-this-guide.html
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/about-this-guide.html
|
||||
|
@ -215,6 +215,9 @@ impl Step for ToolStateCheck {
|
||||
tool, old_state, state
|
||||
);
|
||||
} else {
|
||||
// This warning only appears in the logs, which most
|
||||
// people won't read. It's mostly here for testing and
|
||||
// debugging.
|
||||
eprintln!(
|
||||
"warning: Tool `{}` is not test-pass (is `{}`), \
|
||||
this should be fixed before beta is branched.",
|
||||
@ -222,6 +225,11 @@ impl Step for ToolStateCheck {
|
||||
);
|
||||
}
|
||||
}
|
||||
// `publish_toolstate.py` is responsible for updating
|
||||
// `latest.json` and creating comments/issues warning people
|
||||
// if there is a regression. That all happens in a separate CI
|
||||
// job on the master branch once the PR has passed all tests
|
||||
// on the `auto` branch.
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,7 +238,7 @@ impl Step for ToolStateCheck {
|
||||
}
|
||||
|
||||
if builder.config.channel == "nightly" && env::var_os("TOOLSTATE_PUBLISH").is_some() {
|
||||
commit_toolstate_change(&toolstates, in_beta_week);
|
||||
commit_toolstate_change(&toolstates);
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,11 +333,11 @@ fn prepare_toolstate_config(token: &str) {
|
||||
Err(_) => false,
|
||||
};
|
||||
if !success {
|
||||
panic!("git config key={} value={} successful (status: {:?})", key, value, status);
|
||||
panic!("git config key={} value={} failed (status: {:?})", key, value, status);
|
||||
}
|
||||
}
|
||||
|
||||
// If changing anything here, then please check that src/ci/publish_toolstate.sh is up to date
|
||||
// If changing anything here, then please check that `src/ci/publish_toolstate.sh` is up to date
|
||||
// as well.
|
||||
git_config("user.email", "7378925+rust-toolstate-update@users.noreply.github.com");
|
||||
git_config("user.name", "Rust Toolstate Update");
|
||||
@ -373,14 +381,14 @@ fn read_old_toolstate() -> Vec<RepoState> {
|
||||
///
|
||||
/// * See <https://help.github.com/articles/about-commit-email-addresses/>
|
||||
/// if a private email by GitHub is wanted.
|
||||
fn commit_toolstate_change(current_toolstate: &ToolstateData, in_beta_week: bool) {
|
||||
let old_toolstate = read_old_toolstate();
|
||||
|
||||
fn commit_toolstate_change(current_toolstate: &ToolstateData) {
|
||||
let message = format!("({} CI update)", OS.expect("linux/windows only"));
|
||||
let mut success = false;
|
||||
for _ in 1..=5 {
|
||||
// Update the toolstate results (the new commit-to-toolstate mapping) in the toolstate repo.
|
||||
change_toolstate(¤t_toolstate, &old_toolstate, in_beta_week);
|
||||
// Upload the test results (the new commit-to-toolstate mapping) to the toolstate repo.
|
||||
// This does *not* change the "current toolstate"; that only happens post-landing
|
||||
// via `src/ci/docker/publish_toolstate.sh`.
|
||||
publish_test_results(¤t_toolstate);
|
||||
|
||||
// `git commit` failing means nothing to commit.
|
||||
let status = t!(Command::new("git")
|
||||
@ -429,31 +437,12 @@ fn commit_toolstate_change(current_toolstate: &ToolstateData, in_beta_week: bool
|
||||
}
|
||||
}
|
||||
|
||||
fn change_toolstate(
|
||||
current_toolstate: &ToolstateData,
|
||||
old_toolstate: &[RepoState],
|
||||
in_beta_week: bool,
|
||||
) {
|
||||
let mut regressed = false;
|
||||
for repo_state in old_toolstate {
|
||||
let tool = &repo_state.tool;
|
||||
let state = repo_state.state();
|
||||
let new_state = current_toolstate[tool.as_str()];
|
||||
|
||||
if new_state != state {
|
||||
eprintln!("The state of `{}` has changed from `{}` to `{}`", tool, state, new_state);
|
||||
if new_state < state {
|
||||
if !NIGHTLY_TOOLS.iter().any(|(name, _path)| name == tool) {
|
||||
regressed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if regressed && in_beta_week {
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
/// Updates the "history" files with the latest results.
|
||||
///
|
||||
/// These results will later be promoted to `latest.json` by the
|
||||
/// `publish_toolstate.py` script if the PR passes all tests and is merged to
|
||||
/// master.
|
||||
fn publish_test_results(current_toolstate: &ToolstateData) {
|
||||
let commit = t!(std::process::Command::new("git").arg("rev-parse").arg("HEAD").output());
|
||||
let commit = t!(String::from_utf8(commit.stdout));
|
||||
|
||||
|
@ -23,7 +23,9 @@ GIT_COMMIT_MSG="$(git log --format=%s -n1 HEAD)"
|
||||
cd rust-toolstate
|
||||
FAILURE=1
|
||||
for RETRY_COUNT in 1 2 3 4 5; do
|
||||
# The purpose is to publish the new "current" toolstate in the toolstate repo.
|
||||
# The purpose of this is to publish the new "current" toolstate in the toolstate repo.
|
||||
# This happens post-landing, on master.
|
||||
# (Publishing the per-commit test results happens pre-landing in src/bootstrap/toolstate.rs).
|
||||
"$(ciCheckoutPath)/src/tools/publish_toolstate.py" "$GIT_COMMIT" \
|
||||
"$GIT_COMMIT_MSG" \
|
||||
"$MESSAGE_FILE" \
|
||||
|
@ -120,7 +120,7 @@ Rust. It's also sometimes called "the 'nomicon."
|
||||
|
||||
## The `rustc` Contribution Guide
|
||||
|
||||
[The `rustc` Guide](https://rust-lang.github.io/rustc-guide/) documents how
|
||||
[The `rustc` Guide](https://rustc-dev-guide.rust-lang.org/) documents how
|
||||
the compiler works and how to contribute to it. This is useful if you want to build
|
||||
or modify the Rust compiler from source (e.g. to target something non-standard).
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
# Contributing to rustc
|
||||
|
||||
We'd love to have your help improving `rustc`! To that end, we've written [a
|
||||
whole book][rustc_guide] on its
|
||||
whole book][rustc_dev_guide] on its
|
||||
internals, how it works, and how to get started working on it. To learn
|
||||
more, you'll want to check that out.
|
||||
|
||||
If you would like to contribute to _this_ book, you can find its source in the
|
||||
rustc source at [src/doc/rustc][rustc_book].
|
||||
|
||||
[rustc_guide]: https://rust-lang.github.io/rustc-guide/
|
||||
[rustc_dev_guide]: https://rustc-dev-guide.rust-lang.org/
|
||||
[rustc_book]: https://github.com/rust-lang/rust/tree/master/src/doc/rustc
|
||||
|
@ -42,6 +42,7 @@ pub use linked_list::LinkedList;
|
||||
pub use vec_deque::VecDeque;
|
||||
|
||||
use crate::alloc::{Layout, LayoutErr};
|
||||
use core::fmt::Display;
|
||||
|
||||
/// The error type for `try_reserve` methods.
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
@ -77,6 +78,23 @@ impl From<LayoutErr> for TryReserveError {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
|
||||
impl Display for TryReserveError {
|
||||
fn fmt(
|
||||
&self,
|
||||
fmt: &mut core::fmt::Formatter<'_>,
|
||||
) -> core::result::Result<(), core::fmt::Error> {
|
||||
fmt.write_str("memory allocation failed")?;
|
||||
let reason = match &self {
|
||||
TryReserveError::CapacityOverflow => {
|
||||
" because the computed capacity exceeded the collection's maximum"
|
||||
}
|
||||
TryReserveError::AllocError { .. } => " because the memory allocator returned a error",
|
||||
};
|
||||
fmt.write_str(reason)
|
||||
}
|
||||
}
|
||||
|
||||
/// An intermediate trait for specialization of `Extend`.
|
||||
#[doc(hidden)]
|
||||
trait SpecExtend<I: IntoIterator> {
|
||||
|
@ -2,8 +2,6 @@ use crate::fmt::{Debug, Display, Formatter, LowerExp, Result, UpperExp};
|
||||
use crate::mem::MaybeUninit;
|
||||
use crate::num::flt2dec;
|
||||
|
||||
// ignore-tidy-undocumented-unsafe
|
||||
|
||||
// Don't inline this so callers don't use the stack space this function
|
||||
// requires unless they have to.
|
||||
#[inline(never)]
|
||||
@ -16,6 +14,7 @@ fn float_to_decimal_common_exact<T>(
|
||||
where
|
||||
T: flt2dec::DecodableFloat,
|
||||
{
|
||||
// SAFETY: Possible undefined behavior, see FIXME(#53491)
|
||||
unsafe {
|
||||
let mut buf = MaybeUninit::<[u8; 1024]>::uninit(); // enough for f32 and f64
|
||||
let mut parts = MaybeUninit::<[flt2dec::Part<'_>; 4]>::uninit();
|
||||
@ -48,6 +47,7 @@ fn float_to_decimal_common_shortest<T>(
|
||||
where
|
||||
T: flt2dec::DecodableFloat,
|
||||
{
|
||||
// SAFETY: Possible undefined behavior, see FIXME(#53491)
|
||||
unsafe {
|
||||
// enough for f32 and f64
|
||||
let mut buf = MaybeUninit::<[u8; flt2dec::MAX_SIG_DIGITS]>::uninit();
|
||||
@ -103,6 +103,7 @@ fn float_to_exponential_common_exact<T>(
|
||||
where
|
||||
T: flt2dec::DecodableFloat,
|
||||
{
|
||||
// SAFETY: Possible undefined behavior, see FIXME(#53491)
|
||||
unsafe {
|
||||
let mut buf = MaybeUninit::<[u8; 1024]>::uninit(); // enough for f32 and f64
|
||||
let mut parts = MaybeUninit::<[flt2dec::Part<'_>; 6]>::uninit();
|
||||
@ -132,6 +133,7 @@ fn float_to_exponential_common_shortest<T>(
|
||||
where
|
||||
T: flt2dec::DecodableFloat,
|
||||
{
|
||||
// SAFETY: Possible undefined behavior, see FIXME(#53491)
|
||||
unsafe {
|
||||
// enough for f32 and f64
|
||||
let mut buf = MaybeUninit::<[u8; flt2dec::MAX_SIG_DIGITS]>::uninit();
|
||||
|
@ -1,7 +1,5 @@
|
||||
//! Utilities for formatting and printing strings.
|
||||
|
||||
// ignore-tidy-undocumented-unsafe
|
||||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
use crate::cell::{Cell, Ref, RefCell, RefMut, UnsafeCell};
|
||||
@ -281,6 +279,14 @@ impl<'a> ArgumentV1<'a> {
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "none")]
|
||||
pub fn new<'b, T>(x: &'b T, f: fn(&T, &mut Formatter<'_>) -> Result) -> ArgumentV1<'b> {
|
||||
// SAFETY: `mem::transmute(x)` is safe because
|
||||
// 1. `&'b T` keeps the lifetime it originated with `'b`
|
||||
// (so as to not have an unbounded lifetime)
|
||||
// 2. `&'b T` and `&'b Void` have the same memory layout
|
||||
// (when `T` is `Sized`, as it is here)
|
||||
// `mem::transmute(f)` is safe since `fn(&T, &mut Formatter<'_>) -> Result`
|
||||
// and `fn(&Void, &mut Formatter<'_>) -> Result` have the same ABI
|
||||
// (as long as `T` is `Sized`)
|
||||
unsafe { ArgumentV1 { formatter: mem::transmute(f), value: mem::transmute(x) } }
|
||||
}
|
||||
|
||||
@ -1399,6 +1405,14 @@ impl<'a> Formatter<'a> {
|
||||
|
||||
fn write_formatted_parts(&mut self, formatted: &flt2dec::Formatted<'_>) -> Result {
|
||||
fn write_bytes(buf: &mut dyn Write, s: &[u8]) -> Result {
|
||||
// SAFETY: This is used for `flt2dec::Part::Num` and `flt2dec::Part::Copy`.
|
||||
// It's safe to use for `flt2dec::Part::Num` since every char `c` is between
|
||||
// `b'0'` and `b'9'`, which means `s` is valid UTF-8.
|
||||
// It's also probably safe in practice to use for `flt2dec::Part::Copy(buf)`
|
||||
// since `buf` should be plain ASCII, but it's possible for someone to pass
|
||||
// in a bad value for `buf` into `flt2dec::to_shortest_str` since it is a
|
||||
// public function.
|
||||
// FIXME: Determine whether this could result in UB.
|
||||
buf.write_str(unsafe { str::from_utf8_unchecked(s) })
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
//! Integer and floating-point number formatting
|
||||
|
||||
// ignore-tidy-undocumented-unsafe
|
||||
|
||||
use crate::fmt;
|
||||
use crate::mem::MaybeUninit;
|
||||
use crate::num::flt2dec;
|
||||
@ -84,6 +82,8 @@ trait GenericRadix {
|
||||
}
|
||||
}
|
||||
let buf = &buf[curr..];
|
||||
// SAFETY: The only chars in `buf` are created by `Self::digit` which are assumed to be
|
||||
// valid UTF-8
|
||||
let buf = unsafe {
|
||||
str::from_utf8_unchecked(slice::from_raw_parts(MaybeUninit::first_ptr(buf), buf.len()))
|
||||
};
|
||||
@ -189,11 +189,19 @@ static DEC_DIGITS_LUT: &[u8; 200] = b"0001020304050607080910111213141516171819\
|
||||
macro_rules! impl_Display {
|
||||
($($t:ident),* as $u:ident via $conv_fn:ident named $name:ident) => {
|
||||
fn $name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// 2^128 is about 3*10^38, so 39 gives an extra byte of space
|
||||
let mut buf = [MaybeUninit::<u8>::uninit(); 39];
|
||||
let mut curr = buf.len() as isize;
|
||||
let buf_ptr = MaybeUninit::first_ptr_mut(&mut buf);
|
||||
let lut_ptr = DEC_DIGITS_LUT.as_ptr();
|
||||
|
||||
// SAFETY: Since `d1` and `d2` are always less than or equal to `198`, we
|
||||
// can copy from `lut_ptr[d1..d1 + 1]` and `lut_ptr[d2..d2 + 1]`. To show
|
||||
// that it's OK to copy into `buf_ptr`, notice that at the beginning
|
||||
// `curr == buf.len() == 39 > log(n)` since `n < 2^128 < 10^39`, and at
|
||||
// each step this is kept the same as `n` is divided. Since `n` is always
|
||||
// non-negative, this means that `curr > 0` so `buf_ptr[curr..curr + 1]`
|
||||
// is safe to access.
|
||||
unsafe {
|
||||
// need at least 16 bits for the 4-characters-at-a-time to work.
|
||||
assert!(crate::mem::size_of::<$u>() >= 2);
|
||||
@ -206,6 +214,10 @@ macro_rules! impl_Display {
|
||||
let d1 = (rem / 100) << 1;
|
||||
let d2 = (rem % 100) << 1;
|
||||
curr -= 4;
|
||||
|
||||
// We are allowed to copy to `buf_ptr[curr..curr + 3]` here since
|
||||
// otherwise `curr < 0`. But then `n` was originally at least `10000^10`
|
||||
// which is `10^40 > 2^128 > n`.
|
||||
ptr::copy_nonoverlapping(lut_ptr.offset(d1), buf_ptr.offset(curr), 2);
|
||||
ptr::copy_nonoverlapping(lut_ptr.offset(d2), buf_ptr.offset(curr + 2), 2);
|
||||
}
|
||||
@ -232,6 +244,8 @@ macro_rules! impl_Display {
|
||||
}
|
||||
}
|
||||
|
||||
// SAFETY: `curr` > 0 (since we made `buf` large enough), and all the chars are valid
|
||||
// UTF-8 since `DEC_DIGITS_LUT` is
|
||||
let buf_slice = unsafe {
|
||||
str::from_utf8_unchecked(
|
||||
slice::from_raw_parts(buf_ptr.offset(curr), buf.len() - curr as usize))
|
||||
@ -304,6 +318,8 @@ macro_rules! impl_Exp {
|
||||
};
|
||||
|
||||
// 39 digits (worst case u128) + . = 40
|
||||
// Since `curr` always decreases by the number of digits copied, this means
|
||||
// that `curr >= 0`.
|
||||
let mut buf = [MaybeUninit::<u8>::uninit(); 40];
|
||||
let mut curr = buf.len() as isize; //index for buf
|
||||
let buf_ptr = MaybeUninit::first_ptr_mut(&mut buf);
|
||||
@ -313,6 +329,8 @@ macro_rules! impl_Exp {
|
||||
while n >= 100 {
|
||||
let d1 = ((n % 100) as isize) << 1;
|
||||
curr -= 2;
|
||||
// SAFETY: `d1 <= 198`, so we can copy from `lut_ptr[d1..d1 + 2]` since
|
||||
// `DEC_DIGITS_LUT` has a length of 200.
|
||||
unsafe {
|
||||
ptr::copy_nonoverlapping(lut_ptr.offset(d1), buf_ptr.offset(curr), 2);
|
||||
}
|
||||
@ -324,6 +342,7 @@ macro_rules! impl_Exp {
|
||||
// decode second-to-last character
|
||||
if n >= 10 {
|
||||
curr -= 1;
|
||||
// SAFETY: Safe since `40 > curr >= 0` (see comment)
|
||||
unsafe {
|
||||
*buf_ptr.offset(curr) = (n as u8 % 10_u8) + b'0';
|
||||
}
|
||||
@ -333,11 +352,13 @@ macro_rules! impl_Exp {
|
||||
// add decimal point iff >1 mantissa digit will be printed
|
||||
if exponent != trailing_zeros || added_precision != 0 {
|
||||
curr -= 1;
|
||||
// SAFETY: Safe since `40 > curr >= 0`
|
||||
unsafe {
|
||||
*buf_ptr.offset(curr) = b'.';
|
||||
}
|
||||
}
|
||||
|
||||
// SAFETY: Safe since `40 > curr >= 0`
|
||||
let buf_slice = unsafe {
|
||||
// decode last character
|
||||
curr -= 1;
|
||||
@ -350,6 +371,8 @@ macro_rules! impl_Exp {
|
||||
// stores 'e' (or 'E') and the up to 2-digit exponent
|
||||
let mut exp_buf = [MaybeUninit::<u8>::uninit(); 3];
|
||||
let exp_ptr = MaybeUninit::first_ptr_mut(&mut exp_buf);
|
||||
// SAFETY: In either case, `exp_buf` is written within bounds and `exp_ptr[..len]`
|
||||
// is contained within `exp_buf` since `len <= 3`.
|
||||
let exp_slice = unsafe {
|
||||
*exp_ptr.offset(0) = if upper {b'E'} else {b'e'};
|
||||
let len = if exponent < 10 {
|
||||
|
@ -41,7 +41,7 @@ pub use diagnostic::{Diagnostic, Level, MultiSpan};
|
||||
use std::ops::{Bound, RangeBounds};
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::{fmt, iter, mem};
|
||||
use std::{error, fmt, iter, mem};
|
||||
|
||||
/// The main type provided by this crate, representing an abstract stream of
|
||||
/// tokens, or, more specifically, a sequence of token trees.
|
||||
@ -66,6 +66,16 @@ pub struct LexError {
|
||||
_inner: (),
|
||||
}
|
||||
|
||||
#[stable(feature = "proc_macro_lexerror_impls", since = "1.44.0")]
|
||||
impl fmt::Display for LexError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str("cannot parse string into token stream")
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "proc_macro_lexerror_impls", since = "1.44.0")]
|
||||
impl error::Error for LexError {}
|
||||
|
||||
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
|
||||
impl !Send for LexError {}
|
||||
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
|
||||
|
@ -1,3 +1,3 @@
|
||||
For more information about how rustc works, see the [rustc guide].
|
||||
For more information about how rustc works, see the [rustc dev guide].
|
||||
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/
|
||||
|
@ -1,4 +1,4 @@
|
||||
To learn more about how dependency tracking works in rustc, see the [rustc
|
||||
guide].
|
||||
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/query.html
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/query.html
|
||||
|
@ -174,7 +174,7 @@ impl DepGraph {
|
||||
/// what state they have access to. In particular, we want to
|
||||
/// prevent implicit 'leaks' of tracked state into the task (which
|
||||
/// could then be read without generating correct edges in the
|
||||
/// dep-graph -- see the [rustc guide] for more details on
|
||||
/// dep-graph -- see the [rustc dev guide] for more details on
|
||||
/// the dep-graph). To this end, the task function gets exactly two
|
||||
/// pieces of state: the context `cx` and an argument `arg`. Both
|
||||
/// of these bits of state must be of some type that implements
|
||||
@ -194,7 +194,7 @@ impl DepGraph {
|
||||
/// - If you need 3+ arguments, use a tuple for the
|
||||
/// `arg` parameter.
|
||||
///
|
||||
/// [rustc guide]: https://rust-lang.github.io/rustc-guide/incremental-compilation.html
|
||||
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/incremental-compilation.html
|
||||
pub fn with_task<'a, C, A, R>(
|
||||
&self,
|
||||
key: DepNode,
|
||||
|
@ -60,7 +60,7 @@ impl MaybeFnLike for hir::ImplItem<'_> {
|
||||
impl MaybeFnLike for hir::TraitItem<'_> {
|
||||
fn is_fn_like(&self) -> bool {
|
||||
match self.kind {
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
|
||||
hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -239,7 +239,7 @@ impl<'a> FnLikeNode<'a> {
|
||||
_ => bug!("item FnLikeNode that is not fn-like"),
|
||||
},
|
||||
Node::TraitItem(ti) => match ti.kind {
|
||||
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
|
||||
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
|
||||
method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
|
||||
}
|
||||
_ => bug!("trait method FnLikeNode that is not fn-like"),
|
||||
|
@ -51,7 +51,7 @@ impl<'hir> Entry<'hir> {
|
||||
},
|
||||
|
||||
Node::TraitItem(ref item) => match item.kind {
|
||||
TraitItemKind::Method(ref sig, _) => Some(&sig.decl),
|
||||
TraitItemKind::Fn(ref sig, _) => Some(&sig.decl),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
@ -77,7 +77,7 @@ impl<'hir> Entry<'hir> {
|
||||
},
|
||||
|
||||
Node::TraitItem(item) => match &item.kind {
|
||||
TraitItemKind::Method(sig, _) => Some(sig),
|
||||
TraitItemKind::Fn(sig, _) => Some(sig),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
@ -101,7 +101,7 @@ impl<'hir> Entry<'hir> {
|
||||
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
TraitItemKind::Const(_, Some(body))
|
||||
| TraitItemKind::Method(_, TraitMethod::Provided(body)) => Some(body),
|
||||
| TraitItemKind::Fn(_, TraitMethod::Provided(body)) => Some(body),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
@ -326,12 +326,12 @@ impl<'hir> Map<'hir> {
|
||||
},
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
TraitItemKind::Const(..) => DefKind::AssocConst,
|
||||
TraitItemKind::Method(..) => DefKind::Method,
|
||||
TraitItemKind::Fn(..) => DefKind::AssocFn,
|
||||
TraitItemKind::Type(..) => DefKind::AssocTy,
|
||||
},
|
||||
Node::ImplItem(item) => match item.kind {
|
||||
ImplItemKind::Const(..) => DefKind::AssocConst,
|
||||
ImplItemKind::Method(..) => DefKind::Method,
|
||||
ImplItemKind::Method(..) => DefKind::AssocFn,
|
||||
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
|
||||
ImplItemKind::OpaqueTy(..) => DefKind::AssocOpaqueTy,
|
||||
},
|
||||
@ -472,7 +472,7 @@ impl<'hir> Map<'hir> {
|
||||
| Node::AnonConst(_) => BodyOwnerKind::Const,
|
||||
Node::Ctor(..)
|
||||
| Node::Item(&Item { kind: ItemKind::Fn(..), .. })
|
||||
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. })
|
||||
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Fn(..), .. })
|
||||
| Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => BodyOwnerKind::Fn,
|
||||
Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => BodyOwnerKind::Static(m),
|
||||
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => BodyOwnerKind::Closure,
|
||||
@ -800,7 +800,7 @@ impl<'hir> Map<'hir> {
|
||||
_ => false,
|
||||
},
|
||||
Node::TraitItem(ti) => match ti.kind {
|
||||
TraitItemKind::Method(..) => true,
|
||||
TraitItemKind::Fn(..) => true,
|
||||
_ => false,
|
||||
},
|
||||
Node::ImplItem(ii) => match ii.kind {
|
||||
@ -1311,7 +1311,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
|
||||
Some(Node::TraitItem(ti)) => {
|
||||
let kind = match ti.kind {
|
||||
TraitItemKind::Const(..) => "assoc constant",
|
||||
TraitItemKind::Method(..) => "trait method",
|
||||
TraitItemKind::Fn(..) => "trait method",
|
||||
TraitItemKind::Type(..) => "assoc type",
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! HIR datatypes. See the [rustc guide] for more info.
|
||||
//! HIR datatypes. See the [rustc dev guide] for more info.
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/hir.html
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
|
||||
|
||||
pub mod exports;
|
||||
pub mod map;
|
||||
|
@ -17,9 +17,9 @@
|
||||
//! `instantiate_query_result` method.
|
||||
//!
|
||||
//! For a more detailed look at what is happening here, check
|
||||
//! out the [chapter in the rustc guide][c].
|
||||
//! out the [chapter in the rustc dev guide][c].
|
||||
//!
|
||||
//! [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html
|
||||
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
|
||||
|
||||
use crate::infer::MemberConstraint;
|
||||
use crate::ty::subst::GenericArg;
|
||||
|
@ -14,9 +14,9 @@
|
||||
//! (or `tcx`), which is the central context during most of
|
||||
//! compilation, containing the interners and other things.
|
||||
//!
|
||||
//! For more information about how rustc works, see the [rustc guide].
|
||||
//! For more information about how rustc works, see the [rustc dev guide].
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/
|
||||
//!
|
||||
//! # Note
|
||||
//!
|
||||
|
@ -2,9 +2,9 @@
|
||||
//! the parent links in the region hierarchy.
|
||||
//!
|
||||
//! For more information about how MIR-based region-checking works,
|
||||
//! see the [rustc guide].
|
||||
//! see the [rustc dev guide].
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/mir/borrowck.html
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/borrowck.html
|
||||
|
||||
use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
||||
use crate::ty::{self, DefIdTree, TyCtxt};
|
||||
|
@ -250,7 +250,7 @@ pub enum EvalResult {
|
||||
fn skip_stability_check_due_to_privacy(tcx: TyCtxt<'_>, mut def_id: DefId) -> bool {
|
||||
// Check if `def_id` is a trait method.
|
||||
match tcx.def_kind(def_id) {
|
||||
Some(DefKind::Method) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
|
||||
Some(DefKind::AssocFn) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
|
||||
if let ty::TraitContainer(trait_def_id) = tcx.associated_item(def_id).container {
|
||||
// Trait methods do not declare visibility (even
|
||||
// for visibility info in cstore). Use containing
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! MIR datatypes and passes. See the [rustc guide] for more info.
|
||||
//! MIR datatypes and passes. See the [rustc dev guide] for more info.
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/mir/index.html
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/index.html
|
||||
|
||||
use crate::mir::interpret::{GlobalAlloc, Scalar};
|
||||
use crate::mir::visit::MirVisitable;
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Trait Resolution. See the [rustc guide] for more information on how this works.
|
||||
//! Trait Resolution. See the [rustc dev guide] for more information on how this works.
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/resolution.html
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html
|
||||
|
||||
pub mod query;
|
||||
pub mod select;
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Candidate selection. See the [rustc guide] for more information on how this works.
|
||||
//! Candidate selection. See the [rustc dev guide] for more information on how this works.
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/resolution.html#selection
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html#selection
|
||||
|
||||
use self::EvaluationResult::*;
|
||||
|
||||
|
@ -611,7 +611,7 @@ impl<'tcx> TypeckTables<'tcx> {
|
||||
}
|
||||
|
||||
match self.type_dependent_defs().get(expr.hir_id) {
|
||||
Some(Ok((DefKind::Method, _))) => true,
|
||||
Some(Ok((DefKind::AssocFn, _))) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -916,9 +916,9 @@ pub struct FreeRegionInfo {
|
||||
/// The central data structure of the compiler. It stores references
|
||||
/// to the various **arenas** and also houses the results of the
|
||||
/// various **compiler queries** that have been performed. See the
|
||||
/// [rustc guide] for more details.
|
||||
/// [rustc dev guide] for more details.
|
||||
///
|
||||
/// [rustc guide]: https://rust-lang.github.io/rustc-guide/ty.html
|
||||
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/ty.html
|
||||
#[derive(Copy, Clone)]
|
||||
#[rustc_diagnostic_item = "TyCtxt"]
|
||||
pub struct TyCtxt<'tcx> {
|
||||
|
@ -230,7 +230,7 @@ impl AssocItem {
|
||||
pub fn def_kind(&self) -> DefKind {
|
||||
match self.kind {
|
||||
AssocKind::Const => DefKind::AssocConst,
|
||||
AssocKind::Method => DefKind::Method,
|
||||
AssocKind::Method => DefKind::AssocFn,
|
||||
AssocKind::Type => DefKind::AssocTy,
|
||||
AssocKind::OpaqueTy => DefKind::AssocOpaqueTy,
|
||||
}
|
||||
@ -2872,7 +2872,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
} else {
|
||||
match self.def_kind(def_id).expect("no def for `DefId`") {
|
||||
DefKind::AssocConst | DefKind::Method | DefKind::AssocTy => true,
|
||||
DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy => true,
|
||||
_ => false,
|
||||
}
|
||||
};
|
||||
@ -3051,7 +3051,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
/// `DefId` of the impl that the method belongs to; otherwise, returns `None`.
|
||||
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
|
||||
let item = if def_id.krate != LOCAL_CRATE {
|
||||
if let Some(DefKind::Method) = self.def_kind(def_id) {
|
||||
if let Some(DefKind::AssocFn) = self.def_kind(def_id) {
|
||||
Some(self.associated_item(def_id))
|
||||
} else {
|
||||
None
|
||||
|
@ -1,3 +1,3 @@
|
||||
For more information about how the query system works, see the [rustc guide].
|
||||
For more information about how the query system works, see the [rustc dev guide].
|
||||
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/query.html
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/query.html
|
||||
|
@ -1396,11 +1396,11 @@ pub type Region<'tcx> = &'tcx RegionKind;
|
||||
/// the inference variable is supposed to satisfy the relation
|
||||
/// *for every value of the placeholder region*. To ensure that doesn't
|
||||
/// happen, you can use `leak_check`. This is more clearly explained
|
||||
/// by the [rustc guide].
|
||||
/// by the [rustc dev guide].
|
||||
///
|
||||
/// [1]: http://smallcultfollowing.com/babysteps/blog/2013/10/29/intermingled-parameter-lists/
|
||||
/// [2]: http://smallcultfollowing.com/babysteps/blog/2013/11/04/intermingled-parameter-lists/
|
||||
/// [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/hrtb.html
|
||||
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Copy, RustcEncodable, RustcDecodable, PartialOrd, Ord)]
|
||||
pub enum RegionKind {
|
||||
/// Region bound in a type or fn declaration which will be
|
||||
|
@ -3,7 +3,7 @@ The `rustc_ast` crate contains those things concerned purely with syntax
|
||||
lexer, macro expander, and utilities for traversing ASTs.
|
||||
|
||||
For more information about how these things work in rustc, see the
|
||||
rustc guide:
|
||||
rustc dev guide:
|
||||
|
||||
- [Parsing](https://rust-lang.github.io/rustc-guide/the-parser.html)
|
||||
- [Macro Expansion](https://rust-lang.github.io/rustc-guide/macro-expansion.html)
|
||||
- [Parsing](https://rustc-dev-guide.rust-lang.org/the-parser.html)
|
||||
- [Macro Expansion](https://rustc-dev-guide.rust-lang.org/macro-expansion.html)
|
||||
|
@ -2118,14 +2118,14 @@ pub enum ImplPolarity {
|
||||
/// `impl Trait for Type`
|
||||
Positive,
|
||||
/// `impl !Trait for Type`
|
||||
Negative,
|
||||
Negative(Span),
|
||||
}
|
||||
|
||||
impl fmt::Debug for ImplPolarity {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
ImplPolarity::Positive => "positive".fmt(f),
|
||||
ImplPolarity::Negative => "negative".fmt(f),
|
||||
ImplPolarity::Negative(_) => "negative".fmt(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -761,13 +761,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let names = self.lower_fn_params_to_names(&sig.decl);
|
||||
let (generics, sig) =
|
||||
self.lower_method_sig(generics, sig, trait_item_def_id, false, None);
|
||||
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Required(names)))
|
||||
(generics, hir::TraitItemKind::Fn(sig, hir::TraitMethod::Required(names)))
|
||||
}
|
||||
AssocItemKind::Fn(_, ref sig, ref generics, Some(ref body)) => {
|
||||
let body_id = self.lower_fn_body_block(i.span, &sig.decl, Some(body));
|
||||
let (generics, sig) =
|
||||
self.lower_method_sig(generics, sig, trait_item_def_id, false, None);
|
||||
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Provided(body_id)))
|
||||
(generics, hir::TraitItemKind::Fn(sig, hir::TraitMethod::Provided(body_id)))
|
||||
}
|
||||
AssocItemKind::TyAlias(_, ref generics, ref bounds, ref default) => {
|
||||
let ty = default.as_ref().map(|x| self.lower_ty(x, ImplTraitContext::disallowed()));
|
||||
|
@ -75,7 +75,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
ParenthesizedGenericArgs::Ok
|
||||
}
|
||||
// `a::b::Trait(Args)::TraitItem`
|
||||
Res::Def(DefKind::Method, _)
|
||||
Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::AssocConst, _)
|
||||
| Res::Def(DefKind::AssocTy, _)
|
||||
if i + 2 == proj_start =>
|
||||
|
@ -9,6 +9,7 @@
|
||||
use rustc_ast::ast::*;
|
||||
use rustc_ast::attr;
|
||||
use rustc_ast::expand::is_proc_macro_attr;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
|
||||
use rustc_ast::walk_list;
|
||||
use rustc_ast_pretty::pprust;
|
||||
@ -594,6 +595,54 @@ impl<'a> AstValidator<'a> {
|
||||
.span_label(ident.span, format!("`_` is not a valid name for this `{}` item", kind))
|
||||
.emit();
|
||||
}
|
||||
|
||||
fn deny_generic_params(&self, generics: &Generics, ident_span: Span) {
|
||||
if !generics.params.is_empty() {
|
||||
struct_span_err!(
|
||||
self.session,
|
||||
generics.span,
|
||||
E0567,
|
||||
"auto traits cannot have generic parameters"
|
||||
)
|
||||
.span_label(ident_span, "auto trait cannot have generic parameters")
|
||||
.span_suggestion(
|
||||
generics.span,
|
||||
"remove the parameters",
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
||||
fn deny_super_traits(&self, bounds: &GenericBounds, ident_span: Span) {
|
||||
if let [first @ last] | [first, .., last] = &bounds[..] {
|
||||
let span = first.span().to(last.span());
|
||||
struct_span_err!(self.session, span, E0568, "auto traits cannot have super traits")
|
||||
.span_label(ident_span, "auto trait cannot have super traits")
|
||||
.span_suggestion(
|
||||
span,
|
||||
"remove the super traits",
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
||||
fn deny_items(&self, trait_items: &[P<AssocItem>], ident_span: Span) {
|
||||
if !trait_items.is_empty() {
|
||||
let spans: Vec<_> = trait_items.iter().map(|i| i.ident.span).collect();
|
||||
struct_span_err!(
|
||||
self.session,
|
||||
spans,
|
||||
E0380,
|
||||
"auto traits cannot have methods or associated items"
|
||||
)
|
||||
.span_label(ident_span, "auto trait cannot have items")
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_generic_param_order<'a>(
|
||||
@ -779,7 +828,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
defaultness: _,
|
||||
constness: _,
|
||||
generics: _,
|
||||
of_trait: Some(_),
|
||||
of_trait: Some(ref t),
|
||||
ref self_ty,
|
||||
items: _,
|
||||
} => {
|
||||
@ -794,13 +843,14 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
.help("use `auto trait Trait {}` instead")
|
||||
.emit();
|
||||
}
|
||||
if let (Unsafe::Yes(span), ImplPolarity::Negative) = (unsafety, polarity) {
|
||||
if let (Unsafe::Yes(span), ImplPolarity::Negative(sp)) = (unsafety, polarity) {
|
||||
struct_span_err!(
|
||||
this.session,
|
||||
item.span,
|
||||
sp.to(t.path.span),
|
||||
E0198,
|
||||
"negative impls cannot be unsafe"
|
||||
)
|
||||
.span_label(sp, "negative because of this")
|
||||
.span_label(span, "unsafe because of this")
|
||||
.emit();
|
||||
}
|
||||
@ -816,38 +866,36 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
constness,
|
||||
generics: _,
|
||||
of_trait: None,
|
||||
self_ty: _,
|
||||
ref self_ty,
|
||||
items: _,
|
||||
} => {
|
||||
let error = |annotation_span, annotation| {
|
||||
let mut err = self.err_handler().struct_span_err(
|
||||
self_ty.span,
|
||||
&format!("inherent impls cannot be {}", annotation),
|
||||
);
|
||||
err.span_label(annotation_span, &format!("{} because of this", annotation));
|
||||
err.span_label(self_ty.span, "inherent impl for this type");
|
||||
err
|
||||
};
|
||||
|
||||
self.invalid_visibility(
|
||||
&item.vis,
|
||||
Some("place qualifiers on individual impl items instead"),
|
||||
);
|
||||
if let Unsafe::Yes(span) = unsafety {
|
||||
struct_span_err!(
|
||||
self.session,
|
||||
item.span,
|
||||
E0197,
|
||||
"inherent impls cannot be unsafe"
|
||||
)
|
||||
.span_label(span, "unsafe because of this")
|
||||
.emit();
|
||||
error(span, "unsafe").code(error_code!(E0197)).emit();
|
||||
}
|
||||
if polarity == ImplPolarity::Negative {
|
||||
self.err_handler().span_err(item.span, "inherent impls cannot be negative");
|
||||
if let ImplPolarity::Negative(span) = polarity {
|
||||
error(span, "negative").emit();
|
||||
}
|
||||
if let Defaultness::Default(def_span) = defaultness {
|
||||
let span = self.session.source_map().def_span(item.span);
|
||||
self.err_handler()
|
||||
.struct_span_err(span, "inherent impls cannot be `default`")
|
||||
.span_label(def_span, "`default` because of this")
|
||||
error(def_span, "`default`")
|
||||
.note("only trait implementations may be annotated with `default`")
|
||||
.emit();
|
||||
}
|
||||
if let Const::Yes(span) = constness {
|
||||
self.err_handler()
|
||||
.struct_span_err(item.span, "inherent impls cannot be `const`")
|
||||
.span_label(span, "`const` because of this")
|
||||
error(span, "`const`")
|
||||
.note("only trait implementations may be annotated with `const`")
|
||||
.emit();
|
||||
}
|
||||
@ -882,33 +930,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
ItemKind::Trait(is_auto, _, ref generics, ref bounds, ref trait_items) => {
|
||||
if is_auto == IsAuto::Yes {
|
||||
// Auto traits cannot have generics, super traits nor contain items.
|
||||
if !generics.params.is_empty() {
|
||||
struct_span_err!(
|
||||
self.session,
|
||||
item.span,
|
||||
E0567,
|
||||
"auto traits cannot have generic parameters"
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
if !bounds.is_empty() {
|
||||
struct_span_err!(
|
||||
self.session,
|
||||
item.span,
|
||||
E0568,
|
||||
"auto traits cannot have super traits"
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
if !trait_items.is_empty() {
|
||||
struct_span_err!(
|
||||
self.session,
|
||||
item.span,
|
||||
E0380,
|
||||
"auto traits cannot have methods or associated items"
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
self.deny_generic_params(generics, item.ident.span);
|
||||
self.deny_super_traits(bounds, item.ident.span);
|
||||
self.deny_items(trait_items, item.ident.span);
|
||||
}
|
||||
self.no_questions_in_bounds(bounds, "supertraits", true);
|
||||
|
||||
@ -1153,9 +1177,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
}) = fk.header()
|
||||
{
|
||||
self.err_handler()
|
||||
.struct_span_err(span, "functions cannot be both `const` and `async`")
|
||||
.struct_span_err(
|
||||
vec![*cspan, *aspan],
|
||||
"functions cannot be both `const` and `async`",
|
||||
)
|
||||
.span_label(*cspan, "`const` because of this")
|
||||
.span_label(*aspan, "`async` because of this")
|
||||
.span_label(span, "") // Point at the fn header.
|
||||
.emit();
|
||||
}
|
||||
|
||||
|
@ -337,14 +337,14 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
ast::ItemKind::Impl { polarity, defaultness, .. } => {
|
||||
if polarity == ast::ImplPolarity::Negative {
|
||||
ast::ItemKind::Impl { polarity, defaultness, ref of_trait, .. } => {
|
||||
if let ast::ImplPolarity::Negative(span) = polarity {
|
||||
gate_feature_post!(
|
||||
&self,
|
||||
optin_builtin_traits,
|
||||
i.span,
|
||||
span.to(of_trait.as_ref().map(|t| t.path.span).unwrap_or(span)),
|
||||
"negative trait bounds are not yet fully implemented; \
|
||||
use marker types for now"
|
||||
use marker types for now"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![feature(bindings_after_at)]
|
||||
//! The `rustc_ast_passes` crate contains passes which validate the AST in `syntax`
|
||||
//! parsed by `rustc_parse` and then lowered, after the passes in this crate,
|
||||
//! by `rustc_ast_lowering`.
|
||||
|
@ -1160,7 +1160,7 @@ impl<'a> State<'a> {
|
||||
self.s.space();
|
||||
}
|
||||
|
||||
if polarity == ast::ImplPolarity::Negative {
|
||||
if let ast::ImplPolarity::Negative(_) = polarity {
|
||||
self.s.word("!");
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,6 @@ The `codegen` crate contains the code to convert from MIR into LLVM IR,
|
||||
and then from LLVM IR into machine code. In general it contains code
|
||||
that runs towards the end of the compilation process.
|
||||
|
||||
For more information about how codegen works, see the [rustc guide].
|
||||
For more information about how codegen works, see the [rustc dev guide].
|
||||
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/codegen.html
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/codegen.html
|
||||
|
@ -1,3 +1,3 @@
|
||||
Please read the rustc-guide chapter on [Backend Agnostic Codegen][bac].
|
||||
Please read the rustc-dev-guide chapter on [Backend Agnostic Codegen][bac].
|
||||
|
||||
[bac]: https://rust-lang.github.io/rustc-guide/codegen/backend-agnostic.html
|
||||
[bac]: https://rustc-dev-guide.rust-lang.org/codegen/backend-agnostic.html
|
||||
|
@ -5,6 +5,6 @@ not contain any of the "main logic" of the compiler (though it does
|
||||
have some code related to pretty printing or other minor compiler
|
||||
options).
|
||||
|
||||
For more information about how the driver works, see the [rustc guide].
|
||||
For more information about how the driver works, see the [rustc dev guide].
|
||||
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/rustc-driver.html
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/rustc-driver.html
|
||||
|
@ -72,7 +72,7 @@ pub enum DefKind {
|
||||
Static,
|
||||
/// Refers to the struct or enum variant's constructor.
|
||||
Ctor(CtorOf, CtorKind),
|
||||
Method,
|
||||
AssocFn,
|
||||
AssocConst,
|
||||
|
||||
// Macro namespace
|
||||
@ -107,7 +107,8 @@ impl DefKind {
|
||||
DefKind::Union => "union",
|
||||
DefKind::Trait => "trait",
|
||||
DefKind::ForeignTy => "foreign type",
|
||||
DefKind::Method => "method",
|
||||
// FIXME: Update the description to "assoc fn"
|
||||
DefKind::AssocFn => "method",
|
||||
DefKind::Const => "constant",
|
||||
DefKind::AssocConst => "associated constant",
|
||||
DefKind::TyParam => "type parameter",
|
||||
@ -150,7 +151,7 @@ impl DefKind {
|
||||
| DefKind::ConstParam
|
||||
| DefKind::Static
|
||||
| DefKind::Ctor(..)
|
||||
| DefKind::Method
|
||||
| DefKind::AssocFn
|
||||
| DefKind::AssocConst => ns == Namespace::ValueNS,
|
||||
|
||||
DefKind::Macro(..) => ns == Namespace::MacroNS,
|
||||
|
@ -609,9 +609,9 @@ pub struct ModuleItems {
|
||||
/// The top-level data structure that stores the entire contents of
|
||||
/// the crate currently being compiled.
|
||||
///
|
||||
/// For more details, see the [rustc guide].
|
||||
/// For more details, see the [rustc dev guide].
|
||||
///
|
||||
/// [rustc guide]: https://rust-lang.github.io/rustc-guide/hir.html
|
||||
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
|
||||
#[derive(RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct Crate<'hir> {
|
||||
pub module: Mod<'hir>,
|
||||
@ -1863,8 +1863,8 @@ pub enum TraitMethod<'hir> {
|
||||
pub enum TraitItemKind<'hir> {
|
||||
/// An associated constant with an optional value (otherwise `impl`s must contain a value).
|
||||
Const(&'hir Ty<'hir>, Option<BodyId>),
|
||||
/// A method with an optional body.
|
||||
Method(FnSig<'hir>, TraitMethod<'hir>),
|
||||
/// An associated function with an optional body.
|
||||
Fn(FnSig<'hir>, TraitMethod<'hir>),
|
||||
/// An associated type with (possibly empty) bounds and optional concrete
|
||||
/// type.
|
||||
Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
|
||||
@ -2699,7 +2699,7 @@ impl Node<'_> {
|
||||
|
||||
pub fn fn_decl(&self) -> Option<&FnDecl<'_>> {
|
||||
match self {
|
||||
Node::TraitItem(TraitItem { kind: TraitItemKind::Method(fn_sig, _), .. })
|
||||
Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
|
||||
| Node::ImplItem(ImplItem { kind: ImplItemKind::Method(fn_sig, _), .. })
|
||||
| Node::Item(Item { kind: ItemKind::Fn(fn_sig, _, _), .. }) => Some(fn_sig.decl),
|
||||
Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_decl, _, _), .. }) => {
|
||||
|
@ -911,14 +911,14 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
||||
visitor.visit_ty(ty);
|
||||
walk_list!(visitor, visit_nested_body, default);
|
||||
}
|
||||
TraitItemKind::Method(ref sig, TraitMethod::Required(param_names)) => {
|
||||
TraitItemKind::Fn(ref sig, TraitMethod::Required(param_names)) => {
|
||||
visitor.visit_id(trait_item.hir_id);
|
||||
visitor.visit_fn_decl(&sig.decl);
|
||||
for ¶m_name in param_names {
|
||||
visitor.visit_ident(param_name);
|
||||
}
|
||||
}
|
||||
TraitItemKind::Method(ref sig, TraitMethod::Provided(body_id)) => {
|
||||
TraitItemKind::Fn(ref sig, TraitMethod::Provided(body_id)) => {
|
||||
visitor.visit_fn(
|
||||
FnKind::Method(trait_item.ident, sig, None, &trait_item.attrs),
|
||||
&sig.decl,
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! HIR datatypes. See the [rustc guide] for more info.
|
||||
//! HIR datatypes. See the [rustc dev guide] for more info.
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/hir.html
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
|
||||
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(const_fn)] // For the unsizing cast on `&[]`
|
||||
|
@ -652,7 +652,7 @@ impl<'a> State<'a> {
|
||||
self.word_nbsp("const");
|
||||
}
|
||||
|
||||
if let hir::ImplPolarity::Negative = polarity {
|
||||
if let hir::ImplPolarity::Negative(_) = polarity {
|
||||
self.s.word("!");
|
||||
}
|
||||
|
||||
@ -886,13 +886,13 @@ impl<'a> State<'a> {
|
||||
Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited };
|
||||
self.print_associated_const(ti.ident, &ty, default, &vis);
|
||||
}
|
||||
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(ref arg_names)) => {
|
||||
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Required(ref arg_names)) => {
|
||||
let vis =
|
||||
Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited };
|
||||
self.print_method_sig(ti.ident, sig, &ti.generics, &vis, arg_names, None);
|
||||
self.s.word(";");
|
||||
}
|
||||
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
|
||||
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
|
||||
let vis =
|
||||
Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited };
|
||||
self.head("");
|
||||
|
@ -105,10 +105,10 @@ impl Target {
|
||||
pub fn from_trait_item(trait_item: &TraitItem<'_>) -> Target {
|
||||
match trait_item.kind {
|
||||
TraitItemKind::Const(..) => Target::AssocConst,
|
||||
TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => {
|
||||
TraitItemKind::Fn(_, hir::TraitMethod::Required(_)) => {
|
||||
Target::Method(MethodKind::Trait { body: false })
|
||||
}
|
||||
TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => {
|
||||
TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => {
|
||||
Target::Method(MethodKind::Trait { body: true })
|
||||
}
|
||||
TraitItemKind::Type(..) => Target::AssocTy,
|
||||
|
@ -1,3 +1,3 @@
|
||||
For info on how the incremental compilation works, see the [rustc guide].
|
||||
For info on how the incremental compilation works, see the [rustc dev guide].
|
||||
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/query.html
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/query.html
|
||||
|
@ -328,7 +328,7 @@ impl DirtyCleanVisitor<'tcx> {
|
||||
}
|
||||
}
|
||||
HirNode::TraitItem(item) => match item.kind {
|
||||
TraitItemKind::Method(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT),
|
||||
TraitItemKind::Fn(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT),
|
||||
TraitItemKind::Const(..) => ("NodeTraitConst", LABELS_CONST_IN_TRAIT),
|
||||
TraitItemKind::Type(..) => ("NodeTraitType", LABELS_CONST_IN_TRAIT),
|
||||
},
|
||||
|
@ -1,9 +1,9 @@
|
||||
//! This module contains the "canonicalizer" itself.
|
||||
//!
|
||||
//! For an overview of what canonicalization is and how it fits into
|
||||
//! rustc, check out the [chapter in the rustc guide][c].
|
||||
//! rustc, check out the [chapter in the rustc dev guide][c].
|
||||
//!
|
||||
//! [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html
|
||||
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
|
||||
|
||||
use crate::infer::canonical::{
|
||||
Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, Canonicalized,
|
||||
@ -33,9 +33,9 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||
/// with a mapping M that maps `'?0` to `'static`.
|
||||
///
|
||||
/// To get a good understanding of what is happening here, check
|
||||
/// out the [chapter in the rustc guide][c].
|
||||
/// out the [chapter in the rustc dev guide][c].
|
||||
///
|
||||
/// [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html#canonicalizing-the-query
|
||||
/// [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html#canonicalizing-the-query
|
||||
pub fn canonicalize_query<V>(
|
||||
&self,
|
||||
value: &V,
|
||||
@ -77,9 +77,9 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||
/// reference to `'static` alone.
|
||||
///
|
||||
/// To get a good understanding of what is happening here, check
|
||||
/// out the [chapter in the rustc guide][c].
|
||||
/// out the [chapter in the rustc dev guide][c].
|
||||
///
|
||||
/// [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html#canonicalizing-the-query-result
|
||||
/// [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html#canonicalizing-the-query-result
|
||||
pub fn canonicalize_response<V>(&self, value: &V) -> Canonicalized<'tcx, V>
|
||||
where
|
||||
V: TypeFoldable<'tcx>,
|
||||
|
@ -17,9 +17,9 @@
|
||||
//! `instantiate_query_result` method.
|
||||
//!
|
||||
//! For a more detailed look at what is happening here, check
|
||||
//! out the [chapter in the rustc guide][c].
|
||||
//! out the [chapter in the rustc dev guide][c].
|
||||
//!
|
||||
//! [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html
|
||||
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
|
||||
|
||||
use crate::infer::{ConstVariableOrigin, ConstVariableOriginKind};
|
||||
use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin, TypeVariableOriginKind};
|
||||
|
@ -3,9 +3,9 @@
|
||||
//! encode them therein.
|
||||
//!
|
||||
//! For an overview of what canonicaliation is and how it fits into
|
||||
//! rustc, check out the [chapter in the rustc guide][c].
|
||||
//! rustc, check out the [chapter in the rustc dev guide][c].
|
||||
//!
|
||||
//! [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html
|
||||
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
|
||||
|
||||
use crate::infer::canonical::substitute::{substitute_value, CanonicalExt};
|
||||
use crate::infer::canonical::{
|
||||
@ -196,9 +196,9 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||
/// the query before applying this function.)
|
||||
///
|
||||
/// To get a good understanding of what is happening here, check
|
||||
/// out the [chapter in the rustc guide][c].
|
||||
/// out the [chapter in the rustc dev guide][c].
|
||||
///
|
||||
/// [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html#processing-the-canonicalized-query-result
|
||||
/// [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html#processing-the-canonicalized-query-result
|
||||
pub fn instantiate_query_response_and_region_obligations<R>(
|
||||
&self,
|
||||
cause: &ObligationCause<'tcx>,
|
||||
|
@ -2,9 +2,9 @@
|
||||
//! `Canonical<'tcx, T>`.
|
||||
//!
|
||||
//! For an overview of what canonicalization is and how it fits into
|
||||
//! rustc, check out the [chapter in the rustc guide][c].
|
||||
//! rustc, check out the [chapter in the rustc dev guide][c].
|
||||
//!
|
||||
//! [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html
|
||||
//! [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
|
||||
|
||||
use crate::infer::canonical::{Canonical, CanonicalVarValues};
|
||||
use rustc::ty::fold::TypeFoldable;
|
||||
|
@ -269,7 +269,7 @@ fn item_scope_tag(item: &hir::Item<'_>) -> &'static str {
|
||||
|
||||
fn trait_item_scope_tag(item: &hir::TraitItem<'_>) -> &'static str {
|
||||
match item.kind {
|
||||
hir::TraitItemKind::Method(..) => "method body",
|
||||
hir::TraitItemKind::Fn(..) => "method body",
|
||||
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => "associated item",
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
&segment.args,
|
||||
) {
|
||||
let borrow = tables.borrow();
|
||||
if let Some((DefKind::Method, did)) = borrow.type_dependent_def(e.hir_id) {
|
||||
if let Some((DefKind::AssocFn, did)) = borrow.type_dependent_def(e.hir_id) {
|
||||
let generics = self.tcx.generics_of(did);
|
||||
if !generics.params.is_empty() {
|
||||
err.span_suggestion(
|
||||
|
@ -33,7 +33,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
let fndecl = match self.tcx().hir().get(hir_id) {
|
||||
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(ref m, ..), .. })
|
||||
| Node::TraitItem(&hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Method(ref m, ..),
|
||||
kind: hir::TraitItemKind::Fn(ref m, ..),
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(&hir::ImplItem {
|
||||
|
@ -1,8 +1,8 @@
|
||||
To learn more about how Higher-ranked trait bounds work in the _old_ trait
|
||||
solver, see [this chapter][oldhrtb] of the rustc-guide.
|
||||
solver, see [this chapter][oldhrtb] of the rustc-dev-guide.
|
||||
|
||||
To learn more about how they work in the _new_ trait solver, see [this
|
||||
chapter][newhrtb].
|
||||
|
||||
[oldhrtb]: https://rust-lang.github.io/rustc-guide/traits/hrtb.html
|
||||
[newhrtb]: https://rust-lang.github.io/rustc-guide/borrow_check/region_inference.html#placeholders-and-universes
|
||||
[oldhrtb]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
|
||||
[newhrtb]: https://rustc-dev-guide.rust-lang.org/borrow_check/region_inference.html#placeholders-and-universes
|
||||
|
@ -71,9 +71,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
/// needed (but is also permitted).
|
||||
///
|
||||
/// For more information about how placeholders and HRTBs work, see
|
||||
/// the [rustc guide].
|
||||
/// the [rustc dev guide].
|
||||
///
|
||||
/// [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/hrtb.html
|
||||
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
|
||||
pub fn replace_bound_vars_with_placeholders<T>(
|
||||
&self,
|
||||
binder: &ty::Binder<T>,
|
||||
|
@ -2,6 +2,6 @@
|
||||
Lexical Region Resolution was removed in https://github.com/rust-lang/rust/pull/64790.
|
||||
|
||||
Rust now uses Non-lexical lifetimes. For more info, please see the [borrowck
|
||||
chapter][bc] in the rustc-guide.
|
||||
chapter][bc] in the rustc-dev-guide.
|
||||
|
||||
[bc]: https://rust-lang.github.io/rustc-guide/borrow_check/region_inference.html
|
||||
[bc]: https://rustc-dev-guide.rust-lang.org/borrow_check/region_inference.html
|
||||
|
@ -1,3 +1,3 @@
|
||||
For info on how the current borrowck works, see the [rustc guide].
|
||||
For info on how the current borrowck works, see the [rustc dev guide].
|
||||
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/borrow_check.html
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html
|
||||
|
@ -5,9 +5,9 @@
|
||||
//! this code handles low-level equality and subtyping operations. The
|
||||
//! type check pass in the compiler is found in the `librustc_typeck` crate.
|
||||
//!
|
||||
//! For more information about how rustc works, see the [rustc guide].
|
||||
//! For more information about how rustc works, see the [rustc dev guide].
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/
|
||||
//!
|
||||
//! # Note
|
||||
//!
|
||||
|
@ -1,8 +1,8 @@
|
||||
//! See Rustc Guide chapters on [trait-resolution] and [trait-specialization] for more info on how
|
||||
//! this works.
|
||||
//! See Rustc Dev Guide chapters on [trait-resolution] and [trait-specialization] for more info on
|
||||
//! how this works.
|
||||
//!
|
||||
//! [trait-resolution]: https://rust-lang.github.io/rustc-guide/traits/resolution.html
|
||||
//! [trait-specialization]: https://rust-lang.github.io/rustc-guide/traits/specialization.html
|
||||
//! [trait-resolution]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html
|
||||
//! [trait-specialization]: https://rustc-dev-guide.rust-lang.org/traits/specialization.html
|
||||
|
||||
use crate::infer::{CombinedSnapshot, InferOk, TyCtxtInferExt};
|
||||
use crate::traits::select::IntercrateAmbiguityCause;
|
||||
|
@ -70,7 +70,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
})
|
||||
}
|
||||
hir::Node::TraitItem(hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)),
|
||||
kind: hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(body_id)),
|
||||
..
|
||||
}) => self.describe_generator(*body_id).or_else(|| Some("a trait method")),
|
||||
hir::Node::ImplItem(hir::ImplItem {
|
||||
|
@ -62,7 +62,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
match node {
|
||||
hir::Node::TraitItem(hir::TraitItem {
|
||||
generics,
|
||||
kind: hir::TraitItemKind::Method(..),
|
||||
kind: hir::TraitItemKind::Fn(..),
|
||||
..
|
||||
}) if param_ty && self_ty == self.tcx.types.self_param => {
|
||||
// Restricting `Self` for a single method.
|
||||
@ -73,7 +73,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. })
|
||||
| hir::Node::TraitItem(hir::TraitItem {
|
||||
generics,
|
||||
kind: hir::TraitItemKind::Method(..),
|
||||
kind: hir::TraitItemKind::Fn(..),
|
||||
..
|
||||
})
|
||||
| hir::Node::ImplItem(hir::ImplItem {
|
||||
@ -803,7 +803,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
})
|
||||
| Node::TraitItem(&hir::TraitItem {
|
||||
span,
|
||||
kind: hir::TraitItemKind::Method(ref sig, _),
|
||||
kind: hir::TraitItemKind::Fn(ref sig, _),
|
||||
..
|
||||
}) => (
|
||||
self.tcx.sess.source_map().def_span(span),
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Trait Resolution. See the [rustc guide] for more information on how this works.
|
||||
//! Trait Resolution. See the [rustc dev guide] for more information on how this works.
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/resolution.html
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub mod auto_trait;
|
||||
|
@ -44,7 +44,7 @@ pub trait TypeOp<'tcx>: Sized + fmt::Debug {
|
||||
/// first canonicalize the key and then invoke the query on the tcx,
|
||||
/// which produces the resulting query region constraints.
|
||||
///
|
||||
/// [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html
|
||||
/// [c]: https://rustc-dev-guide.rust-lang.org/traits/canonicalization.html
|
||||
pub trait QueryTypeOp<'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + 'tcx {
|
||||
type QueryResponse: TypeFoldable<'tcx>;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
// ignore-tidy-filelength
|
||||
|
||||
//! Candidate selection. See the [rustc guide] for more information on how this works.
|
||||
//! Candidate selection. See the [rustc dev guide] for more information on how this works.
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/resolution.html#selection
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html#selection
|
||||
|
||||
use self::EvaluationResult::*;
|
||||
use self::SelectionCandidate::*;
|
||||
@ -931,10 +931,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
//
|
||||
// The selection process begins by examining all in-scope impls,
|
||||
// caller obligations, and so forth and assembling a list of
|
||||
// candidates. See the [rustc guide] for more details.
|
||||
// candidates. See the [rustc dev guide] for more details.
|
||||
//
|
||||
// [rustc guide]:
|
||||
// https://rust-lang.github.io/rustc-guide/traits/resolution.html#candidate-assembly
|
||||
// [rustc dev guide]:
|
||||
// https://rustc-dev-guide.rust-lang.org/traits/resolution.html#candidate-assembly
|
||||
|
||||
fn candidate_from_obligation<'o>(
|
||||
&mut self,
|
||||
@ -2447,10 +2447,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
//
|
||||
// Confirmation unifies the output type parameters of the trait
|
||||
// with the values found in the obligation, possibly yielding a
|
||||
// type error. See the [rustc guide] for more details.
|
||||
// type error. See the [rustc dev guide] for more details.
|
||||
//
|
||||
// [rustc guide]:
|
||||
// https://rust-lang.github.io/rustc-guide/traits/resolution.html#confirmation
|
||||
// [rustc dev guide]:
|
||||
// https://rustc-dev-guide.rust-lang.org/traits/resolution.html#confirmation
|
||||
|
||||
fn confirm_candidate(
|
||||
&mut self,
|
||||
|
@ -4,10 +4,10 @@
|
||||
//! At the moment, this implementation support only the simple "chain" rule:
|
||||
//! If any two impls overlap, one must be a strict subset of the other.
|
||||
//!
|
||||
//! See the [rustc guide] for a bit more detail on how specialization
|
||||
//! See the [rustc dev guide] for a bit more detail on how specialization
|
||||
//! fits together with the rest of the trait machinery.
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/specialization.html
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/specialization.html
|
||||
|
||||
pub mod specialization_graph;
|
||||
use specialization_graph::GraphExt;
|
||||
|
@ -465,7 +465,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
|
||||
let desc = match trait_item.kind {
|
||||
hir::TraitItemKind::Const(..) => "an associated constant",
|
||||
hir::TraitItemKind::Method(..) => "a trait method",
|
||||
hir::TraitItemKind::Fn(..) => "a trait method",
|
||||
hir::TraitItemKind::Type(..) => "an associated type",
|
||||
};
|
||||
|
||||
|
@ -343,7 +343,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem<'_>) {
|
||||
if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = item.kind {
|
||||
if let hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(pnames)) = item.kind {
|
||||
self.check_snake_case(cx, "trait method", &item.ident);
|
||||
for param_name in pnames {
|
||||
self.check_snake_case(cx, "variable", param_name);
|
||||
|
@ -54,7 +54,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
||||
match callee.kind {
|
||||
hir::ExprKind::Path(ref qpath) => {
|
||||
match cx.tables.qpath_res(qpath, callee.hir_id) {
|
||||
Res::Def(DefKind::Fn, def_id) | Res::Def(DefKind::Method, def_id) => {
|
||||
Res::Def(DefKind::Fn, def_id) | Res::Def(DefKind::AssocFn, def_id) => {
|
||||
Some(def_id)
|
||||
}
|
||||
// `Res::Local` if it was a closure, for which we
|
||||
|
@ -505,7 +505,7 @@ impl EntryKind {
|
||||
EntryKind::Struct(_, _) => DefKind::Struct,
|
||||
EntryKind::Union(_, _) => DefKind::Union,
|
||||
EntryKind::Fn(_) | EntryKind::ForeignFn(_) => DefKind::Fn,
|
||||
EntryKind::Method(_) => DefKind::Method,
|
||||
EntryKind::Method(_) => DefKind::AssocFn,
|
||||
EntryKind::Type => DefKind::TyAlias,
|
||||
EntryKind::TypeParam => DefKind::TyParam,
|
||||
EntryKind::ConstParam => DefKind::ConstParam,
|
||||
|
@ -805,7 +805,7 @@ impl EncodeContext<'tcx> {
|
||||
)
|
||||
}
|
||||
ty::AssocKind::Method => {
|
||||
let fn_data = if let hir::TraitItemKind::Method(m_sig, m) = &ast_item.kind {
|
||||
let fn_data = if let hir::TraitItemKind::Fn(m_sig, m) = &ast_item.kind {
|
||||
let param_names = match *m {
|
||||
hir::TraitMethod::Required(ref names) => {
|
||||
self.encode_fn_param_names(names)
|
||||
|
@ -480,7 +480,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
}))
|
||||
| Some(hir::Node::TraitItem(hir::TraitItem {
|
||||
ident,
|
||||
kind: hir::TraitItemKind::Method(sig, _),
|
||||
kind: hir::TraitItemKind::Fn(sig, _),
|
||||
..
|
||||
}))
|
||||
| Some(hir::Node::ImplItem(hir::ImplItem {
|
||||
@ -522,7 +522,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
hir::Node::Item(hir::Item { ident, kind: hir::ItemKind::Fn(sig, ..), .. })
|
||||
| hir::Node::TraitItem(hir::TraitItem {
|
||||
ident,
|
||||
kind: hir::TraitItemKind::Method(sig, _),
|
||||
kind: hir::TraitItemKind::Fn(sig, _),
|
||||
..
|
||||
})
|
||||
| hir::Node::ImplItem(hir::ImplItem {
|
||||
|
@ -103,6 +103,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
self.write_scalar(location.ptr, dest)?;
|
||||
}
|
||||
|
||||
sym::abort => {
|
||||
M::abort(self)?;
|
||||
}
|
||||
|
||||
sym::min_align_of
|
||||
| sym::pref_align_of
|
||||
| sym::needs_drop
|
||||
|
@ -169,6 +169,11 @@ pub trait Machine<'mir, 'tcx>: Sized {
|
||||
unwind: Option<mir::BasicBlock>,
|
||||
) -> InterpResult<'tcx>;
|
||||
|
||||
/// Called to evaluate `Abort` MIR terminator.
|
||||
fn abort(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx, !> {
|
||||
throw_unsup_format!("aborting execution is not supported");
|
||||
}
|
||||
|
||||
/// Called for all binary operations where the LHS has pointer type.
|
||||
///
|
||||
/// Returns a (value, overflowed) pair if the operation succeeded
|
||||
|
@ -99,6 +99,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
}
|
||||
}
|
||||
|
||||
Abort => {
|
||||
M::abort(self)?;
|
||||
}
|
||||
|
||||
// When we encounter Resume, we've finished unwinding
|
||||
// cleanup for the current stack frame. We pop it in order
|
||||
// to continue unwinding the next frame
|
||||
@ -114,15 +118,13 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
Unreachable => throw_ub!(Unreachable),
|
||||
|
||||
// These should never occur for MIR we actually run.
|
||||
DropAndReplace { .. } | FalseEdges { .. } | FalseUnwind { .. } => {
|
||||
DropAndReplace { .. }
|
||||
| FalseEdges { .. }
|
||||
| FalseUnwind { .. }
|
||||
| Yield { .. }
|
||||
| GeneratorDrop => {
|
||||
bug!("{:#?} should have been eliminated by MIR pass", terminator.kind)
|
||||
}
|
||||
|
||||
// These are not (yet) supported. It is unclear if they even can occur in
|
||||
// MIR that we actually run.
|
||||
Yield { .. } | GeneratorDrop | Abort => {
|
||||
throw_unsup_format!("Unsupported terminator kind: {:#?}", terminator.kind)
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -545,7 +545,7 @@ fn write_mir_sig(
|
||||
trace!("write_mir_sig: {:?}", src.instance);
|
||||
let kind = tcx.def_kind(src.def_id());
|
||||
let is_function = match kind {
|
||||
Some(DefKind::Fn) | Some(DefKind::Method) | Some(DefKind::Ctor(..)) => true,
|
||||
Some(DefKind::Fn) | Some(DefKind::AssocFn) | Some(DefKind::Ctor(..)) => true,
|
||||
_ => tcx.is_closure(src.def_id()),
|
||||
};
|
||||
match (kind, src.promoted) {
|
||||
|
@ -44,7 +44,7 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {
|
||||
})
|
||||
| Node::TraitItem(hir::TraitItem {
|
||||
kind:
|
||||
hir::TraitItemKind::Method(hir::FnSig { decl, .. }, hir::TraitMethod::Provided(body_id)),
|
||||
hir::TraitItemKind::Fn(hir::FnSig { decl, .. }, hir::TraitMethod::Provided(body_id)),
|
||||
..
|
||||
}) => (*body_id, decl.output.span()),
|
||||
Node::Item(hir::Item { kind: hir::ItemKind::Static(ty, _, body_id), .. })
|
||||
|
@ -600,7 +600,7 @@ fn user_substs_applied_to_res<'tcx>(
|
||||
// a tuple-struct or tuple-variant. This has the type of a
|
||||
// `Fn` but with the user-given substitutions.
|
||||
Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
|
||||
| Res::Def(DefKind::Const, _)
|
||||
| Res::Def(DefKind::AssocConst, _) => {
|
||||
@ -703,7 +703,7 @@ fn convert_path_expr<'a, 'tcx>(
|
||||
match res {
|
||||
// A regular function, constructor function or a constant.
|
||||
Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
|
||||
| Res::SelfCtor(..) => {
|
||||
let user_ty = user_substs_applied_to_res(cx, expr.hir_id, res);
|
||||
|
@ -373,6 +373,16 @@ impl<'a> Parser<'a> {
|
||||
self.token.is_keyword(kw::Async) && self.is_keyword_ahead(1, &[kw::Fn])
|
||||
}
|
||||
|
||||
fn parse_polarity(&mut self) -> ast::ImplPolarity {
|
||||
// Disambiguate `impl !Trait for Type { ... }` and `impl ! { ... }` for the never type.
|
||||
if self.check(&token::Not) && self.look_ahead(1, |t| t.can_begin_type()) {
|
||||
self.bump(); // `!`
|
||||
ast::ImplPolarity::Negative(self.prev_token.span)
|
||||
} else {
|
||||
ast::ImplPolarity::Positive
|
||||
}
|
||||
}
|
||||
|
||||
/// Parses an implementation item.
|
||||
///
|
||||
/// ```
|
||||
@ -411,13 +421,7 @@ impl<'a> Parser<'a> {
|
||||
self.sess.gated_spans.gate(sym::const_trait_impl, span);
|
||||
}
|
||||
|
||||
// Disambiguate `impl !Trait for Type { ... }` and `impl ! { ... }` for the never type.
|
||||
let polarity = if self.check(&token::Not) && self.look_ahead(1, |t| t.can_begin_type()) {
|
||||
self.bump(); // `!`
|
||||
ast::ImplPolarity::Negative
|
||||
} else {
|
||||
ast::ImplPolarity::Positive
|
||||
};
|
||||
let polarity = self.parse_polarity();
|
||||
|
||||
// Parse both types and traits as a type, then reinterpret if necessary.
|
||||
let err_path = |span| ast::Path::from_ident(Ident::new(kw::Invalid, span));
|
||||
|
@ -391,7 +391,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
|
||||
let trait_item = self.krate.trait_item(trait_item_ref.id);
|
||||
match trait_item.kind {
|
||||
hir::TraitItemKind::Const(_, Some(_))
|
||||
| hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => {
|
||||
| hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => {
|
||||
if has_allow_dead_code_or_lang_attr(
|
||||
self.tcx,
|
||||
trait_item.hir_id,
|
||||
@ -682,11 +682,11 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
||||
match trait_item.kind {
|
||||
hir::TraitItemKind::Const(_, Some(body_id))
|
||||
| hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)) => {
|
||||
| hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(body_id)) => {
|
||||
self.visit_nested_body(body_id)
|
||||
}
|
||||
hir::TraitItemKind::Const(_, None)
|
||||
| hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_))
|
||||
| hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(_))
|
||||
| hir::TraitItemKind::Type(..) => {}
|
||||
}
|
||||
}
|
||||
|
@ -162,8 +162,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
},
|
||||
Some(Node::TraitItem(trait_method)) => match trait_method.kind {
|
||||
hir::TraitItemKind::Const(_, ref default) => default.is_some(),
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_))
|
||||
hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => true,
|
||||
hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(_))
|
||||
| hir::TraitItemKind::Type(..) => false,
|
||||
},
|
||||
Some(Node::ImplItem(impl_item)) => {
|
||||
@ -278,11 +278,11 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
Node::TraitItem(trait_method) => {
|
||||
match trait_method.kind {
|
||||
hir::TraitItemKind::Const(_, None)
|
||||
| hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => {
|
||||
| hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(_)) => {
|
||||
// Keep going, nothing to get exported
|
||||
}
|
||||
hir::TraitItemKind::Const(_, Some(body_id))
|
||||
| hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)) => {
|
||||
| hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(body_id)) => {
|
||||
self.visit_nested_body(body_id);
|
||||
}
|
||||
hir::TraitItemKind::Type(..) => {}
|
||||
|
@ -2,9 +2,9 @@
|
||||
//! the parent links in the region hierarchy.
|
||||
//!
|
||||
//! For more information about how MIR-based region-checking works,
|
||||
//! see the [rustc guide].
|
||||
//! see the [rustc dev guide].
|
||||
//!
|
||||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/borrow_check.html
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html
|
||||
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::middle::region::*;
|
||||
|
@ -620,7 +620,7 @@ impl EmbargoVisitor<'tcx> {
|
||||
| DefKind::ForeignTy
|
||||
| DefKind::Fn
|
||||
| DefKind::OpaqueTy
|
||||
| DefKind::Method
|
||||
| DefKind::AssocFn
|
||||
| DefKind::Trait
|
||||
| DefKind::TyParam
|
||||
| DefKind::Variant => (),
|
||||
@ -1298,7 +1298,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
|
||||
_ => None,
|
||||
};
|
||||
let def = def.filter(|(kind, _)| match kind {
|
||||
DefKind::Method
|
||||
DefKind::AssocFn
|
||||
| DefKind::AssocConst
|
||||
| DefKind::AssocTy
|
||||
| DefKind::AssocOpaqueTy
|
||||
|
@ -874,7 +874,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||
| Res::PrimTy(..)
|
||||
| Res::ToolMod => self.r.define(parent, ident, TypeNS, (res, vis, span, expansion)),
|
||||
Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Static, _)
|
||||
| Res::Def(DefKind::Const, _)
|
||||
| Res::Def(DefKind::AssocConst, _)
|
||||
@ -898,7 +898,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||
let field_names = cstore.struct_field_names_untracked(def_id, self.r.session);
|
||||
self.insert_field_names(def_id, field_names);
|
||||
}
|
||||
Res::Def(DefKind::Method, def_id) => {
|
||||
Res::Def(DefKind::AssocFn, def_id) => {
|
||||
if cstore.associated_item_cloned_untracked(def_id).method_has_self_argument {
|
||||
self.r.has_self.insert(def_id);
|
||||
}
|
||||
@ -1243,7 +1243,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
||||
if sig.decl.has_self() {
|
||||
self.r.has_self.insert(item_def_id);
|
||||
}
|
||||
(Res::Def(DefKind::Method, item_def_id), ValueNS)
|
||||
(Res::Def(DefKind::AssocFn, item_def_id), ValueNS)
|
||||
}
|
||||
AssocItemKind::TyAlias(..) => (Res::Def(DefKind::AssocTy, item_def_id), TypeNS),
|
||||
AssocItemKind::Macro(_) => bug!(), // handled above
|
||||
|
@ -266,7 +266,7 @@ impl<'a> PathSource<'a> {
|
||||
| Res::Def(DefKind::Static, _)
|
||||
| Res::Local(..)
|
||||
| Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::AssocConst, _)
|
||||
| Res::SelfCtor(..)
|
||||
| Res::Def(DefKind::ConstParam, _) => true,
|
||||
@ -293,7 +293,7 @@ impl<'a> PathSource<'a> {
|
||||
_ => false,
|
||||
},
|
||||
PathSource::TraitItem(ns) => match res {
|
||||
Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::Method, _)
|
||||
Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::AssocFn, _)
|
||||
if ns == ValueNS =>
|
||||
{
|
||||
true
|
||||
|
@ -124,7 +124,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
|
||||
.unwrap_or(false)
|
||||
}
|
||||
Res::Def(DefKind::Ctor(..), _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Const, _)
|
||||
| Res::Def(DefKind::AssocConst, _)
|
||||
| Res::SelfCtor(_)
|
||||
|
@ -713,7 +713,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
use self::hir::TraitItemKind::*;
|
||||
self.missing_named_lifetime_spots.push((&trait_item.generics).into());
|
||||
match trait_item.kind {
|
||||
Method(ref sig, _) => {
|
||||
Fn(ref sig, _) => {
|
||||
let tcx = self.tcx;
|
||||
self.visit_early_late(
|
||||
Some(tcx.hir().get_parent_item(trait_item.hir_id)),
|
||||
@ -1816,8 +1816,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
match self.tcx.hir().get(fn_id) {
|
||||
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(..), .. })
|
||||
| Node::TraitItem(&hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Method(..),
|
||||
..
|
||||
kind: hir::TraitItemKind::Fn(..), ..
|
||||
})
|
||||
| Node::ImplItem(&hir::ImplItem {
|
||||
kind: hir::ImplItemKind::Method(..), ..
|
||||
@ -2093,9 +2092,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
// `fn` definitions and methods.
|
||||
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(.., body), .. }) => Some(body),
|
||||
|
||||
Node::TraitItem(&hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Method(_, ref m), ..
|
||||
}) => {
|
||||
Node::TraitItem(&hir::TraitItem { kind: hir::TraitItemKind::Fn(_, ref m), .. }) => {
|
||||
if let hir::ItemKind::Trait(.., ref trait_items) =
|
||||
self.tcx.hir().expect_item(self.tcx.hir().get_parent_item(parent)).kind
|
||||
{
|
||||
|
@ -741,7 +741,7 @@ impl<'a> NameBinding<'a> {
|
||||
fn is_importable(&self) -> bool {
|
||||
match self.res() {
|
||||
Res::Def(DefKind::AssocConst, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::AssocTy, _) => false,
|
||||
_ => true,
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||
| Res::Def(HirDefKind::Ctor(..), _) => {
|
||||
Some(Ref { kind: RefKind::Variable, span, ref_id: id_from_def_id(res.def_id()) })
|
||||
}
|
||||
Res::Def(HirDefKind::Method, decl_id) => {
|
||||
Res::Def(HirDefKind::AssocFn, decl_id) => {
|
||||
let def_id = if decl_id.is_local() {
|
||||
let ti = self.tcx.associated_item(decl_id);
|
||||
|
||||
|
@ -519,7 +519,7 @@ impl Sig for ast::Item {
|
||||
text.push(' ');
|
||||
|
||||
let trait_sig = if let Some(ref t) = *of_trait {
|
||||
if polarity == ast::ImplPolarity::Negative {
|
||||
if let ast::ImplPolarity::Negative(_) = polarity {
|
||||
text.push('!');
|
||||
}
|
||||
let trait_sig = t.path.make(offset + text.len(), id, scx)?;
|
||||
|
@ -120,6 +120,7 @@ symbols! {
|
||||
abi_unadjusted,
|
||||
abi_vectorcall,
|
||||
abi_x86_interrupt,
|
||||
abort,
|
||||
aborts,
|
||||
address,
|
||||
add_with_overflow,
|
||||
|
@ -1,6 +1,6 @@
|
||||
`librustc_target` contains some very low-level details that are
|
||||
specific to different compilation targets and so forth.
|
||||
|
||||
For more information about how rustc works, see the [rustc guide].
|
||||
For more information about how rustc works, see the [rustc dev guide].
|
||||
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/
|
||||
|
@ -185,7 +185,7 @@ crate fn environment(tcx: TyCtxt<'_>, def_id: DefId) -> Environment<'_> {
|
||||
|
||||
let node_kind = match node {
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
TraitItemKind::Method(..) => NodeKind::Fn,
|
||||
TraitItemKind::Fn(..) => NodeKind::Fn,
|
||||
_ => NodeKind::Other,
|
||||
},
|
||||
|
||||
|
@ -108,13 +108,13 @@ impl<'tcx> Lower<PolyDomainGoal<'tcx>> for ty::Predicate<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Used for implied bounds related rules (see rustc guide).
|
||||
/// Used for implied bounds related rules (see rustc dev guide).
|
||||
trait IntoFromEnvGoal {
|
||||
/// Transforms an existing goal into a `FromEnv` goal.
|
||||
fn into_from_env_goal(self) -> Self;
|
||||
}
|
||||
|
||||
/// Used for well-formedness related rules (see rustc guide).
|
||||
/// Used for well-formedness related rules (see rustc dev guide).
|
||||
trait IntoWellFormedGoal {
|
||||
/// Transforms an existing goal into a `WellFormed` goal.
|
||||
fn into_well_formed_goal(self) -> Self;
|
||||
@ -178,7 +178,7 @@ crate fn program_clauses_for(tcx: TyCtxt<'_>, def_id: DefId) -> Clauses<'_> {
|
||||
fn program_clauses_for_trait(tcx: TyCtxt<'_>, def_id: DefId) -> Clauses<'_> {
|
||||
// `trait Trait<P1..Pn> where WC { .. } // P0 == Self`
|
||||
|
||||
// Rule Implemented-From-Env (see rustc guide)
|
||||
// Rule Implemented-From-Env (see rustc dev guide)
|
||||
//
|
||||
// ```
|
||||
// forall<Self, P1..Pn> {
|
||||
@ -282,7 +282,7 @@ fn program_clauses_for_impl(tcx: TyCtxt<'tcx>, def_id: DefId) -> Clauses<'tcx> {
|
||||
return List::empty();
|
||||
}
|
||||
|
||||
// Rule Implemented-From-Impl (see rustc guide)
|
||||
// Rule Implemented-From-Impl (see rustc dev guide)
|
||||
//
|
||||
// `impl<P0..Pn> Trait<A1..An> for A0 where WC { .. }`
|
||||
//
|
||||
@ -501,7 +501,7 @@ pub fn program_clauses_for_associated_type_def(tcx: TyCtxt<'_>, item_id: DefId)
|
||||
}
|
||||
|
||||
pub fn program_clauses_for_associated_type_value(tcx: TyCtxt<'_>, item_id: DefId) -> Clauses<'_> {
|
||||
// Rule Normalize-From-Impl (see rustc guide)
|
||||
// Rule Normalize-From-Impl (see rustc dev guide)
|
||||
//
|
||||
// ```
|
||||
// impl<P0..Pn> Trait<A1..An> for A0 {
|
||||
|
@ -1,5 +1,5 @@
|
||||
For high-level intro to how type checking works in rustc, see the
|
||||
[type checking] chapter of the [rustc guide].
|
||||
[type checking] chapter of the [rustc dev guide].
|
||||
|
||||
[type checking]: https://rust-lang.github.io/rustc-guide/type-checking.html
|
||||
[rustc guide]: https://rust-lang.github.io/rustc-guide/
|
||||
[type checking]: https://rustc-dev-guide.rust-lang.org/type-checking.html
|
||||
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/
|
||||
|
@ -2588,7 +2588,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
}
|
||||
|
||||
// Case 4. Reference to a method or associated const.
|
||||
DefKind::Method | DefKind::AssocConst => {
|
||||
DefKind::AssocFn | DefKind::AssocConst => {
|
||||
if segments.len() >= 2 {
|
||||
let generics = tcx.generics_of(def_id);
|
||||
path_segs.push(PathSeg(generics.parent.unwrap(), last - 1));
|
||||
|
@ -412,8 +412,8 @@ fn extract_spans_for_error_reporting<'a, 'tcx>(
|
||||
TypeError::Mutability => {
|
||||
if let Some(trait_m_hir_id) = tcx.hir().as_local_hir_id(trait_m.def_id) {
|
||||
let trait_m_iter = match tcx.hir().expect_trait_item(trait_m_hir_id).kind {
|
||||
TraitItemKind::Method(ref trait_m_sig, _) => trait_m_sig.decl.inputs.iter(),
|
||||
_ => bug!("{:?} is not a TraitItemKind::Method", trait_m),
|
||||
TraitItemKind::Fn(ref trait_m_sig, _) => trait_m_sig.decl.inputs.iter(),
|
||||
_ => bug!("{:?} is not a TraitItemKind::Fn", trait_m),
|
||||
};
|
||||
|
||||
impl_m_iter
|
||||
@ -440,10 +440,10 @@ fn extract_spans_for_error_reporting<'a, 'tcx>(
|
||||
if let Some(trait_m_hir_id) = tcx.hir().as_local_hir_id(trait_m.def_id) {
|
||||
let (trait_m_output, trait_m_iter) =
|
||||
match tcx.hir().expect_trait_item(trait_m_hir_id).kind {
|
||||
TraitItemKind::Method(ref trait_m_sig, _) => {
|
||||
TraitItemKind::Fn(ref trait_m_sig, _) => {
|
||||
(&trait_m_sig.decl.output, trait_m_sig.decl.inputs.iter())
|
||||
}
|
||||
_ => bug!("{:?} is not a TraitItemKind::Method", trait_m),
|
||||
_ => bug!("{:?} is not a TraitItemKind::Fn", trait_m),
|
||||
};
|
||||
|
||||
let impl_iter = impl_sig.inputs().iter();
|
||||
@ -708,7 +708,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
||||
let trait_m_hir_id = tcx.hir().as_local_hir_id(trait_m.def_id);
|
||||
let trait_span = if let Some(trait_id) = trait_m_hir_id {
|
||||
match tcx.hir().expect_trait_item(trait_id).kind {
|
||||
TraitItemKind::Method(ref trait_m_sig, _) => {
|
||||
TraitItemKind::Fn(ref trait_m_sig, _) => {
|
||||
let pos = if trait_number_args > 0 { trait_number_args - 1 } else { 0 };
|
||||
if let Some(arg) = trait_m_sig.decl.inputs.get(pos) {
|
||||
Some(if pos == 0 {
|
||||
|
@ -237,7 +237,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
|
||||
// ZST in a temporary, so skip its type, just in case it
|
||||
// can significantly complicate the generator type.
|
||||
Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) => {
|
||||
// NOTE(eddyb) this assumes a path expression has
|
||||
// no nested expressions to keep track of.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user