Skip to content

Commit 604d4ce

Browse files
committed
Auto merge of #48849 - Manishearth:rollup, r=Manishearth
Rollup of 7 pull requests - Successful merges: #48292, #48682, #48699, #48738, #48752, #48789, #48808 - Failed merges:
2 parents c90f682 + 4579753 commit 604d4ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1464
-1021
lines changed

src/libcore/num/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -3900,6 +3900,13 @@ fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32) -> Result<T, Par
39003900
/// This error is used as the error type for the `from_str_radix()` functions
39013901
/// on the primitive integer types, such as [`i8::from_str_radix`].
39023902
///
3903+
/// # Potential causes
3904+
///
3905+
/// Among other causes, `ParseIntError` can be thrown because of leading or trailing whitespace
3906+
/// in the string e.g. when it is obtained from the standard input.
3907+
/// Using the [`str.trim()`] method ensures that no whitespace remains before parsing.
3908+
///
3909+
/// [`str.trim()`]: ../../std/primitive.str.html#method.trim
39033910
/// [`i8::from_str_radix`]: ../../std/primitive.i8.html#method.from_str_radix
39043911
#[derive(Debug, Clone, PartialEq, Eq)]
39053912
#[stable(feature = "rust1", since = "1.0.0")]

src/librustc/hir/check_attr.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ struct CheckAttrVisitor<'a, 'tcx: 'a> {
4747
impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
4848
/// Check any attribute.
4949
fn check_attributes(&self, item: &hir::Item, target: Target) {
50-
self.tcx.trans_fn_attrs(self.tcx.hir.local_def_id(item.id));
50+
if target == Target::Fn {
51+
self.tcx.trans_fn_attrs(self.tcx.hir.local_def_id(item.id));
52+
} else if let Some(a) = item.attrs.iter().find(|a| a.check_name("target_feature")) {
53+
self.tcx.sess.struct_span_err(a.span, "attribute should be applied to a function")
54+
.span_label(item.span, "not a function")
55+
.emit();
56+
}
5157

5258
for attr in &item.attrs {
5359
if let Some(name) = attr.name() {

src/librustc/infer/error_reporting/mod.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
138138
self.explain_span(scope_decorated_tag, span)
139139
}
140140

141-
ty::ReEarlyBound(_) | ty::ReFree(_) => self.msg_span_from_free_region(region),
142-
143-
ty::ReStatic => ("the static lifetime".to_owned(), None),
141+
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReStatic => {
142+
self.msg_span_from_free_region(region)
143+
}
144144

145145
ty::ReEmpty => ("the empty lifetime".to_owned(), None),
146146

@@ -175,6 +175,19 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
175175
}
176176

177177
fn msg_span_from_free_region(self, region: ty::Region<'tcx>) -> (String, Option<Span>) {
178+
match *region {
179+
ty::ReEarlyBound(_) | ty::ReFree(_) => {
180+
self.msg_span_from_early_bound_and_free_regions(region)
181+
},
182+
ty::ReStatic => ("the static lifetime".to_owned(), None),
183+
_ => bug!(),
184+
}
185+
}
186+
187+
fn msg_span_from_early_bound_and_free_regions(
188+
self,
189+
region: ty::Region<'tcx>,
190+
) -> (String, Option<Span>) {
178191
let scope = region.free_region_binding_scope(self);
179192
let node = self.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
180193
let unknown;

0 commit comments

Comments
 (0)