Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #65075

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8e3b9d2
Stabilize todo macro
Jun 15, 2019
560bf1b
Update src/libcore/macros.rs
Sep 4, 2019
711f673
Update macros.rs
Sep 4, 2019
445e735
Prevent rustdoc feature to be passed down to doctests
GuillaumeGomez Sep 25, 2019
366fdeb
Add new rustdoc-ui test to ensuire that rustdoc feature isn't passed …
GuillaumeGomez Sep 30, 2019
2ab7a67
Replace mentions of IRC with Discord
Oct 2, 2019
a336536
Set RUST_BACKTRACE=0 in tests that include a backtrace in stderr
Aaron1011 Oct 2, 2019
a8b2fe0
[RFC 2091] Add #[track_caller] attribute.
ayosec Jul 20, 2019
a8d70d1
Add visit_projection_elem method to visitors
spastorino Oct 2, 2019
e9deff0
track_caller run-pass test, lint cleanup, PR review.
anp Oct 3, 2019
1e78d99
track_caller feature gate starts in 1.40.0.
anp Oct 3, 2019
287ceed
Deprecate `#![plugin]` and `#[plugin_registrar]`.
Centril Sep 21, 2019
1b8ec97
plugin_registrary: use normal deprecation instead of hard coded warning.
Centril Oct 3, 2019
da86007
Mark #![feature(track_caller)] as incomplete.
anp Oct 3, 2019
8ac9104
track_caller error numbers and text.
anp Oct 3, 2019
9e301d1
track_caller tests account for incomplete feature warning.
anp Oct 3, 2019
d1f95ef
--bless ui-fulldeps tests
Centril Oct 3, 2019
d1310dc
proc_macro: Add `Span::mixed_site` exposing `macro_rules` hygiene
petrochenkov Sep 22, 2019
4396a1c
add regression test for #60218
nikomatsakis Sep 20, 2019
3a4921c
The crux of the bug fix.
pnkfelix Sep 27, 2019
a18d424
Allocate a new diagnostic for defaulted type parameters cannot use `S…
pnkfelix Sep 27, 2019
e86af1b
Add long error explanation for E0556
GuillaumeGomez Oct 3, 2019
1d49f9a
update ui tests
GuillaumeGomez Oct 3, 2019
126bf3b
typo: fix typo in E0392
mathstuf Oct 3, 2019
b9ed642
Make visit_projection iterative
spastorino Oct 2, 2019
e443e1b
Regression tests.
pnkfelix Sep 27, 2019
2d5f4df
Rollup merge of #61879 - stjepang:stabilize-todo, r=withoutboats
tmandry Oct 3, 2019
ae41bcd
Rollup merge of #64675 - Centril:deprecate-plugin, r=oli-obk
tmandry Oct 3, 2019
a647b74
Rollup merge of #64690 - petrochenkov:mixed, r=dtolnay
tmandry Oct 3, 2019
b6d8169
Rollup merge of #64706 - nikomatsakis:issue-60218-test-case, r=centril
tmandry Oct 3, 2019
cd0028e
Rollup merge of #64741 - GuillaumeGomez:prevent-rustdoc-feature-docte…
tmandry Oct 3, 2019
4cc2872
Rollup merge of #64842 - pnkfelix:fix-issue-61631-self-in-type-param-…
tmandry Oct 3, 2019
51dd307
Rollup merge of #65004 - BO41:mentions, r=alexcrichton
tmandry Oct 3, 2019
772f689
Rollup merge of #65018 - Aaron1011:fix/backtrace-stderr, r=nikomatsakis
tmandry Oct 3, 2019
6d6a3fb
Rollup merge of #65037 - anp:track-caller, r=oli-obk
tmandry Oct 3, 2019
c086b9f
Rollup merge of #65055 - GuillaumeGomez:long-err-explanation-E0556, r…
tmandry Oct 3, 2019
a9244f7
Rollup merge of #65056 - spastorino:place-mut-visitor-adjusts, r=oli-obk
tmandry Oct 3, 2019
5264e69
Rollup merge of #65057 - mathstuf:fix-warning-typo, r=Centril
tmandry Oct 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ In the Rust community we strive to go the extra step to look out for each other.

And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could've communicated better — remember that it's your responsibility to make your fellow Rustaceans comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust.

The enforcement policies listed above apply to all official Rust venues; including official IRC channels (#rust, #rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo); GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org (users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Rust Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion.
The enforcement policies listed above apply to all official Rust venues; including all communication channels (Rust Discord server, Rust Zulip server); GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org (users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Rust Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion.

*Adapted from the [Node.js Policy on Trolling](https://blog.izs.me/2012/08/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).*

Expand Down
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ links to the major sections:
* [Helpful Links and Information](#helpful-links-and-information)

If you have questions, please make a post on [internals.rust-lang.org][internals] or
hop on the [Rust Discord server][rust-discord], [Rust Zulip server][rust-zulip] or [#rust-internals][pound-rust-internals].
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].

Expand All @@ -25,7 +25,6 @@ to contribute to it in more detail than this document.
If this is your first time contributing, the [walkthrough] chapter of the guide
can give you a good example of how a typical contribution would go.

[pound-rust-internals]: https://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals
[internals]: https://internals.rust-lang.org
[rust-discord]: http://discord.gg/rust-lang
[rust-zulip]: https://rust-lang.zulipchat.com
Expand Down Expand Up @@ -404,7 +403,7 @@ If you're looking for somewhere to start, check out the [E-easy][eeasy] tag.
There are a number of other ways to contribute to Rust that don't deal with
this repository.

Answer questions in [#rust][pound-rust], or on [users.rust-lang.org][users],
Answer questions in the _Get Help!_ channels from the [Rust Discord server][rust-discord], on [users.rust-lang.org][users],
or on [StackOverflow][so].

Participate in the [RFC process](https://github.com/rust-lang/rfcs).
Expand All @@ -413,7 +412,7 @@ Find a [requested community library][community-library], build it, and publish
it to [Crates.io](http://crates.io). Easier said than done, but very, very
valuable!

[pound-rust]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
[rust-discord]: https://discord.gg/rust-lang
[users]: https://users.rust-lang.org/
[so]: http://stackoverflow.com/questions/tagged/rust
[community-library]: https://github.com/rust-lang/rfcs/labels/A-community-library
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,17 @@ The Rust community congregates in a few places:

To contribute to Rust, please see [CONTRIBUTING](CONTRIBUTING.md).

Rust has an [IRC] culture and most real-time collaboration happens in a
variety of channels on Mozilla's IRC network, irc.mozilla.org. The
most popular channel is [#rust], a venue for general discussion about
Rust. And a good place to ask for help would be [#rust-beginners].
Most real-time collaboration happens in a variety of channels on the
[Rust Discord server][rust-discord], with channels dedicated for getting help,
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
various parts of the compiler work.

Also, you may find the [rustdocs for the compiler itself][rustdocs] useful.

[IRC]: https://en.wikipedia.org/wiki/Internet_Relay_Chat
[#rust]: irc://irc.mozilla.org/rust
[#rust-beginners]: irc://irc.mozilla.org/rust-beginners
[rust-discord]: https://discord.gg/rust-lang
[rustc guide]: https://rust-lang.github.io/rustc-guide/about-this-guide.html
[rustdocs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/

Expand Down
8 changes: 5 additions & 3 deletions src/bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ are:
`Config` struct.
* Adding a sanity check? Take a look at `bootstrap/sanity.rs`.

If you have any questions feel free to reach out on `#rust-infra` on IRC or ask on
internals.rust-lang.org. When you encounter bugs, please file issues on the
rust-lang/rust issue tracker.
If you have any questions feel free to reach out on `#infra` channel in the
[Rust Discord server][rust-discord] or ask on internals.rust-lang.org. When
you encounter bugs, please file issues on the rust-lang/rust issue tracker.

