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 11 pull requests #76621

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
688f447
Stabilize future readiness fns
yoshuawuyts Jul 14, 2020
3797f29
[WIP] give better errors for broken intra doc links
jyn514 Aug 20, 2020
f45e7b5
Update .stderr
jyn514 Aug 21, 2020
4ace4e7
Use fewer `.to_string()`s
jyn514 Aug 21, 2020
fcb2199
Report if the thing exists in another namespace
jyn514 Aug 21, 2020
42bed03
Pass on the DefId so rustdoc can name it in suggestions
jyn514 Aug 21, 2020
f4e6ebd
Fix tests and improve error message if `::` isn't found
jyn514 Aug 21, 2020
002d3a9
Don't give misleading errors for `f::A`, where f is in the value name…
jyn514 Aug 21, 2020
7b8d0be
Remove some TODOs
jyn514 Aug 21, 2020
e2d69f2
Make errors more concise and helpful
jyn514 Aug 21, 2020
19d1002
Fix failures to resolve primitives
jyn514 Aug 21, 2020
ebc8cb4
Turn NoParentItem from a panic into an ICE
jyn514 Aug 21, 2020
6875220
Use rustc_resolve's descr() instead of rewriting it
jyn514 Aug 21, 2020
418f608
Give a better error message when linking to a macro with the wrong di…
jyn514 Aug 21, 2020
2ca6f11
Fix rebase conflicts
jyn514 Aug 22, 2020
bb9d157
Address my own review comments
jyn514 Aug 25, 2020
f2826d9
Show the first path segment which failed to resolve.
jyn514 Aug 25, 2020
d67eb1f
Don't suggest \[ \] if there's a :: in the path
jyn514 Aug 28, 2020
ee683ef
Say 'prefix with `kind@`' instead of 'prefix with the item kind'
jyn514 Aug 28, 2020
efdc3fa
Give a much better error message when an item has a macro disambiguator
jyn514 Aug 28, 2020
8318a18
x.py bless
jyn514 Aug 29, 2020
cd72d90
Find the first segment that failed to resolve for _any_ namespace
jyn514 Sep 1, 2020
b869aa5
Add saturating methods for `Duration`
marmeladema Aug 30, 2020
75e471a
Add MaybeUninit::drop.
m-ou-se Sep 8, 2020
caef832
Fix doc comment on MaybeUninit::drop.
m-ou-se Sep 8, 2020
656a17b
Rename MaybeUninit::drop to assume_init_drop.
m-ou-se Sep 9, 2020
a14efd1
Rename MaybeUninit::read to assume_init_read.
m-ou-se Sep 9, 2020
a94b2cb
Add safety docs about T's invariants in MaybeUninit::assume_init_drop.
m-ou-se Sep 9, 2020
43c7a9b
Fix broken doc links in MaybeUninit.
m-ou-se Sep 9, 2020
f7b6ace
Use IOV_MAX and UIO_MAXIOV constants in limit vectored I/O
Thomasdezeeuw Sep 10, 2020
7c3e1ff
Update libc in Cargo.lock
Thomasdezeeuw Sep 10, 2020
283d4c4
Ignore `|` and `+` tokens during proc-macro pretty-print check
Aaron1011 Sep 10, 2020
15aa6f3
add debug-logging to config.toml
guswynn Sep 10, 2020
fb8d070
Add ui test for 74672 and 76571
tesuji Sep 11, 2020
c3d048a
Ignore rustc_private items from std docs
tesuji Sep 10, 2020
439b766
replacing sub's that can wrap by saturating_sub's
ad-anssi Sep 11, 2020
1854f8b
Warn for #[unstable] on trait impls when it has no effect.
m-ou-se Sep 9, 2020
e5c645f
Turn useless #[unstable] attributes into errors.
m-ou-se Sep 10, 2020
f6fbf66
Mark RefUnwindSafe impls for stable atomic types as stable.
m-ou-se Sep 10, 2020
cf8e5d1
Mark Error impl for LayoutErr as stable.
m-ou-se Sep 10, 2020
89fb34f
Turn unstable trait impl error into a lint, so it can be disabled.
m-ou-se Sep 10, 2020
471fb62
Allow unstable From impl for [Raw]Waker.
m-ou-se Sep 10, 2020
1c1bfba
Add test for unstable trait impl lint.
m-ou-se Sep 10, 2020
f9059a4
add non-regression test for issue #76597
ad-anssi Sep 11, 2020
62068a5
repairing broken error message and rustfix application for the new test
ad-anssi Sep 11, 2020
56f5c7f
comments + add max_level_info so false works with debug_assertions on
guswynn Sep 11, 2020
0be66d7
just max_level_info
guswynn Sep 11, 2020
c394624
Ignore unnecessary unsafe warnings
Thomasdezeeuw Sep 11, 2020
c213c68
box ResolutionFailures on the heap
jyn514 Sep 11, 2020
57250ef
Use `span_label` instead of `note`
jyn514 Sep 11, 2020
b2a5a7a
Remove unnecessary clone
jyn514 Sep 11, 2020
5ea3eaf
Name the current module
jyn514 Sep 11, 2020
14cc177
Improve `ineffective_unstable_trait_impl` error message.
m-ou-se Sep 11, 2020
5e126c9
better diag when const ranges are used in patterns
guswynn Sep 1, 2020
e7f5a4d
Rollup merge of #74328 - yoshuawuyts:stabilize-future-readiness-fns, …
Dylan-DPC Sep 12, 2020
b0b016c
Rollup merge of #75756 - jyn514:diagnostic-suggestions, r=estebank
Dylan-DPC Sep 12, 2020
42c1bde
Rollup merge of #76114 - marmeladema:duration-saturating-ops, r=shepm…
Dylan-DPC Sep 12, 2020
5185c39
Rollup merge of #76222 - guswynn:const_diag, r=estebank
Dylan-DPC Sep 12, 2020
b6bdb2c
Rollup merge of #76484 - fusion-engineering-forks:maybe-uninit-drop, …
Dylan-DPC Sep 12, 2020
a493e97
Rollup merge of #76538 - fusion-engineering-forks:check-useless-unsta…
Dylan-DPC Sep 12, 2020
39a4aec
Rollup merge of #76561 - Thomasdezeeuw:iov-constant-limits, r=Amanieu
Dylan-DPC Sep 12, 2020
e8689d3
Rollup merge of #76571 - lzutao:rustdoc-private-traits, r=jyn514
Dylan-DPC Sep 12, 2020
bd3b10e
Rollup merge of #76585 - Aaron1011:ignore-vert-plus, r=petrochenkov
Dylan-DPC Sep 12, 2020
db0d8e0
Rollup merge of #76588 - guswynn:debug_logging, r=jyn514,Mark-Simulacrum
Dylan-DPC Sep 12, 2020
d234dac
Rollup merge of #76598 - ad-anssi:diagnostic_errors_fix, r=estebank
Dylan-DPC Sep 12, 2020
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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1610,9 +1610,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"

