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 8 pull requests #67846

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
368ac73
no longer promote non-pattern const functions
RalfJung Dec 22, 2019
8d189ed
Suggest calling method when first argument is `self`
VirrageS Nov 30, 2019
8e5b2c8
Add more detailed suggestion
VirrageS Dec 9, 2019
0918539
Add arguments to suggestion method call
VirrageS Dec 21, 2019
7353afd
Extend suggestion span to whole method call
VirrageS Dec 22, 2019
2168c0b
Extract checking for self arg to separate method
VirrageS Dec 23, 2019
7b91ef8
Simplify match expr
VirrageS Dec 23, 2019
cfab634
Add a test for #37333
michalt Jan 1, 2020
23f5431
Cleanup linkchecker whitelist
ollie27 Jan 1, 2020
562389d
- remove syntax::{span_warn!, span_err!, span_fatal!. struct_err!}
Centril Dec 31, 2019
67be07d
address review comments
Centril Jan 2, 2020
485e98a
Implement uncommon_codepoints lint.
crlf0710 Jan 2, 2020
7fd014d
tweak wording of mismatched delimiter errors
euclio Jan 3, 2020
ae002c1
Also remove const-hack for abs
jumbatm Jan 3, 2020
d0fe179
Rollup merge of #66913 - VirrageS:help-self, r=varkor,Centril
Centril Jan 3, 2020
10f153f
Rollup merge of #67531 - RalfJung:tame-promotion, r=nikomatsakis
Centril Jan 3, 2020
6a42b64
Rollup merge of #67770 - Centril:reduce-diversity-2, r=petrochenkov
Centril Jan 3, 2020
1ce3f0d
Rollup merge of #67773 - michalt:issue-37333-test, r=nikomatsakis
Centril Jan 3, 2020
a29a7d5
Rollup merge of #67789 - ollie27:linkchecker_whitelist, r=nikomatsakis
Centril Jan 3, 2020
8017b78
Rollup merge of #67810 - crlf0710:uncommon_codepoints_lint, r=Manishe…
Centril Jan 3, 2020
e35ce61
Rollup merge of #67835 - euclio:delimiter-wording, r=Centril
Centril Jan 3, 2020
3f83bc8
Rollup merge of #67845 - jumbatm:also-unconst-hack-abs, r=oli-obk
Centril Jan 3, 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
18 changes: 18 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3642,6 +3642,7 @@ dependencies = [
"rustc_span",
"rustc_target",
"syntax",
"unicode-security",
]