[rust-discord]: https://discord.gg/rust-lang
5 changes: 5 additions & 0 deletions src/doc/unstable-book/src/language-features/track-caller.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# `track_caller`

The tracking issue for this feature is: [#47809](https://github.com/rust-lang/rust/issues/47809).

------------------------
16 changes: 10 additions & 6 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ macro_rules! writeln {
/// The unsafe counterpart of this macro is the [`unreachable_unchecked`] function, which
/// will cause undefined behavior if the code is reached.
///
/// [`panic!`]: ../std/macro.panic.html
/// [`panic!`]: ../std/macro.panic.html
/// [`unreachable_unchecked`]: ../std/hint/fn.unreachable_unchecked.html
/// [`std::hint`]: ../std/hint/index.html
///
Expand All @@ -474,6 +474,7 @@ macro_rules! writeln {
/// This will always [`panic!`]
///
/// [`panic!`]: ../std/macro.panic.html
///
/// # Examples
///
/// Match arms:
Expand Down Expand Up @@ -525,6 +526,9 @@ macro_rules! unreachable {
/// code type-check, or if you're implementing a trait that requires multiple
/// methods, and you're only planning on using one of them.
///
/// There is no difference between `unimplemented!` and `todo!` apart from the
/// name.
///
/// # Panics
///
/// This will always [panic!](macro.panic.html)
Expand Down Expand Up @@ -579,8 +583,10 @@ macro_rules! unimplemented {
/// Indicates unfinished code.
///
/// This can be useful if you are prototyping and are just looking to have your
/// code typecheck. `todo!` works exactly like `unimplemented!`. The only
/// difference between the two macros is the name.
/// code typecheck.
///
/// There is no difference between `unimplemented!` and `todo!` apart from the
/// name.
///
/// # Panics
///
Expand All @@ -602,8 +608,6 @@ macro_rules! unimplemented {
/// `baz()`, so we can use `todo!`:
///
/// ```
/// #![feature(todo_macro)]
///
/// # trait Foo {
/// # fn bar(&self);
/// # fn baz(&self);
Expand All @@ -629,7 +633,7 @@ macro_rules! unimplemented {
/// }
/// ```
#[macro_export]
#[unstable(feature = "todo_macro", issue = "59277")]
#[stable(feature = "todo_macro", since = "1.39.0")]
macro_rules! todo {
() => (panic!("not yet implemented"));
($($arg:tt)+) => (panic!("not yet implemented: {}", $crate::format_args!($($arg)+)));
Expand Down
1 change: 1 addition & 0 deletions src/libproc_macro/bridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ macro_rules! with_api {
fn debug($self: $S::Span) -> String;
fn def_site() -> $S::Span;
fn call_site() -> $S::Span;
fn mixed_site() -> $S::Span;
fn source_file($self: $S::Span) -> $S::SourceFile;
fn parent($self: $S::Span) -> Option<$S::Span>;
fn source($self: $S::Span) -> $S::Span;
Expand Down
9 changes: 9 additions & 0 deletions src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ impl Span {
Span(bridge::client::Span::call_site())
}

/// A span that represents `macro_rules` hygiene, and sometimes resolves at the macro
/// definition site (local variables, labels, `$crate`) and sometimes at the macro
/// call site (everything else).
/// The span location is taken from the call-site.
#[unstable(feature = "proc_macro_mixed_site", issue = "65049")]
pub fn mixed_site() -> Span {
Span(bridge::client::Span::mixed_site())
}

/// The original source file into which this span points.
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn source_file(&self) -> SourceFile {
Expand Down
10 changes: 10 additions & 0 deletions src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2234,6 +2234,15 @@ These attributes are meant to only be used by the standard library and are
rejected in your own crates.
"##,

E0736: r##"
#[track_caller] and #[naked] cannot be applied to the same function.

This is primarily due to ABI incompatibilities between the two attributes.
See [RFC 2091] for details on this and other limitations.

[RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md
"##,

;
// E0006, // merged with E0005
// E0101, // replaced with E0282
Expand Down Expand Up @@ -2296,4 +2305,5 @@ rejected in your own crates.
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
E0727, // `async` generators are not yet supported
E0728, // `await` must be in an `async` function or block
E0735, // invalid track_caller application/syntax
}
30 changes: 29 additions & 1 deletion src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::ty::TyCtxt;
use crate::ty::query::Providers;

use std::fmt::{self, Display};
use syntax::symbol::sym;
use syntax::{attr, symbol::sym};
use syntax_pos::Span;

#[derive(Copy, Clone, PartialEq)]
Expand Down Expand Up @@ -103,6 +103,8 @@ impl CheckAttrVisitor<'tcx> {
self.check_marker(attr, item, target)
} else if attr.check_name(sym::target_feature) {
self.check_target_feature(attr, item, target)
} else if attr.check_name(sym::track_caller) {
self.check_track_caller(attr, &item, target)
} else {
true
};
Expand Down Expand Up @@ -135,6 +137,32 @@ impl CheckAttrVisitor<'tcx> {
}
}

/// Checks if a `#[track_caller]` is applied to a non-naked function. Returns `true` if valid.
fn check_track_caller(&self, attr: &hir::Attribute, item: &hir::Item, target: Target) -> bool {
if target != Target::Fn {
struct_span_err!(
self.tcx.sess,
attr.span,
E0735,
"attribute should be applied to function"
)
.span_label(item.span, "not a function")
.emit();
false
} else if attr::contains_name(&item.attrs, sym::naked) {
struct_span_err!(
self.tcx.sess,
attr.span,
E0736,
"cannot use `#[track_caller]` with `#[naked]`",
)
.emit();
false
} else {
true
}
}

/// Checks if the `#[non_exhaustive]` attribute on an `item` is valid. Returns `true` if valid.
fn check_non_exhaustive(
&self,
Expand Down
4 changes: 3 additions & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2716,7 +2716,9 @@ bitflags! {
const USED = 1 << 9;
/// #[ffi_returns_twice], indicates that an extern function can return
/// multiple times
const FFI_RETURNS_TWICE = 1 << 10;
const FFI_RETURNS_TWICE = 1 << 10;
/// #[track_caller]: allow access to the caller location
const TRACK_CALLER = 1 << 11;
}
}

Expand Down
58 changes: 38 additions & 20 deletions src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ macro_rules! make_mir_visitor {
self.super_projection(base, projection, context, location);
}

fn visit_projection_elem(&mut self,
base: & $($mutability)? PlaceBase<'tcx>,
proj_base: & $($mutability)? [PlaceElem<'tcx>],
elem: & $($mutability)? PlaceElem<'tcx>,
context: PlaceContext,
location: Location) {
self.super_projection_elem(base, proj_base, elem, context, location);
}

fn visit_constant(&mut self,
constant: & $($mutability)? Constant<'tcx>,
location: Location) {
Expand Down Expand Up @@ -725,27 +734,36 @@ macro_rules! make_mir_visitor {
projection: & $($mutability)? [PlaceElem<'tcx>],
context: PlaceContext,
location: Location) {
if let [proj_base @ .., elem] = projection {
self.visit_projection(base, proj_base, context, location);
let mut cursor = projection;
while let [proj_base @ .., elem] = cursor {
cursor = proj_base;
self.visit_projection_elem(base, cursor, elem, context, location);
}
}

match elem {
ProjectionElem::Field(_field, ty) => {
self.visit_ty(ty, TyContext::Location(location));
}
ProjectionElem::Index(local) => {
self.visit_local(
local,
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
location
);
}
ProjectionElem::Deref |
ProjectionElem::Subslice { from: _, to: _ } |
ProjectionElem::ConstantIndex { offset: _,
min_length: _,
from_end: _ } |
ProjectionElem::Downcast(_, _) => {
}
fn super_projection_elem(&mut self,
_base: & $($mutability)? PlaceBase<'tcx>,
_proj_base: & $($mutability)? [PlaceElem<'tcx>],
elem: & $($mutability)? PlaceElem<'tcx>,
_context: PlaceContext,
location: Location) {
match elem {
ProjectionElem::Field(_field, ty) => {
self.visit_ty(ty, TyContext::Location(location));
}
ProjectionElem::Index(local) => {
self.visit_local(
local,
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
location
);
}
ProjectionElem::Deref |
ProjectionElem::Subslice { from: _, to: _ } |
ProjectionElem::ConstantIndex { offset: _,
min_length: _,
from_end: _ } |
ProjectionElem::Downcast(_, _) => {
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/librustc_mir/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,25 +404,25 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
self.super_assign(dest, rvalue, location);
}

fn visit_projection(
fn visit_projection_elem(
&mut self,
place_base: &PlaceBase<'tcx>,
proj: &[PlaceElem<'tcx>],
proj_base: &[PlaceElem<'tcx>],
elem: &PlaceElem<'tcx>,
context: PlaceContext,
location: Location,
) {
trace!(
"visit_place_projection: proj={:?} context={:?} location={:?}",
proj,
"visit_projection_elem: place_base={:?} proj_base={:?} elem={:?} \
context={:?} location={:?}",
place_base,
proj_base,
elem,
context,
location,
);
self.super_projection(place_base, proj, context, location);

let (elem, proj_base) = match proj.split_last() {
Some(x) => x,
None => return,
};
self.super_projection_elem(place_base, proj_base, elem, context, location);

match elem {
ProjectionElem::Deref => {
Expand Down
Loading