[[package]]
name = "libc"
version = "0.2.74"
version = "0.2.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10"
checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ features = ['unprefixed_malloc_on_supported_platforms']
[features]
jemalloc = ['jemalloc-sys']
llvm = ['rustc_driver/llvm']
max_level_info = ['rustc_driver/max_level_info']
3 changes: 2 additions & 1 deletion compiler/rustc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["dylib"]

[dependencies]
libc = "0.2"
tracing = { version = "0.1.18", features = ["release_max_level_info"] }
tracing = { version = "0.1.18" }
tracing-subscriber = { version = "0.2.10", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
rustc_middle = { path = "../rustc_middle" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
Expand Down Expand Up @@ -38,3 +38,4 @@ winapi = { version = "0.3", features = ["consoleapi", "debugapi", "processenv"]

[features]
llvm = ['rustc_interface/llvm']
max_level_info = ['tracing/max_level_info']
6 changes: 3 additions & 3 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,15 +959,15 @@ impl EmitterWriter {
'_',
line_offset + pos,
width_offset + depth,
code_offset + annotation.start_col - left,
(code_offset + annotation.start_col).saturating_sub(left),
style,
);
}
_ if self.teach => {
buffer.set_style_range(
line_offset,
code_offset + annotation.start_col - left,
code_offset + annotation.end_col - left,
(code_offset + annotation.start_col).saturating_sub(left),
(code_offset + annotation.end_col).saturating_sub(left),
style,
annotation.is_primary,
);
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rustc_ast::NodeId;
use rustc_macros::HashStable_Generic;
use rustc_span::hygiene::MacroKind;

use std::array::IntoIter;
use std::fmt::Debug;

/// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct.
Expand Down Expand Up @@ -291,6 +292,14 @@ impl<T> PerNS<T> {
pub fn map<U, F: FnMut(T) -> U>(self, mut f: F) -> PerNS<U> {
PerNS { value_ns: f(self.value_ns), type_ns: f(self.type_ns), macro_ns: f(self.macro_ns) }
}

pub fn into_iter(self) -> IntoIter<T, 3> {
IntoIter::new([self.value_ns, self.type_ns, self.macro_ns])
}

pub fn iter(&self) -> IntoIter<&T, 3> {
IntoIter::new([&self.value_ns, &self.type_ns, &self.macro_ns])
}
}

impl<T> ::std::ops::Index<Namespace> for PerNS<T> {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//!
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html

#![feature(array_value_iter)]
#![feature(crate_visibility_modifier)]
#![feature(const_fn)] // For the unsizing cast on `&[]`
#![feature(const_panic)]
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ pub fn tokenstream_probably_equal_for_proc_macro(
| token::CloseDelim(DelimToken::NoDelim)
// The pretty printer collapses many semicolons into one.
| token::Semi
// We don't preserve leading `|` tokens in patterns, so
// we ignore them entirely
| token::BinOp(token::BinOpToken::Or)
// We don't preserve trailing '+' tokens in trait bounds,
// so we ignore them entirely
| token::BinOp(token::BinOpToken::Plus)
// The pretty printer can turn `$crate` into `::crate_name`
| token::ModSep = token.kind {
return false;
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,13 @@ impl<'a> Parser<'a> {
Ok(t) => {
// Parsed successfully, therefore most probably the code only
// misses a separator.
let mut exp_span = self.sess.source_map().next_point(sp);
if self.sess.source_map().is_multiline(exp_span) {
exp_span = sp;
}
expect_err
.span_suggestion_short(
self.sess.source_map().next_point(sp),
exp_span,
&format!("missing `{}`", token_str),
token_str,
Applicability::MaybeIncorrect,
Expand Down
73 changes: 71 additions & 2 deletions compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::{Generics, HirId, Item, StructField, Variant};
use rustc_hir::{Generics, HirId, Item, StructField, TraitRef, Ty, TyKind, Variant};
use rustc_middle::hir::map::Map;
use rustc_middle::middle::privacy::AccessLevels;
use rustc_middle::middle::stability::{DeprecationEntry, Index};
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_session::lint;
use rustc_session::lint::builtin::INEFFECTIVE_UNSTABLE_TRAIT_IMPL;
use rustc_session::parse::feature_err;
use rustc_session::Session;
use rustc_span::symbol::{sym, Symbol};
Expand Down Expand Up @@ -538,7 +539,37 @@ impl Visitor<'tcx> for Checker<'tcx> {
// For implementations of traits, check the stability of each item
// individually as it's possible to have a stable trait with unstable
// items.
hir::ItemKind::Impl { of_trait: Some(ref t), items, .. } => {
hir::ItemKind::Impl { of_trait: Some(ref t), self_ty, items, .. } => {
if self.tcx.features().staged_api {
// If this impl block has an #[unstable] attribute, give an
// error if all involved types and traits are stable, because
// it will have no effect.
// See: https://github.com/rust-lang/rust/issues/55436
if let (Some(Stability { level: attr::Unstable { .. }, .. }), _) =
attr::find_stability(&self.tcx.sess, &item.attrs, item.span)
{
let mut c = CheckTraitImplStable { tcx: self.tcx, fully_stable: true };
c.visit_ty(self_ty);
c.visit_trait_ref(t);
if c.fully_stable {
let span = item
.attrs
.iter()
.find(|a| a.has_name(sym::unstable))
.map_or(item.span, |a| a.span);
self.tcx.struct_span_lint_hir(
INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
item.hir_id,
span,
|lint| lint
.build("an `#[unstable]` annotation here has no effect")
.note("see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information")
.emit()
);
}
}
}

if let Res::Def(DefKind::Trait, trait_did) = t.path.res {
for impl_item_ref in items {
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
Expand Down Expand Up @@ -598,6 +629,44 @@ impl Visitor<'tcx> for Checker<'tcx> {
}
}

struct CheckTraitImplStable<'tcx> {
tcx: TyCtxt<'tcx>,
fully_stable: bool,
}

impl Visitor<'tcx> for CheckTraitImplStable<'tcx> {
type Map = Map<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
}

fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, _id: hir::HirId) {
if let Some(def_id) = path.res.opt_def_id() {
if let Some(stab) = self.tcx.lookup_stability(def_id) {
self.fully_stable &= stab.level.is_stable();
}
}
intravisit::walk_path(self, path)
}

fn visit_trait_ref(&mut self, t: &'tcx TraitRef<'tcx>) {
if let Res::Def(DefKind::Trait, trait_did) = t.path.res {
if let Some(stab) = self.tcx.lookup_stability(trait_did) {
self.fully_stable &= stab.level.is_stable();
}
}
intravisit::walk_trait_ref(self, t)
}

fn visit_ty(&mut self, t: &'tcx Ty<'tcx>) {
if let TyKind::Never = t.kind {
self.fully_stable = false;
}
intravisit::walk_ty(self, t)
}
}

/// Given the list of enabled features that were not language features (i.e., that
/// were expected to be library features), and the list of features used from
/// libraries, identify activated features that don't exist and error about them.
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_session/src/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! lints are all available in `rustc_lint::builtin`.

use crate::lint::FutureIncompatibleInfo;
use crate::{declare_lint, declare_lint_pass};
use crate::{declare_lint, declare_lint_pass, declare_tool_lint};
use rustc_span::edition::Edition;
use rustc_span::symbol::sym;

Expand Down Expand Up @@ -555,6 +555,12 @@ declare_lint! {
};
}

declare_tool_lint! {
pub rustc::INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
Deny,
"detects `#[unstable]` on stable trait implementations for stable types"
}

declare_lint_pass! {
/// Does nothing as a lint pass, but registers some `Lint`s
/// that are used by other parts of the compiler.
Expand Down Expand Up @@ -630,6 +636,7 @@ declare_lint_pass! {
INCOMPLETE_INCLUDE,
CENUM_IMPL_DROP_CAST,
CONST_EVALUATABLE_UNCHECKED,
INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
]
}

Expand Down
39 changes: 34 additions & 5 deletions compiler/rustc_typeck/src/check/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_hir::{HirId, Pat, PatKind};
use rustc_infer::infer;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_middle::ty::subst::GenericArg;
use rustc_middle::ty::{self, BindingMode, Ty, TypeFoldable};
use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeFoldable};
use rustc_span::hygiene::DesugaringKind;
use rustc_span::source_map::{Span, Spanned};
use rustc_span::symbol::Ident;
Expand Down Expand Up @@ -735,7 +735,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Some(err) =
self.demand_suptype_with_origin(&self.pattern_cause(ti, pat.span), expected, pat_ty)
{
self.emit_bad_pat_path(err, pat.span, res, pat_res, segments, ti.parent_pat);
self.emit_bad_pat_path(err, pat.span, res, pat_res, pat_ty, segments, ti.parent_pat);
}
pat_ty
}
Expand All @@ -746,6 +746,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pat_span: Span,
res: Res,
pat_res: Res,
pat_ty: Ty<'tcx>,
segments: &'b [hir::PathSegment<'b>],
parent_pat: Option<&Pat<'_>>,
) {
Expand All @@ -771,9 +772,37 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
}
_ => {
let msg = "introduce a new binding instead";
let sugg = format!("other_{}", ident.as_str().to_lowercase());
e.span_suggestion(ident.span, msg, sugg, Applicability::HasPlaceholders);
let const_def_id = match pat_ty.kind() {
Adt(def, _) => match res {
Res::Def(DefKind::Const, _) => Some(def.did),
_ => None,
},
_ => None,
};

let ranges = &[
self.tcx.lang_items().range_struct(),
self.tcx.lang_items().range_from_struct(),
self.tcx.lang_items().range_to_struct(),
self.tcx.lang_items().range_full_struct(),
self.tcx.lang_items().range_inclusive_struct(),
self.tcx.lang_items().range_to_inclusive_struct(),
];
if const_def_id != None && ranges.contains(&const_def_id) {
let msg = "constants only support matching by type, \
if you meant to match against a range of values, \
consider using a range pattern like `min ..= max` in the match block";
e.note(msg);
} else {
let msg = "introduce a new binding instead";
let sugg = format!("other_{}", ident.as_str().to_lowercase());
e.span_suggestion(
ident.span,
msg,
sugg,
Applicability::HasPlaceholders,
);
}
}
};
}
Expand Down
10 changes: 8 additions & 2 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,19 @@
# binary, otherwise they are omitted.
#
# Defaults to rust.debug value
#debug-assertions = false
#debug-assertions = debug

# Whether or not debug assertions are enabled for the standard library.
# Overrides the `debug-assertions` option, if defined.
#
# Defaults to rust.debug-assertions value
#debug-assertions-std = false
#debug-assertions-std = debug-assertions

# Whether or not to leave debug! and trace! calls in the rust binary.
# Overrides the `debug-assertions` option, if defined.
#
# Defaults to rust.debug-assertions value
#debug-logging = debug-assertions

# Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`.
# `0` - no debug info
Expand Down
2 changes: 2 additions & 0 deletions library/alloc/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub trait Wake {
}
}

#[allow(rustc::ineffective_unstable_trait_impl)]
#[unstable(feature = "wake_trait", issue = "69912")]
impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for Waker {
fn from(waker: Arc<W>) -> Waker {
Expand All @@ -42,6 +43,7 @@ impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for Waker {
}
}

#[allow(rustc::ineffective_unstable_trait_impl)]
#[unstable(feature = "wake_trait", issue = "69912")]
impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for RawWaker {
fn from(waker: Arc<W>) -> RawWaker {
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/array/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> {
// dead now (i.e. do not touch). As `idx` was the start of the
// alive-zone, the alive zone is now `data[alive]` again, restoring
// all invariants.
unsafe { self.data.get_unchecked(idx).read() }
unsafe { self.data.get_unchecked(idx).assume_init_read() }
})
}

Expand Down Expand Up @@ -136,7 +136,7 @@ impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, N> {
// dead now (i.e. do not touch). As `idx` was the end of the
// alive-zone, the alive zone is now `data[alive]` again, restoring
// all invariants.
unsafe { self.data.get_unchecked(idx).read() }
unsafe { self.data.get_unchecked(idx).assume_init_read() }
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ pub use self::future::Future;
#[unstable(feature = "into_future", issue = "67644")]
pub use into_future::IntoFuture;

#[unstable(feature = "future_readiness_fns", issue = "70921")]
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
pub use pending::{pending, Pending};
#[unstable(feature = "future_readiness_fns", issue = "70921")]
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
pub use ready::{ready, Ready};

#[unstable(feature = "future_poll_fn", issue = "72302")]
Expand Down
Loading