[[package]]
Expand Down Expand Up @@ -3774,6 +3775,7 @@ version = "0.0.0"
dependencies = [
"rustc",
"rustc_error_codes",
"rustc_errors",
"rustc_metadata",
"rustc_span",
"syntax",
Expand All @@ -3787,6 +3789,7 @@ dependencies = [
"rustc",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
"rustc_span",
"rustc_typeck",
"syntax",
Expand Down Expand Up @@ -4940,6 +4943,21 @@ dependencies = [
"smallvec 1.0.0",
]

[[package]]
name = "unicode-script"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b2c5c29e805da6817f5af6a627d65adb045cebf05cccd5a3493d6109454391c"

[[package]]
name = "unicode-security"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c49d35967fa037b881acc34ef717c38c4b5560eba10e3685271b3f530bb19634"
dependencies = [
"unicode-script",
]

[[package]]
name = "unicode-segmentation"
version = "1.6.0"
Expand Down
24 changes: 6 additions & 18 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1997,27 +1997,15 @@ $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
#[allow_internal_unstable(const_if_match)]
#[inline]
#[rustc_inherit_overflow_checks]
pub const fn abs(self) -> Self {
// Note that the #[inline] above means that the overflow
// semantics of the subtraction depend on the crate we're being
// inlined into.

// sign is -1 (all ones) for negative numbers, 0 otherwise.
let sign = self >> ($BITS - 1);
// For positive self, sign == 0 so the expression is simply
// (self ^ 0) - 0 == self == abs(self).
//
// For negative self, self ^ sign == self ^ all_ones.
// But all_ones ^ self == all_ones - self == -1 - self.
// So for negative numbers, (self ^ sign) - sign is
// (-1 - self) - -1 == -self == abs(self).
//
// The subtraction overflows when self is min_value(), because
// (-1 - min_value()) - -1 is max_value() - -1 which overflows.
// This is exactly when we want self.abs() to overflow.
(self ^ sign) - sign
if self.is_negative() {
-self
} else {
self
}
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/libcore/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ impl Duration {
/// ```
#[stable(feature = "duration", since = "1.3.0")]
#[inline]
#[rustc_promotable]
#[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]
pub const fn from_millis(millis: u64) -> Duration {
Duration {
Expand All @@ -195,7 +194,6 @@ impl Duration {
/// ```
#[stable(feature = "duration_from_micros", since = "1.27.0")]
#[inline]
#[rustc_promotable]
#[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]
pub const fn from_micros(micros: u64) -> Duration {
Duration {
Expand All @@ -218,7 +216,6 @@ impl Duration {
/// ```
#[stable(feature = "duration_extras", since = "1.27.0")]
#[inline]
#[rustc_promotable]
#[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]
pub const fn from_nanos(nanos: u64) -> Duration {
Duration {
Expand Down
16 changes: 12 additions & 4 deletions src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use crate::lint::builtin::UNUSED_ATTRIBUTES;
use crate::ty::query::Providers;
use crate::ty::TyCtxt;

use errors::struct_span_err;
use rustc_span::Span;

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

Expand Down Expand Up @@ -428,21 +430,27 @@ impl CheckAttrVisitor<'tcx> {
// Error on repr(transparent, <anything else>).
if is_transparent && hints.len() > 1 {
let hint_spans: Vec<_> = hint_spans.clone().collect();
span_err!(
struct_span_err!(
self.tcx.sess,
hint_spans,
E0692,
"transparent {} cannot have other repr hints",
target
);
)
.emit();
}
// Warn on repr(u8, u16), repr(C, simd), and c-like-enum-repr(C, u8)
if (int_reprs > 1)
|| (is_simd && is_c)
|| (int_reprs == 1 && is_c && item.map_or(false, |item| is_c_like_enum(item)))
{
let hint_spans: Vec<_> = hint_spans.collect();
span_warn!(self.tcx.sess, hint_spans, E0566, "conflicting representation hints");
struct_span_err!(
self.tcx.sess,
hint_spans.collect::<Vec<Span>>(),
E0566,
"conflicting representation hints",
)
.emit();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use crate::ty::{
Region, Ty, TyCtxt, TypeFoldable,
};

use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
use errors::{struct_span_err, Applicability, DiagnosticBuilder, DiagnosticStyledString};
use rustc_error_codes::*;
use rustc_span::{Pos, Span};
use rustc_target::spec::abi;
Expand Down
15 changes: 6 additions & 9 deletions src/librustc/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::infer::type_variable::TypeVariableOriginKind;
use crate::infer::InferCtxt;
use crate::ty::print::Print;
use crate::ty::{self, DefIdTree, Infer, Ty, TyVar};
use errors::{Applicability, DiagnosticBuilder};
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
use rustc_span::Span;
use std::borrow::Cow;
use syntax::source_map::DesugaringKind;
Expand Down Expand Up @@ -153,14 +153,11 @@ pub enum TypeAnnotationNeeded {

impl Into<errors::DiagnosticId> for TypeAnnotationNeeded {
fn into(self) -> errors::DiagnosticId {
syntax::diagnostic_used!(E0282);
syntax::diagnostic_used!(E0283);
syntax::diagnostic_used!(E0284);
errors::DiagnosticId::Error(match self {
Self::E0282 => "E0282".to_string(),
Self::E0283 => "E0283".to_string(),
Self::E0284 => "E0284".to_string(),
})
match self {
Self::E0282 => errors::error_code!(E0282),
Self::E0283 => errors::error_code!(E0283),
Self::E0284 => errors::error_code!(E0284),
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::infer::error_reporting::nice_region_error::util::AnonymousParamInfo;
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::util::common::ErrorReported;

use errors::struct_span_err;
use rustc_error_codes::*;

impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::hir::{FunctionRetTy, TyKind};
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::ty;
use errors::{Applicability, DiagnosticBuilder};
use errors::{struct_span_err, Applicability, DiagnosticBuilder};

use rustc_error_codes::*;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::infer::{self, InferCtxt, SubregionOrigin};
use crate::middle::region;
use crate::ty::error::TypeError;
use crate::ty::{self, Region};
use errors::DiagnosticBuilder;
use errors::{struct_span_err, DiagnosticBuilder};

use rustc_error_codes::*;

Expand Down
8 changes: 2 additions & 6 deletions src/librustc/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder, TypeVisitor};
use crate::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, SubstsRef};
use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt};
use crate::util::nodemap::DefIdMap;
use errors::DiagnosticBuilder;
use errors::{struct_span_err, DiagnosticBuilder};
use rustc::session::config::nightly_options;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lrc;
Expand Down Expand Up @@ -523,11 +523,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
err.span_label(span, label);

if nightly_options::is_nightly_build() {
help!(
err,
"add #![feature(member_constraints)] to the crate attributes \
to enable"
);
err.help("add #![feature(member_constraints)] to the crate attributes to enable");
}

err.emit();
Expand Down
7 changes: 7 additions & 0 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ declare_lint! {
"detects overlapping patterns"
}

declare_lint! {
pub BINDINGS_WITH_VARIANT_NAME,
Warn,
"detects pattern bindings with the same name as one of the matched variants"
}

declare_lint! {
pub UNUSED_MACROS,
Warn,
Expand Down Expand Up @@ -459,6 +465,7 @@ declare_lint_pass! {
UNREACHABLE_CODE,
UNREACHABLE_PATTERNS,
OVERLAPPING_PATTERNS,
BINDINGS_WITH_VARIANT_NAME,
UNUSED_MACROS,
WARNINGS,
UNUSED_FEATURES,
Expand Down
7 changes: 4 additions & 3 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ use crate::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt};
use crate::util::common::time;
use crate::util::nodemap::FxHashMap;

use errors::DiagnosticBuilder;
use errors::{struct_span_err, DiagnosticBuilder};
use rustc_data_structures::sync::{self, join, par_iter, ParallelIterator};
use rustc_span::{symbol::Symbol, MultiSpan, Span};
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
use std::slice;
use syntax::ast;
use syntax::util::lev_distance::find_best_match_for_name;
Expand Down Expand Up @@ -295,7 +295,8 @@ impl LintStore {
CheckLintNameResult::Ok(_) => None,
CheckLintNameResult::Warning(ref msg, _) => Some(sess.struct_warn(msg)),
CheckLintNameResult::NoLint(suggestion) => {
let mut err = struct_err!(sess, E0602, "unknown lint: `{}`", lint_name);
let mut err =
struct_span_err!(sess, DUMMY_SP, E0602, "unknown lint: `{}`", lint_name);

if let Some(suggestion) = suggestion {
err.help(&format!("did you mean: `{}`", suggestion));
Expand Down
7 changes: 4 additions & 3 deletions src/librustc/lint/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::lint::context::{CheckLintNameResult, LintStore};
use crate::lint::{self, Level, Lint, LintId, LintSource};
use crate::session::Session;
use crate::util::nodemap::FxHashMap;
use errors::{Applicability, DiagnosticBuilder};
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use syntax::ast;
use syntax::attr;
Expand Down Expand Up @@ -274,13 +274,14 @@ impl<'a> LintLevelsBuilder<'a> {
let tool_name = if meta_item.path.segments.len() > 1 {
let tool_ident = meta_item.path.segments[0].ident;
if !attr::is_known_lint_tool(tool_ident) {
span_err!(
struct_span_err!(
sess,
tool_ident.span,
E0710,
"an unknown tool name found in scoped lint: `{}`",
pprust::path_to_string(&meta_item.path),
);
)
.emit();
continue;
}

Expand Down
6 changes: 4 additions & 2 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::util::nodemap::FxHashMap;

use crate::hir;
use crate::hir::itemlikevisit::ItemLikeVisitor;
use errors::struct_span_err;
use rustc_macros::HashStable;
use rustc_span::Span;
use syntax::ast;
Expand Down Expand Up @@ -184,7 +185,8 @@ impl LanguageItemCollector<'tcx> {
span,
E0152,
"duplicate lang item found: `{}`.",
name),
name
),
None => {
match self.tcx.extern_crate(item_def_id) {
Some(ExternCrate {dependency_of, ..}) => {
Expand All @@ -204,7 +206,7 @@ impl LanguageItemCollector<'tcx> {
},
};
if let Some(span) = self.tcx.hir().span_if_local(original_def_id) {
span_note!(&mut err, span, "first defined here.");
err.span_note(span, "first defined here.");
} else {
match self.tcx.extern_crate(original_def_id) {
Some(ExternCrate {dependency_of, ..}) => {
Expand Down
10 changes: 7 additions & 3 deletions src/librustc/middle/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::hir::def_id::DefId;
use crate::hir::intravisit;
use crate::hir::intravisit::{NestedVisitorMap, Visitor};
use crate::ty::TyCtxt;
use errors::struct_span_err;
use rustc_data_structures::fx::FxHashSet;
use rustc_span::Span;
use rustc_target::spec::PanicStrategy;
Expand Down Expand Up @@ -124,9 +125,12 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
self.items.missing.push(lang_items::$item);
}
} else)* {
span_err!(self.tcx.sess, span, E0264,
"unknown external lang item: `{}`",
name);
struct_span_err!(
self.tcx.sess, span, E0264,
"unknown external lang item: `{}`",
name
)
.emit();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::ty::query::TyCtxtAt;
use crate::ty::{self, layout, Ty};

use backtrace::Backtrace;
use errors::DiagnosticBuilder;
use errors::{struct_span_err, DiagnosticBuilder};
use hir::GeneratorKind;
use rustc_macros::HashStable;
use rustc_span::{Pos, Span};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::ty::TypeckTables;
use crate::ty::{self, AdtKind, DefIdTree, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable};
use crate::util::nodemap::{FxHashMap, FxHashSet};

use errors::{pluralize, Applicability, DiagnosticBuilder, Style};
use errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, Style};
use rustc::hir::def_id::LOCAL_CRATE;
use rustc_span::source_map::SourceMap;
use rustc_span::{ExpnKind, MultiSpan, Span, DUMMY_SP};
Expand Down
Loading